public function indexAction() { $View = new View('category/list'); $View->assign('_title_', _('Categories')); $categories = CategoryModel::getAll(); $View->assign('categories', $categories); $View->display(); }
/** * Enabling and disabling categories from list. * * @since 2.0.0 * @access public */ public function manageCategories() { // Check permission $this->permission(['Garden.Community.Manage', 'Garden.Settings.Manage'], false); $this->setHighlightRoute('vanilla/settings/categories'); $this->addJsFile('manage-categories.js'); $this->addJsFile('jquery.alphanumeric.js'); // This now works on latest jQuery version 1.10.2 // // Jan29, 2014, upgraded jQuery UI to 1.10.3 from 1.8.11 $this->addJsFile('nestedSortable/jquery-ui.min.js'); // Newer nestedSortable, but does not work. //$this->addJsFile('js/library/nestedSortable/jquery.mjs.nestedSortable.js'); // old jquery-ui //$this->addJsFile('js/library/nestedSortable.1.3.4/jquery-ui-1.8.11.custom.min.js'); $this->addJsFile('nestedSortable.1.3.4/jquery.ui.nestedSortable.js'); $this->title(t('Categories')); // Get category data $CategoryData = $this->CategoryModel->getAll('TreeLeft'); // Set CanDelete per-category so we can override later if we want. $canDelete = checkPermission(['Garden.Community.Manage', 'Garden.Settings.Manage']); array_walk($CategoryData->result(), function (&$value) use($canDelete) { setvalr('CanDelete', $value, $canDelete); }); $this->setData('CategoryData', $CategoryData, true); // Setup & save forms $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->setField(array('Vanilla.Categories.MaxDisplayDepth', 'Vanilla.Categories.DoHeadings', 'Vanilla.Categories.HideModule')); // Set the model on the form. $this->Form->setModel($ConfigurationModel); // Define MaxDepthOptions $DepthData = array(); $DepthData['2'] = sprintf(t('more than %s deep'), plural(1, '%s level', '%s levels')); $DepthData['3'] = sprintf(t('more than %s deep'), plural(2, '%s level', '%s levels')); $DepthData['4'] = sprintf(t('more than %s deep'), plural(3, '%s level', '%s levels')); $DepthData['0'] = t('never'); $this->setData('MaxDepthData', $DepthData); // If seeing the form for the first time... if ($this->Form->authenticatedPostBack() === false) { // Apply the config settings to the form. $this->Form->setData($ConfigurationModel->Data); } else { if ($this->Form->save() !== false) { CategoryModel::clearCache(); $this->informMessage(t("Your settings have been saved.")); } } // Render default view $this->render(); }