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

Revision 2244, 4.3 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   
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 . "/../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, $siteinfo = true) {
63        $data = get_object_vars($obj);
64       
65        foreach ($data as $key => $value){
66            $this->_smarty->assign($key, $value);
67        }
68       
69        if($siteinfo) {
70            // ¥µ¥¤¥È¾ðÊó¤ò³ä¤êÅö¤Æ¤ë
71            $objSiteInfo = new SC_SiteInfo();
72            $arrInfo['arrSiteInfo'] = $objSiteInfo->data;
73           
74            // ÅÔÆ»Éܸ©Ì¾¤òÊÑ´¹
75            global $arrPref;
76            $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']];
77           
78            foreach ($arrInfo as $key => $value){
79                $this->_smarty->assign($key, $value);
80            }
81        }       
82    }
83   
84    // Ï¢ÁÛÇÛÎóÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£
85    function assignarray($array) {
86        foreach ($array as $key => $val) {
87            $this->_smarty->assign($key, $val);
88        }
89    }
90
91    /* ¥µ¥¤¥È½é´üÀßÄê */
92    function initpath() {
93        global $SC_VIEW_PHP_DIR;
94       
95        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl';
96        $array['tpl_root_id'] = sfGetRootId();
97        $this->assignarray($array);
98    }
99}
100
101class SC_AdminView extends SC_View{
102    function SC_AdminView() {
103        parent::SC_View();
104        $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;
105        $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;
106        $this->initpath();
107    }
108   
109    function printr($data){
110        print_r($data);
111    }
112}
113
114class SC_SiteView extends SC_View{
115    function SC_SiteView() {
116        parent::SC_View();
117        $this->_smarty->template_dir = TEMPLATE_DIR;
118        $this->_smarty->compile_dir = COMPILE_DIR;
119        $this->initpath();
120       
121        // PHP5¤Ç¤Ïsession¤ò¥¹¥¿¡¼¥È¤¹¤ëÁ°¤Ë¥Ø¥Ã¥À¡¼¾ðÊó¤òÁ÷¿®¤·¤Æ¤¤¤ë¤È·Ù¹ð¤¬½Ð¤ë¤¿¤á¡¢Àè¤Ë¥»¥Ã¥·¥ç¥ó¤ò¥¹¥¿¡¼¥È¤¹¤ë¤è¤¦¤ËÊѹ¹
122        sfDomainSessionStart();
123    }
124}
125
126class SC_UserView extends SC_SiteView{
127    function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) {
128        parent::SC_SiteView();
129        $this->_smarty->template_dir = $template_dir;
130        $this->_smarty->compile_dir = $compile_dir;
131    }
132}
133
134class SC_InstallView extends SC_View{
135    function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) {
136        parent::SC_View();
137        $this->_smarty->template_dir = $template_dir;
138        $this->_smarty->compile_dir = $compile_dir;
139    }
140}
141
142?>
Note: See TracBrowser for help on using the repository browser.