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

Revision 15780, 7.4 KB checked in by nanasess, 17 years ago (diff)

TPL_DIR を assign するように修正

  • 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_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                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        $this->assign("TPL_DIR", URL_DIR . USER_DIR
77                      . "templates/" . TEMPLATE_NAME . "/");
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
108      // オブジェクト内の変数をすべて割り当てる。
109      function assignobj($obj) {
110        $data = get_object_vars($obj);
111
112        foreach ($data as $key => $value){
113            $this->_smarty->assign($key, $value);
114        }
115      }
116
117      // 連想配列内の変数をすべて割り当てる。
118      function assignarray($array) {
119          foreach ($array as $key => $val) {
120              $this->_smarty->assign($key, $val);
121          }
122      }
123
124    /* サイト初期設定 */
125    function initpath() {
126        global $SC_VIEW_PHP_DIR;
127
128        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl';
129
130        $objDb = new SC_Helper_DB_Ex();
131        $array['tpl_root_id'] = $objDb->sfGetRootId();
132        $this->assignarray($array);
133    }
134
135    // デバッグ
136    function debug($var = true){
137        $this->_smarty->debugging = $var;
138    }
139
140
141}
142
143class SC_AdminView extends SC_View{
144    function SC_AdminView() {
145        parent::SC_View(false);
146        $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;
147        $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;
148        $this->initpath();
149    }
150}
151
152class 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
172class 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
180class 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
188class 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?>
Note: See TracBrowser for help on using the repository browser.