source: temp/trunk/html/admin/design/template.php @ 3324

Revision 3324, 8.6 KB checked in by kakinaka, 20 years ago (diff)

blank

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3require_once("../../require.php");
4
5class LC_Page {
6    var $arrForm;
7    var $arrHidden;
8    var $arrSubnavi = array(
9        1 => 'top',
10        2 => 'product',
11        3 => 'detail',
12        4 => 'mypage',
13    );
14
15    function LC_Page() {
16        $this->tpl_mainpage = 'design/template.tpl';
17        $this->tpl_subnavi = 'design/subnavi.tpl';
18        $this->tpl_subno = 'template';
19        $this->tpl_subno_template = $this->arrSubnavi[1];
20        $this->tpl_mainno = "design";
21        $this->tpl_subtitle = '¥Æ¥ó¥×¥ì¡¼¥ÈÁªÂò';
22    }
23}
24
25$objPage = new LC_Page();
26$objView = new SC_AdminView();
27$objSess = new SC_Session();
28
29// ǧ¾Ú²ÄÈݤÎȽÄê
30$objSess = new SC_Session();
31sfIsSuccess($objSess);
32
33// GET¤ÎÃͤò¼õ¤±¼è¤ë
34$get_tpl_subno_template = $_GET['tpl_subno_template'];
35
36// GET¤ÇÃͤ¬Á÷¤é¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¤½¤ÎÃͤò¸µ¤Ë²èÌÌɽ¼¨¤òÀÚ¤êÂØ¤¨¤ë
37if ($get_tpl_subno_template != ""){
38    // Á÷¤é¤ì¤Æ¤­¤¿Ãͤ¬ÇÛÎó¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤ÐTOP¤òɽ¼¨
39    if (in_array($get_tpl_subno_template,$objPage->arrSubnavi)){
40        $tpl_subno_template = $get_tpl_subno_template;
41    }else{
42        $tpl_subno_template = $objPage->arrSubnavi[1];
43    }
44} else {
45    // GET¤ÇÃͤ¬¤Ê¤±¤ì¤ÐPOST¤ÎÃͤò»ÈÍѤ¹¤ë
46    if ($_POST['tpl_subno_template'] != ""){
47        $tpl_subno_template = $_POST['tpl_subno_template'];
48    }else{
49        $tpl_subno_template = $objPage->arrSubnavi[1];
50    }
51}
52$objPage->tpl_subno_template = $tpl_subno_template;
53
54// ÅÐÏ¿¤ò²¡¤µ¤ì¤¿¤Ð¤¢¤Ë¤ÏDB¤Ø¥Ç¡¼¥¿¤ò¹¹¿·¤Ë¹Ô¤¯
55if ($_POST['mode'] == "confirm"){
56    // DB¤Ø¥Ç¡¼¥¿¹¹¿·
57    lfUpdData();
58   
59    // ¥Æ¥ó¥×¥ì¡¼¥È¤Î¾å½ñ¤­
60    lfChangeTemplate();
61   
62    sfprintr($_POST);
63}
64
65// POSTÃͤΰú¤­·Ñ¤®
66$objPage->arrForm = $_POST;
67
68// ²èÁü¼èÆÀ
69$tpl_arrTemplate = array();
70$objPage->arrTemplate = lfgetTemplate();
71
72// ¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯¼èÆÀ
73$objPage->MainImage = $objPage->arrTemplate['check'];
74$objPage->arrTemplate['check'] = array($objPage->arrTemplate['check']=>"check");
75
76sfprintr($objPage->arrTemplate);
77
78// ²èÌ̤Îɽ¼¨
79$objView->assignobj($objPage);
80$objView->display(MAIN_FRAME);
81
82//---------------------------------------------------------------------------------------------------------------------------------------------------------
83
84/**************************************************************************************************************
85 * ´Ø¿ô̾   ¡§lfgetTemplate
86 * ½èÍýÆâÍÆ ¡§²èÌ̤Ëɽ¼¨¤¹¤ë²èÁü¤ò¼èÆÀ¤¹¤ë
87 * °ú¿ô     ¡§¤Ê¤·
88 * Ìá¤êÃÍ   ¡§²èÌ̤Ëɽ¼¨¤¹¤ë²èÁü(ÇÛÎó)
89 **************************************************************************************************************/
90function lfgetTemplate(){
91    global $objPage;
92    $filepath = "/test/kakinaka/";
93   
94    $arrTemplateImage = array();    // ²èÌÌɽ¼¨²èÁü³ÊǼÍÑ
95    $Image = "";                    // ¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
96    $disp = "";
97    $arrDefcheck = array();         // radio¥Ü¥¿¥ó¤Î¥Ç¥Õ¥©¥ë¥È¥Á¥§¥Ã¥¯³ÊǼÍÑ
98   
99    // DB¤«¤é¸½ºßÁªÂò¤µ¤ì¤Æ¤¤¤ë¥Ç¡¼¥¿¼èÆÀ
100    $arrDefcheck = lfgetTemplaeBaseData();
101   
102    // ¥Æ¥ó¥×¥ì¡¼¥È¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë
103    $objQuery = new SC_Query();
104    $sql = "SELECT template_code,template_name,file_path FROM dtb_template ORDER BY create_date DESC";
105    $arrTemplate = $objQuery->getall($sql);
106   
107    switch($objPage->tpl_subno_template) {
108        // TOP
109        case $objPage->arrSubnavi[1]:
110            $Image = "TopImage.jpg";            // ¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
111            $disp = $objPage->arrSubnavi[1];
112            break;
113           
114        // ¾¦ÉʰìÍ÷
115        case $objPage->arrSubnavi[2]:
116            $Image = "ProdImage.jpg";           // ¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
117            $disp = $objPage->arrSubnavi[2];
118            break;
119           
120        // ¾¦ÉʾܺÙ
121        case $objPage->arrSubnavi[3]:
122            $Image = "DetailImage.jpg";         // ¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
123            $disp = $objPage->arrSubnavi[3];
124            break;
125           
126        // MY¥Ú¡¼¥¸
127        case $objPage->arrSubnavi[4]:
128            $Image = "MypageImage.jpg";         //¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
129            $disp = $objPage->arrSubnavi[4];
130            break;
131    }
132
133    // ²èÁüɽ¼¨ÇÛÎóºîÀ®
134    foreach($arrTemplate as $key => $val){
135        $arrTemplateImage['image'][$val['template_code']] = $filepath . $val['template_code'] . "/" . $Image;
136        $arrTemplateImage['code'][$key] = $val['template_code'];
137    }
138   
139   
140    // ½é´ü¥Á¥§¥Ã¥¯
141    if (isset($arrDefcheck[$disp])){
142        $arrTemplateImage['check'] = $arrDefcheck[$disp];
143    }else{
144        $arrTemplateImage['check'] = 1;
145    }
146   
147    return $arrTemplateImage;
148}
149
150/**************************************************************************************************************
151 * ´Ø¿ô̾   ¡§lfgetTemplaeBaseData
152 * ½èÍýÆâÍÆ ¡§DB¤ËÊݸ¤µ¤ì¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë
153 * °ú¿ô     ¡§¤Ê¤·
154 * Ìá¤êÃÍ   ¡§DB¤ËÊݸ¤µ¤ì¤Æ¤¤¤ë¥Æ¥ó¥×¥ì¡¼¥È¥Ç¡¼¥¿(ÇÛÎó)
155 **************************************************************************************************************/
156function lfgetTemplaeBaseData(){
157    $objDBConn = new SC_DbConn;     // DBÁàºî¥ª¥Ö¥¸¥§¥¯¥È
158    $sql = "";                      // ¥Ç¡¼¥¿¼èÆÀSQLÀ¸À®ÍÑ
159    $arrRet = array();              // ¥Ç¡¼¥¿¼èÆÀÍÑ
160   
161    $sql = "SELECT top_tpl AS top, product_tpl AS product, detail_tpl AS detail, mypage_tpl AS mypage FROM dtb_baseinfo";
162    $arrRet = $objDBConn->getAll($sql);
163   
164    return $arrRet[0];
165}
166
167/**************************************************************************************************************
168 * ´Ø¿ô̾   ¡§lfUpdData
169 * ½èÍýÆâÍÆ ¡§DB¤Ë¥Ç¡¼¥¿¤òÊݸ¤¹¤ë
170 * °ú¿ô     ¡§¤Ê¤·
171 * Ìá¤êÃÍ   ¡§À®¸ù TRUE¡¢¥¨¥é¡¼ FALSE
172 **************************************************************************************************************/
173function lfUpdData(){
174    global $objPage;
175    $objDBConn = new SC_DbConn;     // DBÁàºî¥ª¥Ö¥¸¥§¥¯¥È
176    $sql = "";                      // ¥Ç¡¼¥¿¼èÆÀSQLÀ¸À®ÍÑ
177    $arrRet = array();              // ¥Ç¡¼¥¿¼èÆÀÍÑ(¹¹¿·È½Äê)
178
179    // ¥Ç¡¼¥¿¼èÆÀ   
180    $sql = "SELECT top_tpl AS top, product_tpl AS product, detail_tpl AS detail, mypage_tpl AS mypage FROM dtb_baseinfo";
181    $arrRet = $objDBConn->getAll($sql);
182
183    $chk_tpl = $_POST['check_template'];
184    // ¥Ç¡¼¥¿¤¬¼èÆÀ¤Ç¤­¤Ê¤±¤ì¤ÐINSERT¡¢¤Ç¤­¤ì¤ÐUPDATE
185    if (isset($arrRet[0])){
186        // UPDATE
187        $arrVal = $arrRet[0];
188       
189        // TOP¤òÊѹ¹¤·¤¿¾ì¹ç¤Ë¤ÏÁ´²èÌÌÊѹ¹
190        if ($objPage->tpl_subno_template == $objPage->arrSubnavi[1]){
191            $arrVal = array($chk_tpl,$chk_tpl,$chk_tpl,$chk_tpl);
192        }else{
193            $arrVal[$objPage->tpl_subno_template] = $chk_tpl;
194        }
195        $sql= "update dtb_baseinfo set top_tpl = ?, product_tpl = ?, detail_tpl = ?, mypage_tpl = ?, update_date = now()";
196    }else{
197        // INSERT
198        $arrVal = array(null,null,null,null);
199       
200        // TOP¤òÊѹ¹¤·¤¿¾ì¹ç¤Ë¤ÏÁ´²èÌÌÊѹ¹
201        if ($objPage->tpl_subno_template == $objPage->arrSubnavi[1]){
202            $arrVal = array($chk_tpl,$chk_tpl,$chk_tpl,$chk_tpl);
203        }else{
204            $arrVal[$chk_tpl-1] =$chk_tpl;
205        }
206        $sql= "insert into dtb_baseinfo (top_tpl,product_tpl,detail_tpl,mypage_tpl, update_date) values (?,?,?,?,now());";
207    }
208
209    // SQL¼Â¹Ô 
210    $arrRet = $objDBConn->query($sql,$arrVal);
211   
212    return $arrRet;
213}
214
215/**************************************************************************************************************
216 * ´Ø¿ô̾   ¡§lfChangeTemplate
217 * ½èÍýÆâÍÆ ¡§¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤ò¾å½ñ¤­¤¹¤ë
218 * °ú¿ô     ¡§¤Ê¤·
219 * Ìá¤êÃÍ   ¡§À®¸ù TRUE¡¢¥¨¥é¡¼ FALSE
220 **************************************************************************************************************/
221function lfChangeTemplate(){
222    global $objPage;
223    $tpl_path = "html/test/kakinaka/";
224   
225    $tpl_name = "";
226    $tpl_element = "";
227   
228    $chk_tpl = $_POST['check_template'];
229   
230    // ¥Æ¥ó¥×¥ì¡¼¥È¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë
231    $objQuery = new SC_Query();
232    $sql = "SELECT template_code,template_name,file_path FROM dtb_template WHERE template_code = ?";
233    $arrTemplate = $objQuery->getall($sql, array($chk_tpl));   
234   
235    switch($objPage->tpl_subno_template) {
236        // TOP
237        case $objPage->arrSubnavi[1]:
238            $tpl_element = "TopTemplate";           // ¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
239            $tpl_name = "top.tpl";
240            break;
241           
242        // ¾¦ÉʰìÍ÷
243        case $objPage->arrSubnavi[2]:
244            $tpl_element = "ProdTemplate";          // ¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
245            $tpl_name = "product.tpl";
246            break;
247           
248        // ¾¦ÉʾܺÙ
249        case $objPage->arrSubnavi[3]:
250            $tpl_element = "DetailTemplate";            // ¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
251            $tpl_name = "detail.tpl";
252            break;
253           
254        // MY¥Ú¡¼¥¸
255        case $objPage->arrSubnavi[4]:
256            $tpl_element = "MypageTemplate";            //¥¤¥á¡¼¥¸¤ÎÇÛÎóÍ×ÁÇ̾³ÊǼÍÑ
257            $tpl_name = "mypage.tpl";
258            break;
259
260        default:
261            break;
262    }
263   
264    $taget_tpl_path = ROOT_DIR . $tpl_path . $arrTemplate[0]['template_code'] . "/";
265    $save_tpl_path = ROOT_DIR . $tpl_path;
266   
267    // TOP¤òÊѹ¹¤·¤¿¾ì¹ç¤Ë¤ÏÁ´²èÌÌÊѹ¹
268    if ($objPage->tpl_subno_template == $objPage->arrSubnavi[1]){
269        // ¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤ò¥³¥Ô¡¼
270        copy($taget_tpl_path . "/top.tpl", $save_tpl_path . "top.tpl");
271        copy($taget_tpl_path . "/list.tpl", $save_tpl_path . "list.tpl");
272        copy($taget_tpl_path . "/detail.tpl", $save_tpl_path . "detail.tpl");
273       
274        // MYPAGE¤Î¥Õ¥¡¥¤¥ë¤ò¼èÆÀ¤¹¤ë
275        $arrMypage=glob($taget_tpl_path."mypage/" . "*" );
276       
277        // ¥Õ¥©¥ë¥À¤¬¤Ê¤±¤ì¤ÐºîÀ®¤¹¤ë
278        if(!is_dir($save_tpl_path."mypage")){
279            mkdir($save_tpl_path."mypage");
280        }
281       
282        foreach($arrMypage as $key => $val){
283            $matches = array();
284            mb_ereg("^(.*[\/])(.*)",$val, $matches);
285            $data=$matches[2];
286           
287            sfprintr($matches);
288            copy($val, $save_tpl_path . "mypage/" . $data);
289        }
290
291        // ¥Ö¥í¥Ã¥¯¥Ç¡¼¥¿¤Î¥³¥Ô¡¼
292    }else{
293        // ¥Æ¥ó¥×¥ì¡¼¥È¥Õ¥¡¥¤¥ë¤ò¥³¥Ô¡¼
294        copy($tpl_path . "/" . $tpl_name, $save_tpl_path . $tpl_name);
295    }
296}
Note: See TracBrowser for help on using the repository browser.