OSDN Git Service

コンテンツ取得アドオン更新。
authornaoki hirata <naoki@magic3.org>
Sat, 24 Jun 2017 01:18:18 +0000 (10:18 +0900)
committernaoki hirata <naoki@magic3.org>
Sat, 24 Jun 2017 01:18:18 +0000 (10:18 +0900)
include/addons/bloglib/blogLib.php
include/addons/contentlib/contentLib.php
include/addons/contentlib/contentLibDb.php
include/wp/contentApi.php

index e7128f3..8b85fd9 100644 (file)
@@ -21,6 +21,7 @@ class blogLib extends Addon
        private $db;    // DB接続オブジェクト
        private $blogId = '';   // ブログID
        private $templateId = '';       // テンプレートID
+       const CF_ENTRY_VIEW_COUNT               = 'entry_view_count';                   // 記事表示数
        
        /**
         * コンストラクタ
@@ -198,6 +199,16 @@ class blogLib extends Addon
                return true;
        }
        /**
+        * 記事一覧の表示項目数を取得
+        *
+        * @return int                          表示項目数
+        */
+       function getPublicContentViewCount()
+       {
+               $itemCount = $this->getConfig(self::CF_ENTRY_VIEW_COUNT);
+               return $itemCount;
+       }
+       /**
         * 公開中のエントリー項目を取得。アクセス制限も行う。
         *
         * @param int           $limit                          取得する項目数
@@ -213,7 +224,7 @@ class blogLib extends Addon
         * @param string        $blogId                         ブログID(nullのとき指定なし)
         * @return                      なし
         */
-       function getPublicEntryItems($limit, $page, $entryId, $now, $startDt, $endDt, $keywords, $langId, $order, $callback, $blogId = null)
+       function getPublicContentList($limit, $page, $entryId, $now, $startDt, $endDt, $keywords, $langId, $order, $callback, $blogId = null)
        {
                global $gEnvManager;
                
index 3b0740c..9bc6d76 100644 (file)
@@ -127,6 +127,17 @@ class contentLib
                }
        }
        /**
+        * コンテンツ一覧の表示項目数を取得
+        *
+        * @return int                          表示項目数
+        */
+       function getPublicContentViewCount()
+       {
+       //      $itemCount = $this->getConfig(self::CF_ENTRY_VIEW_COUNT);
+               $itemCount = 10;
+               return $itemCount;
+       }
+       /**
         * 公開中のエントリー項目を取得。アクセス制限も行う。
         *
         * @param int           $limit                          取得する項目数
@@ -141,12 +152,12 @@ class contentLib
         * @param function      $callback                       コールバック関数
         * @return                      なし
         */
-       function getPublicEntryItems($limit, $page, $contentId, $now, $startDt, $endDt, $keywords, $langId, $order, $callback)
+       function getPublicContentList($limit, $page, $contentId, $now, $startDt, $endDt, $keywords, $langId, $order, $callback)
        {
                global $gEnvManager;
                
                $userId = $gEnvManager->getCurrentUserId();
-               $this->db->getPublicEntryItems($limit, $page, $contentId, $now, $startDt, $endDt, $keywords, $langId, $order, $userId, $callback);
+               $this->db->getPublicContentItems($limit, $page, $contentId, $now, $startDt, $endDt, $keywords, $langId, $order, $userId, $callback);
        }
 }
 ?>
index 5cb77a7..cc3abbc 100644 (file)
@@ -68,7 +68,7 @@ class contentLibDb extends BaseDb
         * @param string        $contentType            コンテンツタイプ(空文字列=汎用コンテンツ)
         * @return                      なし
         */
-       function getPublicEntryItems($limit, $page, $contentId, $now, $startDt, $endDt, $keywords, $langId, $order, $userId, $callback, $contentType = '')
+       function getPublicContentItems($limit, $page, $contentId, $now, $startDt, $endDt, $keywords, $langId, $order, $userId, $callback, $contentType = '')
        {
                $initDt = $this->gEnv->getInitValueOfTimestamp();
                $offset = $limit * ($page -1);
index cccf779..40133d8 100644 (file)
@@ -112,19 +112,30 @@ class ContentApi extends BaseApi
         *
         * @param array $params                 クエリー作成用パラメータ(連想配列)
         * @param strin $langId                 言語ID。空の場合は現在の言語。
-        * @param int   $limit                  取得する項目数最大値
+        * @param int   $limit                  取得する項目数最大値(0の場合はデフォルト値)
         * @param int   $pageNo                 取得するページ番号(1~)
         * @return                                              なし
         */
        public function setCondition($params, $langId, $limit, $pageNo)
        {
                global $gEnvManager;
-                       
-               if (empty($langId)) $langId = $gEnvManager->getCurrentLanguage();
-               $this->langId = $langId;                                // コンテンツの言語(コンテンツ取得用)
-               $this->limit = $limit;                                  // コンテンツ取得数(コンテンツ取得用)
-               $this->pageNo = $pageNo;                                // ページ番号(コンテンツ取得用)
+
+               // アドオンオブジェクト取得
+               $addonObj = $this->_getAddonObj();
+               
+               // 一覧の表示項目数取得
+               $viewCount = $addonObj->getPublicContentViewCount();
+               
+               // 初期値設定
+               $this->langId = $gEnvManager->getCurrentLanguage();                             // コンテンツの言語(コンテンツ取得用)
+               $this->limit = $viewCount;                                      // コンテンツ取得数(コンテンツ取得用)
+               $this->pageNo = 1;                              // ページ番号(コンテンツ取得用)
                $this->now = date("Y/m/d H:i:s");       // 現在日時
+               
+               // パラメータ値で更新
+               if (!empty($langId)) $this->langId = $langId;                           // コンテンツの言語(コンテンツ取得用)
+               if (!empty($limit))$this->limit = $limit;                                       // コンテンツ取得数(コンテンツ取得用)
+               if (!empty($pageNo))$this->pageNo = $pageNo;                            // ページ番号(コンテンツ取得用)
        }
        /**
         * [WordPressテンプレート用API]コンテンツを取得
@@ -141,10 +152,11 @@ class ContentApi extends BaseApi
                } else {
                        $entryId = $this->contentId;            // コンテンツIDを指定。コンテンツIDは複数あり。
                }
-       
-               // データ取得
+               // アドオンオブジェクト取得
                $addonObj = $this->_getAddonObj();
-               $addonObj->getPublicEntryItems($this->limit, $this->pageNo, $entryId, $this->now, $startDt, $endDt, $keywords, $this->langId, $order, array($this, '_itemListLoop'), null/*ブログID*/);
+               
+               // データ取得
+               $addonObj->getPublicContentList($this->limit, $this->pageNo, $entryId, $this->now, $startDt, $endDt, $keywords, $this->langId, $order, array($this, '_itemListLoop'), null/*ブログID*/);
                
                return $this->contentArray;
        }
@@ -212,7 +224,7 @@ class ContentApi extends BaseApi
                $post->post_date = $date;
                $post->post_date_gmt = '';
                $post->post_password = '';
-               $post->post_name = $title;              // エンコーディングが必要?
+               $post->post_name = '';          // スラッグ等で使用されるので設定しない
                $post->post_type = 'post';
                $post->post_status = 'publish';
                $post->to_ping = '';