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

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