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.
for (var $i in resultList.items) {
var $item = resultList.items[$i];
- $('<li><a href="' + $item.link + '">' + WCF.String.escapeHTML($item.title) + '</a></li>').appendTo(this._list);
+ $('<li><a href="' + $item.link + '"><span>' + WCF.String.escapeHTML($item.title) + '</span>' + ($item.subtitle ? '<small>' + WCF.String.escapeHTML($item.subtitle) + '</small>' : '') + '</a></li>').appendTo(this._list);
this._itemCount++;
}
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()
*/
protected $link = '';
+ /**
+ * item subtitle
+ * @var string
+ */
+ protected $subtitle = '';
+
/**
* item title
* @var string
*
* @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;
}
/**
return $this->title;
}
+ /**
+ * Returns the item subtitle.
+ *
+ * @return string
+ */
+ public function getSubtitle() {
+ return $this->subtitle;
+ }
+
/**
* @see \wcf\system\search\acp\ACPSearchResult::getTitle()
*/
<?php
namespace wcf\system\search\acp;
use wcf\system\database\util\PreparedStatementConditionBuilder;
+use wcf\system\menu\acp\ACPMenu;
use wcf\system\WCF;
/**
continue;
}
- $results[] = new ACPSearchResult($languageItems[$menuItem->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;
<?php
namespace wcf\system\search\acp;
+use wcf\system\cache\builder\OptionCacheBuilder;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
$statement = WCF::getDB()->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)) {
}
$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;
<?php
namespace wcf\system\search\acp;
+use wcf\system\cache\builder\UserGroupOptionCacheBuilder;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\request\LinkHandler;
use wcf\system\WCF;
$statement = WCF::getDB()->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)) {
}
$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;
}
}
+ > a > small {
+ display: block;
+ }
+
> a + span.badge {
display: none;
}
<item name="wcf.acp.search.provider.com.woltlab.wcf.package"><![CDATA[Pakete]]></item>
<item name="wcf.acp.search.provider.com.woltlab.wcf.user"><![CDATA[Benutzer]]></item>
<item name="wcf.acp.search.provider.com.woltlab.wcf.userGroupOption"><![CDATA[Berechtigungen]]></item>
+ <item name="wcf.acp.search.result.subtitle"><![CDATA[{implode from=$pieces item=piece glue=' » '}{$piece|language}{/implode}]]></item>
</category>
<category name="wcf.acp.stat">
<item name="wcf.acp.search.provider.com.woltlab.wcf.package"><![CDATA[Packages]]></item>
<item name="wcf.acp.search.provider.com.woltlab.wcf.user"><![CDATA[Users]]></item>
<item name="wcf.acp.search.provider.com.woltlab.wcf.userGroupOption"><![CDATA[Permissions]]></item>
+ <item name="wcf.acp.search.result.subtitle"><![CDATA[{implode from=$pieces item=piece glue=' » '}{$piece|language}{/implode}]]></item>
</category>
<category name="wcf.acp.stat">