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

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