| 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 | |
|---|
| 12 | class 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","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 | |
|---|
| 47 | if(ADMIN_MODE == '1') { |
|---|
| 48 | $this->time_start = time(); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | // ¥µ¥¤¥È¾ðÊó¤ò¼èÆÀ¤¹¤ë |
|---|
| 52 | if($siteinfo) { |
|---|
| 53 | if(!defined('LOAD_SITEINFO')) { |
|---|
| 54 | $this->objSiteInfo = new SC_SiteInfo(); |
|---|
| 55 | $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data; |
|---|
| 56 | |
|---|
| 57 | // ÅÔÆ»Éܸ©Ì¾¤òÊÑ´¹ |
|---|
| 58 | global $arrPref; |
|---|
| 59 | $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']]; |
|---|
| 60 | |
|---|
| 61 | // ¥µ¥¤¥È¾ðÊó¤ò³ä¤êÅö¤Æ¤ë |
|---|
| 62 | foreach ($arrInfo as $key => $value){ |
|---|
| 63 | $this->_smarty->assign($key, $value); |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | define('LOAD_SITEINFO', 1); |
|---|
| 67 | } |
|---|
| 68 | } |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | // ¥Æ¥ó¥×¥ì¡¼¥È¤ËÃͤò³ä¤êÅö¤Æ¤ë |
|---|
| 72 | function assign($val1, $val2) { |
|---|
| 73 | $this->_smarty->assign($val1, $val2); |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤ò¼èÆÀ |
|---|
| 77 | function fetch($template) { |
|---|
| 78 | return $this->_smarty->fetch($template); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤òɽ¼¨ |
|---|
| 82 | function display($template, $no_error = false) { |
|---|
| 83 | if(!$no_error) { |
|---|
| 84 | global $GLOBAL_ERR; |
|---|
| 85 | if(!defined('OUTPUT_ERR')) { |
|---|
| 86 | print($GLOBAL_ERR); |
|---|
| 87 | define('OUTPUT_ERR','ON'); |
|---|
| 88 | } |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | $this->_smarty->display($template); |
|---|
| 92 | if(ADMIN_MODE == '1') { |
|---|
| 93 | $time_end = time(); |
|---|
| 94 | $time = $time_end - $this->time_start; |
|---|
| 95 | print("½èÍý»þ´Ö:" . $time . "ÉÃ"); |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | // ¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£ |
|---|
| 100 | function assignobj($obj) { |
|---|
| 101 | $data = get_object_vars($obj); |
|---|
| 102 | |
|---|
| 103 | foreach ($data as $key => $value){ |
|---|
| 104 | $this->_smarty->assign($key, $value); |
|---|
| 105 | } |
|---|
| 106 | } |
|---|
| 107 | |
|---|
| 108 | // Ï¢ÁÛÇÛÎóÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£ |
|---|
| 109 | function assignarray($array) { |
|---|
| 110 | foreach ($array as $key => $val) { |
|---|
| 111 | $this->_smarty->assign($key, $val); |
|---|
| 112 | } |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | /* ¥µ¥¤¥È½é´üÀßÄê */ |
|---|
| 116 | function initpath() { |
|---|
| 117 | global $SC_VIEW_PHP_DIR; |
|---|
| 118 | |
|---|
| 119 | $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl'; |
|---|
| 120 | $array['tpl_root_id'] = sfGetRootId(); |
|---|
| 121 | $this->assignarray($array); |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | // ¥Ç¥Ð¥Ã¥° |
|---|
| 125 | function debug($var = true){ |
|---|
| 126 | $this->_smarty->debugging($var); |
|---|
| 127 | } |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | class SC_AdminView extends SC_View{ |
|---|
| 131 | function SC_AdminView() { |
|---|
| 132 | parent::SC_View(false); |
|---|
| 133 | $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR; |
|---|
| 134 | $this->_smarty->compile_dir = COMPILE_ADMIN_DIR; |
|---|
| 135 | $this->initpath(); |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | function printr($data){ |
|---|
| 139 | print_r($data); |
|---|
| 140 | } |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | class SC_SiteView extends SC_View{ |
|---|
| 144 | function SC_SiteView($cart = true) { |
|---|
| 145 | parent::SC_View(); |
|---|
| 146 | $this->_smarty->template_dir = TEMPLATE_DIR; |
|---|
| 147 | $this->_smarty->compile_dir = COMPILE_DIR; |
|---|
| 148 | $this->initpath(); |
|---|
| 149 | |
|---|
| 150 | // PHP5¤Ç¤Ïsession¤ò¥¹¥¿¡¼¥È¤¹¤ëÁ°¤Ë¥Ø¥Ã¥À¡¼¾ðÊó¤òÁ÷¿®¤·¤Æ¤¤¤ë¤È·Ù¹ð¤¬½Ð¤ë¤¿¤á¡¢Àè¤Ë¥»¥Ã¥·¥ç¥ó¤ò¥¹¥¿¡¼¥È¤¹¤ë¤è¤¦¤ËÊѹ¹ |
|---|
| 151 | sfDomainSessionStart(); |
|---|
| 152 | |
|---|
| 153 | if($cart){ |
|---|
| 154 | $include_dir = realpath(dirname( __FILE__)); |
|---|
| 155 | require_once($include_dir . "/SC_CartSession.php"); |
|---|
| 156 | $objCartSess = new SC_CartSession(); |
|---|
| 157 | $objCartSess->setPrevURL($_SERVER['REQUEST_URI']); |
|---|
| 158 | } |
|---|
| 159 | } |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | class SC_UserView extends SC_SiteView{ |
|---|
| 163 | function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) { |
|---|
| 164 | parent::SC_SiteView(); |
|---|
| 165 | $this->_smarty->template_dir = $template_dir; |
|---|
| 166 | $this->_smarty->compile_dir = $compile_dir; |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | class SC_InstallView extends SC_View{ |
|---|
| 171 | function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) { |
|---|
| 172 | parent::SC_View(false); |
|---|
| 173 | $this->_smarty->template_dir = $template_dir; |
|---|
| 174 | $this->_smarty->compile_dir = $compile_dir; |
|---|
| 175 | } |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | ?> |
|---|