source: branches/feature-module-update/data/class/pages/upgrade/helper/LC_Upgrade_Helper_Json.php @ 16944

Revision 16944, 2.3 KB checked in by adachi, 16 years ago (diff)

JSONデータが正常にデコードできない不具合を修正

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php
Line 
1<?php
2require_once DATA_PATH . 'module/Services/JSON.php';
3/**
4 * Enter description here...
5 *
6 */
7class LC_Upgrade_Helper_Json extends Services_JSON {
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 LC_Upgrade_Helper_Json() {
22        parent::Services_JSON();
23    }
24
25    /**
26     * Enter description here...
27     *
28     */
29    function isError() {
30        return $this->isSuccess() ? false : true;
31    }
32
33    function isSuccess() {
34        if ($this->arrData['status'] === OSTORE_STATUS_SUCCESS) {
35            return true;
36        }
37        return false;
38    }
39
40    /**
41     * Enter description here...
42     *
43     * @param unknown_type $errCode
44     * @param unknown_type $errMessage
45     */
46    function setError($errCode) {
47        $masterData = new SC_DB_MasterData();
48        $arrOStoreErrMsg = $masterData->getMasterData("mtb_ownersstore_err");
49
50        $this->arrData['status']  = OSTORE_STATUS_ERROR;
51        $this->arrData['errcode'] = $errCode;
52        $this->arrData['msg']  = isset($arrOStoreErrMsg[$errCode])
53            ? $arrOStoreErrMsg[$errCode]
54            : $arrOStoreErrMsg[OSTORE_E_UNKNOWN];
55    }
56
57    /**
58     * Enter description here...
59     *
60     * @param mixed $data
61     */
62    function setSuccess($data = array(), $msg = '') {
63        $this->arrData['status'] = OSTORE_STATUS_SUCCESS;
64        $this->arrData['data']   = $data;
65        $this->arrData['msg']    = $msg;
66    }
67
68    /**
69     * Enter description here...
70     *
71     */
72    function display() {
73        header("Content-Type: text/javascript; charset=UTF-8");
74        echo $this->encode($this->arrData);
75    }
76
77    /**
78     * JSONデータをデコードする.
79     *
80     * php5.2.0からpreg_match関数に渡せるデータ長に制限がある(?)ため,
81     * Services_JSONが正常に動作しなくなる.
82     * そのため5.2.0以上の場合は組み込み関数のjson_decode()を使用する.
83     *
84     * @param string $str
85     * @return StdClass
86     */
87    function decode($str) {
88        if (version_compare(phpversion(), '5.2.0', '>=')) {
89            return json_decode($str);
90        }
91
92        return parent::decode($str);
93    }
94}
Note: See TracBrowser for help on using the repository browser.