source: branches/version-2_5-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ProductRank.php @ 19805

Revision 19805, 6.0 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部実装

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
  • 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-2010 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
24// {{{ requires
25require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php");
26
27/**
28 * 商品並べ替え のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Products_ProductRank extends LC_Page_Admin {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'products/product_rank.tpl';
47        $this->tpl_subnavi = 'products/subnavi.tpl';
48        $this->tpl_mainno = 'products';
49        $this->tpl_subno = 'product_rank';
50        $this->tpl_subtitle = '商品並び替え';
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    function process() {
59        $this->action();
60        $this->sendResponse();
61    }
62
63    /**
64     * Page のアクション.
65     *
66     * @return void
67     */
68    function action() {
69        $objQuery = new SC_Query();
70        $objSess = new SC_Session();
71        $objDb = new SC_Helper_DB_Ex();
72
73        // 認証可否の判定
74        SC_Utils_Ex::sfIsSuccess($objSess);
75
76        $this->tpl_pageno = isset($_POST['pageno']) ? $_POST['pageno'] : "";
77
78        // 通常時は親カテゴリを0に設定する。
79        $this->arrForm['parent_category_id'] =
80            isset($_POST['parent_category_id']) ? $_POST['parent_category_id'] : 0;
81
82        if (!isset($_POST['mode'])) $_POST['mode'] = "";
83        switch($_POST['mode']) {
84        case 'up':
85            $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
86            $objDb->sfRankUp("dtb_product_categories", "product_id", $_POST['product_id'], $where);
87            break;
88        case 'down':
89            $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
90            $objDb->sfRankDown("dtb_product_categories", "product_id", $_POST['product_id'], $where);
91            break;
92        case 'move':
93            $key = "pos-".$_POST['product_id'];
94            $input_pos = mb_convert_kana($_POST[$key], "n");
95            if(SC_Utils_Ex::sfIsInt($input_pos)) {
96                $where = "category_id = " . SC_Utils_Ex::sfQuoteSmart($_POST['parent_category_id']);
97                $objDb->sfMoveRank("dtb_product_categories", "product_id", $_POST['product_id'], $input_pos, $where);
98            }
99            break;
100        case 'tree':
101            // カテゴリの切替は、ページ番号をクリアする。
102            $this->tpl_pageno = "";
103            break;
104           
105        case 'renumber':
106            $sql = <<< __EOS__
107                UPDATE dtb_product_categories
108                SET
109                    rank =
110                        (
111                            SELECT COUNT(*)
112                            FROM dtb_product_categories t_in
113                            WHERE t_in.category_id = dtb_product_categories.category_id
114                                AND (
115                                    t_in.rank < dtb_product_categories.rank
116                                    OR (
117                                        t_in.rank = dtb_product_categories.rank
118                                        AND t_in.product_id < dtb_product_categories.product_id
119                                    )
120                                )
121                        ) + 1
122                WHERE dtb_product_categories.category_id = ?
123__EOS__;
124            $objQuery->query($sql, array($_POST['parent_category_id']));
125            break;
126       
127        default:
128            break;
129        }
130
131        $this->arrTree = $objDb->sfGetCatTree($this->arrForm['parent_category_id']);
132        $this->arrProductsList =
133            $this->lfGetProduct($this->arrForm['parent_category_id']);
134    }
135
136    /**
137     * デストラクタ.
138     *
139     * @return void
140     */
141    function destroy() {
142        parent::destroy();
143    }
144
145    /* 商品読み込み */
146    function lfGetProduct($category_id) {
147        // FIXME SC_Product クラスを使用した実装
148        $objQuery = new SC_Query();
149        $col = "product_id, name, main_list_image, product_code_min, product_code_max, status";
150        $table = "vw_products_allclass AS allcls";
151        $where = "del_flg = 0 AND category_id = ?";
152
153        // 行数の取得
154        $linemax = $objQuery->count($table, $where, array($category_id));
155        // 該当件数表示用
156        $this->tpl_linemax = $linemax;
157
158        $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnNaviPage", NAVI_PMAX);
159        $startno = $objNavi->start_row;
160        $this->tpl_start_row = $objNavi->start_row;
161        $this->tpl_strnavi = $objNavi->strnavi;     // Navi表示文字列
162        $this->tpl_pagemax = $objNavi->max_page;    // ページ最大数(「上へ下へ」表示判定用)
163        $this->tpl_disppage = $objNavi->now_page;   // 表示ページ番号(「上へ下へ」表示判定用)
164
165        // 取得範囲の指定(開始行番号、行数のセット)
166        $objQuery->setLimitOffset(SEARCH_PMAX, $startno);
167
168        $objQuery->setOrder("product_rank DESC, product_id DESC");
169
170        $arrRet = $objQuery->select($col, $table, $where, array($category_id));
171        return $arrRet;
172    }
173}
174?>
Note: See TracBrowser for help on using the repository browser.