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

Revision 15697, 7.4 KB checked in by nanasess, 19 years ago (diff)

default_modifier 修正

  • 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");
10require_once($SC_VIEW_PHP_DIR . "/../include/php_ini.inc");
11//require_once(CLASS_PATH . "util_extends/SC_Utils_Ex.php");
12
13class 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->register_function("printXMLDeclaration", array("SC_Utils_Ex", "printXMLDeclaration"));
51        $this->_smarty->default_modifiers = array('script_escape', "escape");
52
53        if(ADMIN_MODE == '1') {
54            $this->time_start = time();
55        }
56
57        // サイト情報を取得する
58        if($siteinfo) {
59            if(!defined('LOAD_SITEINFO')) {
60                $this->objSiteInfo = new SC_SiteInfo();
61                $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data;
62
63                // 都道府県名を変換
64                global $arrPref;
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    // テンプレートに値を割り当てる
78    function assign($val1, $val2) {
79        $this->_smarty->assign($val1, $val2);
80    }
81
82    // テンプレートの処理結果を取得
83    function fetch($template) {
84        return $this->_smarty->fetch($template);
85    }
86
87    // テンプレートの処理結果を表示
88    function display($template, $no_error = false) {
89        if(!$no_error) {
90            global $GLOBAL_ERR;
91            if(!defined('OUTPUT_ERR')) {
92                print($GLOBAL_ERR);
93                define('OUTPUT_ERR','ON');
94            }
95        }
96
97        $this->_smarty->display($template);
98        if(ADMIN_MODE == '1') {
99            $time_end = time();
100            $time = $time_end - $this->time_start;
101            print("処理時間:" . $time . "秒");
102        }
103    }
104
105      // オブジェクト内の変数をすべて割り当てる。
106      function assignobj($obj) {
107        $data = get_object_vars($obj);
108
109        foreach ($data as $key => $value){
110            $this->_smarty->assign($key, $value);
111        }
112      }
113
114      // 連想配列内の変数をすべて割り当てる。
115      function assignarray($array) {
116          foreach ($array as $key => $val) {
117              $this->_smarty->assign($key, $val);
118          }
119      }
120
121    /* サイト初期設定 */
122    function initpath() {
123        global $SC_VIEW_PHP_DIR;
124
125        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl';
126
127        $objDb = new SC_Helper_DB_Ex();
128        $array['tpl_root_id'] = $objDb->sfGetRootId();
129        $this->assignarray($array);
130    }
131
132    // デバッグ
133    function debug($var = true){
134        $this->_smarty->debugging = $var;
135    }
136
137
138}
139
140class SC_AdminView extends SC_View{
141    function SC_AdminView() {
142        parent::SC_View(false);
143        $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;
144        $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;
145        $this->_smarty->default_modifiers = array('script_escape');
146        $this->initpath();
147    }
148
149    function printr($data){
150        print_r($data);
151    }
152}
153
154class SC_SiteView extends SC_View{
155    function SC_SiteView($cart = true) {
156        parent::SC_View();
157
158        $this->_smarty->template_dir = TEMPLATE_DIR;
159        $this->_smarty->compile_dir = COMPILE_DIR;
160        $this->initpath();
161
162        // PHP5ではsessionをスタートする前にヘッダー情報を送信していると警告が出るため、先にセッションをスタートするように変更
163        SC_Utils_Ex::sfDomainSessionStart();
164
165        if($cart){
166            $include_dir = realpath(dirname( __FILE__));
167            require_once($include_dir . "/SC_CartSession.php");
168            $objCartSess = new SC_CartSession();
169            $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
170        }
171    }
172}
173
174class SC_UserView extends SC_SiteView{
175    function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) {
176        parent::SC_SiteView();
177        $this->_smarty->template_dir = $template_dir;
178        $this->_smarty->compile_dir = $compile_dir;
179    }
180}
181
182class SC_InstallView extends SC_View{
183    function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) {
184        parent::SC_View(false);
185        $this->_smarty->template_dir = $template_dir;
186        $this->_smarty->compile_dir = $compile_dir;
187    }
188}
189
190class SC_MobileView extends SC_SiteView {
191    function SC_MobileView() {
192        parent::SC_SiteView();
193        $this->_smarty->template_dir = MOBILE_TEMPLATE_DIR;
194        $this->_smarty->compile_dir = MOBILE_COMPILE_DIR;
195    }
196}
197?>
Note: See TracBrowser for help on using the repository browser.