/**
 *
 *
 * @param array $category
 */
function writeCategoryOptions($category)
{
    $cdd = new DropdownModule('', '', 'dropdown-category-options', 'dropdown-menu-right');
    $cdd->setTrigger(displayAsSymbol($category['DisplayAs']), 'button', 'btn');
    $cdd->setView('dropdown-twbs');
    $cdd->setForceDivider(true);
    $cdd->addGroup('', 'edit')->addLink(t('View'), $category['Url'], 'edit.view')->addLink(t('Edit'), "/vanilla/settings/editcategory?categoryid={$category['CategoryID']}", 'edit.edit');
    $cdd->addGroup(t('Display as'), 'displayas');
    foreach (CategoryModel::getDisplayAsOptions() as $displayAs => $label) {
        $cssClass = strcasecmp($displayAs, $category['DisplayAs']) === 0 ? 'selected' : '';
        $icon = displayAsSymbol($displayAs);
        $cdd->addLink(t($label), '#', 'displayas.' . strtolower($displayAs), 'js-displayas ' . $cssClass, [], ['icon' => $icon, 'attributes' => ['data-displayas' => strtolower($displayAs)]], false);
    }
    $cdd->addGroup('', 'actions')->addLink(t('Add Subcategory'), "/vanilla/settings/addcategory?parent={$category['CategoryID']}", 'actions.add');
    $cdd->addGroup('', 'delete')->addLink(t('Delete'), "/vanilla/settings/deletecategory?categoryid={$category['CategoryID']}", 'delete.delete', 'js-modal');
    echo $cdd->toString();
}
 /**
  * Returns an array of dropdown menus with the data from the filters array or an array containing an empty string
  * to make it safe for echoing out.
  *
  * @return array An array of dropdown menus or an array containing an empty string.
  */
 protected function getFilterDropdowns()
 {
     if (!$this->filters) {
         return [''];
     }
     $dropdowns = [];
     foreach ($this->filters as $filterSet) {
         // Check to see if there's a category restriction.
         if ($categories = val('categories', $filterSet)) {
             if (!in_array($this->categoryID, $categories)) {
                 continue;
             }
         }
         $setKey = val('key', $filterSet);
         $dropdown = new DropdownModule('discussions-filter-' . $setKey, val('name', $filterSet), 'discussion-filter');
         // Override the trigger text?
         $selectedValue = val($setKey, $this->selectedFilters);
         if ($selectedValue && $selectedValue != 'none') {
             $selected = val('name', $filterSet['filters'][$selectedValue]);
             $dropdown->setTrigger($selected);
         }
         $dropdown->setView($this->dropdownView);
         $dropdown->setForceDivider(true);
         // Adds dividers between groups in the dropdown.
         // Add the filters to the dropdown
         foreach (val('filters', $filterSet) as $filter) {
             $key = val('group', $filter, '') . '.' . val('key', $filter);
             $queryString = DiscussionModel::getSortFilterQueryString($this->selectedSort, $this->selectedFilters, '', [$setKey => val('key', $filter)]);
             $pathAndQuery = $this->getPagelessPath() . $queryString;
             if (empty($pathAndQuery)) {
                 $pathAndQuery = '/';
             }
             $url = url($pathAndQuery);
             $dropdown->addLink(val('name', $filter), $url, $key, '', array(), false, array('rel' => 'nofollow'));
         }
         $dropdowns[] = $dropdown;
     }
     return $dropdowns;
 }