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

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