From: Matthias Schmidt Date: Wed, 20 Aug 2014 14:55:37 +0000 (+0200) Subject: Add subtitle to acp search result issues X-Git-Tag: 2.1.0_Alpha_1~419 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=790aadd93e497bc095eed27de3405e9b7e6bb298;p=GitHub%2FWoltLab%2FWCF.git Add subtitle to acp search result issues This changes make it possible to distinguish items with the same name. The subtitle will only be displayed if search results with the same title are in the same list. --- diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 901fac0636..f31a9f0c27 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -1922,7 +1922,7 @@ WCF.ACP.Search = WCF.Search.Base.extend({ for (var $i in resultList.items) { var $item = resultList.items[$i]; - $('
  • ' + WCF.String.escapeHTML($item.title) + '
  • ').appendTo(this._list); + $('
  • ' + WCF.String.escapeHTML($item.title) + '' + ($item.subtitle ? '' + WCF.String.escapeHTML($item.subtitle) + '' : '') + '
  • ').appendTo(this._list); this._itemCount++; } diff --git a/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php b/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php index 41ef14c52a..8a46dd3a44 100644 --- a/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php +++ b/wcfsetup/install/files/lib/data/acp/search/provider/ACPSearchProviderAction.class.php @@ -39,10 +39,26 @@ class ACPSearchProviderAction extends AbstractDatabaseObjectAction implements IS foreach ($resultList as $item) { $items[] = array( 'link' => $item->getLink(), + 'subtitle' => $item->getSubtitle(), 'title' => $item->getTitle() ); } + foreach ($items as $key => &$item) { + $double = false; + foreach ($items as $key2 => $item2) { + if ($key != $key2 && $item['title'] == $item2['title']) { + $double = true; + break; + } + } + + if (!$double) { + unset($item['subtitle']); + } + } + unset($item); + $data[] = array( 'items' => $items, 'title' => $resultList->getTitle() diff --git a/wcfsetup/install/files/lib/system/search/acp/ACPSearchResult.class.php b/wcfsetup/install/files/lib/system/search/acp/ACPSearchResult.class.php index 18bc6ae67a..17fead893d 100644 --- a/wcfsetup/install/files/lib/system/search/acp/ACPSearchResult.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/ACPSearchResult.class.php @@ -18,6 +18,12 @@ class ACPSearchResult { */ protected $link = ''; + /** + * item subtitle + * @var string + */ + protected $subtitle = ''; + /** * item title * @var string @@ -29,10 +35,12 @@ class ACPSearchResult { * * @param string $title * @param string $link + * @param string $subtitle */ - public function __construct($title, $link) { + public function __construct($title, $link, $subtitle = '') { $this->title = $title; $this->link = $link; + $this->subtitle = $subtitle; } /** @@ -53,6 +61,15 @@ class ACPSearchResult { return $this->title; } + /** + * Returns the item subtitle. + * + * @return string + */ + public function getSubtitle() { + return $this->subtitle; + } + /** * @see \wcf\system\search\acp\ACPSearchResult::getTitle() */ diff --git a/wcfsetup/install/files/lib/system/search/acp/MenuItemACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/MenuItemACPSearchResultProvider.class.php index a0438ae5a4..87a2f1e761 100644 --- a/wcfsetup/install/files/lib/system/search/acp/MenuItemACPSearchResultProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/MenuItemACPSearchResultProvider.class.php @@ -1,6 +1,7 @@ menuItem], $menuItem->getLink()); + $parentMenuItem = $menuItem->parentMenuItem; + $parentMenuItems = array(); + while ($parentMenuItem && isset(ACPMenu::getInstance()->menuItems[$parentMenuItem])) { + array_unshift($parentMenuItems, $parentMenuItem); + + $parentMenuItem = ACPMenu::getInstance()->menuItemList[$parentMenuItem]->parentMenuItem; + } + $results[] = new ACPSearchResult($languageItems[$menuItem->menuItem], $menuItem->getLink(), WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', array( + 'pieces' => $parentMenuItems + ))); } return $results; diff --git a/wcfsetup/install/files/lib/system/search/acp/OptionACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/OptionACPSearchResultProvider.class.php index a8820ae18c..5e2076ca1e 100644 --- a/wcfsetup/install/files/lib/system/search/acp/OptionACPSearchResultProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/OptionACPSearchResultProvider.class.php @@ -1,5 +1,6 @@ prepareStatement($sql); // don't use a limit here $statement->execute($conditions->getParameters()); + $optionCategories = OptionCacheBuilder::getInstance()->getData(array(), 'categories'); + while ($option = $statement->fetchObject('wcf\data\option\Option')) { // category is not accessible if (!$this->isValid($option->categoryName)) { @@ -72,7 +75,17 @@ class OptionACPSearchResultProvider extends AbstractCategorizedACPSearchResultPr } $link = LinkHandler::getInstance()->getLink('Option', array('id' => $this->getCategoryID($this->getTopCategory($option->categoryName)->parentCategoryName)), 'optionName='.$option->optionName.'#'.$this->getCategoryName($option->categoryName)); - $results[] = new ACPSearchResult($languageItems[$option->optionName], $link); + $categoryName = $option->categoryName; + $parentCategories = array(); + while (isset($optionCategories[$categoryName])) { + array_unshift($parentCategories, 'wcf.acp.option.category.'.$optionCategories[$categoryName]->categoryName); + + $categoryName = $optionCategories[$categoryName]->parentCategoryName; + } + + $results[] = new ACPSearchResult($languageItems[$option->optionName], $link, WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', array( + 'pieces' => $parentCategories + ))); } return $results; diff --git a/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php b/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php index 59ead1c296..e140978d6b 100644 --- a/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php +++ b/wcfsetup/install/files/lib/system/search/acp/UserGroupOptionACPSearchResultProvider.class.php @@ -1,5 +1,6 @@ prepareStatement($sql); // don't use a limit here $statement->execute($conditions->getParameters()); + $optionCategories = UserGroupOptionCacheBuilder::getInstance()->getData(array(), 'categories'); + while ($userGroupOption = $statement->fetchObject('wcf\data\user\group\option\UserGroupOption')) { // category is not accessible if (!$this->isValid($userGroupOption->categoryName)) { @@ -74,7 +77,17 @@ class UserGroupOptionACPSearchResultProvider extends AbstractCategorizedACPSearc } $link = LinkHandler::getInstance()->getLink('UserGroupOption', array('id' => $userGroupOption->optionID)); - $results[] = new ACPSearchResult($languageItems[$userGroupOption->optionName], $link); + $categoryName = $userGroupOption->categoryName; + $parentCategories = array(); + while (isset($optionCategories[$categoryName])) { + array_unshift($parentCategories, 'wcf.acp.group.option.category.'.$optionCategories[$categoryName]->categoryName); + + $categoryName = $optionCategories[$categoryName]->parentCategoryName; + } + + $results[] = new ACPSearchResult($languageItems[$userGroupOption->optionName], $link, WCF::getLanguage()->getDynamicVariable('wcf.acp.search.result.subtitle', array( + 'pieces' => $parentCategories + ))); } return $results; diff --git a/wcfsetup/install/files/style/dropdown.less b/wcfsetup/install/files/style/dropdown.less index 8a4a369c60..fb190afd9e 100644 --- a/wcfsetup/install/files/style/dropdown.less +++ b/wcfsetup/install/files/style/dropdown.less @@ -216,6 +216,10 @@ } } + > a > small { + display: block; + } + > a + span.badge { display: none; } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 8c970f7495..0ecff6ca53 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1233,6 +1233,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 9c72e94eb6..95e91ebfdf 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1232,6 +1232,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> +