source: branches/feature-module-update/data/class/SC_View.php @ 16531

Revision 16531, 8.3 KB checked in by nanasess, 19 years ago (diff)

GLOBAL_ERR を body 内に div タグで出力するように修正

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
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");
10//require_once(CLASS_EX_PATH . "util_extends/SC_Utils_Ex.php");
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", array("SC_Utils_Ex", "sfDispDBDate"));
25        $this->_smarty->register_modifier("sfConvSendDateToDisp", array("SC_Utils_Ex", "sfConvSendDateToDisp"));
26        $this->_smarty->register_modifier("sfConvSendWdayToDisp", array("SC_Utils_Ex", "sfConvSendWdayToDisp"));
27        $this->_smarty->register_modifier("sfGetVal", array("SC_Utils_Ex", "sfGetVal"));
28        $this->_smarty->register_modifier("sfGetErrorColor", array("SC_Utils_Ex", "sfGetErrorColor"));
29        $this->_smarty->register_modifier("sfTrim", array("SC_Utils_Ex", "sfTrim"));
30        $this->_smarty->register_modifier("sfPreTax", array("SC_Utils_Ex", "sfPreTax"));
31        $this->_smarty->register_modifier("sfPrePoint", array("SC_Utils_Ex", "sfPrePoint"));
32        $this->_smarty->register_modifier("sfGetChecked",array("SC_Utils_Ex", "sfGetChecked"));
33        $this->_smarty->register_modifier("sfTrimURL", array("SC_Utils_Ex", "sfTrimURL"));
34        $this->_smarty->register_modifier("sfMultiply", array("SC_Utils_Ex", "sfMultiply"));
35        $this->_smarty->register_modifier("sfPutBR", array("SC_Utils_Ex", "sfPutBR"));
36        $this->_smarty->register_modifier("sfRmDupSlash", array("SC_Utils_Ex", "sfRmDupSlash"));
37        $this->_smarty->register_modifier("sfCutString", array("SC_Utils_Ex", "sfCutString"));
38        $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../smarty_extends");
39        $this->_smarty->register_modifier("sf_mb_convert_encoding", array("SC_Utils_Ex", "sf_mb_convert_encoding"));
40        $this->_smarty->register_modifier("sf_mktime", array("SC_Utils_Ex", "sf_mktime"));
41        $this->_smarty->register_modifier("sf_date", array("SC_Utils_Ex", "sf_date"));
42        $this->_smarty->register_modifier("str_replace", array("SC_Utils_Ex", "str_replace"));
43        $this->_smarty->register_modifier("sfGetEnabled", array("SC_Utils_Ex", "sfGetEnabled"));
44//        $this->_smarty->register_modifier("sfPrintEbisTag", array("SC_Utils_Ex", "sfPrintEbisTag"));
45//        $this->_smarty->register_modifier("sfPrintAffTag", array("SC_Utils_Ex", "sfPrintAffTag"));
46        $this->_smarty->register_modifier("sfGetCategoryId", array("SC_Utils_Ex", "sfGetCategoryId"));
47        $this->_smarty->register_function("sfIsHTTPS", array("SC_Utils_Ex", "sfIsHTTPS"));
48        $this->_smarty->register_function("sfSetErrorStyle", array("SC_Utils_Ex", "sfSetErrorStyle"));
49        $this->_smarty->register_function("printXMLDeclaration", array("SC_Utils_Ex", "printXMLDeclaration"));
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                $masterData = new SC_DB_MasterData_Ex();
64                $arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));
65                $arrInfo['arrSiteInfo']['pref'] =
66                    isset($arrPref[$arrInfo['arrSiteInfo']['pref']])
67                    ? $arrPref[$arrInfo['arrSiteInfo']['pref']] : "";
68
69                 // サイト情報を割り当てる
70                foreach ($arrInfo as $key => $value){
71                    $this->_smarty->assign($key, $value);
72                }
73
74                define('LOAD_SITEINFO', 1);
75            }
76        }
77
78        // テンプレート変数を割り当て
79        $this->assign("TPL_DIR", URL_DIR . USER_DIR
80                      . "templates/" . TEMPLATE_NAME . "/");
81
82        // ヘッダとフッタを割り当て
83        $header_tpl = USER_INC_PATH . "header.tpl";
84        $footer_tpl = USER_INC_PATH . "footer.tpl";
85
86        // ユーザー作成のテンプレートが無ければ, 指定テンプレートを割り当て
87        if (!$this->_smarty->template_exists($header_tpl)) {
88            $header_tpl = TEMPLATE_DIR . "header.tpl";
89        }
90        if (!$this->_smarty->template_exists($footer_tpl)) {
91            $footer_tpl = TEMPLATE_DIR . "footer.tpl";
92        }
93
94        $this->assign("header_tpl", $header_tpl);
95        $this->assign("footer_tpl", $footer_tpl);
96    }
97
98    // テンプレートに値を割り当てる
99    function assign($val1, $val2) {
100        $this->_smarty->assign($val1, $val2);
101    }
102
103    // テンプレートの処理結果を取得
104    function fetch($template) {
105        return $this->_smarty->fetch($template);
106    }
107
108    // テンプレートの処理結果を表示
109    function display($template, $no_error = false) {
110        if(!$no_error) {
111            global $GLOBAL_ERR;
112            if(!defined('OUTPUT_ERR')) {
113                // GLOBAL_ERR を割り当て
114                $this->assign("GLOBAL_ERR", $GLOBAL_ERR);
115                define('OUTPUT_ERR','ON');
116            }
117        }
118
119        $this->_smarty->display($template);
120        if(ADMIN_MODE == '1') {
121            $time_end = time();
122            $time = $time_end - $this->time_start;
123            print("処理時間:" . $time . "秒");
124        }
125    }
126
127      // オブジェクト内の変数をすべて割り当てる。
128      function assignobj($obj) {
129        $data = get_object_vars($obj);
130
131        foreach ($data as $key => $value){
132            $this->_smarty->assign($key, $value);
133        }
134      }
135
136      // 連想配列内の変数をすべて割り当てる。
137      function assignarray($array) {
138          foreach ($array as $key => $val) {
139              $this->_smarty->assign($key, $val);
140          }
141      }
142
143    /* サイト初期設定 */
144    function initpath() {
145        global $SC_VIEW_PHP_DIR;
146
147        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl';
148
149        $objDb = new SC_Helper_DB_Ex();
150        $array['tpl_root_id'] = $objDb->sfGetRootId();
151        $this->assignarray($array);
152    }
153
154    // デバッグ
155    function debug($var = true){
156        $this->_smarty->debugging = $var;
157    }
158
159
160}
161
162class SC_AdminView extends SC_View{
163    function SC_AdminView() {
164        parent::SC_View(false);
165        $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;
166        $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;
167        $this->initpath();
168    }
169}
170
171class SC_SiteView extends SC_View{
172    function SC_SiteView($cart = true) {
173        parent::SC_View();
174
175        $this->_smarty->template_dir = TEMPLATE_DIR;
176        $this->_smarty->compile_dir = COMPILE_DIR;
177        $this->initpath();
178
179        // PHP5ではsessionをスタートする前にヘッダー情報を送信していると警告が出るため、先にセッションをスタートするように変更
180        SC_Utils_Ex::sfDomainSessionStart();
181
182        if($cart){
183            $include_dir = realpath(dirname( __FILE__));
184            require_once($include_dir . "/SC_CartSession.php");
185            $objCartSess = new SC_CartSession();
186            $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
187        }
188    }
189}
190
191class SC_UserView extends SC_SiteView{
192    function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) {
193        parent::SC_SiteView();
194        $this->_smarty->template_dir = $template_dir;
195        $this->_smarty->compile_dir = $compile_dir;
196    }
197}
198
199class SC_InstallView extends SC_View{
200    function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) {
201        parent::SC_View(false);
202        $this->_smarty->template_dir = $template_dir;
203        $this->_smarty->compile_dir = $compile_dir;
204    }
205}
206
207class SC_MobileView extends SC_SiteView {
208    function SC_MobileView() {
209        parent::SC_SiteView();
210        $this->_smarty->template_dir = MOBILE_TEMPLATE_DIR;
211        $this->_smarty->compile_dir = MOBILE_COMPILE_DIR;
212    }
213}
214?>
Note: See TracBrowser for help on using the repository browser.