aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2018-04-01 17:06:20 +0200
committerThomas Lange <code@nerdmind.de>2018-04-01 17:06:20 +0200
commit36965226acd25178ce3d28633aadc1749f85b9f2 (patch)
tree55fccdaf919b18809f9143eac051185fe977cfc3
parent2a017afea40941f6cc18208a6f595ee129ae143c (diff)
downloadblog-36965226acd25178ce3d28633aadc1749f85b9f2.tar.gz
blog-36965226acd25178ce3d28633aadc1749f85b9f2.tar.xz
blog-36965226acd25178ce3d28633aadc1749f85b9f2.zip
Replace method calls "getSearchResultIDs" with "getSearchResults"
This commit replaces the method calls of "Item::getSearchResultIDs" with "Item::getSearchResults". In addition, the associated Item instances (Page or Post) are therefore now created with "Factory::buildByAttribute" instead of "Factory::build" (because "getSearchResults" returns an array of Attribute instances while "getSearchResultIDs" had returned an array of unique item IDs without attribute data).
-rw-r--r--admin/page/search.php16
-rw-r--r--admin/post/search.php16
-rw-r--r--core/include/search/main.php8
3 files changed, 18 insertions, 22 deletions
diff --git a/admin/page/search.php b/admin/page/search.php
index d97370d..0506a0d 100644
--- a/admin/page/search.php
+++ b/admin/page/search.php
@@ -14,17 +14,15 @@ require '../../core/application.php';
# IF: Handle search request
#===============================================================================
if($search = HTTP::GET('q')) {
- if($pageIDs = Page\Item::getSearchResultIDs($search, $Database)) {
- foreach($pageIDs as $pageID) {
- try {
- $Page = Page\Factory::build($pageID);
- $User = User\Factory::build($Page->attr('user'));
+ foreach(Page\Item::getSearchResults($search, $Database) as $Attribute) {
+ try {
+ $Page = Page\Factory::buildByAttribute($Attribute);
+ $User = User\Factory::build($Page->attr('user'));
- $pages[] = generatePageItemTemplate($Page, $User);
- }
- catch(Page\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $pages[] = generatePageItemTemplate($Page, $User);
}
+ catch(Page\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
}
diff --git a/admin/post/search.php b/admin/post/search.php
index c2c83ca..ac472f8 100644
--- a/admin/post/search.php
+++ b/admin/post/search.php
@@ -14,17 +14,15 @@ require '../../core/application.php';
# IF: Handle search request
#===============================================================================
if($search = HTTP::GET('q')) {
- if($postIDs = Post\Item::getSearchResultIDs($search, [NULL, NULL, NULL], $Database)) {
- foreach($postIDs as $postID) {
- try {
- $Post = Post\Factory::build($postID);
- $User = User\Factory::build($Post->attr('user'));
+ foreach(Post\Item::getSearchResults($search, [NULL, NULL, NULL], $Database) as $Attribute) {
+ try {
+ $Post = Post\Factory::buildByAttribute($Attribute);
+ $User = User\Factory::build($Post->attr('user'));
- $posts[] = generatePostItemTemplate($Post, $User);
- }
- catch(Post\Exception $Exception){}
- catch(User\Exception $Exception){}
+ $posts[] = generatePostItemTemplate($Post, $User);
}
+ catch(Post\Exception $Exception){}
+ catch(User\Exception $Exception){}
}
}
diff --git a/core/include/search/main.php b/core/include/search/main.php
index 8854b79..5a9708e 100644
--- a/core/include/search/main.php
+++ b/core/include/search/main.php
@@ -11,7 +11,7 @@ $M_LIST = $Database->query(sprintf('SELECT DISTINCT MONTH(time_insert) AS temp F
$Y_LIST = $Database->query(sprintf('SELECT DISTINCT YEAR(time_insert) AS temp FROM %s ORDER BY temp', Post\Attribute::TABLE));
if($search = HTTP::GET('q')) {
- if(!$postIDs = Post\Item::getSearchResultIDs($search, [HTTP::GET('d'), HTTP::GET('m'), HTTP::GET('y')], $Database)) {
+ if(!$attributes = Post\Item::getSearchResults($search, [HTTP::GET('d'), HTTP::GET('m'), HTTP::GET('y')], $Database)) {
$message = $Language->text('search_no_results', escapeHTML($search));
}
}
@@ -38,10 +38,10 @@ $search_data = [
# TRY: Template\Exception
#===============================================================================
try {
- if(isset($postIDs) AND !empty($postIDs)) {
- foreach($postIDs as $postID) {
+ if(isset($attributes) AND !empty($attributes)) {
+ foreach($attributes as $Attribute) {
try {
- $Post = Post\Factory::build($postID);
+ $Post = Post\Factory::buildByAttribute($Attribute);
$User = User\Factory::build($Post->attr('user'));
$posts[] = generatePostItemTemplate($Post, $User);