public function categories($config = array())
 {
     $config = new Library\ObjectConfig($config);
     $config->append(array('name' => 'categories_category_id', 'row' => '', 'uncategorised' => false, 'max_depth' => '9'))->append(array('selected' => $config->row->{$config->name}))->append(array('filter' => array('sort' => 'title', 'parent' => null, 'published' => null, 'table' => $config->row->getTable()->getBase())));
     $categories = $this->getObject('com:categories.model.categories')->setState(Library\ObjectConfig::unbox($config->filter))->getRowset();
     $iterator = new DatabaseIteratorNode($categories);
     $iterator->setMaxDepth($config->max_depth);
     $options = $this->options(array('entity' => $iterator, 'value' => 'id', 'label' => 'title'));
     if ($config->uncategorised) {
         array_unshift($options, $this->option(array('label' => $this->translate('Uncategorized'), 'value' => '0', 'id' => '0')));
     }
     //Add the options to the config object
     $config->options = $options;
     return parent::radiolist($config);
 }
示例#2
0
 public function categories($config = array())
 {
     $config = new Library\ObjectConfig($config);
     $config->append(array('name' => 'category', 'deselect' => true, 'selected' => $config->category, 'prompt' => '- Select -', 'table' => '', 'parent' => '', 'max_depth' => 9));
     if ($config->deselect) {
         $options[] = $this->option(array('label' => $this->translate($config->prompt), 'value' => 0));
     }
     $categories = $this->getObject('com:categories.model.categories')->table($config->table)->parent($config->parent)->sort('title')->getRowset();
     $iterator = new DatabaseIteratorNode($categories);
     $iterator->setMaxDepth($config->max_depth);
     foreach ($iterator as $category) {
         $title = substr('---------', 0, $iterator->getDepth()) . $category->title;
         $options[] = $this->option(array('label' => $title, 'value' => $category->id));
     }
     $config->options = $options;
     return $this->optionlist($config);
 }