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

Revision 6913, 4.9 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/*
3 * Copyright(c) 2000-2006 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8$SC_VIEW_PHP_DIR = realpath(dirname(__FILE__));
9require_once($SC_VIEW_PHP_DIR . "/../module/Smarty/libs/Smarty.class.php");
10
11class SC_View {
12   
13    var $_smarty;
14    var $objSiteInfo; // ¥µ¥¤¥È¾ðÊó
15   
16    // ¥³¥ó¥¹¥È¥é¥¯¥¿
17    function SC_View($siteinfo = true) {
18        global $SC_VIEW_PHP_DIR;
19
20        $this->_smarty = new Smarty;
21        $this->_smarty->left_delimiter = '<!--{';
22        $this->_smarty->right_delimiter = '}-->';
23        $this->_smarty->register_modifier("sfDispDBDate","sfDispDBDate");
24        $this->_smarty->register_modifier("sfConvSendDateToDisp","sfConvSendDateToDisp");
25        $this->_smarty->register_modifier("sfConvSendWdayToDisp","sfConvSendWdayToDisp");
26        $this->_smarty->register_modifier("sfGetVal", "sfGetVal");
27        $this->_smarty->register_function("sfSetErrorStyle","sfSetErrorStyle");
28        $this->_smarty->register_function("sfGetErrorColor","sfGetErrorColor");
29        $this->_smarty->register_function("srTrim", "sfTrim");
30        $this->_smarty->register_function("sfPreTax", "sfPreTax");
31        $this->_smarty->register_function("sfPrePoint", "sfPrePoint");
32        $this->_smarty->register_function("sfGetChecked", "sfGetChecked");
33        $this->_smarty->register_function("sfTrimURL", "sfTrimURL");
34        $this->_smarty->register_function("sfMultiply", "sfMultiply");
35        $this->_smarty->register_function("sfPutBR", "sfPutBR");
36        $this->_smarty->register_function("sfRmDupSlash", "sfRmDupSlash");
37        $this->_smarty->register_function("sfCutString", "sfCutString");
38        $this->_smarty->plugins_dir=array("plugins", $SC_VIEW_PHP_DIR . "/../smarty_extends");
39        $this->_smarty->register_function("sf_mb_convert_encoding","sf_mb_convert_encoding");
40        $this->_smarty->register_function("sf_mktime","sf_mktime");
41        $this->_smarty->register_function("sf_date","sf_date");
42        $this->_smarty->register_function("str_replace","str_replace");
43        $this->_smarty->register_function("sfPrintEbisTag","sfPrintEbisTag");
44        $this->_smarty->register_function("sfPrintAffTag","sfPrintAffTag");
45       
46        if(ADMIN_MODE == '1') {     
47            $this->time_start = time();
48        }
49
50        // ¥µ¥¤¥È¾ðÊó¤ò¼èÆÀ¤¹¤ë
51        if($siteinfo) {
52            if(!defined('LOAD_SITEINFO')) {
53                $this->objSiteInfo = new SC_SiteInfo();
54                $arrInfo['arrSiteInfo'] = $this->objSiteInfo->data;
55               
56                // ÅÔÆ»Éܸ©Ì¾¤òÊÑ´¹
57                global $arrPref;
58                $arrInfo['arrSiteInfo']['pref'] = $arrPref[$arrInfo['arrSiteInfo']['pref']];
59               
60                // ¥µ¥¤¥È¾ðÊó¤ò³ä¤êÅö¤Æ¤ë
61                foreach ($arrInfo as $key => $value){
62                    $this->_smarty->assign($key, $value);
63                }
64               
65                define('LOAD_SITEINFO', 1);
66            }
67        }
68    }
69   
70    // ¥Æ¥ó¥×¥ì¡¼¥È¤ËÃͤò³ä¤êÅö¤Æ¤ë
71    function assign($val1, $val2) {
72        $this->_smarty->assign($val1, $val2);
73    }
74   
75    // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤ò¼èÆÀ
76    function fetch($template) {
77        return $this->_smarty->fetch($template);
78    }
79   
80    // ¥Æ¥ó¥×¥ì¡¼¥È¤Î½èÍý·ë²Ì¤òɽ¼¨
81    function display($template, $no_error = false) {
82        if(!$no_error) {
83            global $GLOBAL_ERR;
84            if(!defined('OUTPUT_ERR')) {
85                print($GLOBAL_ERR);
86                define('OUTPUT_ERR','ON');
87            }
88        }
89        $this->_smarty->display($template);
90        if(ADMIN_MODE == '1') {
91            $time_end = time();
92            $time = $time_end - $this->time_start;
93            print("½èÍý»þ´Ö:" . $time . "ÉÃ");
94        }
95    }
96   
97    // ¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£
98    function assignobj($obj) {
99        $data = get_object_vars($obj);
100       
101        foreach ($data as $key => $value){
102            $this->_smarty->assign($key, $value);
103        }
104    }
105   
106    // Ï¢ÁÛÇÛÎóÆâ¤ÎÊÑ¿ô¤ò¤¹¤Ù¤Æ³ä¤êÅö¤Æ¤ë¡£
107    function assignarray($array) {
108        foreach ($array as $key => $val) {
109            $this->_smarty->assign($key, $val);
110        }
111    }
112
113    /* ¥µ¥¤¥È½é´üÀßÄê */
114    function initpath() {
115        global $SC_VIEW_PHP_DIR;
116       
117        $array['tpl_mainnavi'] = $SC_VIEW_PHP_DIR . '/../Smarty/templates/frontparts/mainnavi.tpl';
118        $array['tpl_root_id'] = sfGetRootId();
119        $this->assignarray($array);
120    }
121}
122
123class SC_AdminView extends SC_View{
124    function SC_AdminView() {
125        parent::SC_View(false);
126        $this->_smarty->template_dir = TEMPLATE_ADMIN_DIR;
127        $this->_smarty->compile_dir = COMPILE_ADMIN_DIR;
128        $this->initpath();
129    }
130
131    function printr($data){
132        print_r($data);
133    }
134}
135
136class SC_SiteView extends SC_View{
137    function SC_SiteView() {
138        parent::SC_View();
139        $this->_smarty->template_dir = TEMPLATE_DIR;
140        $this->_smarty->compile_dir = COMPILE_DIR;
141        $this->initpath();
142       
143        // PHP5¤Ç¤Ïsession¤ò¥¹¥¿¡¼¥È¤¹¤ëÁ°¤Ë¥Ø¥Ã¥À¡¼¾ðÊó¤òÁ÷¿®¤·¤Æ¤¤¤ë¤È·Ù¹ð¤¬½Ð¤ë¤¿¤á¡¢Àè¤Ë¥»¥Ã¥·¥ç¥ó¤ò¥¹¥¿¡¼¥È¤¹¤ë¤è¤¦¤ËÊѹ¹
144        sfDomainSessionStart();
145    }
146}
147
148class SC_UserView extends SC_SiteView{
149    function SC_UserView($template_dir, $compile_dir = COMPILE_DIR) {
150        parent::SC_SiteView();
151        $this->_smarty->template_dir = $template_dir;
152        $this->_smarty->compile_dir = $compile_dir;
153    }
154}
155
156class SC_InstallView extends SC_View{
157    function SC_InstallView($template_dir, $compile_dir = COMPILE_DIR) {
158        parent::SC_View(false);
159        $this->_smarty->template_dir = $template_dir;
160        $this->_smarty->compile_dir = $compile_dir;
161    }
162}
163
164?>
Note: See TracBrowser for help on using the repository browser.