From: naoki hirata Date: Sat, 24 Jun 2017 01:18:18 +0000 (+0900) Subject: コンテンツ取得アドオン更新。 X-Git-Tag: v2.20.1~20 X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=5d69b9c12ca76287b609458959e998a1ea01003d;p=magic3%2Fmagic3.git コンテンツ取得アドオン更新。 --- diff --git a/include/addons/bloglib/blogLib.php b/include/addons/bloglib/blogLib.php index e7128f3f..8b85fd93 100644 --- a/include/addons/bloglib/blogLib.php +++ b/include/addons/bloglib/blogLib.php @@ -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; diff --git a/include/addons/contentlib/contentLib.php b/include/addons/contentlib/contentLib.php index 3b0740ca..9bc6d765 100644 --- a/include/addons/contentlib/contentLib.php +++ b/include/addons/contentlib/contentLib.php @@ -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); } } ?> diff --git a/include/addons/contentlib/contentLibDb.php b/include/addons/contentlib/contentLibDb.php index 5cb77a70..cc3abbc5 100644 --- a/include/addons/contentlib/contentLibDb.php +++ b/include/addons/contentlib/contentLibDb.php @@ -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); diff --git a/include/wp/contentApi.php b/include/wp/contentApi.php index cccf7798..40133d8f 100644 --- a/include/wp/contentApi.php +++ b/include/wp/contentApi.php @@ -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 = '';