source: branches/dev/data/class/SC_View.php @ 14507

Revision 14507, 5.8 KB checked in by naka, 19 years ago (diff)
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8$SC_VIEW_PHP_DIR = realpath(dirname(__FILE__));
9require_once($SC_VIEW_PHP_DIR . "/../module/Smarty/libs/Smarty.class.php");
10require_once($SC_VIEW_PHP_DIR . "/../include/php_ini.inc");
11
12
13function modifiers_test($val) {
14    return "#".$val."#";
15}
16
17class SC_View {
18   
19    var $_smarty;
20    var $objSiteInfo; // ¥µ¥¤¥È¾ðÊó
21   
22    // ¥³¥ó¥¹¥È¥é¥¯¥¿
23    function SC_View($siteinfo = true) {
24        global $SC_VIEW_PHP_DIR;
25
26        $this->_smarty = new Smarty;
27        $this->_smarty->left_delimiter = '<!--{';
28        $this->_smarty->right_delimiter = '}-->';
29        $this->_smarty->register_modifier("sfDispDBDate","sfDispDBDate");
30        $this->_smarty->register_modifier("sfConvSendDateToDisp","sfConvSendDateToDisp");
31        $this->_smarty->register_modifier("sfConvSendWdayToDisp","sfConvSendWdayToDisp");
32        $this->_smarty->register_modifier("sfGetVal", "sfGetVal");
33        $this->_smarty->register_function("sfSetErrorStyle","sfSetErrorStyle");
34        $this->_smarty->register_function("sfGetErrorColor","sfGetErrorColor");
35        $this->_smarty->register_function("sfTrim", "sfTrim");
36        $this->_smarty->register_function("sfPreTax", "sfPreTax");
37        $this->_smarty->register_function("sfPrePoint", "sfPrePoint");
38        $this->_smarty->register_function("sfGetChecked", "sfGetChecked");
39        $this->_smarty->register_function("sfTrimURL", "sfTrimURL");
40        $this->_smarty->register_function("sfMultiply", "sfMultiply");
41        $this->_smarty->register_function("sfPutBR", "sfPutBR");
42        $this->_smarty->register_function("sfRmDupSlash", "sfRmDupSlash");
43        $this->_smarty->register_function("sfCutString", "sfCutString");
44        $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../smarty_extends");
45        $this->_smarty->register_function("sf_mb_convert_encoding","sf_mb_convert_encoding");
46        $this->_smarty->register_function("sf_mktime","sf_mktime");
47        $this->_smarty->register_function("sf_date","sf_date");
48        $this->_smarty->register_function("str_replace","str_replace");
49        $this->_smarty->register_function("sfPrintEbisTag","sfPrintEbisTag");
50        $this->_smarty->register_function("sfPrintAffTag","sfPrintAffTag");
51        //$this->_smarty->default_modifiers = array('script_escape');
52        $this->_smarty->default_modifiers = array('modifiers_test');
53       
54        sfPrintR($this->_smarty->default_modifiers);
55       
56        if(ADMIN_MODE == '1') {     
57            $this->time_start = time();
58        }
59
60        // ¥µ¥¤¥È¾ðÊó¤ò¼èÆÀ¤¹¤ë
61        if($siteinfo) {
62            if(!defined('LOAD_SITEINFO')) {
63                $this->objSiteInfo = new SC_SiteInfo();
64                $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data;
65               
66                // ÅÔÆ»Éܸ©Ì¾¤òÊÑ´¹
67                global $arrPref;
68                $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']];
69               
70                // ¥µ¥¤¥È¾ðÊó¤ò³ä¤êÅö¤Æ¤ë
71                foreach ($arrInfo as $key => $value){
72                    $this->_smarty->assign($key, $value);
73                }
74               
75                define('LOAD_SITEINFO', 1);
76            }
77        }
78    }
79   
80    // ¥Æ¥ó¥×¥ì¡¼¥È¤ËÃͤò³ä¤êÅö¤Æ¤ë
81    function assign($val1, $val2) {
82        $this->_smarty->assign($val1, $val2);
83    }
84   
85    // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤ò¼èÆÀ
86    function fetch($template) {
87        return $this->_smarty->fetch($template);
88    }
89   
90    // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤òɽ¼¨
91    function display($template, $no_error = false) {
92        if(!$no_error) {
93            global $GLOBAL_ERR;
94            if(!defined('OUTPUT_ERR')) {
95                print($GLOBAL_ERR);
96                define('OUTPUT_ERR','ON');
97            }
98        }
99       
100        $this->_smarty->display($template);
101        if(ADMIN_MODE == '1') {
102            $time_end = time();
103            $time = $time_end - $this->time_start;
104            print("½èÍý»þ´Ö:" . $time . "ÉÃ");
105        }
106       
107        print($_SERVER["SERVER_ADDR"]."-");
108    }
109   
110    // ¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£
111    function assignobj($obj) {
112        $data = get_object_vars($obj);
113       
114        foreach ($data as $key => $value){
115            $this->_smarty->assign($key, $value);
116        }
117    }
118   
119    // Ï¢ÁÛÇÛÎóÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£
120    function assignarray($array) {
121        foreach ($array as $key => $val) {
122            $this->_smarty->assign($key, $val);
123        }
124    }
125
126    /* ¥µ¥¤¥È½é´üÀßÄê */
127    function initpath() {
128        global $SC_VIEW_PHP_DIR;
129       
130        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl';
131        $array['tpl_root_id'] = sfGetRootId();
132        $this->assignarray($array);
133    }
134   
135    // ¥Ç¥Ð¥Ã¥°
136    function debug($var = true){
137        $this->_smarty->debugging = $var;
138    }   
139}
140
141class SC_AdminView extends SC_View{
142    function SC_AdminView() {
143        parent::SC_View(false);
144        $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;
145        $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;
146        $this->initpath();
147    }
148
149    function printr($data){
150        print_r($data);
151    }
152}
153
154class SC_SiteView extends SC_View{
155    function SC_SiteView($cart = true) {
156        parent::SC_View();
157       
158        $this->_smarty->template_dir = TEMPLATE_DIR;
159        $this->_smarty->compile_dir = COMPILE_DIR;
160        $this->initpath();
161       
162        // PHP5¤Ç¤Ïsession¤ò¥¹¥¿¡¼¥È¤¹¤ëÁ°¤Ë¥Ø¥Ã¥À¡¼¾ðÊó¤òÁ÷¿®¤·¤Æ¤¤¤ë¤È·Ù¹ð¤¬½Ð¤ë¤¿¤á¡¢Àè¤Ë¥»¥Ã¥·¥ç¥ó¤ò¥¹¥¿¡¼¥È¤¹¤ë¤è¤¦¤ËÊѹ¹
163        sfDomainSessionStart();
164       
165        if($cart){
166            $include_dir = realpath(dirname( __FILE__));
167            require_once($include_dir . "/SC_CartSession.php");
168            $objCartSess = new SC_CartSession();
169            $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
170        }
171    }
172}
173
174class SC_UserView extends SC_SiteView{
175    function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) {
176        parent::SC_SiteView();
177        $this->_smarty->template_dir = $template_dir;
178        $this->_smarty->compile_dir = $compile_dir;
179    }
180}
181
182class SC_InstallView extends SC_View{
183    function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) {
184        parent::SC_View(false);
185        $this->_smarty->template_dir = $template_dir;
186        $this->_smarty->compile_dir = $compile_dir;
187    }
188}
189
190class SC_MobileView extends SC_SiteView {
191    function SC_MobileView() {
192        parent::SC_SiteView();
193        $this->_smarty->template_dir = MOBILE_TEMPLATE_DIR;
194        $this->_smarty->compile_dir = MOBILE_COMPILE_DIR;
195    }   
196}
197?>
Note: See TracBrowser for help on using the repository browser.