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

Revision 14608, 5.6 KB checked in by adati, 17 years ago (diff)

ipアドレスの表示を、DEBUG_MODEがfalseの時は出ないように修正

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