예제 #1
0
파일: category.php 프로젝트: bizanto/Hooked
 public function edit()
 {
     // disable menu
     YRequest::setVar('hidemainmenu', 1);
     // get request vars
     $cid = YRequest::getArray('cid.0', '', 'int');
     $edit = $cid > 0;
     // get category
     if ($edit) {
         $this->category = YTable::getInstance('category')->get($cid);
     } else {
         $this->category = new Category();
         $this->category->parent = 0;
     }
     // get category params
     $this->params = $this->category->getParams();
     // set toolbar items
     $text = $edit ? JText::_('Edit') : JText::_('New');
     $this->joomla->set('JComponentTitle', $this->application->getToolbarTitle(JText::_('Category') . ': ' . $this->category->name . ' <small><small>[ ' . $text . ' ]</small></small>'));
     JToolBarHelper::save();
     JToolBarHelper::custom('saveandnew', 'saveandnew', 'saveandnew', 'Save & New', false);
     JToolBarHelper::apply();
     JToolBarHelper::cancel('cancel', $edit ? 'Close' : 'Cancel');
     ZooHelper::toolbarHelp();
     // select published state
     $this->lists['select_published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $this->category->published);
     // get categories and exclude the current category
     $categories = $this->application->getCategories();
     unset($categories[$this->category->id]);
     // build category tree
     $list = CategoryHelper::buildTreeList(0, CategoryHelper::buildTree($this->application->id, $categories));
     $options = array(JHTML::_('select.option', '0', JText::_('Root')));
     foreach ($list as $item) {
         $options[] = JHTML::_('select.option', $item->id, '&nbsp;&nbsp;&nbsp;' . $item->treename);
     }
     // select parent category
     $this->lists['select_parent'] = JHTML::_('select.genericlist', $options, 'parent', 'class="inputbox" size="10"', 'value', 'text', $this->category->parent);
     // display view
     $this->getView()->setLayout('edit')->display();
 }
예제 #2
0
 public function getCategoryTree($published = false, $user = null, $item_count = false)
 {
     // get category tree
     if (empty($this->_category_tree)) {
         // get categories and item count
         $categories = $this->getCategories($published, $item_count);
         $this->_category_tree = CategoryHelper::buildTree($this->id, $categories);
     }
     return $this->_category_tree;
 }