source: branches/version-2_13-dev/data/class/pages/admin/contents/LC_Page_Admin_Contents.php @ 22857

Revision 22857, 8.3 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
25
26/**
27 * コンテンツ管理 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Admin_Contents extends LC_Page_Admin_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43        $this->tpl_mainpage = 'contents/index.tpl';
44        $this->tpl_subno = 'index';
45        $this->tpl_mainno = 'contents';
46        $this->arrForm = array(
47            'year' => date('Y'),
48            'month' => date('n'),
49            'day' => date('j'),
50        );
51        $this->tpl_maintitle = 'コンテンツ管理';
52        $this->tpl_subtitle = '新着情報管理';
53        //---- 日付プルダウン設定
54        $objDate = new SC_Date_Ex(ADMIN_NEWS_STARTYEAR);
55        $this->arrYear = $objDate->getYear();
56        $this->arrMonth = $objDate->getMonth();
57        $this->arrDay = $objDate->getDay();
58    }
59
60    /**
61     * Page のプロセス.
62     *
63     * @return void
64     */
65    function process()
66    {
67        $this->action();
68        $this->sendResponse();
69    }
70
71    /**
72     * Page のアクション.
73     *
74     * @return void
75     */
76    function action()
77    {
78        $objNews = new SC_Helper_News_Ex();
79
80        $objFormParam = new SC_FormParam_Ex();
81        $this->lfInitParam($objFormParam);
82        $objFormParam->setParam($_POST);
83        $objFormParam->convParam();
84
85        $news_id = $objFormParam->getValue('news_id');
86
87        //---- 新規登録/編集登録
88        switch ($this->getMode()) {
89            case 'edit':
90                $this->arrErr = $this->lfCheckError($objFormParam);
91                if (!SC_Utils_Ex::isBlank($this->arrErr['news_id'])) {
92                    trigger_error('', E_USER_ERROR);
93                    return;
94                }
95
96                if (count($this->arrErr) <= 0) {
97                    // POST値の引き継ぎ
98                    $arrParam = $objFormParam->getHashArray();
99                    // 登録実行
100                    $res_news_id = $this->doRegist($news_id, $arrParam, $objNews);
101                    if ($res_news_id !== FALSE) {
102                        // 完了メッセージ
103                        $news_id = $res_news_id;
104                        $this->tpl_onload = "alert('登録が完了しました。');";
105                    }
106                }
107                // POSTデータを引き継ぐ
108                $this->tpl_news_id = $news_id;
109                break;
110
111            case 'pre_edit':
112                $news = $objNews->getNews($news_id);
113                list($news['year'],$news['month'],$news['day']) = $this->splitNewsDate($news['cast_news_date']);
114                $objFormParam->setParam($news);
115
116                // POSTデータを引き継ぐ
117                $this->tpl_news_id = $news_id;
118                break;
119
120            case 'delete':
121            //---- データ削除
122                $objNews->deleteNews($news_id);
123                //自分にリダイレクト(再読込による誤動作防止)
124                SC_Response_Ex::reload();
125                break;
126
127            //---- 表示順位移動
128            case 'up':
129                $objNews->rankUp($news_id);
130
131                // リロード
132                SC_Response_Ex::reload();
133                break;
134
135            case 'down':
136                $objNews->rankDown($news_id);
137
138                // リロード
139                SC_Response_Ex::reload();
140                break;
141
142            case 'moveRankSet':
143            //---- 指定表示順位移動
144                $input_pos = $this->getPostRank($news_id);
145                if (SC_Utils_Ex::sfIsInt($input_pos)) {
146                    $objNews->moveRank($news_id, $input_pos);
147                }
148                SC_Response_Ex::reload();
149                break;
150
151            default:
152                break;
153        }
154
155        $this->arrNews = $objNews->getList();
156        $this->line_max = count($this->arrNews);
157
158        $this->arrForm = $objFormParam->getFormParamList();
159    }
160
161    /**
162     * デストラクタ.
163     *
164     * @return void
165     */
166    function destroy()
167    {
168        parent::destroy();
169    }
170
171    /**
172     * 入力されたパラメーターのエラーチェックを行う。
173     * @param Object $objFormParam
174     * @return Array エラー内容
175     */
176    function lfCheckError(&$objFormParam)
177    {
178        $objErr = new SC_CheckError_Ex($objFormParam->getHashArray());
179        $objErr->arrErr = $objFormParam->checkError();
180        $objErr->doFunc(array('日付', 'year', 'month', 'day'), array('CHECK_DATE'));
181
182        return $objErr->arrErr;
183    }
184
185    /**
186     * パラメーターの初期化を行う
187     * @param Object $objFormParam
188     */
189    function lfInitParam(&$objFormParam)
190    {
191        $objFormParam->addParam('news_id', 'news_id');
192        $objFormParam->addParam('日付(年)', 'year', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
193        $objFormParam->addParam('日付(月)', 'month', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
194        $objFormParam->addParam('日付(日)', 'day', INT_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
195        $objFormParam->addParam('タイトル', 'news_title', MTEXT_LEN, 'KVa', array('EXIST_CHECK','MAX_LENGTH_CHECK','SPTAB_CHECK'));
196        $objFormParam->addParam('URL', 'news_url', URL_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
197        $objFormParam->addParam('本文', 'news_comment', LTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
198        $objFormParam->addParam('別ウィンドウで開く', 'link_method', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
199    }
200
201    /**
202     * 登録処理を実行.
203     *
204     * @param integer $news_id
205     * @param array $sqlval
206     * @param object $objNews
207     * @return multiple
208     */
209    function doRegist($news_id, $sqlval, SC_Helper_News_Ex $objNews)
210    {
211        $sqlval['news_id'] = $news_id;
212        $sqlval['creator_id'] = $_SESSION['member_id'];
213        $sqlval['link_method'] = $this->checkLinkMethod($sqlval['link_method']);
214        $sqlval['news_date'] = $this->getRegistDate($sqlval);
215        unset($sqlval['year'], $sqlval['month'], $sqlval['day']);
216
217        return $objNews->saveNews($sqlval);
218    }
219
220    /**
221     * データの登録日を返す。
222     * @param Array $arrPost POSTのグローバル変数
223     * @return string 登録日を示す文字列
224     */
225    function getRegistDate($arrPost)
226    {
227        $registDate = $arrPost['year'] .'/'. $arrPost['month'] .'/'. $arrPost['day'];
228
229        return $registDate;
230    }
231
232    /**
233     * チェックボックスの値が空の時は無効な値として1を格納する
234     * @param int $link_method
235     * @return int
236     */
237    function checkLinkMethod($link_method)
238    {
239        if (strlen($link_method) == 0) {
240            $link_method = 1;
241        }
242
243        return $link_method;
244    }
245
246    /**
247     * ニュースの日付の値をフロントでの表示形式に合わせるために分割
248     * @param String $news_date
249     */
250    function splitNewsDate($news_date)
251    {
252        return explode('-', $news_date);
253    }
254
255    /**
256     * POSTされたランクの値を取得する
257     * @param Object $objFormParam
258     * @param Integer $news_id
259     */
260    function getPostRank($news_id)
261    {
262        if (strlen($news_id) > 0 && is_numeric($news_id) == true) {
263            $key = 'pos-' . $news_id;
264            $input_pos = $_POST[$key];
265            return $input_pos;
266        }
267    }
268}
Note: See TracBrowser for help on using the repository browser.