From: Marcel Werk Date: Thu, 7 Jul 2016 15:45:07 +0000 (+0200) Subject: Added missing 'lookup' implentations X-Git-Tag: 3.0.0_Beta_1~1248 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=aa9ee9601925ba89e1f2e45c13293a840e25f690;p=GitHub%2FWoltLab%2FWCF.git Added missing 'lookup' implentations --- 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; } /**