source: branches/feature-templates/html/admin/design/template.php @ 15812

Revision 15812, 4.4 KB checked in by adachi, 15 years ago (diff)

細かな修正

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