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

Revision 22856, 2.2 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
  • 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    var $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    function __construct()
22    {
23        parent::Services_JSON();
24    }
25
26    /**
27     * Enter description here...
28     *
29     */
30    function isError()
31    {
32        return $this->isSuccess() ? false : true;
33    }
34
35    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     * @param unknown_type $errMessage
49     */
50    function setError($errCode)
51    {
52        $masterData = new SC_DB_MasterData_Ex();
53        $arrOStoreErrMsg = $masterData->getMasterData('mtb_ownersstore_err');
54
55        $this->arrData['status']  = OSTORE_STATUS_ERROR;
56        $this->arrData['errcode'] = $errCode;
57        $this->arrData['msg']  = isset($arrOStoreErrMsg[$errCode])
58            ? $arrOStoreErrMsg[$errCode]
59            : $arrOStoreErrMsg[OSTORE_E_UNKNOWN];
60    }
61
62    /**
63     * Enter description here...
64     *
65     * @param mixed $data
66     */
67    function setSuccess($data = array(), $msg = '')
68    {
69        $this->arrData['status'] = OSTORE_STATUS_SUCCESS;
70        $this->arrData['data']   = $data;
71        $this->arrData['msg']    = $msg;
72    }
73
74    /**
75     * Enter description here...
76     *
77     */
78    function display()
79    {
80        header('Content-Type: text/javascript; charset=UTF-8');
81        echo $this->encode($this->arrData);
82    }
83
84    /**
85     * JSONデータをデコードする.
86     *
87     * php5.2.0からpreg_match関数に渡せるデータ長に制限がある(?)ため,
88     * Services_JSONが正常に動作しなくなる.
89     * そのため5.2.0以上の場合は組み込み関数のjson_decode()を使用する.
90     *
91     * @param string $str
92     * @return StdClass
93     * @see SC_Utils_Ex::jsonDecode
94     */
95    function decode($str)
96    {
97        return SC_Utils_Ex::jsonDecode($str);
98    }
99}
Note: See TracBrowser for help on using the repository browser.