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

Revision 22567, 2.2 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

  • 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        return false;
41    }
42
43    /**
44     * Enter description here...
45     *
46     * @param unknown_type $errCode
47     * @param unknown_type $errMessage
48     */
49    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    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    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    function decode($str)
95    {
96        return SC_Utils_Ex::jsonDecode($str);
97    }
98}
Note: See TracBrowser for help on using the repository browser.