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

Revision 2270, 4.5 KB checked in by kakinaka, 20 years ago (diff)

blank

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