source: temp/trunk/data/class/SC_View.php @ 2259

Revision 2259, 4.7 KB checked in by naka, 20 years ago (diff)

* empty log message *

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