/**
  * Display a list of all option groups
  *
  * @return  void
  */
 public function displayTask()
 {
     $this->view->filters = array('sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'filter_order', 'title'), 'sort_Dir' => Request::getState($this->_option . '.' . $this->_controller . '.sortdir', 'filter_order_Dir', 'ASC'), 'limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'));
     $obj = new Archive();
     // Get record count
     $this->view->total = $obj->optionGroups('count', $this->view->filters);
     // Get records
     $this->view->rows = $obj->optionGroups('list', $this->view->filters);
     //print_r($this->view->rows); die;
     // For all records here get options
     $options = new \stdClass();
     $warehouse = new Warehouse();
     foreach ($this->view->rows as $r) {
         $key = $r->ogId;
         $allOptions = $warehouse->getOptionGroupOptions($key, 'rows', false);
         //print_r($allOptions); die;
         // Count how many active and how many inactive options there are
         $optionCounter = new \stdClass();
         $optionCounter->active = 0;
         $optionCounter->inactive = 0;
         foreach ($allOptions as $optionInfo) {
             if ($optionInfo->oActive) {
                 $optionCounter->active++;
             } else {
                 $optionCounter->inactive++;
             }
         }
         $options->{$key} = $optionCounter;
     }
     //print_r($options); die;
     $this->view->options = $options;
     // Set any errors
     if ($this->getError()) {
         foreach ($this->getErrors() as $error) {
             $this->view->setError($error);
         }
     }
     // Output the HTML
     //print_r($this->view); die;
     $this->view->display();
 }
Beispiel #2
0
 /**
  * Get a count or list of options
  *
  * @param      string  	$rtrn	What data to return
  * @param      int   	$ogId 	Option group Id
  * @param      array   	$filters Filters to apply to data retrieval
  * @return     mixed
  */
 public function options($rtrn = 'rows', $ogId, $filters = array())
 {
     if (!isset($filters['sort'])) {
         $filters['sort'] = 'title';
     }
     if (!isset($filters['sort_Dir'])) {
         $filters['sort_Dir'] = 'ASC';
     }
     $warehouse = new Warehouse();
     switch (strtolower($rtrn)) {
         case 'count':
             return $warehouse->getOptionGroupOptions($ogId, 'count', false);
             break;
         case 'list':
         case 'rows':
         case 'results':
         default:
             if (!($results = $warehouse->getOptionGroupOptions($ogId, 'rows', false, $filters))) {
                 $results = array();
             }
             return new \Hubzero\Base\ItemList($results);
     }
 }