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

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