Changeset 15078 for branches/feature-module-update/data/class/SC_View.php
- Timestamp:
- 2007/07/20 15:58:59 (19 years ago)
- Location:
- branches/feature-module-update
- Files:
-
- 1 edited
- 2 copied
-
. (copied) (copied from branches/rel) (1 prop)
-
data (copied) (copied from branches/rel/data)
-
data/class/SC_View.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/feature-module-update
-
Property
svn:ignore
set to
.cache
.settings
.projectOptions
-
Property
svn:ignore
set to
-
branches/feature-module-update/data/class/SC_View.php
r15053 r15078 9 9 require_once($SC_VIEW_PHP_DIR . "/../module/Smarty/libs/Smarty.class.php"); 10 10 require_once($SC_VIEW_PHP_DIR . "/../include/php_ini.inc"); 11 //require_once(CLASS_PATH . "util_extends/SC_Utils_Ex.php"); 11 12 12 13 class SC_View { 13 14 14 15 var $_smarty; 15 var $objSiteInfo; // ¥µ¥¤¥È¾ðÊó 16 17 // ¥³¥ó¥¹¥È¥é¥¯¥¿16 var $objSiteInfo; // サイト情報 17 18 // コンストラクタ 18 19 function SC_View($siteinfo = true) { 19 global $SC_VIEW_PHP_DIR;20 global $SC_VIEW_PHP_DIR; 20 21 21 $this->_smarty = new Smarty;22 $this->_smarty->left_delimiter = '<!--{';23 $this->_smarty->right_delimiter = '}-->';24 $this->_smarty->register_modifier("sfDispDBDate","sfDispDBDate");25 $this->_smarty->register_modifier("sfConvSendDateToDisp","sfConvSendDateToDisp");26 $this->_smarty->register_modifier("sfConvSendWdayToDisp","sfConvSendWdayToDisp");27 $this->_smarty->register_modifier("sfGetVal", "sfGetVal");28 $this->_smarty->register_function("sfSetErrorStyle","sfSetErrorStyle");29 $this->_smarty->register_function("sfGetErrorColor","sfGetErrorColor");30 $this->_smarty->register_function("sfTrim", "sfTrim");31 $this->_smarty->register_function("sfPreTax", "sfPreTax");32 $this->_smarty->register_function("sfPrePoint", "sfPrePoint");33 $this->_smarty->register_function("sfGetChecked", "sfGetChecked");34 $this->_smarty->register_function("sfTrimURL", "sfTrimURL");35 $this->_smarty->register_function("sfMultiply", "sfMultiply");36 $this->_smarty->register_function("sfPutBR", "sfPutBR");37 $this->_smarty->register_function("sfRmDupSlash", "sfRmDupSlash");38 $this->_smarty->register_function("sfCutString", "sfCutString");39 $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../smarty_extends");40 $this->_smarty->register_function("sf_mb_convert_encoding","sf_mb_convert_encoding");41 $this->_smarty->register_function("sf_mktime","sf_mktime");42 $this->_smarty->register_function("sf_date","sf_date");43 $this->_smarty->register_function("str_replace","str_replace");44 $this->_smarty->register_function("sfPrintEbisTag","sfPrintEbisTag");45 $this->_smarty->register_function("sfPrintAffTag","sfPrintAffTag");46 $this->_smarty->register_function("sfIsHTTPS", "sfIsHTTPS");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_function("sfSetErrorStyle", array("SC_Utils_Ex", "sfSetErrorStyle")); 30 $this->_smarty->register_function("sfGetErrorColor", array("SC_Utils_Ex", "sfGetErrorColor")); 31 $this->_smarty->register_function("sfTrim", array("SC_Utils_Ex", "sfTrim")); 32 $this->_smarty->register_function("sfPreTax", array("SC_Utils_Ex", "sfPreTax")); 33 $this->_smarty->register_function("sfPrePoint", array("SC_Utils_Ex", "sfPrePoint")); 34 $this->_smarty->register_function("sfGetChecked",array("SC_Utils_Ex", "sfGetChecked")); 35 $this->_smarty->register_function("sfTrimURL", array("SC_Utils_Ex", "sfTrimURL")); 36 $this->_smarty->register_function("sfMultiply", array("SC_Utils_Ex", "sfMultiply")); 37 $this->_smarty->register_function("sfPutBR", array("SC_Utils_Ex", "sfPutBR")); 38 $this->_smarty->register_function("sfRmDupSlash", array("SC_Utils_Ex", "sfRmDupSlash")); 39 $this->_smarty->register_function("sfCutString", array("SC_Utils_Ex", "sfCutString")); 40 $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../smarty_extends"); 41 $this->_smarty->register_function("sf_mb_convert_encoding", array("SC_Utils_Ex", "sf_mb_convert_encoding")); 42 $this->_smarty->register_function("sf_mktime", array("SC_Utils_Ex", "sf_mktime")); 43 $this->_smarty->register_function("sf_date", array("SC_Utils_Ex", "sf_date")); 44 $this->_smarty->register_function("str_replace", array("SC_Utils_Ex", "str_replace")); 45 $this->_smarty->register_function("sfPrintEbisTag", array("SC_Utils_Ex", "sfPrintEbisTag")); 46 $this->_smarty->register_function("sfPrintAffTag", array("SC_Utils_Ex", "sfPrintAffTag")); 47 $this->_smarty->register_function("sfIsHTTPS", array("SC_Utils_Ex", "sfIsHTTPS")); 47 48 $this->_smarty->default_modifiers = array('script_escape'); 48 49 if(ADMIN_MODE == '1') {50 $this->time_start = time();51 }52 49 53 // ¥µ¥¤¥È¾ðÊó¤ò¼èÆÀ¤¹¤ë 54 if($siteinfo) { 55 if(!defined('LOAD_SITEINFO')) { 56 $this->objSiteInfo = new SC_SiteInfo(); 57 $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data; 58 59 // ÅÔÆ»Éܸ©Ì¾¤òÊÑ´¹ 60 global $arrPref; 61 $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']]; 62 63 // ¥µ¥¤¥È¾ðÊó¤ò³ä¤êÅö¤Æ¤ë 64 foreach ($arrInfo as $key => $value){ 65 $this->_smarty->assign($key, $value); 66 } 67 68 define('LOAD_SITEINFO', 1); 69 } 70 } 71 } 72 73 // ¥Æ¥ó¥×¥ì¡¼¥È¤ËÃͤò³ä¤êÅö¤Æ¤ë 50 if(ADMIN_MODE == '1') { 51 $this->time_start = time(); 52 } 53 54 // サイト情報を取得する 55 if($siteinfo) { 56 if(!defined('LOAD_SITEINFO')) { 57 $this->objSiteInfo = new SC_SiteInfo(); 58 $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data; 59 60 // 都道府県名を変換 61 global $arrPref; 62 $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']]; 63 64 // サイト情報を割り当てる 65 foreach ($arrInfo as $key => $value){ 66 $this->_smarty->assign($key, $value); 67 } 68 69 define('LOAD_SITEINFO', 1); 70 } 71 } 72 } 73 74 // テンプレートに値を割り当てる 74 75 function assign($val1, $val2) { 75 76 $this->_smarty->assign($val1, $val2); 76 77 } 77 78 // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤ò¼èÆÀ78 79 // テンプレートの処理結果を取得 79 80 function fetch($template) { 80 81 return $this->_smarty->fetch($template); 81 82 } 82 83 // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤òɽ¼¨83 84 // テンプレートの処理結果を表示 84 85 function display($template, $no_error = false) { 85 if(!$no_error) { 86 global $GLOBAL_ERR; 87 if(!defined('OUTPUT_ERR')) { 88 print($GLOBAL_ERR); 89 define('OUTPUT_ERR','ON'); 90 } 91 } 92 93 $this->_smarty->display($template); 94 if(ADMIN_MODE == '1') { 95 $time_end = time(); 96 $time = $time_end - $this->time_start; 97 print("½èÍý»þ´Ö:" . $time . "ÉÃ"); 98 } 99 } 100 101 // ¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£ 102 function assignobj($obj) { 103 $data = get_object_vars($obj); 104 105 foreach ($data as $key => $value){ 106 $this->_smarty->assign($key, $value); 107 } 108 } 109 110 // Ï¢ÁÛÇÛÎóÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£ 111 function assignarray($array) { 112 foreach ($array as $key => $val) { 113 $this->_smarty->assign($key, $val); 114 } 115 } 86 if(!$no_error) { 87 global $GLOBAL_ERR; 88 if(!defined('OUTPUT_ERR')) { 89 print($GLOBAL_ERR); 90 define('OUTPUT_ERR','ON'); 91 } 92 } 116 93 117 /* ¥µ¥¤¥È½é´üÀßÄê */ 118 function initpath() { 119 global $SC_VIEW_PHP_DIR; 120 121 $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl'; 122 $array['tpl_root_id'] = sfGetRootId(); 123 $this->assignarray($array); 124 } 125 126 // ¥Ç¥Ð¥Ã¥° 127 function debug($var = true){ 128 $this->_smarty->debugging = $var; 129 } 94 $this->_smarty->display($template); 95 if(ADMIN_MODE == '1') { 96 $time_end = time(); 97 $time = $time_end - $this->time_start; 98 print("処理時間:" . $time . "秒"); 99 } 100 } 101 102 // オブジェクト内の変数をすべて割り当てる。 103 function assignobj($obj) { 104 $data = get_object_vars($obj); 105 106 foreach ($data as $key => $value){ 107 $this->_smarty->assign($key, $value); 108 } 109 } 110 111 // 連想配列内の変数をすべて割り当てる。 112 function assignarray($array) { 113 foreach ($array as $key => $val) { 114 $this->_smarty->assign($key, $val); 115 } 116 } 117 118 /* サイト初期設定 */ 119 function initpath() { 120 global $SC_VIEW_PHP_DIR; 121 122 $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl'; 123 $array['tpl_root_id'] = SC_Utils::sfGetRootId(); 124 $this->assignarray($array); 125 } 126 127 // デバッグ 128 function debug($var = true){ 129 $this->_smarty->debugging = $var; 130 } 130 131 } 131 132 132 133 class SC_AdminView extends SC_View{ 133 134 function SC_AdminView() { 134 parent::SC_View(false);135 $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;136 $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;137 $this->initpath();138 }135 parent::SC_View(false); 136 $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR; 137 $this->_smarty->compile_dir = COMPILE_ADMIN_DIR; 138 $this->initpath(); 139 } 139 140 140 function printr($data){141 print_r($data);142 }141 function printr($data){ 142 print_r($data); 143 } 143 144 } 144 145 145 146 class SC_SiteView extends SC_View{ 146 147 function SC_SiteView($cart = true) { 147 parent::SC_View();148 149 $this->_smarty->template_dir = TEMPLATE_DIR;150 $this->_smarty->compile_dir = COMPILE_DIR;151 $this->initpath();152 153 // PHP5¤Ç¤Ïsession¤ò¥¹¥¿¡¼¥È¤¹¤ëÁ°¤Ë¥Ø¥Ã¥À¡¼¾ðÊó¤òÁ÷¿®¤·¤Æ¤¤¤ë¤È·Ù¹ð¤¬½Ð¤ë¤¿¤á¡¢Àè¤Ë¥»¥Ã¥·¥ç¥ó¤ò¥¹¥¿¡¼¥È¤¹¤ë¤è¤¦¤ËÊѹ¹ 154 sfDomainSessionStart();155 156 if($cart){157 $include_dir = realpath(dirname( __FILE__));158 require_once($include_dir . "/SC_CartSession.php");159 $objCartSess = new SC_CartSession();160 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']);161 }162 }148 parent::SC_View(); 149 150 $this->_smarty->template_dir = TEMPLATE_DIR; 151 $this->_smarty->compile_dir = COMPILE_DIR; 152 $this->initpath(); 153 154 // PHP5ではsessionをスタートする前にヘッダー情報を送信していると警告が出るため、先にセッションをスタートするように変更 155 SC_Utils::sfDomainSessionStart(); 156 157 if($cart){ 158 $include_dir = realpath(dirname( __FILE__)); 159 require_once($include_dir . "/SC_CartSession.php"); 160 $objCartSess = new SC_CartSession(); 161 $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); 162 } 163 } 163 164 } 164 165 165 166 class SC_UserView extends SC_SiteView{ 166 167 function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) { 167 parent::SC_SiteView();168 $this->_smarty->template_dir = $template_dir;169 $this->_smarty->compile_dir = $compile_dir;170 }168 parent::SC_SiteView(); 169 $this->_smarty->template_dir = $template_dir; 170 $this->_smarty->compile_dir = $compile_dir; 171 } 171 172 } 172 173 173 174 class SC_InstallView extends SC_View{ 174 175 function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) { 175 parent::SC_View(false);176 $this->_smarty->template_dir = $template_dir;177 $this->_smarty->compile_dir = $compile_dir;178 }176 parent::SC_View(false); 177 $this->_smarty->template_dir = $template_dir; 178 $this->_smarty->compile_dir = $compile_dir; 179 } 179 180 } 180 181 181 182 class SC_MobileView extends SC_SiteView { 182 183 function SC_MobileView() { 183 parent::SC_SiteView();184 $this->_smarty->template_dir = MOBILE_TEMPLATE_DIR;185 $this->_smarty->compile_dir = MOBILE_COMPILE_DIR;186 } 184 parent::SC_SiteView(); 185 $this->_smarty->template_dir = MOBILE_TEMPLATE_DIR; 186 $this->_smarty->compile_dir = MOBILE_COMPILE_DIR; 187 } 187 188 } 188 189 ?>
Note: See TracChangeset
for help on using the changeset viewer.
