From aa9ee9601925ba89e1f2e45c13293a840e25f690 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Thu, 7 Jul 2016 17:45:07 +0200 Subject: [PATCH] Added missing 'lookup' implentations --- .../page/handler/ArticlePageHandler.class.php | 22 ++++++++++-- .../CategoryArticleListPageHandler.class.php | 34 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php index 066d3eb143..9b72476814 100644 --- a/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/ArticlePageHandler.class.php @@ -1,5 +1,6 @@ sqlSelects = "(SELECT title FROM wcf".WCF_N."_article_content WHERE articleID = article.articleID AND (languageID IS NULL OR languageID = ".WCF::getLanguage()->languageID.") LIMIT 1) AS title"; + $articleList->getConditionBuilder()->add('article.articleID IN (SELECT articleID FROM wcf'.WCF_N.'_article_content WHERE title LIKE ?)', ['%' . $searchString . '%']); + $articleList->sqlLimit = 10; + $articleList->sqlOrderBy = 'title'; + $articleList->readObjects(); + + $results = []; + foreach ($articleList->getObjects() as $article) { + $results[] = [ + 'description' => $article->getFormattedTeaser(), + 'image' => ($article->getImage() ? $article->getImage()->getElementTag(48) : ''), + 'link' => $article->getLink(), + 'objectID' => $article->articleID, + 'title' => $article->getTitle() + ]; + } + + return $results; } /** diff --git a/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php b/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php index 1bf04e96f3..c6ed7ee481 100644 --- a/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php +++ b/wcfsetup/install/files/lib/system/page/handler/CategoryArticleListPageHandler.class.php @@ -1,8 +1,10 @@ add('category.objectTypeID = ?', [ObjectTypeCache::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.category', 'com.woltlab.wcf.article.category')]); + $conditionBuilder->add('(category.title LIKE ? OR language_item.languageItemValue LIKE ?)', ['%' . $searchString . '%', '%' . $searchString . '%']); + $sql = "SELECT DISTINCT categoryID + FROM wcf".WCF_N."_category category + LEFT JOIN wcf".WCF_N."_language_item language_item + ON (language_item.languageItem = category.title) + ".$conditionBuilder; + $statement = WCF::getDB()->prepareStatement($sql, 10); + $statement->execute($conditionBuilder->getParameters()); + $results = []; + while ($categoryID = $statement->fetchColumn()) { + $category = ArticleCategory::getCategory($categoryID); + + // build hierarchy + $description = ''; + foreach ($category->getParentCategories() as $parentCategory) { + $description .= $parentCategory->getTitle() . ' » '; + } + + $results[] = [ + 'description' => $description, + 'image' => 'fa-folder-open-o', + 'link' => $category->getLink(), + 'objectID' => $categoryID, + 'title' => $category->getTitle() + ]; + } + + return $results; } /** -- 2.20.1