public function index(DataObjectCollection $collection, $sh = '', &$c_query = null) { $display_fields = array(); $model = $collection->getModel(); // If selection of display fields is disabled, don't set them up if (!$this->search->disable_field_selection) { foreach ($model->getFields() as $fieldname => $field) { if ($fieldname != 'id' && $fieldname != 'usercompanyid' && substr($fieldname, -3) != '_id' && !isset($model->belongsToField[$fieldname])) { $display_fields[$fieldname] = $field->tag; } } $selected_fields = array(); if (isset($this->_data['Search']['display_fields'])) { foreach ($this->_data['Search']['display_fields'] as $fieldname => $field) { $selected_fields[$fieldname] = prettify($field); } } else { foreach ($collection->getFields() as $fieldname => $field) { if (substr($fieldname, -3) != '_id') { $selected_fields[$fieldname] = $field->tag; } } } $this->view->set('selected_fields', $selected_fields); $display_fields = array_diff($display_fields, $selected_fields); $this->view->set('display_fields', $display_fields); } if (!isset($this->_data['ajax_print'])) { parent::index($collection, $sh, $c_query); return; } showtime('start-controller-index'); $collection->setParams(); if (!$sh instanceof SearchHandler) { $sh = $this->setSearchHandler($collection); } showtime('sh-extracted'); // Need to set the orderby of the collection in the searchhandler? // But if this is set in the collection, seems to take it // so why not here? showtime('pre-load'); // TODO: Printing needs looking at; the model is too complicated and // therefore maintenance is difficult. Needs breaking down into more // logical discrete units. // BEWARE: the following may not work for all cases // needs extensive testing; this is implemented for selectorController output if ($this->_data['session_key'] == 'undefined') { $sh->setLimit(0); $collection->load($sh); $this->PrintCollection($collection); } // echo 'controller::index setting printing session data<br>'; // in this instance we can only pass the data through the session // but it's only the collection name and search id :-) $_SESSION['printing'][$this->_data['session_key']]['collection'] = get_class($collection); $_SESSION['printing'][$this->_data['session_key']]['search_id'] = $this->_data['search_id']; exit; showtime('end-controller-index'); }