public function select_item_component_output($status = 'generate') { // build options array $options = array('type' => array('csv' => '', 'pdf' => '', 'xml' => ''), 'output' => array('print' => '', 'save' => '', 'email' => '', 'view' => ''), 'filename' => 'Item_Component_list_' . fix_date(date(DATE_FORMAT))); // simply return the options if we're only at the dialog stage if (strtolower($status) === "dialog") { return $options; } $flash = Flash::Instance(); $s_data = array(); $params['options']['parent_id'] = $this->_templateobject->getDisplayFieldNames(); // so set context from calling module if (isset($this->_data['parent_id'])) { $s_data['parent_id'] = $this->_data['parent_id']; } elseif (!isset($this->_data['Search']['parent_id'])) { $s_data['parent_id'] = NULL; } $params['type'] = $this->module; parent::setSearch('SelectorItemSearch', 'useDefault', $s_data, $params); // load the default display fields into the session, we need these as we cannot rely on getting the headings from the data itself $_SESSION['selected_items']['headings'] = $this->_templateobject->getDisplayFieldNames(); $this->_templateobject->idField = 'id'; $this->_templateobject->orderby = $this->itemFields; $collection = new SelectorCollection(clone $this->_templateobject); $collection->setTableName($collection->selectorLinkOverview($this->itemFields, $this->linkTableName, $this->targetModel, $this->targetFields)); $sh = $this->setSearchHandler($collection); $sh->setFields(array_merge(array('id', 'item_id', 'target_id'), $this->itemFields, $this->targetFields)); if (!isset($this->_data['orderby']) && !isset($this->_data['page'])) { $sh->addConstraint(SelectorCollection::getItemHierarchy($this->module, $this->search->getValue('parent_id'))); } // set the query count sql - if no constraints, then just get count from link table $criteria = $sh->constraints->__toString(); if (empty($criteria)) { $c_query = 'select count(*) as count from ' . $this->linkTableName . ' link'; } // get list of items matching search criteria parent::index($collection, $sh, $c_query); $this->view->set('collection', $collection); $this->setTemplateName('selector_index'); }