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

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