[Svn-src-all:3919] [version-2_13-dev 22833] #2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

kimoto admin @ mail.ec-cube.net
2013年 5月 21日 (火) 12:01:24 JST


Subversion committed to /home/svn/open 22833
http://svn.ec-cube.net/open_trac/changeset/22833
┌────────────────────────────┐
│更新者 :  kimoto                                       │
│更新日時:  2013-05-21 12:01:24 +0900 (火, 21  5月 2013)│
└────────────────────────────┘

Log:
--------------------------------------------------------
 #2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)
 商品表示条件が点在しているので1箇所にまとめてプラグインを作りやすいよう
 にする

Changed:                      [U:修正,A:追加,D:削除]
--------------------------------------------------------
U   branches/version-2_13-dev/data/class/SC_Product.php
U   branches/version-2_13-dev/data/class/helper/SC_Helper_DB.php
U   branches/version-2_13-dev/data/class/pages/LC_Page_Sitemap.php
U   branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_List.php
U   branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php
U   branches/version-2_13-dev/data/class/pages/rss/LC_Page_Rss_Products.php

変更: branches/version-2_13-dev/data/class/SC_Product.php
===================================================================
--- branches/version-2_13-dev/data/class/SC_Product.php	2013-05-21 02:35:42 UTC (rev 22832)
+++ branches/version-2_13-dev/data/class/SC_Product.php	2013-05-21 03:01:24 UTC (rev 22833)
@@ -772,4 +772,10 @@
 
         return $sql;
     }
+
+    function getProductDispConditions($tablename = null) {
+        $tablename = ($tablename) ? $tablename . '.' : null;
+        return $tablename . 'del_flg = 0 AND ' . $tablename . 'status = 1 ';
+    }
+
 }

変更: branches/version-2_13-dev/data/class/helper/SC_Helper_DB.php
===================================================================
--- branches/version-2_13-dev/data/class/helper/SC_Helper_DB.php	2013-05-21 02:35:42 UTC (rev 22832)
+++ branches/version-2_13-dev/data/class/helper/SC_Helper_DB.php	2013-05-21 03:01:24 UTC (rev 22833)
@@ -28,7 +28,7 @@
  * @author LOCKON CO.,LTD.
  * @version $Id:SC_Helper_DB.php 15532 2007-08-31 14:39:46Z nanasess $
  */
-class SC_Helper_DB 
+class SC_Helper_DB
 {
 
     // {{{ properties
@@ -90,7 +90,7 @@
         }
         return false;
     }
-    
+
     function sfColumnAdd($tableName, $colName, $colType) {
         $objQuery =& SC_Query_Ex::getSingletonInstance($dsn);
         return $objQuery->query("ALTER TABLE $tableName ADD $colName $colType ");
@@ -184,7 +184,7 @@
     /**
      * 基本情報のキャッシュデータファイルを生成する
      * データはsfGetBasisDataより取得。
-     * 
+     *
      * このメソッドが直接呼ばれるのは、
      *「基本情報管理>SHOPマスター」の更新完了後。
      * sfGetBasisDataCacheでは、
@@ -725,7 +725,7 @@
         }
 
         //共通のfrom/where文の構築
-        $sql_where = 'alldtl.del_flg = 0 AND alldtl.status = 1';
+        $sql_where = SC_Product_Ex::getProductDispConditions('alldtl');
         // 在庫無し商品の非表示
         if (NOSTOCK_HIDDEN) {
             $where_products_class = '(stock >= 1 OR stock_unlimited = 1)';
@@ -1160,10 +1160,10 @@
         $oldRank = $objQuery->get('rank', $tableName, $getWhere, array($keyId));
 
         $max = $objQuery->max('rank', $tableName, $where);
-        
+
         // 更新するランク値を取得
         $newRank = $this->getNewRank($pos, $max);
-        // 他のItemのランクを調整する 
+        // 他のItemのランクを調整する
         $ret = $this->moveOtherItemRank($newRank, $oldRank, $objQuery, $tableName, $where);
         if (!$ret) {
             // 他のランク変更がなければ処理を行わない
@@ -1183,18 +1183,18 @@
 
         $objQuery->commit();
     }
-    
+
     /**
      * 指定された位置の値をDB用のRANK値に変換する
      * 指定位置が1番目に移動なら、newRankは最大値
      * 指定位置が1番下へ移動なら、newRankは1
-     * 
+     *
      * @param int $position 指定された位置
      * @param int $maxRank 現在のランク最大値
      * @return int $newRank DBに登録するRANK値
-     */ 
+     */
     function getNewRank($position, $maxRank) {
-        
+
         if ($position > $maxRank) {
             $newRank = 1;
         } else if ($position < 1) {
@@ -1207,15 +1207,15 @@
 
     /**
      * 指定した順位の商品から移動させる商品までのrankを1つずらす
-     * 
+     *
      * @param int $newRank
      * @param int $oldRank
      * @param object $objQuery
      * @param string $where
-     * @return boolean 
+     * @return boolean
      */
     function moveOtherItemRank($newRank, $oldRank, &$objQuery, $tableName, $addWhere) {
-        
+
         $sqlval = array();
         $arrRawSql = array();
         $where = 'rank BETWEEN ? AND ?';
@@ -1234,12 +1234,12 @@
             //入れ替え先の順位が入れ替え元の順位と同じ場合なにもしない
             return false;
         }
-        
+
         return $objQuery->update($tableName, $sqlval, $where, $arrWhereVal, $arrRawSql);
-        
+
     }
-    
 
+
     /**
      * ランクを含むレコードを削除する.
      *
@@ -1323,7 +1323,7 @@
 
     /**
      * カテゴリ変更時の移動処理を行う.
-     * 
+     *
      * ※この関数って、どこからも呼ばれていないのでは??
      *
      * @param SC_Query $objQuery SC_Query インスタンス
@@ -1621,7 +1621,7 @@
 
     /**
      * レコード件数を計算.
-     * 
+     *
      * @param string $table
      * @param string $where
      * @param array $arrval

変更: branches/version-2_13-dev/data/class/pages/LC_Page_Sitemap.php
===================================================================
--- branches/version-2_13-dev/data/class/pages/LC_Page_Sitemap.php	2013-05-21 02:35:42 UTC (rev 22832)
+++ branches/version-2_13-dev/data/class/pages/LC_Page_Sitemap.php	2013-05-21 03:01:24 UTC (rev 22833)
@@ -50,7 +50,7 @@
  * :TODO: 各ページの changefreq や priority を指定できるようにする
  * :TODO: filemtime 関数を使えば、静的なページの更新時間も取得できそう
  */
-class LC_Page_Sitemap extends LC_Page_Ex 
+class LC_Page_Sitemap extends LC_Page_Ex
 {
 
     // }}}
@@ -239,7 +239,7 @@
     function getAllDetail()
     {
         $objQuery = SC_Query_Ex::getSingletonInstance();
-        $sql = 'SELECT product_id, update_date FROM dtb_products WHERE del_flg = 0 AND status = 1';
+        $sql = 'SELECT product_id, update_date FROM dtb_products WHERE ' . SC_Product_Ex::getProductDispConditions();
         $result = $objQuery->getAll($sql);
 
         $arrRet = array();

変更: branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_List.php
===================================================================
--- branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_List.php	2013-05-21 02:35:42 UTC (rev 22832)
+++ branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_List.php	2013-05-21 03:01:24 UTC (rev 22833)
@@ -31,7 +31,7 @@
  * @author LOCKON CO.,LTD.
  * @version $Id$
  */
-class LC_Page_Products_List extends LC_Page_Ex 
+class LC_Page_Products_List extends LC_Page_Ex
 {
 
     // {{{ properties
@@ -361,7 +361,7 @@
         }
         // ▼対象商品IDの抽出
         // 商品検索条件の作成(未削除、表示)
-        $searchCondition['where'] = 'alldtl.del_flg = 0 AND alldtl.status = 1 ';
+        $searchCondition['where'] = SC_Product_Ex::getProductDispConditions('alldtl');
 
         if (strlen($searchCondition['where_category']) >= 1) {
             $searchCondition['where'] .= ' AND EXISTS (SELECT * FROM dtb_product_categories WHERE ' . $searchCondition['where_category'] . ' AND product_id = alldtl.product_id)';
@@ -482,7 +482,7 @@
 
     /**
      *
-     * @param type $objProduct 
+     * @param type $objProduct
      * @return void
      */
     function doDefault(&$objProduct)

変更: branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php
===================================================================
--- branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php	2013-05-21 02:35:42 UTC (rev 22832)
+++ branches/version-2_13-dev/data/class/pages/products/LC_Page_Products_Review.php	2013-05-21 03:01:24 UTC (rev 22833)
@@ -31,7 +31,7 @@
  * @author LOCKON CO.,LTD.
  * @version $Id:LC_Page_Products_Review.php 15532 2007-08-31 14:39:46Z nanasess $
  */
-class LC_Page_Products_Review extends LC_Page_Ex 
+class LC_Page_Products_Review extends LC_Page_Ex
 {
 
     // {{{ properties
@@ -202,7 +202,7 @@
     {
         $objQuery =& SC_Query_Ex::getSingletonInstance();
 
-        return $objQuery->get('name', 'dtb_products', 'product_id = ? AND del_flg = 0 AND status = 1', array($product_id));
+        return $objQuery->get('name', 'dtb_products', 'product_id = ? AND ' . SC_Product_Ex::getProductDispConditions(), array($product_id));
     }
 
     //登録実行

変更: branches/version-2_13-dev/data/class/pages/rss/LC_Page_Rss_Products.php
===================================================================
--- branches/version-2_13-dev/data/class/pages/rss/LC_Page_Rss_Products.php	2013-05-21 02:35:42 UTC (rev 22832)
+++ branches/version-2_13-dev/data/class/pages/rss/LC_Page_Rss_Products.php	2013-05-21 03:01:24 UTC (rev 22833)
@@ -31,7 +31,7 @@
  * @author LOCKON CO.,LTD.
  * @version $Id$
  */
-class LC_Page_Rss_Products extends LC_Page_Ex 
+class LC_Page_Rss_Products extends LC_Page_Ex
 {
 
     // }}}
@@ -295,9 +295,9 @@
     function lfGetProductsAllclass(&$objQuery)
     {
         // --- 商品一覧の取得
-        $objQuery->setWhere('del_flg = 0 AND status = 1');
+        $objProduct = new SC_Product_Ex();
+        $objQuery->setWhere($objProduct->getProductDispConditions());
         $objQuery->setOrder('product_id');
-        $objProduct = new SC_Product_Ex();
         $arrProductLsit = $objProduct->lists($objQuery);
         // 各商品のカテゴリIDとランクの取得
         $arrProducts = array();




Svn-src-all メーリングリストの案内