source: branches/version-2_12-multilang/data/class/api/operations/ItemLookup.php @ 22032

Revision 22032, 4.9 KB checked in by pineray, 12 years ago (diff)

#1890 コード中のメッセージを集約

class/api 以下のファイル内の文字列を差し替え.

Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2012 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/**
25 * APIの基本クラス
26 *
27 * @package Api
28 * @author LOCKON CO.,LTD.
29 * @version $Id$
30 */
31require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';
32
33class API_ItemLookup extends SC_Api_Abstract_Ex {
34
35    protected $operation_name = 'ItemLookup';
36    protected $operation_description = '';
37    protected $default_auth_types = self::API_AUTH_TYPE_OPEN;
38    protected $default_enable = '1';
39    protected $default_is_log = '0';
40    protected $default_sub_data = '';
41
42    public function __construct() {
43        parent::__construct();
44        $this->operation_description = SC_I18n_Ex::t('API_ITEMLOOKUP_DESC');
45    }
46
47    public function doAction($arrParam) {
48        $arrRequest = $this->doInitParam($arrParam);
49        if (!$this->isParamError()) {
50            $objProduct = new SC_Product_Ex();
51
52            switch ($arrRequest['IdType']) {
53            case 'product_code':
54                $search_column = 'product_code';
55                break;
56            case 'product_class_id':
57                $arrProduct = $objProduct->getDetailAndProductsClass($arrRequest['ItemId']);
58                break;
59            case 'product_id':
60            default:
61                $arrProduct = $objProduct->getDetail($arrRequest['ItemId']);
62                break;
63            }
64
65            $objProduct->setProductsClassByProductIds(array($arrProduct['product_id']));
66
67            if ($arrProduct['del_flg'] == '0' && $arrProduct['status'] == '1') {
68                unset($arrProduct['note']);
69                $this->setResponse('product_id', $arrProduct['product_id']);
70                $this->setResponse('DetailPageURL', HTTP_URL . 'products/detail.php?product_id=' . $arrProduct['product_id']);
71                $this->setResponse('Title', $arrProduct['name']);
72                $this->setResponse('ItemAttributes', $arrProduct);
73                return true;
74            } else {
75                $this->addError('ItemLookup.Error', SC_I18n_Ex::t('API_ITEMLOOKUP_ERROR'));
76            }
77        }
78
79        return false;
80    }
81
82    protected function checkErrorExtended($arrParam) {
83        switch ($arrParam['IdType']) {
84        case 'product_code':
85            break;
86        case 'product_id':
87        case 'product_class_id':
88        default:
89            $objErr = new SC_CheckError_Ex($arrParam);
90            $objErr->doFunc(array(SC_I18n_Ex::t('PARAM_LABEL_ITEMID'), 'ItemId', INT_LEN), array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
91            $this->addError($objErr->arrErr);
92            break;
93        }
94    }
95
96    protected function lfInitParam(&$objFormParam) {
97        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_CONDITION'), 'Condition', STEXT_LEN, 'a', array('ALNUM_CHECK', 'MAX_LENGTH_CHECK'));
98        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_IDTYPE'), 'IdType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
99        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_ITEMID'), 'ItemId', STEXT_LEN, 'a', array('EXIST_CHECK', 'GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
100        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_RELATEDITEMSPAGE'), 'RelatedItemsPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
101        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_RELATIONSHIPTYPE'), 'RelationshipType', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
102        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_REVIEWPAGE'), 'ReviewPage', INT_LEN, 'N', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
103        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_REVIEWSORT'), 'ReviewSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
104        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_TAGPAGE'), 'TagPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
105        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_TAGSPERPAGE'), 'TagsPerPage', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
106        $objFormParam->addParam(SC_I18n_Ex::t('PARAM_LABEL_TAGSORT'), 'TagSort', STEXT_LEN, 'a', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK'));
107    }
108
109    public function getResponseGroupName() {
110        return 'Item';
111    }
112}
Note: See TracBrowser for help on using the repository browser.