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

Revision 16326, 8.1 KB checked in by naka, 19 years ago (diff)

class_extendsディレクトリの追加

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