source: branches/comu/html/admin/contents/page_edit.php @ 12197

Revision 12197, 3.0 KB checked in by adati, 17 years ago (diff)

1.3.0正式版のマージ

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("./page_edit.inc");
9
10class LC_Page {
11    function LC_Page() {
12        $this->tpl_mainpage = 'contents/page_edit.tpl';
13        $this->tpl_mainno = 'contents';
14        $this->tpl_subnavi = 'contents/subnavi.tpl';
15        $this->tpl_subno = "page_edit";
16        global $arrPageList;
17        $this->arrPageList = $arrPageList;
18        $this->tpl_subtitle = '¥Ú¡¼¥¸ÊÔ½¸';
19    }
20}
21
22$conn = new SC_DBConn();
23$objPage = new LC_Page();
24$objView = new SC_AdminView();
25$objSess = new SC_Session();
26
27$objFormParam = new SC_FormParam();         // ¥Õ¥©¡¼¥àÍÑ
28lfInitParam();                              // ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½
29$objFormParam->setParam($_POST);            // POSTÃͤμèÆÀ
30
31switch($_POST['mode']) {
32case 'edit':
33    $objPage->arrErr = $objFormParam->checkError();
34    if(count($objPage->arrErr) == 0) {
35        $page = $_POST['page'];
36        if($arrPageTpl[$page] != "") {
37            // °ì»þ¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤à
38            $path = TEMPLATE_FTP_DIR . $arrPageTpl[$page] . ".tmp";
39            $ret = lfWriteFile($path, $objFormParam->getValue('template'));
40            // ËÜÈÖ¥Õ¥¡¥¤¥ë¤ËÈ¿±Ç
41            if($ret > 0) {
42                $dst_path = TEMPLATE_FTP_DIR . $arrPageTpl[$page];
43                if(!copy($path, $dst_path)) {
44                    print("¥Õ¥¡¥¤¥ë¤Î½ñ¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£");
45                }
46            }
47        }
48    }   
49    break;
50case 'preview':
51    $objPage->arrErr = $objFormParam->checkError();
52    if(count($objPage->arrErr) == 0) {
53        $page = $_POST['page'];
54        if($arrPageTpl[$page] != "") {
55            // °ì»þ¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤à
56            $path = TEMPLATE_FTP_DIR . $arrPageTpl[$page] . ".tmp";
57            $ret = lfWriteFile($path, $objFormParam->getValue('template'));
58            // ¥×¥ì¥Ó¥å¡¼É½¼¨
59            $url = $arrPageURL[$page] . "tpl=" . $arrPageTpl[$page] . ".tmp";
60            $objPage->tpl_onload ="window.open('$url', 'preview');";
61        }
62    }   
63    break;
64case 'select':
65    $page = $_POST['page'];
66    if($arrPageTpl[$page] != "") {
67        // ¥Õ¥¡¥¤¥ë¤ÎÃæ¿È¤òÆɤó¤Çʸ»úÎó¤Ë³ÊǼ¤¹¤ë
68        $path = TEMPLATE_FTP_DIR . $arrPageTpl[$page];
69        if(file_exists($path)) {
70            $fp = fopen($path, "r");
71            $contents = fread($fp, filesize($path));
72            $objFormParam->setValue('template', $contents);
73            fclose($fp);
74        }
75    } else {
76        $objFormParam->setValue('template', "");
77    }
78    break;
79default:
80   
81    break;
82}
83
84/*
85
86// ¥Õ¥¡¥¤¥ë¤ÎÃæ¿È¤òÆɤó¤Çʸ»úÎó¤Ë³ÊǼ¤¹¤ë
87$path = TEMPLATE_FTP_DIR . "index.tpl";
88$fp = fopen($path, "r");
89$contents = fread($fp, filesize($path));
90
91$objFormParam->setValue('template', $contents);
92
93fclose($fp);
94
95*/
96
97// ÆþÎÏÃͤμèÆÀ
98$objPage->arrForm = $objFormParam->getFormParamList();
99
100$objView->assignobj($objPage);
101$objView->display(MAIN_FRAME);
102//---------------------------------------------------------
103/* ¥Ñ¥é¥á¡¼¥¿¾ðÊó¤Î½é´ü²½ */
104function lfInitParam() {
105    global $objFormParam;
106    $objFormParam->addParam("¥Ú¡¼¥¸ÁªÂò", "page", INT_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
107    $objFormParam->addParam("¥Æ¥ó¥×¥ì¡¼¥È", "template", LLTEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
108}
109
110function lfWriteFile($path, $string) {
111    $fp = fopen($path,"w+");
112    flock($fp, LOCK_EX);
113    $ret = fwrite($fp, $string);
114    fclose($fp);
115    return $ret;
116}
117
118?>
Note: See TracBrowser for help on using the repository browser.