source: branches/feature-module-update/data/class/pages/admin/contents/LC_Page_Admin_Contents_CampaignCreateTag.php @ 16582

Revision 16582, 6.5 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • 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
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 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_PATH . "pages/LC_Page.php");
26
27/**
28 * キャンペーンタグ生成 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Contents_CampaignCreateTag extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'contents/campaign_create_tag.tpl';
47        $this->tpl_mainno = 'create';
48        $this->tpl_subtitle = '商品設定';
49        $this->allowClientCache();
50    }
51
52    /**
53     * Page のプロセス.
54     *
55     * @return void
56     */
57    function process() {
58        $objView = new SC_AdminView();
59        $objSess = new SC_Session();
60        $objQuery = new SC_Query();
61        $objDb = new SC_Helper_DB_Ex();
62
63        // 認証可否の判定
64        SC_Utils_Ex::sfIsSuccess($objSess);
65
66        switch($_POST['mode']) {
67
68            // 商品検索
69        case  'search':
70            // POST値の引き継ぎ
71            $this->arrForm = $_POST;
72            // 入力文字の強制変換
73            $this->lfConvertParam();
74
75            $where = "del_flg = 0";
76
77            // where句生成
78            foreach ($this->arrForm as $key => $val) {
79                if($val == "") {
80                    continue;
81                }
82
83                switch ($key) {
84                case 'search_name':
85                    $where .= " AND name ILIKE ?";
86                    $arrval[] = "%$val%";
87                    break;
88                case 'search_category_id':
89                    // 子カテゴリIDの取得
90                    $arrRet = $objDb->sfGetChildsID("dtb_category", "parent_category_id", "category_id", $val);
91                    $tmp_where = "";
92                    foreach ($arrRet as $val) {
93                        if($tmp_where == "") {
94                            $tmp_where.= " AND ( category_id = ?";
95                        } else {
96                            $tmp_where.= " OR category_id = ?";
97                        }
98                        $arrval[] = $val;
99                    }
100                    $where.= $tmp_where . " )";
101                    break;
102                case 'search_product_id':
103                    if($val != "") {
104                        $where .= " AND product_id = ?";
105                        if(!SC_Utils_Ex::sfIsInt($val)) $val = 0;
106                        $arrval[] = $val;
107                    }
108                    break;
109                default:
110                    break;
111                }
112            }
113
114            $order = "update_date DESC, product_id DESC ";
115
116            // 読み込む列とテーブルの指定
117            $col = "product_id, name, category_id, main_list_image, status, product_code, price01, stock, stock_unlimited";
118            $from = "vw_products_nonclass AS noncls ";
119
120            // 行数の取得
121            $linemax = $objQuery->count("dtb_products", $where, $arrval);
122            $this->tpl_linemax = $linemax;              // 何件が該当しました。表示用
123
124            // ページ送りの処理
125            if(is_numeric($_POST['search_page_max'])) {
126                $page_max = $_POST['search_page_max'];
127            } else {
128                $page_max = SEARCH_PMAX;
129            }
130
131            // ページ送りの取得
132            $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
133            $this->tpl_strnavi = $objNavi->strnavi;     // 表示文字列
134            $startno = $objNavi->start_row;
135
136            // 取得範囲の指定(開始行番号、行数のセット)
137            if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno);
138            // 表示順序
139            $objQuery->setorder($order);
140
141            // 検索結果の取得
142            $this->arrProducts = $objQuery->select($col, $from, $where, $arrval);
143            break;
144
145            // タグ表示
146        case 'view':
147
148            // タグを生成
149            $create_tag = $this->lfGetCreateTag($_POST['product_id']);
150            $this->tpl_create_tag = $create_tag;
151            break;
152        }
153
154        // カテゴリ取得
155        $this->arrCatList = $objDb->sfGetCategoryList();
156
157        //---- ページ表示
158        $objView->assignobj($this);
159        $objView->display($this->tpl_mainpage);
160    }
161
162    /**
163     * デストラクタ.
164     *
165     * @return void
166     */
167    function destroy() {
168        parent::destroy();
169    }
170
171    /* 取得文字列の変換 */
172    function lfConvertParam() {
173        /*
174         *  文字列の変換
175         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
176         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
177         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
178         *  n :  「全角」数字を「半角(ハンカク)」に変換
179         */
180        $arrConvList['search_name'] = "KVa";
181        $arrConvList['search_product_code'] = "KVa";
182
183        // 文字変換
184        foreach ($arrConvList as $key => $val) {
185            // POSTされてきた値のみ変換する。
186            if(isset($this->arrForm[$key])) {
187                $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val);
188            }
189        }
190    }
191
192    /* タグを生成 */
193    function lfGetCreateTag($product_id) {
194        // 書き込みタグ
195        $read_file = file_get_contents(CAMPAIGN_BLOC_PATH . "cart_tag.tpl");
196        $read_file = ereg_replace("<{assign_product_id}>", $product_id, $read_file);
197        // カートタグ保存用ファイル作成
198        $create_tag .= "<!--{* ▼商品ID$product_id *}-->\n";
199        $create_tag .= $read_file;
200
201        return $create_tag;
202    }
203
204}
205?>
Note: See TracBrowser for help on using the repository browser.