source: branches/version-2_13-dev/data/class/pages/upgrade/helper/LC_Upgrade_Helper_Json.php @ 23605

Revision 23605, 2.2 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

  • PHP Analyzer
  • PHP PDepend
  • PHP Similarity Analyzer
  • PHP Change Tracking Analyzer
  • 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 * Enter description here...
4 *
5 */
6class LC_Upgrade_Helper_Json extends Services_JSON
7{
8    /** */
9    public $arrData = array(
10        'status'  => null,
11        'errcode' => null,
12        'msg'     => null,
13        'data'    => array()
14    );
15
16    /**
17     * Enter description here...
18     *
19     * @return SC_Upgrade_Helper_Json
20     */
21    public function __construct()
22    {
23        parent::Services_JSON();
24    }
25
26    /**
27     * Enter description here...
28     *
29     */
30    public function isError()
31    {
32        return $this->isSuccess() ? false : true;
33    }
34
35    public function isSuccess()
36    {
37        if ($this->arrData['status'] === OSTORE_STATUS_SUCCESS) {
38            return true;
39        }
40
41        return false;
42    }
43
44    /**
45     * Enter description here...
46     *
47     * @param unknown_type $errCode
48     */
49    public function setError($errCode)
50    {
51        $masterData = new SC_DB_MasterData_Ex();
52        $arrOStoreErrMsg = $masterData->getMasterData('mtb_ownersstore_err');
53
54        $this->arrData['status']  = OSTORE_STATUS_ERROR;
55        $this->arrData['errcode'] = $errCode;
56        $this->arrData['msg']  = isset($arrOStoreErrMsg[$errCode])
57            ? $arrOStoreErrMsg[$errCode]
58            : $arrOStoreErrMsg[OSTORE_E_UNKNOWN];
59    }
60
61    /**
62     * Enter description here...
63     *
64     * @param mixed $data
65     */
66    public function setSuccess($data = array(), $msg = '')
67    {
68        $this->arrData['status'] = OSTORE_STATUS_SUCCESS;
69        $this->arrData['data']   = $data;
70        $this->arrData['msg']    = $msg;
71    }
72
73    /**
74     * Enter description here...
75     *
76     */
77    public function display()
78    {
79        header('Content-Type: text/javascript; charset=UTF-8');
80        echo $this->encode($this->arrData);
81    }
82
83    /**
84     * JSONデータをデコードする.
85     *
86     * php5.2.0からpreg_match関数に渡せるデータ長に制限がある(?)ため,
87     * Services_JSONが正常に動作しなくなる.
88     * そのため5.2.0以上の場合は組み込み関数のjson_decode()を使用する.
89     *
90     * @param  string   $str
91     * @return StdClass
92     * @see SC_Utils_Ex::jsonDecode
93     */
94    public function decode($str)
95    {
96        return SC_Utils_Ex::jsonDecode($str);
97    }
98}
Note: See TracBrowser for help on using the repository browser.