1 | <?php |
---|
2 | /* |
---|
3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
4 | * |
---|
5 | * http://www.lockon.co.jp/ |
---|
6 | */ |
---|
7 | require_once '../require.php'; |
---|
8 | require_once DATA_PATH . "module/Tar.php"; |
---|
9 | require_once DATA_PATH . "module/SearchReplace.php"; |
---|
10 | require_once DATA_PATH . "include/file_manager.inc"; |
---|
11 | |
---|
12 | // ǧ¾Ú²ÄÈݤÎȽÄê |
---|
13 | $objSession = new SC_Session(); |
---|
14 | sfIsSuccess($objSession); |
---|
15 | |
---|
16 | class LC_Page { |
---|
17 | var $tpl_mainpage = 'design/template.tpl'; |
---|
18 | var $tpl_subnavi = 'design/subnavi.tpl'; |
---|
19 | var $tpl_subno = 'template'; |
---|
20 | var $tpl_mainno = "design"; |
---|
21 | var $tpl_subtitle = '¥Æ¥ó¥×¥ì¡¼¥ÈÀßÄê'; |
---|
22 | |
---|
23 | var $arrErr = array(); |
---|
24 | var $arrForm = array(); |
---|
25 | } |
---|
26 | |
---|
27 | $objPage = new LC_Page(); |
---|
28 | |
---|
29 | // uniqid¤ò¥Æ¥ó¥×¥ì¡¼¥È¤ØËä¤á¹þ¤ß |
---|
30 | $objPage->uniqid = $objSession->getUniqId(); |
---|
31 | |
---|
32 | $objView = new SC_AdminView(); |
---|
33 | |
---|
34 | switch(lfGetMode()) { |
---|
35 | |
---|
36 | // ÅÐÏ¿¥Ü¥¿¥ó²¡²¼»þ |
---|
37 | case 'register': |
---|
38 | // ²èÌÌÁ«°Ü¤ÎÀµÅöÀ¥Á¥§¥Ã¥¯ |
---|
39 | if (!sfIsValidTransition($objSession)) { |
---|
40 | sfDispError(''); |
---|
41 | } |
---|
42 | // ¥Ñ¥é¥á¡¼¥¿¸¡¾Ú |
---|
43 | $objForm = lfInitRegister(); |
---|
44 | if ($objForm->checkError()) { |
---|
45 | sfDispError(''); |
---|
46 | } |
---|
47 | |
---|
48 | $template_code = $objForm->getValue('template_code'); |
---|
49 | |
---|
50 | if ($template_code == 'default') { |
---|
51 | $objPage->tpl_onload="alert('½é´ü¥Ç¥¶¥¤¥ó¤ØÌᤷ¤Þ¤·¤¿¡£');"; |
---|
52 | break; |
---|
53 | } |
---|
54 | |
---|
55 | // DB¤Ø»ÈÍѤ¹¤ë¥Æ¥ó¥×¥ì¡¼¥È¤òÅÐÏ¿ |
---|
56 | lfRegisterTemplate($template_code); |
---|
57 | |
---|
58 | // ¥Æ¥ó¥×¥ì¡¼¥È¤Î¾å½ñ¤ |
---|
59 | lfChangeTemplate($template_code); |
---|
60 | |
---|
61 | $objView->_smarty->clear_compiled_tpl(); |
---|
62 | |
---|
63 | // ´°Î»¥á¥Ã¥»¡¼¥¸ |
---|
64 | $objPage->tpl_onload="alert('ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£');"; |
---|
65 | break; |
---|
66 | |
---|
67 | // ºï½ü¥Ü¥¿¥ó²¡²¼»þ |
---|
68 | case 'delete': |
---|
69 | // ²èÌÌÁ«°Ü¤ÎÀµÅöÀ¥Á¥§¥Ã¥¯ |
---|
70 | if (!sfIsValidTransition($objSession)) { |
---|
71 | sfDispError(''); |
---|
72 | } |
---|
73 | // ¥Ñ¥é¥á¡¼¥¿¸¡¾Ú |
---|
74 | $objForm = lfInitDelete(); |
---|
75 | if ($objForm->checkError()) { |
---|
76 | sfDispError(''); |
---|
77 | } |
---|
78 | |
---|
79 | $template_code = $objForm->getValue('template_code_delete'); |
---|
80 | if ($template_code == lfGetNowTemplate()) { |
---|
81 | $objPage->tpl_onload = "alert('ÁªÂòÃæ¤Î¥Æ¥ó¥×¥ì¡¼¥È¤Ïºï½ü½ÐÍè¤Þ¤»¤ó');"; |
---|
82 | break; |
---|
83 | } |
---|
84 | |
---|
85 | lfDeleteTemplate($template_code); |
---|
86 | break; |
---|
87 | |
---|
88 | // ¥×¥ì¥Ó¥å¡¼¥Ü¥¿¥ó²¡²¼»þ |
---|
89 | case 'preview': |
---|
90 | break; |
---|
91 | |
---|
92 | default: |
---|
93 | break; |
---|
94 | } |
---|
95 | |
---|
96 | // default¥Ñ¥é¥á¡¼¥¿¤Î¥»¥Ã¥È |
---|
97 | $objPage->templates = lfGetAllTemplates(); |
---|
98 | $objPage->now_template = lfGetNowtemplate(); |
---|
99 | |
---|
100 | // ²èÌ̤Îɽ¼¨ |
---|
101 | $objView->assignobj($objPage); |
---|
102 | $objView->display(MAIN_FRAME); |
---|
103 | |
---|
104 | /** |
---|
105 | * POST¤µ¤ì¤ëmode¥Ñ¥é¥á¡¼¥¿¤ò¼èÆÀ¤¹¤ë. |
---|
106 | * |
---|
107 | * @param void |
---|
108 | * @return string mode¥Ñ¥é¥á¡¼¥¿, ̵¤±¤ì¤Ðnull |
---|
109 | */ |
---|
110 | function lfGetMode(){ |
---|
111 | if (isset($_POST['mode'])) return $_POST['mode']; |
---|
112 | } |
---|
113 | |
---|
114 | function lfInitRegister() { |
---|
115 | $objForm = new SC_FormParam(); |
---|
116 | $objForm->addParam( |
---|
117 | 'template_code', 'template_code', STEXT_LEN, '', |
---|
118 | array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") |
---|
119 | ); |
---|
120 | $objForm->setParam($_POST); |
---|
121 | |
---|
122 | return $objForm; |
---|
123 | } |
---|
124 | |
---|
125 | function lfInitDelete() { |
---|
126 | $objForm = new SC_FormParam(); |
---|
127 | $objForm->addParam( |
---|
128 | 'template_code_delete', 'template_code_delete', STEXT_LEN, '', |
---|
129 | array("EXIST_CHECK","SPTAB_CHECK","MAX_LENGTH_CHECK", "ALNUM_CHECK") |
---|
130 | ); |
---|
131 | $objForm->setParam($_POST); |
---|
132 | |
---|
133 | return $objForm; |
---|
134 | } |
---|
135 | |
---|
136 | /** |
---|
137 | * ¸½ºßŬÍѤ·¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Ñ¥Ã¥±¡¼¥¸Ì¾¤ò¼èÆÀ¤¹¤ë. |
---|
138 | * |
---|
139 | * @param void |
---|
140 | * @return string ¥Æ¥ó¥×¥ì¡¼¥È¥Ñ¥Ã¥±¡¼¥¸Ì¾ |
---|
141 | */ |
---|
142 | function lfGetNowTemplate() { |
---|
143 | $objQuery = new SC_Query(); |
---|
144 | $arrRet = $objQuery->select('top_tpl', 'dtb_baseinfo'); |
---|
145 | if (isset($arrRet[0]['top_tpl'])) { |
---|
146 | return $arrRet[0]['top_tpl']; |
---|
147 | } |
---|
148 | return null; |
---|
149 | } |
---|
150 | |
---|
151 | /** |
---|
152 | * »ÈÍѤ¹¤ë¥Æ¥ó¥×¥ì¡¼¥È¤òDB¤ØÅÐÏ¿¤¹¤ë |
---|
153 | */ |
---|
154 | function lfRegisterTemplate($template_code) { |
---|
155 | $objQuery = new SC_Query(); |
---|
156 | $objQuery->update( |
---|
157 | 'dtb_baseinfo', |
---|
158 | array('top_tpl'=> $template_code) |
---|
159 | ); |
---|
160 | } |
---|
161 | /** |
---|
162 | * ¥Æ¥ó¥×¥ì¡¼¥È¤ò¾å½ñ¤¥³¥Ô¡¼¤¹¤ë. |
---|
163 | */ |
---|
164 | function lfChangeTemplate($template_code){ |
---|
165 | $from = TPL_PKG_PATH . $template_code . '/user_edit/'; |
---|
166 | |
---|
167 | if (!file_exists($from)) { |
---|
168 | $mess = $from . '¤Ï¸ºß¤·¤Þ¤»¤ó'; |
---|
169 | } else { |
---|
170 | $to = USER_PATH; |
---|
171 | $mess = sfCopyDir($from, $to, '', true); |
---|
172 | } |
---|
173 | return $mess; |
---|
174 | } |
---|
175 | |
---|
176 | function lfGetAllTemplates() { |
---|
177 | $objQuery = new SC_Query(); |
---|
178 | $arrRet = $objQuery->select('*', 'dtb_templates'); |
---|
179 | if (empty($arrRet)) return array(); |
---|
180 | |
---|
181 | return $arrRet; |
---|
182 | } |
---|
183 | |
---|
184 | function lfDeleteTemplate($template_code) { |
---|
185 | $objQuery = new SC_Query(); |
---|
186 | $objQuery->delete('dtb_templates', 'template_code = ?', array($template_code)); |
---|
187 | |
---|
188 | sfDelFile(TPL_PKG_PATH . $template_code); |
---|
189 | } |
---|
190 | ?> |
---|