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__)); |
---|
9 | require_once($SC_VIEW_PHP_DIR . "/../module/Smarty/libs/Smarty.class.php"); |
---|
10 | require_once($SC_VIEW_PHP_DIR . "/../include/php_ini.inc"); |
---|
11 | //require_once(CLASS_PATH . "util_extends/SC_Utils_Ex.php"); |
---|
12 | |
---|
13 | class SC_View { |
---|
14 | |
---|
15 | var $_smarty; |
---|
16 | var $objSiteInfo; // サイト情報 |
---|
17 | |
---|
18 | // コンストラクタ |
---|
19 | function SC_View($siteinfo = true) { |
---|
20 | global $SC_VIEW_PHP_DIR; |
---|
21 | |
---|
22 | $this->_smarty = new Smarty; |
---|
23 | $this->_smarty->left_delimiter = '<!--{'; |
---|
24 | $this->_smarty->right_delimiter = '}-->'; |
---|
25 | $this->_smarty->register_modifier("sfDispDBDate", array("SC_Utils_Ex", "sfDispDBDate")); |
---|
26 | $this->_smarty->register_modifier("sfConvSendDateToDisp", array("SC_Utils_Ex", "sfConvSendDateToDisp")); |
---|
27 | $this->_smarty->register_modifier("sfConvSendWdayToDisp", array("SC_Utils_Ex", "sfConvSendWdayToDisp")); |
---|
28 | $this->_smarty->register_modifier("sfGetVal", array("SC_Utils_Ex", "sfGetVal")); |
---|
29 | $this->_smarty->register_modifier("sfGetErrorColor", array("SC_Utils_Ex", "sfGetErrorColor")); |
---|
30 | $this->_smarty->register_modifier("sfTrim", array("SC_Utils_Ex", "sfTrim")); |
---|
31 | $this->_smarty->register_modifier("sfPreTax", array("SC_Utils_Ex", "sfPreTax")); |
---|
32 | $this->_smarty->register_modifier("sfPrePoint", array("SC_Utils_Ex", "sfPrePoint")); |
---|
33 | $this->_smarty->register_modifier("sfGetChecked",array("SC_Utils_Ex", "sfGetChecked")); |
---|
34 | $this->_smarty->register_modifier("sfTrimURL", array("SC_Utils_Ex", "sfTrimURL")); |
---|
35 | $this->_smarty->register_modifier("sfMultiply", array("SC_Utils_Ex", "sfMultiply")); |
---|
36 | $this->_smarty->register_modifier("sfPutBR", array("SC_Utils_Ex", "sfPutBR")); |
---|
37 | $this->_smarty->register_modifier("sfRmDupSlash", array("SC_Utils_Ex", "sfRmDupSlash")); |
---|
38 | $this->_smarty->register_modifier("sfCutString", array("SC_Utils_Ex", "sfCutString")); |
---|
39 | $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../smarty_extends"); |
---|
40 | $this->_smarty->register_modifier("sf_mb_convert_encoding", array("SC_Utils_Ex", "sf_mb_convert_encoding")); |
---|
41 | $this->_smarty->register_modifier("sf_mktime", array("SC_Utils_Ex", "sf_mktime")); |
---|
42 | $this->_smarty->register_modifier("sf_date", array("SC_Utils_Ex", "sf_date")); |
---|
43 | $this->_smarty->register_modifier("str_replace", array("SC_Utils_Ex", "str_replace")); |
---|
44 | $this->_smarty->register_modifier("sfGetEnabled", array("SC_Utils_Ex", "sfGetEnabled")); |
---|
45 | // $this->_smarty->register_modifier("sfPrintEbisTag", array("SC_Utils_Ex", "sfPrintEbisTag")); |
---|
46 | // $this->_smarty->register_modifier("sfPrintAffTag", array("SC_Utils_Ex", "sfPrintAffTag")); |
---|
47 | $this->_smarty->register_modifier("sfGetCategoryId", array("SC_Utils_Ex", "sfGetCategoryId")); |
---|
48 | $this->_smarty->register_function("sfIsHTTPS", array("SC_Utils_Ex", "sfIsHTTPS")); |
---|
49 | $this->_smarty->register_function("sfSetErrorStyle", array("SC_Utils_Ex", "sfSetErrorStyle")); |
---|
50 | $this->_smarty->default_modifiers = array('script_escape'); |
---|
51 | |
---|
52 | if(ADMIN_MODE == '1') { |
---|
53 | $this->time_start = time(); |
---|
54 | } |
---|
55 | |
---|
56 | // サイト情報を取得する |
---|
57 | if($siteinfo) { |
---|
58 | if(!defined('LOAD_SITEINFO')) { |
---|
59 | $this->objSiteInfo = new SC_SiteInfo(); |
---|
60 | $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data; |
---|
61 | |
---|
62 | // 都道府県名を変換 |
---|
63 | global $arrPref; |
---|
64 | $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']]; |
---|
65 | |
---|
66 | // サイト情報を割り当てる |
---|
67 | foreach ($arrInfo as $key => $value){ |
---|
68 | $this->_smarty->assign($key, $value); |
---|
69 | } |
---|
70 | |
---|
71 | define('LOAD_SITEINFO', 1); |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | // テンプレートに値を割り当てる |
---|
77 | function assign($val1, $val2) { |
---|
78 | $this->_smarty->assign($val1, $val2); |
---|
79 | } |
---|
80 | |
---|
81 | // テンプレートの処理結果を取得 |
---|
82 | function fetch($template) { |
---|
83 | return $this->_smarty->fetch($template); |
---|
84 | } |
---|
85 | |
---|
86 | // テンプレートの処理結果を表示 |
---|
87 | function display($template, $no_error = false) { |
---|
88 | if(!$no_error) { |
---|
89 | global $GLOBAL_ERR; |
---|
90 | if(!defined('OUTPUT_ERR')) { |
---|
91 | print($GLOBAL_ERR); |
---|
92 | define('OUTPUT_ERR','ON'); |
---|
93 | } |
---|
94 | } |
---|
95 | |
---|
96 | $this->_smarty->display($template); |
---|
97 | if(ADMIN_MODE == '1') { |
---|
98 | $time_end = time(); |
---|
99 | $time = $time_end - $this->time_start; |
---|
100 | print("処理時間:" . $time . "秒"); |
---|
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 | |
---|
126 | $objDb = new SC_Helper_DB_Ex(); |
---|
127 | $array['tpl_root_id'] = $objDb->sfGetRootId(); |
---|
128 | $this->assignarray($array); |
---|
129 | } |
---|
130 | |
---|
131 | // デバッグ |
---|
132 | function debug($var = true){ |
---|
133 | $this->_smarty->debugging = $var; |
---|
134 | } |
---|
135 | |
---|
136 | |
---|
137 | } |
---|
138 | |
---|
139 | class SC_AdminView extends SC_View{ |
---|
140 | function SC_AdminView() { |
---|
141 | parent::SC_View(false); |
---|
142 | $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR; |
---|
143 | $this->_smarty->compile_dir = COMPILE_ADMIN_DIR; |
---|
144 | $this->initpath(); |
---|
145 | } |
---|
146 | |
---|
147 | function printr($data){ |
---|
148 | print_r($data); |
---|
149 | } |
---|
150 | } |
---|
151 | |
---|
152 | class SC_SiteView extends SC_View{ |
---|
153 | function SC_SiteView($cart = true) { |
---|
154 | parent::SC_View(); |
---|
155 | |
---|
156 | $this->_smarty->template_dir = TEMPLATE_DIR; |
---|
157 | $this->_smarty->compile_dir = COMPILE_DIR; |
---|
158 | $this->initpath(); |
---|
159 | |
---|
160 | // PHP5ではsessionをスタートする前にヘッダー情報を送信していると警告が出るため、先にセッションをスタートするように変更 |
---|
161 | SC_Utils_Ex::sfDomainSessionStart(); |
---|
162 | |
---|
163 | if($cart){ |
---|
164 | $include_dir = realpath(dirname( __FILE__)); |
---|
165 | require_once($include_dir . "/SC_CartSession.php"); |
---|
166 | $objCartSess = new SC_CartSession(); |
---|
167 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); |
---|
168 | } |
---|
169 | } |
---|
170 | } |
---|
171 | |
---|
172 | class SC_UserView extends SC_SiteView{ |
---|
173 | function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) { |
---|
174 | parent::SC_SiteView(); |
---|
175 | $this->_smarty->template_dir = $template_dir; |
---|
176 | $this->_smarty->compile_dir = $compile_dir; |
---|
177 | } |
---|
178 | } |
---|
179 | |
---|
180 | class SC_InstallView extends SC_View{ |
---|
181 | function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) { |
---|
182 | parent::SC_View(false); |
---|
183 | $this->_smarty->template_dir = $template_dir; |
---|
184 | $this->_smarty->compile_dir = $compile_dir; |
---|
185 | } |
---|
186 | } |
---|
187 | |
---|
188 | class SC_MobileView extends SC_SiteView { |
---|
189 | function SC_MobileView() { |
---|
190 | parent::SC_SiteView(); |
---|
191 | $this->_smarty->template_dir = MOBILE_TEMPLATE_DIR; |
---|
192 | $this->_smarty->compile_dir = MOBILE_COMPILE_DIR; |
---|
193 | } |
---|
194 | } |
---|
195 | ?> |
---|