| 1 | <?php |
|---|
| 2 | $SC_VIEW_PHP_DIR = realpath(dirname(__FILE__)); |
|---|
| 3 | require_once($SC_VIEW_PHP_DIR . "/../module/Smarty/libs/Smarty.class.php"); |
|---|
| 4 | |
|---|
| 5 | class SC_View { |
|---|
| 6 | |
|---|
| 7 | var $_smarty; |
|---|
| 8 | |
|---|
| 9 | // ¥³¥ó¥¹¥È¥é¥¯¥¿ |
|---|
| 10 | function SC_View() { |
|---|
| 11 | global $SC_VIEW_PHP_DIR; |
|---|
| 12 | |
|---|
| 13 | $this->_smarty = new Smarty; |
|---|
| 14 | $this->_smarty->left_delimiter = '<!--{'; |
|---|
| 15 | $this->_smarty->right_delimiter = '}-->'; |
|---|
| 16 | $this->_smarty->register_modifier("sfDispDBDate","sfDispDBDate"); |
|---|
| 17 | $this->_smarty->register_modifier("sfConvSendDateToDisp","sfConvSendDateToDisp"); |
|---|
| 18 | $this->_smarty->register_modifier("sfConvSendWdayToDisp","sfConvSendWdayToDisp"); |
|---|
| 19 | $this->_smarty->register_modifier("sfGetVal", "sfGetVal"); |
|---|
| 20 | $this->_smarty->register_function("sfSetErrorStyle","sfSetErrorStyle"); |
|---|
| 21 | $this->_smarty->register_function("sfGetErrorColor","sfGetErrorColor"); |
|---|
| 22 | $this->_smarty->register_function("srTrim", "sfTrim"); |
|---|
| 23 | $this->_smarty->register_function("sfPreTax", "sfPreTax"); |
|---|
| 24 | $this->_smarty->register_function("sfPrePoint", "sfPrePoint"); |
|---|
| 25 | $this->_smarty->register_function("sfGetChecked", "sfGetChecked"); |
|---|
| 26 | $this->_smarty->register_function("sfTrimURL", "sfTrimURL"); |
|---|
| 27 | $this->_smarty->register_function("sfMultiply", "sfMultiply"); |
|---|
| 28 | $this->_smarty->register_function("sfPutBR", "sfPutBR"); |
|---|
| 29 | $this->_smarty->register_function("sfRmDupSlash", "sfRmDupSlash"); |
|---|
| 30 | $this->_smarty->register_function("sfCutString", "sfCutString"); |
|---|
| 31 | $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../data/smarty_extends"); |
|---|
| 32 | $this->_smarty->register_function("sf_mb_convert_encoding","sf_mb_convert_encoding"); |
|---|
| 33 | $this->_smarty->register_function("sf_mktime","sf_mktime"); |
|---|
| 34 | $this->_smarty->register_function("sf_date","sf_date"); |
|---|
| 35 | |
|---|
| 36 | if(ADMIN_MODE == '1') { |
|---|
| 37 | $this->time_start = time(); |
|---|
| 38 | } |
|---|
| 39 | } |
|---|
| 40 | |
|---|
| 41 | // ¥Æ¥ó¥×¥ì¡¼¥È¤ËÃͤò³ä¤êÅö¤Æ¤ë |
|---|
| 42 | function assign($val1, $val2) { |
|---|
| 43 | $this->_smarty->assign($val1, $val2); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤ò¼èÆÀ |
|---|
| 47 | function fetch($template) { |
|---|
| 48 | return $this->_smarty->fetch($template); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤òɽ¼¨ |
|---|
| 52 | function display($template) { |
|---|
| 53 | $this->_smarty->display($template); |
|---|
| 54 | if(ADMIN_MODE == '1') { |
|---|
| 55 | $time_end = time(); |
|---|
| 56 | $time = $time_end - $this->time_start; |
|---|
| 57 | print("½èÍý»þ´Ö:" . $time . "ÉÃ"); |
|---|
| 58 | } |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | // ¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£ |
|---|
| 62 | function assignobj($obj) { |
|---|
| 63 | $data = get_object_vars($obj); |
|---|
| 64 | |
|---|
| 65 | foreach ($data as $key => $value){ |
|---|
| 66 | $this->_smarty->assign($key, $value); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | // ¥µ¥¤¥È¾ðÊó¤ò³ä¤êÅö¤Æ¤ë |
|---|
| 70 | $objSiteInfo = new SC_SiteInfo(); |
|---|
| 71 | $arrInfo['arrSiteInfo'] = $objSiteInfo->data; |
|---|
| 72 | |
|---|
| 73 | // ÅÔÆ»Éܸ©Ì¾¤òÊÑ´¹ |
|---|
| 74 | global $arrPref; |
|---|
| 75 | $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']]; |
|---|
| 76 | |
|---|
| 77 | foreach ($arrInfo as $key => $value){ |
|---|
| 78 | $this->_smarty->assign($key, $value); |
|---|
| 79 | } |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | // Ï¢ÁÛÇÛÎóÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£ |
|---|
| 83 | function assignarray($array) { |
|---|
| 84 | foreach ($array as $key => $val) { |
|---|
| 85 | $this->_smarty->assign($key, $val); |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | /* ¥µ¥¤¥È½é´üÀßÄê */ |
|---|
| 90 | function initpath() { |
|---|
| 91 | global $SC_VIEW_PHP_DIR; |
|---|
| 92 | |
|---|
| 93 | $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../data/Smarty/templates/frontparts/mainnavi.tpl'; |
|---|
| 94 | $array['tpl_root_id'] = sfGetRootId(); |
|---|
| 95 | $this->assignarray($array); |
|---|
| 96 | } |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | class SC_AdminView extends SC_View{ |
|---|
| 100 | function SC_AdminView() { |
|---|
| 101 | parent::SC_View(); |
|---|
| 102 | $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR; |
|---|
| 103 | $this->_smarty->compile_dir = COMPILE_ADMIN_DIR; |
|---|
| 104 | $this->initpath(); |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | function printr($data){ |
|---|
| 108 | print_r($data); |
|---|
| 109 | } |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | class SC_SiteView extends SC_View{ |
|---|
| 113 | function SC_SiteView() { |
|---|
| 114 | parent::SC_View(); |
|---|
| 115 | $this->_smarty->template_dir = TEMPLATE_DIR; |
|---|
| 116 | $this->_smarty->compile_dir = COMPILE_DIR; |
|---|
| 117 | $this->initpath(); |
|---|
| 118 | |
|---|
| 119 | // PHP5¤Ç¤Ïsession¤ò¥¹¥¿¡¼¥È¤¹¤ëÁ°¤Ë¥Ø¥Ã¥À¡¼¾ðÊó¤òÁ÷¿®¤·¤Æ¤¤¤ë¤È·Ù¹ð¤¬½Ð¤ë¤¿¤á¡¢Àè¤Ë¥»¥Ã¥·¥ç¥ó¤ò¥¹¥¿¡¼¥È¤¹¤ë¤è¤¦¤ËÊѹ¹ |
|---|
| 120 | sfDomainSessionStart(); |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | class SC_UserView extends SC_SiteView{ |
|---|
| 125 | function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) { |
|---|
| 126 | parent::SC_SiteView(); |
|---|
| 127 | $this->_smarty->template_dir = $template_dir; |
|---|
| 128 | $this->_smarty->compile_dir = $compile_dir; |
|---|
| 129 | } |
|---|
| 130 | } |
|---|
| 131 | ?> |
|---|