OSDN Git Service

Eコマースメインウィジェット更新。
authornaoki hirata <naoki@magic3.org>
Tue, 19 Sep 2017 05:27:14 +0000 (14:27 +0900)
committernaoki hirata <naoki@magic3.org>
Tue, 19 Sep 2017 05:27:14 +0000 (14:27 +0900)
include/etc/product/.gitkeep [new file with mode: 0644]
include/etc/product/thumb/.gitkeep [new file with mode: 0644]
include/sql/update_widgets.sql
widgets/ec_main/include/container/admin_ec_mainImageWidgetContainer.php
widgets/ec_main/include/db/ec_mainProductDb.php

diff --git a/include/etc/product/.gitkeep b/include/etc/product/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/include/etc/product/thumb/.gitkeep b/include/etc/product/thumb/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
index 7394444..d180255 100644 (file)
@@ -175,7 +175,7 @@ INSERT INTO _widgets
 DELETE FROM _widgets WHERE wd_id = 'ec_main';\r
 INSERT INTO _widgets\r
 (wd_id,     wd_name,              wd_type,   wd_content_type, wd_category_id, wd_edit_content, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description, wd_add_script_lib_a,  wd_has_admin, wd_initialized, wd_cache_type, wd_view_control_type, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
-('ec_main', 'Eコマース-メイン', 'product', 'commerce',      'commerce',     true, '2.2.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                'Eコマースのメインプログラム。会員登録処理や商品購入処理などを行う。', 'product_detail=ckeditor_m3toolbar;image=jquery.jcrop,elfinder;calcorder_detail=ckeditor_m3toolbar;delivmethod_detail=ckeditor_m3toolbar;paymethod_detail=ckeditor_m3toolbar;other=ckeditor_m3toolbar;', true,         true,   0, 2, '2016-09-19', now(), now());\r
+('ec_main', 'Eコマース-メイン', 'product', 'commerce',      'commerce',     true, '2.5.0',    'Naoki Hirata', 'Magic3.org', 'GPL',      10,                'Eコマースのメインプログラム。会員登録処理や商品購入処理などを行う。', 'product_detail=ckeditor_m3toolbar;image=jquery.jcrop,elfinder;calcorder_detail=ckeditor_m3toolbar;delivmethod_detail=ckeditor_m3toolbar;paymethod_detail=ckeditor_m3toolbar;other=ckeditor_m3toolbar;', true,         true,   0, 2, '2016-09-19', now(), now());\r
 DELETE FROM _widgets WHERE wd_id = 'ec_product_slide';\r
 INSERT INTO _widgets\r
 (wd_id,              wd_name,                        wd_category_id, wd_version, wd_author,      wd_copyright, wd_license, wd_official_level, wd_description, wd_add_script_lib, wd_add_script_lib_a,   wd_has_admin, wd_enable_operation, wd_use_instance_def, wd_initialized, wd_cache_type, wd_view_control_type, wd_release_dt, wd_install_dt, wd_create_dt) VALUES\r
index e5a5001..26f3dbb 100644 (file)
@@ -96,7 +96,7 @@ class admin_ec_mainImageWidgetContainer extends admin_ec_mainBaseWidgetContainer
                                // アイキャッチ画像を非公開ディレクトリに保存
                                $privateThumbDir = $this->gInstance->getImageManager()->getSystemPrivateThumbPath(M3_VIEW_TYPE_PRODUCT, photo_shopCommonDef::$_deviceType);
                                $ret = mvFileToDir($tmpDir, $filenames, $privateThumbDir);
-                               
+
                                // 画像を公開ディレクトリにコピー
                                $publicThumbDir = $this->gInstance->getImageManager()->getSystemThumbPath(M3_VIEW_TYPE_PRODUCT, photo_shopCommonDef::$_deviceType);
                                if ($ret) $ret = cpFileToDir($privateThumbDir, $filenames, $publicThumbDir);
@@ -106,8 +106,8 @@ class admin_ec_mainImageWidgetContainer extends admin_ec_mainBaseWidgetContainer
                                
                                // 製品情報のサムネールファイル名を更新
                                $thumbFilename = implode(';', $filenames);
-                               if ($ret) $ret = self::$_mainDb->updateThumbFilename($productId, $langId, $thumbFilename, $eyecatchSrcPath);
-                               
+                               if ($ret) $ret = $this->db->updateThumbFilename($productId, $langId, $thumbFilename, $eyecatchSrcPath);
+
                                if ($ret){
                                        $this->setMsg(self::MSG_GUIDANCE, 'データを更新しました');
                                        
@@ -142,7 +142,7 @@ class admin_ec_mainImageWidgetContainer extends admin_ec_mainBaseWidgetContainer
                                rmDirectory($tmpDir);
                                        
                                // 製品情報のサムネールファイル名を更新
-                               $ret = self::$_mainDb->updateThumbFilename($productId, $langId, '', ''/*サムネール作成元画像のパス*/);
+                               $ret = $this->db->updateThumbFilename($productId, $langId, '', ''/*サムネール作成元画像のパス*/);
                                
                                if ($ret){
                                        $this->setMsg(self::MSG_GUIDANCE, 'アイキャッチ画像を削除しました');
@@ -194,7 +194,7 @@ class admin_ec_mainImageWidgetContainer extends admin_ec_mainBaseWidgetContainer
                        }
                        
                        // 記事内でアイキャッチ画像に使用した画像を取得
-                       $originalEyecatchUrl = '';
+/*                     $originalEyecatchUrl = '';
                        $privateThumbDir = $this->gInstance->getImageManager()->getSystemPrivateThumbPath(M3_VIEW_TYPE_PRODUCT, photo_shopCommonDef::$_deviceType);
                        $imagePath = $privateThumbDir . '/' . $filename;
                        if (!empty($row['pt_thumb_filename']) && !file_exists($imagePath)){// 画像が作成されていて、非公開ディレクトリに画像がない場合
@@ -202,7 +202,7 @@ class admin_ec_mainImageWidgetContainer extends admin_ec_mainBaseWidgetContainer
                                $originalEyecatchPath = $this->gInstance->getImageManager()->getFirstImagePath($html);
                                if (empty($originalEyecatchPath) && !empty($html2)) $originalEyecatchPath = $this->gInstance->getImageManager()->getFirstImagePath($html2);             // 本文1に画像がないときは本文2を検索
                                if (!empty($originalEyecatchPath)) $originalEyecatchUrl = $this->gEnv->getUrlToPath($originalEyecatchPath);             // URLに変換
-                       }
+                       }*/
                        
                        // アイキャッチ画像削除用ボタンを表示
                        if (!empty($row['pt_thumb_filename'])) $this->tmpl->setAttribute('delete_eyecatch_button', 'visibility', 'visible');
@@ -232,7 +232,7 @@ class admin_ec_mainImageWidgetContainer extends admin_ec_mainBaseWidgetContainer
                $this->tmpl->addVar("_widget", "eyecatch_url", $this->convertUrlToHtmlEntity($this->getUrl($eyecatchUrl . '?' . date('YmdHis'))));
                $this->tmpl->addVar("_widget", "eyecatch_new_image", $eyecatchImagTag);                 // 置き換え用アイキャッチ画像
                $this->tmpl->addVar("_widget", "move_icon_tag", $moveIconTag);                  // 画像変更表示用アイコン
-               $this->tmpl->addVar("_widget", "original_eyecatch_url", $this->convertUrlToHtmlEntity($this->getUrl($originalEyecatchUrl)));            // アイキャッチ画像の元の画像
+//             $this->tmpl->addVar("_widget", "original_eyecatch_url", $this->convertUrlToHtmlEntity($this->getUrl($originalEyecatchUrl)));            // アイキャッチ画像の元の画像
                $this->tmpl->addVar("_widget", "eyecatch_size", $imageSize . 'x' . $imageSize);
                $this->tmpl->addVar("_widget", "product_id", $this->convertToDispString($productId));
        }
index 82aa3ec..6073cef 100644 (file)
@@ -8,7 +8,7 @@
  *
  * @package    Magic3 Framework
  * @author     平田直毅(Naoki Hirata) <naoki@aplo.co.jp>
- * @copyright  Copyright 2006-2016 Magic3 Project.
+ * @copyright  Copyright 2006-2017 Magic3 Project.
  * @license    http://www.gnu.org/copyleft/gpl.html  GPL License
  * @version    SVN: $Id$
  * @link       http://www.magic3.org
@@ -1191,5 +1191,70 @@ class ec_mainProductDb extends BaseDb
                }
                return $index;
        }
+       /**
+        * サムネールファイル名の更新
+        *
+        * @param string $id                    製品ID
+        * @param string $langId                言語ID
+        * @param string $thumbFilename サムネールファイル名
+        * @param string $thumbSrc              サムネール作成元画像ファイル(resourceディレクトリからの相対パス)
+        * @return bool                                 true = 成功、false = 失敗
+        */
+       function updateThumbFilename($id, $langId, $thumbFilename, $thumbSrc)
+       {
+               $serial = $this->getProductSerialNoById($id, $langId);
+               if (empty($serial)) return false;
+               
+               $now = date("Y/m/d H:i:s");     // 現在日時
+               $userId = $this->gEnv->getCurrentUserId();      // 現在のユーザ
+                                               
+               // トランザクション開始
+               $this->startTransaction();
+               
+               // 指定のシリアルNoのレコードが削除状態でないかチェック
+               $queryStr  = 'SELECT * FROM product ';
+               $queryStr .=   'WHERE pt_serial = ? ';
+               $ret = $this->selectRecord($queryStr, array(intval($serial)), $row);
+               if ($ret){              // 既に登録レコードがあるとき
+                       if ($row['pt_deleted']){                // レコードが削除されていれば終了
+                               $this->endTransaction();
+                               return false;
+                       }
+               } else {                // 存在しない場合は終了
+                       $this->endTransaction();
+                       return false;
+               }
+               // 日付を更新
+               $queryStr  = 'UPDATE product ';
+               $queryStr .=   'SET pt_thumb_filename = ?, ';   // サムネールファイル名
+               $queryStr .=     'pt_thumb_src = ?, ';                  // サムネール作成元画像ファイル
+               $queryStr .=     'pt_update_user_id = ?, ';
+               $queryStr .=     'pt_update_dt = ? ';
+               $queryStr .=   'WHERE pt_serial = ?';
+               $this->execStatement($queryStr, array($thumbFilename, $thumbSrc, $userId, $now, intval($serial)));
+               
+               // トランザクション確定
+               $ret = $this->endTransaction();
+               return $ret;
+       }
+       /**
+        * 製品情報のシリアル番号を製品IDで取得
+        *
+        * @param string        $id                                     製品ID
+        * @param string        $langId                         言語ID
+        * @return int                                                  シリアル番号、取得できないときは0を返す
+        */
+       function getProductSerialNoById($id, $langId)
+       {
+               $serial = 0;
+               $queryStr  = 'SELECT * FROM product ';
+               $queryStr .=   'WHERE pt_deleted = false ';     // 削除されていない
+               $queryStr .=   'AND pt_history_index >= 0 ';            // 正規(Regular)記事を対象
+               $queryStr .=   'AND pt_id = ? ';
+               $queryStr .=   'AND pt_language_id = ? ';
+               $ret = $this->selectRecord($queryStr, array($id, $langId), $row);
+               if ($ret) $serial = $row['pt_serial'];
+               return $serial;
+       }
 }
 ?>