OSDN Git Service

WordPressテンプレート機能更新。
authornaoki hirata <naoki@magic3.org>
Tue, 4 Jul 2017 00:24:16 +0000 (09:24 +0900)
committernaoki hirata <naoki@magic3.org>
Tue, 4 Jul 2017 00:24:16 +0000 (09:24 +0900)
include/container/baseFrameContainer.php
include/sql/sample/blog_demo2.sql
include/wp/contentApi.php
include/wp/wp-includes/class-wp-query.php

index 8ff5603..8df1e11 100644 (file)
@@ -793,6 +793,9 @@ class BaseFrameContainer extends Core
                        switch ($contentType){
                        case M3_VIEW_TYPE_CONTENT:              // 汎用コンテンツ
                                if ($firstKey == M3_REQUEST_PARAM_CONTENT_ID || $firstKey == M3_REQUEST_PARAM_CONTENT_ID_SHORT){        // コンテンツIDのとき
+                                       // ページタイプを設定
+                                       $GLOBALS['gContentApi']->setPageType('page');
+                                       
                                        // フルパスで返るので相対パスに修正
                                        $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_page_template());            // 固定ページテンプレート
                                        
@@ -809,12 +812,25 @@ class BaseFrameContainer extends Core
 //                             if ($firstKey == M3_REQUEST_PARAM_BLOG_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ID_SHORT ||                     // ブログIDのとき
 //                                     $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT){              // ブログ記事IDのとき
                                if ($firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID || $firstKey == M3_REQUEST_PARAM_BLOG_ENTRY_ID_SHORT){          // ブログ記事IDのとき
+                                       // ページタイプを設定
+                                       $GLOBALS['gContentApi']->setPageType('single');
+                                       
                                        // フルパスで返るので相対パスに修正
                                        $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_single_template());          // 記事詳細テンプレート
                                        
                                        // コンテンツID設定
                                        $firstValue = $this->gRequest->trimValueOf($firstKey);
                                        $GLOBALS['gContentApi']->setContentId($firstValue);
+                               } else {
+                                       // 検索条件が設定されている場合は検索ページを表示
+                                       $value = $this->gRequest->trimValueOf('s');
+                                       if (!empty($value)){
+                                               // ページタイプを設定
+                                               $GLOBALS['gContentApi']->setPageType('search');                 // 検索結果表示
+                                       
+                                               // フルパスで返るので相対パスに修正
+                                               $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_search_template());          // 検索結果テンプレート
+                                       }
                                }
                                break;
                        case M3_VIEW_TYPE_WIKI: // Wiki
@@ -827,6 +843,9 @@ class BaseFrameContainer extends Core
                                break;
                        default:
                                // コンテンツタイプが設定されていないページに場合は、固定ページ用のテンプレートを使用
+                               // ページタイプを設定
+                               $GLOBALS['gContentApi']->setPageType('page');
+                                       
                                // フルパスで返るので相対パスに修正
                                $defaultIndexFile = $this->_getRelativeTemplateIndexPath($curTemplate, get_page_template());            // 固定ページテンプレート
                                break;
index 86eb106..960a313 100644 (file)
@@ -35,7 +35,7 @@ UPDATE _page_id SET pg_active = false WHERE pg_id = 'm_index' AND pg_type = 0;
 DELETE FROM _page_id WHERE pg_type = 1 AND pg_priority < 100;
 INSERT INTO _page_id 
 (pg_id,          pg_type,      pg_name,                            pg_description,                       pg_priority, pg_active, pg_visible, pg_editable) VALUES
-('front',        1,            'トップ画面',                       'トップ画面用',                       0,           true,      true,       true),
+('front',        1,            'トップ画面',                       'トップ画面用',                       0,           false,      true,       true),
 ('content',      1,            'コンテンツ',                       'コンテンツ画面用',                   1,           true,      true,       false),
 ('shop',         1,            'ECショップ',                       'ECショップ画面用',                   2,           false,      true,       true),
 ('shop_safe',    1,            'ECショップ(セキュリティ保護)',     'ECショップ(セキュリティ保護)画面用', 3,           false,      true,       true),
index 05d75d6..92d9fb8 100644 (file)
@@ -21,11 +21,15 @@ require_once(M3_SYSTEM_INCLUDE_PATH . '/common/valueCheck.php');
 class ContentApi extends BaseApi
 {
        private $contentType;                   // コンテンツタイプ
+       private $pageType;                              // ページタイプ(WordPressテンプレートのpage,single,search)
        private $accessPoint;                   // アクセスポイント(空文字列=PC用,m=携帯用,s=スマートフォン用)
        private $langId;                                // コンテンツの言語(コンテンツ取得用)
        private $limit;                                 // コンテンツ取得数(コンテンツ取得用)
        private $pageNo;                                // ページ番号(1~)(コンテンツ取得用)
        private $order;                                 // コンテンツ並び順(0=昇順,1=降順)
+       private $keywords;                              // 検索条件(キーワード)
+       private $startDt;                               // 検索条件(期間開始日時)
+       private $endDt;                                 // 検索条件(期間終了日時)
        private $contentArray;                  // 取得コンテンツ
        private $contentId;                             // 表示するコンテンツのID(複数の場合は配列)
        private $prevNextBaseValue;             // 前後のコンテンツ取得用のベース値
@@ -109,13 +113,16 @@ class ContentApi extends BaseApi
        /**
         * [WordPressテンプレート用API]SQLクエリー用のパラメータを設定
         *
-        * @param array $params                 クエリー作成用パラメータ(連想配列)
-        * @param strin $langId                 言語ID。空の場合は現在の言語。
-        * @param int   $limit                  取得する項目数最大値(0の場合はデフォルト値)
-        * @param int   $pageNo                 取得するページ番号(1~)
-        * @return                                              なし
+        * @param array $params                         クエリー作成用パラメータ(連想配列)
+        * @param strin $langId                         言語ID。空の場合は現在の言語。
+        * @param int   $limit                          取得する項目数最大値(0の場合はデフォルト値)
+        * @param int   $pageNo                         取得するページ番号(1~)
+        * @param string,array $keywords        検索条件(キーワード)
+        * @param timestamp $startDt            検索条件(期間開始日時)
+        * @param timestamp $endDt                      検索条件(期間終了日時)
+        * @return                                                      なし
         */
-       public function setCondition($params, $langId, $limit, $pageNo)
+       public function setCondition($params, $langId, $limit, $pageNo, $keywords = '', $startDt = null, $endDt = null)
        {
                // アドオンオブジェクト取得
                $addonObj = $this->_getAddonObj();
@@ -130,6 +137,9 @@ class ContentApi extends BaseApi
                $this->pageNo = 1;                                                      // ページ番号(コンテンツ取得用)
                $this->order = 1;                                                       // コンテンツ並び順。デフォルトは降順。
                $this->now = date("Y/m/d H:i:s");                       // 現在日時
+               $this->keywords = $keywords;            // 検索条件(キーワード)
+               $this->startDt = $startDt;                      // 検索条件(期間開始日時)
+               $this->endDt = $endDt;                          // 検索条件(期間終了日時)
                
                // パラメータ値で更新
                if (!empty($langId)) $this->langId = $langId;                           // コンテンツの言語(コンテンツ取得用)
@@ -155,7 +165,7 @@ class ContentApi extends BaseApi
                $addonObj = $this->_getAddonObj();
                
                // データ取得
-               $addonObj->getPublicContentList($this->limit, $this->pageNo, $entryId, $this->now, $startDt, $endDt, $keywords, $this->langId, $this->order, array($this, '_itemListLoop'),  null/*カテゴリーID*/, null/*ブログID*/);
+               $addonObj->getPublicContentList($this->limit, $this->pageNo, $entryId, $this->now, $this->startDt, $this->endDt, $this->keywords, $this->langId, $this->order, array($this, '_itemListLoop'),  null/*カテゴリーID*/, null/*ブログID*/);
                
                return $this->contentArray;
        }
@@ -416,6 +426,25 @@ class ContentApi extends BaseApi
                return $this->contentType;
        }
        /**
+        * ページタイプを設定
+        *
+        * @param string $type                                  ページタイプ(page,single,search)
+        * @return                                                              なし
+        */
+       function setPageType($type)
+       {
+               $this->pageType = $type;
+       }
+       /**
+        * ページタイプを取得
+        *
+        * @return string                                               ページタイプ(page,single,search)
+        */
+       function getPageType()
+       {
+               return $this->pageType;
+       }
+       /**
         * コンテンツIDを設定
         *
         * @param string $idStr                 コンテンツID文字列
index cb29dd6..74f4c0c 100644 (file)
@@ -1703,7 +1703,15 @@ class WP_Query {
                        $wpPostObj = new WP_Post($post);
                        $this->posts = array($wpPostObj);
                } else {
-                       $gContentApi->setCondition(array(), ''/*現在の言語*/, 0/*最大取得数(デフォルト)*/, $pageNo/*ページ番号*/);
+                       $keywords = '';
+                       
+                       // 検索結果表示の場合はキーワードを取得
+                       $pageType = $gContentApi->getPageType();
+                       if ($pageType == 'search'){
+                               $keywords = $gRequestManager->trimValueOf('s');
+                       }
+                       
+                       $gContentApi->setCondition(array(), ''/*現在の言語*/, 0/*最大取得数(デフォルト)*/, $pageNo/*ページ番号*/, $keywords);
                        $this->posts = $gContentApi->getContentList();
                        
                        // コンテンツ総数を取得