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