source: branches/comu-ver2/data/class/SC_View.php @ 18495

Revision 18495, 9.2 KB checked in by Seasoft, 12 years ago (diff)

r18052 の対応漏れ。
フォーラムにて、pigmon 様からご指摘。 http://xoops.ec-cube.net/modules/newbb/viewtopic.php?viewmode=thread&topic_id=4929&forum=5&post_id=25047

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24$SC_VIEW_PHP_DIR = realpath(dirname(__FILE__));
25require_once($SC_VIEW_PHP_DIR . "/../module/Smarty/libs/Smarty.class.php");
26//require_once(CLASS_EX_PATH . "util_extends/SC_Utils_Ex.php");
27
28class SC_View {
29
30    var $_smarty;
31    var $objSiteInfo; // サイト情報
32
33    // コンストラクタ
34    function SC_View($siteinfo = true) {
35        global $SC_VIEW_PHP_DIR;
36
37        $this->_smarty = new Smarty;
38        $this->_smarty->left_delimiter = '<!--{';
39        $this->_smarty->right_delimiter = '}-->';
40        $this->_smarty->register_modifier("sfDispDBDate", array("SC_Utils_Ex", "sfDispDBDate"));
41        $this->_smarty->register_modifier("sfConvSendDateToDisp", array("SC_Utils_Ex", "sfConvSendDateToDisp"));
42        $this->_smarty->register_modifier("sfConvSendWdayToDisp", array("SC_Utils_Ex", "sfConvSendWdayToDisp"));
43        $this->_smarty->register_modifier("sfGetVal", array("SC_Utils_Ex", "sfGetVal"));
44        $this->_smarty->register_modifier("sfGetErrorColor", array("SC_Utils_Ex", "sfGetErrorColor"));
45        $this->_smarty->register_modifier("sfTrim", array("SC_Utils_Ex", "sfTrim"));
46        $this->_smarty->register_modifier("sfPreTax", array("SC_Helper_DB_Ex", "sfPreTax"));
47        $this->_smarty->register_modifier("sfPrePoint", array("SC_Utils_Ex", "sfPrePoint"));
48        $this->_smarty->register_modifier("sfGetChecked",array("SC_Utils_Ex", "sfGetChecked"));
49        $this->_smarty->register_modifier("sfTrimURL", array("SC_Utils_Ex", "sfTrimURL"));
50        $this->_smarty->register_modifier("sfMultiply", array("SC_Utils_Ex", "sfMultiply"));
51        $this->_smarty->register_modifier("sfPutBR", array("SC_Utils_Ex", "sfPutBR"));
52        $this->_smarty->register_modifier("sfRmDupSlash", array("SC_Utils_Ex", "sfRmDupSlash"));
53        $this->_smarty->register_modifier("sfCutString", array("SC_Utils_Ex", "sfCutString"));
54        $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../smarty_extends");
55        $this->_smarty->register_modifier("sf_mb_convert_encoding", array("SC_Utils_Ex", "sf_mb_convert_encoding"));
56        $this->_smarty->register_modifier("sf_mktime", array("SC_Utils_Ex", "sf_mktime"));
57        $this->_smarty->register_modifier("sf_date", array("SC_Utils_Ex", "sf_date"));
58        $this->_smarty->register_modifier("str_replace", array("SC_Utils_Ex", "str_replace"));
59        $this->_smarty->register_modifier("sfGetEnabled", array("SC_Utils_Ex", "sfGetEnabled"));
60//        $this->_smarty->register_modifier("sfPrintEbisTag", array("SC_Utils_Ex", "sfPrintEbisTag"));
61//        $this->_smarty->register_modifier("sfPrintAffTag", array("SC_Utils_Ex", "sfPrintAffTag"));
62        $this->_smarty->register_modifier("sfGetCategoryId", array("SC_Utils_Ex", "sfGetCategoryId"));
63        $this->_smarty->register_modifier("sfNoImageMainList", array("SC_Utils_Ex", "sfNoImageMainList"));
64        $this->_smarty->register_function("sfIsHTTPS", array("SC_Utils_Ex", "sfIsHTTPS"));
65        $this->_smarty->register_function("sfSetErrorStyle", array("SC_Utils_Ex", "sfSetErrorStyle"));
66        $this->_smarty->register_function("printXMLDeclaration", array("SC_Utils_Ex", "printXMLDeclaration"));
67        $this->_smarty->default_modifiers = array('script_escape');
68
69        if(ADMIN_MODE == '1') {
70            $this->time_start = time();
71        }
72
73        // サイト情報を取得する
74        if($siteinfo) {
75            if(!defined('LOAD_SITEINFO')) {
76                $this->objSiteInfo = new SC_SiteInfo();
77                $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data;
78
79                // 都道府県名を変換
80                $masterData = new SC_DB_MasterData_Ex();
81                $arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank"));
82                $arrInfo['arrSiteInfo']['pref'] =
83                    isset($arrPref[$arrInfo['arrSiteInfo']['pref']])
84                    ? $arrPref[$arrInfo['arrSiteInfo']['pref']] : "";
85
86                 // サイト情報を割り当てる
87                foreach ($arrInfo as $key => $value){
88                    $this->_smarty->assign($key, $value);
89                }
90
91                define('LOAD_SITEINFO', 1);
92            }
93        }
94
95        // テンプレート変数を割り当て
96        $this->assign("TPL_DIR", TPL_DIR);
97
98        // ヘッダとフッタを割り当て
99        $header_tpl = USER_PATH . USER_PACKAGE_DIR . TEMPLATE_NAME . "/" . "header.tpl";
100        $footer_tpl = USER_PATH . USER_PACKAGE_DIR . TEMPLATE_NAME . "/" . "footer.tpl";
101
102        // ユーザー作成のテンプレートが無ければ, 指定テンプレートを割り当て
103        if (!$this->_smarty->template_exists($header_tpl)) {
104            $header_tpl = TEMPLATE_DIR . "header.tpl";
105        }
106        if (!$this->_smarty->template_exists($footer_tpl)) {
107            $footer_tpl = TEMPLATE_DIR . "footer.tpl";
108        }
109
110        $this->assign("header_tpl", $header_tpl);
111        $this->assign("footer_tpl", $footer_tpl);
112    }
113
114    // テンプレートに値を割り当てる
115    function assign($val1, $val2) {
116        $this->_smarty->assign($val1, $val2);
117    }
118
119    // テンプレートの処理結果を取得
120    function fetch($template) {
121        return $this->_smarty->fetch($template);
122    }
123
124    // テンプレートの処理結果を表示
125    function display($template, $no_error = false) {
126        if(!$no_error) {
127            global $GLOBAL_ERR;
128            if(!defined('OUTPUT_ERR')) {
129                // GLOBAL_ERR を割り当て
130                $this->assign("GLOBAL_ERR", $GLOBAL_ERR);
131                define('OUTPUT_ERR','ON');
132            }
133        }
134
135        $this->_smarty->display($template);
136        if(ADMIN_MODE == '1') {
137            $time_end = time();
138            $time = $time_end - $this->time_start;
139            print("処理時間:" . $time . "秒");
140        }
141    }
142
143      // オブジェクト内の変数をすべて割り当てる。
144      function assignobj($obj) {
145        $data = get_object_vars($obj);
146
147        foreach ($data as $key => $value){
148            $this->_smarty->assign($key, $value);
149        }
150      }
151
152      // 連想配列内の変数をすべて割り当てる。
153      function assignarray($array) {
154          foreach ($array as $key => $val) {
155              $this->_smarty->assign($key, $val);
156          }
157      }
158
159    /* サイト初期設定 */
160    function initpath() {
161        global $SC_VIEW_PHP_DIR;
162
163        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl';
164
165        $objDb = new SC_Helper_DB_Ex();
166        $array['tpl_root_id'] = $objDb->sfGetRootId();
167        $this->assignarray($array);
168    }
169
170    // デバッグ
171    function debug($var = true){
172        $this->_smarty->debugging = $var;
173    }
174
175
176}
177
178class SC_AdminView extends SC_View{
179    function SC_AdminView() {
180        parent::SC_View(false);
181        $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;
182        $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;
183        $this->initpath();
184    }
185}
186
187class SC_SiteView extends SC_View{
188    function SC_SiteView($setPrevURL = true) {
189        parent::SC_View();
190
191        $this->_smarty->template_dir = TEMPLATE_DIR;
192        $this->_smarty->compile_dir = COMPILE_DIR;
193        $this->initpath();
194
195        // PHP5ではsessionをスタートする前にヘッダー情報を送信していると警告が出るため、先にセッションをスタートするように変更
196        SC_Utils_Ex::sfDomainSessionStart();
197
198        if ($setPrevURL) {
199            $include_dir = realpath(dirname( __FILE__));
200            require_once($include_dir . "/SC_CartSession.php");
201            $objCartSess = new SC_CartSession();
202            $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);
203        }
204    }
205}
206
207class SC_UserView extends SC_SiteView{
208    function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) {
209        parent::SC_SiteView();
210        $this->_smarty->template_dir = $template_dir;
211        $this->_smarty->compile_dir = $compile_dir;
212    }
213}
214
215class SC_InstallView extends SC_View{
216    function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) {
217        parent::SC_View(false);
218        $this->_smarty->template_dir = $template_dir;
219        $this->_smarty->compile_dir = $compile_dir;
220    }
221}
222
223class SC_MobileView extends SC_SiteView {
224    function SC_MobileView() {
225        parent::SC_SiteView();
226        $this->_smarty->template_dir = MOBILE_TEMPLATE_DIR;
227        $this->_smarty->compile_dir = MOBILE_COMPILE_DIR;
228    }
229}
230?>
Note: See TracBrowser for help on using the repository browser.