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

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