[Svn-src-all:1538] [version-2_5-dev 20434] #803(JSON モジュールの統一及び高速化)
nanasess
admin @ mail.ec-cube.net
2011年 2月 28日 (月) 11:26:54 JST
Subversion committed to /home/svn/open 20434
http://svn.ec-cube.net/open_trac/changeset/20434
┌────────────────────────────┐
│更新者 : nanasess │
│更新日時: 2011-02-28 11:26:53 +0900 (月, 28 2月 2011)│
└────────────────────────────┘
Log:
--------------------------------------------------------
#803(JSON モジュールの統一及び高速化)
Changed: [U:修正,A:追加,D:削除]
--------------------------------------------------------
U branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin_Home.php
U branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php
U branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php
U branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
U branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php
U branches/version-2_5-dev/data/class/pages/upgrade/helper/LC_Upgrade_Helper_Json.php
U branches/version-2_5-dev/data/class/util/SC_Utils.php
U branches/version-2_5-dev/data/require_classes.php
U branches/version-2_5-dev/html/test/upgrade/index.php
変更: 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 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin_Home.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -316,8 +316,7 @@
$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)) {
SC_Utils_Ex::sfErrorHeader(">> 更新情報の取得に失敗しました。");
変更: 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 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -158,8 +158,7 @@
* @param SC_Product $objProduct
*/
function getTplJavascript(&$objProduct){
- $objJson = new Services_JSON();
- return 'productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . '; ';
+ return 'productsClassCategories = ' . SC_Utils_Ex::jsonEncode($objProduct->classCategories) . '; ';
}
変更: 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 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_Detail.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -131,8 +131,7 @@
$this->tpl_product_class_id = $objProduct->classCategories[$product_id]['']['']['product_class_id'];
$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();';
@@ -315,7 +314,7 @@
function lfMakeSelect() {
return 'fnSetClassCategories('
. 'document.form1, '
- . Services_JSON::encode($this->objFormParam->getValue('classcategory_id2'))
+ . SC_Utils_Ex::jsonEncode($this->objFormParam->getValue('classcategory_id2'))
. '); ';
}
変更: 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 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -151,10 +151,7 @@
// 商品ステータスを取得
$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) {
$js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});";
変更: 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 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/class/pages/shopping/LC_Page_Shopping_Payment.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -142,8 +142,7 @@
}
if (SC_Display::detectDevice() != DEVICE_TYPE_MOBILE) {
- $objJson = new Services_JSON();
- echo $objJson->encode($arrSelectedDeliv);
+ echo SC_Utils_Ex::jsonEncode($arrSelectedDeliv);
exit;
} else {
$this->arrPayment = $arrSelectedDeliv['arrPayment'];
変更: 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 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/class/pages/upgrade/helper/LC_Upgrade_Helper_Json.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -82,14 +82,9 @@
*
* @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);
}
}
変更: branches/version-2_5-dev/data/class/util/SC_Utils.php
===================================================================
--- branches/version-2_5-dev/data/class/util/SC_Utils.php 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/class/util/SC_Utils.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -2310,5 +2310,50 @@
return $page_max;
}
+ /**
+ * 値を 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);
+ }
+ }
}
?>
変更: branches/version-2_5-dev/data/require_classes.php
===================================================================
--- branches/version-2_5-dev/data/require_classes.php 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/data/require_classes.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-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");
require_once(CLASS_EX_REALDIR . "db_extends/SC_DB_MasterData_Ex.php");
変更: branches/version-2_5-dev/html/test/upgrade/index.php
===================================================================
--- branches/version-2_5-dev/html/test/upgrade/index.php 2011-02-27 19:10:49 UTC (rev 20433)
+++ branches/version-2_5-dev/html/test/upgrade/index.php 2011-02-28 02:26:53 UTC (rev 20434)
@@ -95,8 +95,7 @@
// FIXME 一覧を取得するたびに更新されるのは微妙かも..
updateModuleTable($arrProductsList);
- $objJson = new Services_JSON();
- echo $objJson->encode($arrRet);
+ echo SC_Utils_Ex::jsonEncode($arrRet);
}
/**
Svn-src-all メーリングリストの案内