source: branches/version-2_13-dev/data/class/pages/admin/products/LC_Page_Admin_Products_Maker.php @ 23124

Revision 23124, 6.5 KB checked in by kimoto, 11 years ago (diff)

#2043 typo修正・ソース整形・ソースコメントの改善 for 2.13.0
PHP4的な書き方の修正

  • 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
RevLine 
[17263]1<?php
2/*
3 * This file is part of EC-CUBE
4 *
[22206]5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
[17263]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
[20534]24require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
[17263]25
26/**
[19909]27 * メーカー登録 のページクラス.
[17263]28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
[20256]31 * @version $Id$
[17263]32 */
[22856]33class LC_Page_Admin_Products_Maker extends LC_Page_Admin_Ex
[22567]34{
[17263]35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
[23124]40    public function init()
[22567]41    {
[17263]42        parent::init();
43        $this->tpl_mainpage = 'products/maker.tpl';
44        $this->tpl_subno = 'maker';
[20911]45        $this->tpl_maintitle = '商品管理';
[19909]46        $this->tpl_subtitle = 'メーカー登録';
[17263]47        $this->tpl_mainno = 'products';
48    }
49
50    /**
51     * Page のプロセス.
52     *
53     * @return void
54     */
[23124]55    public function process()
[22567]56    {
[19661]57        $this->action();
58        $this->sendResponse();
59    }
60
61    /**
62     * Page のアクション.
63     *
64     * @return void
65     */
[23124]66    public function action()
[22567]67    {
[22578]68        $objMaker = new SC_Helper_Maker_Ex();
[20501]69        $objFormParam = new SC_FormParam_Ex();
[17263]70
[20970]71        // パラメーター情報の初期化
[20252]72        $this->lfInitParam($objFormParam);
[20220]73
[20252]74        // POST値をセット
75        $objFormParam->setParam($_POST);
[20540]76
[20252]77        // POST値の入力文字変換
78        $objFormParam->convParam();
[20220]79
[20598]80        //maker_idを変数にセット
81        $maker_id = $objFormParam->getValue('maker_id');
82
[20252]83        // モードによる処理切り替え
[21441]84        switch ($this->getMode()) {
[21526]85            // 編集処理
86            case 'edit':
[22578]87                // エラーチェック
88                $this->arrErr = $this->lfCheckError($objFormParam, $objMaker);
89                if (!SC_Utils_Ex::isBlank($this->arrErr['maker_id'])) {
90                    trigger_error('', E_USER_ERROR);
[23124]91
[22578]92                    return;
93                }
[20252]94
[21526]95                if (count($this->arrErr) <= 0) {
[22578]96                    // POST値の引き継ぎ
97                    $arrParam = $objFormParam->getHashArray();
98                    // 登録実行
99                    $res_maker_id = $this->doRegist($maker_id, $arrParam, $objMaker);
100                    if ($res_maker_id !== FALSE) {
101                        // 完了メッセージ
102                        $maker_id = $res_maker_id;
103                        $this->tpl_onload = "alert('登録が完了しました。');";
[21526]104                    }
[17263]105                }
[22578]106                // POSTデータを引き継ぐ
107                $this->tpl_maker_id = $maker_id;
[21526]108                break;
109
110            // 編集前処理
111            case 'pre_edit':
[22735]112                $maker = $objMaker->getMaker($maker_id);
[22578]113                $objFormParam->setParam($maker);
114
115                // POSTデータを引き継ぐ
116                $this->tpl_maker_id = $maker_id;
[21526]117                break;
[20220]118
[21526]119            // メーカー順変更
120            case 'up':
[22578]121                $objMaker->rankUp($maker_id);
122
123                // リロード
124                SC_Response_Ex::reload();
125                break;
126
[21526]127            case 'down':
[22578]128                $objMaker->rankDown($maker_id);
[21591]129
[21526]130                // リロード
131                SC_Response_Ex::reload();
132                break;
[20220]133
[21526]134            // 削除
135            case 'delete':
[22578]136                $objMaker->delete($maker_id);
[21591]137
[21526]138                // リロード
139                SC_Response_Ex::reload();
140                break;
[20220]141
[21526]142            default:
143                break;
[17263]144        }
145
[22578]146        $this->arrForm = $objFormParam->getFormParamList();
147
[20220]148        // メーカー情報読み込み
[22578]149        $this->arrMaker = $objMaker->getList();
[17263]150    }
151
152    /**
[20970]153     * パラメーター情報の初期化を行う.
[20252]154     *
[23124]155     * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
[20252]156     * @return void
157     */
[23124]158    public function lfInitParam(&$objFormParam)
[22567]159    {
[21514]160        $objFormParam->addParam('メーカーID', 'maker_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
161        $objFormParam->addParam('メーカー名', 'name', SMTEXT_LEN, 'KVa', array('EXIST_CHECK','SPTAB_CHECK','MAX_LENGTH_CHECK'));
[20252]162    }
[20220]163
164    /**
[22578]165     * 登録処理を実行.
[22856]166     *
[23124]167     * @param  integer  $maker_id
168     * @param  array    $sqlval
169     * @param  object   $objMaker
[22578]170     * @return multiple
[20220]171     */
[23124]172    public function doRegist($maker_id, $sqlval, SC_Helper_Maker_Ex $objMaker)
[22567]173    {
[22578]174        $sqlval['maker_id'] = $maker_id;
[17263]175        $sqlval['creator_id'] = $_SESSION['member_id'];
[22856]176
[22735]177        return $objMaker->saveMaker($sqlval);
[17263]178    }
179
[20220]180    /**
[20252]181     * 入力エラーチェック.
[20220]182     *
183     * @return array $objErr->arrErr エラー内容
184     */
[23124]185    public function lfCheckError(&$objFormParam, SC_Helper_Maker_Ex &$objMaker)
[22567]186    {
[21697]187        $arrErr = $objFormParam->checkError();
[22578]188        $arrForm = $objFormParam->getHashArray();
[21697]189
[20220]190        // maker_id の正当性チェック
[21441]191        if (!empty($arrForm['maker_id'])) {
[21743]192            if (!SC_Utils_Ex::sfIsInt($arrForm['maker_id'])
[21527]193                || SC_Utils_Ex::sfIsZeroFilling($arrForm['maker_id'])
[22735]194                || !$objMaker->getMaker($arrForm['maker_id'])
[21527]195            ) {
196                // maker_idが指定されていて、且つその値が不正と思われる場合はエラー
[21697]197                $arrErr['maker_id'] = '※ メーカーIDが不正です<br />';
[20220]198            }
199        }
[21697]200        if (!isset($arrErr['name'])) {
[22578]201            $arrMaker = $objMaker->getByName($arrForm['name']);
[20220]202
[17263]203            // 編集中のレコード以外に同じ名称が存在する場合
[22578]204            if (
205                    !SC_Utils_Ex::isBlank($arrMaker)
206                    && $arrMaker['maker_id'] != $arrForm['maker_id']
207                    && $arrMaker['name'] == $arrForm['name']
208                ) {
[21697]209                $arrErr['name'] = '※ 既に同じ内容の登録が存在します。<br />';
[17263]210            }
211        }
[20220]212
[21697]213        return $arrErr;
[17263]214    }
215}
Note: See TracBrowser for help on using the repository browser.