Index: /branches/version-2_5-dev/html/test/upgrade/index.php
===================================================================
--- /branches/version-2_5-dev/html/test/upgrade/index.php (revision 19684)
+++ /branches/version-2_5-dev/html/test/upgrade/index.php (revision 20434)
@@ -96,6 +96,5 @@
updateModuleTable($arrProductsList);
- $objJson = new Services_JSON();
- echo $objJson->encode($arrRet);
+ echo SC_Utils_Ex::jsonEncode($arrRet);
}
Index: /branches/version-2_5-dev/data/require_classes.php
===================================================================
--- /branches/version-2_5-dev/data/require_classes.php (revision 20306)
+++ /branches/version-2_5-dev/data/require_classes.php (revision 20434)
@@ -22,5 +22,4 @@
*/
-require_once(DATA_REALDIR . "module/Services/JSON.php");
require_once(CLASS_EX_REALDIR . "util_extends/GC_Utils_Ex.php");
require_once(CLASS_EX_REALDIR . "util_extends/SC_Utils_Ex.php");
Index: /branches/version-2_5-dev/data/class/pages/upgrade/helper/LC_Upgrade_Helper_Json.php
===================================================================
--- /branches/version-2_5-dev/data/class/pages/upgrade/helper/LC_Upgrade_Helper_Json.php (revision 19684)
+++ /branches/version-2_5-dev/data/class/pages/upgrade/helper/LC_Upgrade_Helper_Json.php (revision 20434)
@@ -83,13 +83,8 @@
* @param string $str
* @return StdClass
+ * @see SC_Utils_Ex::jsonDecode
*/
function decode($str) {
- if (function_exists('json_decode')) {
- LC_Upgrade_Helper_Log::log(' *use json_decode()');
- return json_decode($str);
- }
-
- LC_Upgrade_Helper_Log::log(' *use Services_JSON::decode()');
- return parent::decode($str);
+ return SC_Utils_Ex::jsonDecode($str);
}
}
Index: /branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php
===================================================================
--- /branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php (revision 20384)
+++ /branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php (revision 20434)
@@ -143,6 +143,5 @@
if (SC_Display::detectDevice() != DEVICE_TYPE_MOBILE) {
- $objJson = new Services_JSON();
- echo $objJson->encode($arrSelectedDeliv);
+ echo SC_Utils_Ex::jsonEncode($arrSelectedDeliv);
exit;
} else {
Index: /branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php
===================================================================
--- /branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php (revision 20427)
+++ /branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php (revision 20434)
@@ -159,6 +159,5 @@
*/
function getTplJavascript(&$objProduct){
- $objJson = new Services_JSON();
- return 'productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . '; ';
+ return 'productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . '; ';
}
Index: /branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin_Home.php
===================================================================
--- /branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin_Home.php (revision 20345)
+++ /branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin_Home.php (revision 20434)
@@ -317,6 +317,5 @@
$jsonStr = @file_get_contents($url, false, stream_context_create($context));
- $objJson = new Services_JSON;
- $arrTmpData = is_string($jsonStr) ? $objJson->decode($jsonStr) : null;
+ $arrTmpData = is_string($jsonStr) ? SC_Utils_Ex::jsonDecode($jsonStr) : null;
if (empty($arrTmpData)) {
Index: /branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php
===================================================================
--- /branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php (revision 20408)
+++ /branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php (revision 20434)
@@ -132,6 +132,5 @@
$this->tpl_product_type = $objProduct->classCategories[$product_id]['']['']['product_type'];
- $objJson = new Services_JSON();
- $this->tpl_javascript .= 'classCategories = ' . $objJson->encode($objProduct->classCategories[$product_id]) . ';';
+ $this->tpl_javascript .= 'classCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories[$product_id]) . ';';
$this->tpl_javascript .= 'function lnOnLoad(){' . $this->js_lnOnload . '}';
$this->tpl_onload .= 'lnOnLoad();';
@@ -316,5 +315,5 @@
return 'fnSetClassCategories('
. 'document.form1, '
- . Services_JSON::encode($this->objFormParam->getValue('classcategory_id2'))
+ . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
. '); ';
}
Index: /branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
===================================================================
--- /branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php (revision 20344)
+++ /branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php (revision 20434)
@@ -152,8 +152,5 @@
$this->productStatus = $this->arrProducts["productStatus"];
unset($this->arrProducts["productStatus"]);
-
- $objJson = new Services_JSON();
- $this->tpl_javascript .= 'var productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . ';';
-
+ $this->tpl_javascript .= 'var productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . ';';
//onloadスクリプトを設定
foreach ($this->arrProducts as $arrProduct) {
Index: /branches/version-2_5-dev/data/class/util/SC_Utils.php
===================================================================
--- /branches/version-2_5-dev/data/class/util/SC_Utils.php (revision 20428)
+++ /branches/version-2_5-dev/data/class/util/SC_Utils.php (revision 20434)
@@ -2311,4 +2311,49 @@
}
+ /**
+ * 値を JSON 形式にして返す.
+ *
+ * この関数は, json_encode() 又は Services_JSON::encode() のラッパーです.
+ * json_encode() 関数が使用可能な場合は json_encode() 関数を使用する.
+ * 使用できない場合は, Services_JSON::encode() 関数を使用する.
+ *
+ * @param mixed $value JSON 形式にエンコードする値
+ * @return string JSON 形式にした文字列
+ * @see json_encode()
+ * @see Services_JSON::encode()
+ */
+ function jsonEncode($value) {
+ if (function_exists('json_encode')) {
+ return json_encode($value);
+ } else {
+ require_once(dirname(__FILE__) . '/../../module/Services/JSON.php');
+ GC_Utils::gfPrintLog(' *use Services_JSON::encode(). faster than using the json_encode!');
+ $objJson = new Services_JSON();
+ return $objJson->encode($value);
+ }
+ }
+
+ /**
+ * JSON 文字列をデコードする.
+ *
+ * この関数は, json_decode() 又は Services_JSON::decode() のラッパーです.
+ * json_decode() 関数が使用可能な場合は json_decode() 関数を使用する.
+ * 使用できない場合は, Services_JSON::decode() 関数を使用する.
+ *
+ * @param string $json JSON 形式にエンコードされた文字列
+ * @return mixed デコードされた PHP の型
+ * @see json_decode()
+ * @see Services_JSON::decode()
+ */
+ function jsonDecode($json) {
+ if (function_exists('json_decode')) {
+ return json_decode($json);
+ } else {
+ require_once(dirname(__FILE__) . '/../../module/Services/JSON.php');
+ GC_Utils::gfPrintLog(' *use Services_JSON::decode(). faster than using the json_decode!');
+ $objJson = new Services_JSON();
+ return $objJson->decode($json);
+ }
+ }
}
?>