/** * Check if the search all field (name=fabrik_list_filter_all) has submitted data * * If it has then go through all elements, and add in a filter * for each element whose data type matches the search type * (e.g. if searching a string then ignore int() fields) * * If another filter has posted some data then don't add in a 'search all' record for that filter * * @param array &$filters filter array * * @return void */ private function getSearchAllFilters(&$filters) { $input = $this->app->input; $requestKey = $this->getSearchAllRequestKey(); $search = $this->getSearchAllValue('query'); if ($search == '') { if (array_key_exists($requestKey, $_POST)) { // Empty search string sent unset any searchall filters $ks = array_keys($filters); $filterKeys = array_keys(FArrayHelper::getValue($filters, 'search_type', array())); foreach ($filterKeys as $filterKey) { if (FArrayHelper::getValue($filters['search_type'], $filterKey, '') == 'searchall') { foreach ($ks as $k) { /** * $$$ rob 10/04/2012 simply unsetting the array leaves the array pointer, but somewhere we recreate * $filters['search_type'] so its index becomes out of sync. see http://fabrikar.com/forums/showthread.php?t=25698 * unset($filters[$k][$filterKey]); */ $filters[$k] = array(); } } } } } if ($search == '') { // Clear full text search all if (array_key_exists($requestKey, $_POST)) { $this->clearAFilter($filters, 9999); } return; } $listId = $input->getInt('listid', -1); // Check that we actually have the correct list id (or -1 if filter from viz) if ($this->listModel->getTable()->id == $listId || $listId == -1) { if ($this->listModel->getParams()->get('search-mode-advanced')) { $this->doBooleanSearch($filters, $search); } else { $this->insertSearchAllIntoFilters($filters, $search); } } }
/** * Get the headings for the csv file * * @return array heading labels */ public function getHeadings() { $input = $this->app->input; $w = new FabrikWorker(); $table = $this->model->getTable(); $params = $this->model->getParams(); $headingFormat = $params->get('csvfullname'); $data = $this->model->getData(); $g = current($data); if (empty($g)) { return $g; } $r = current($g); $formModel = $this->model->getFormModel(); $groups = $formModel->getGroupsHiarachy(); $h = array(); if (!is_object($r)) { return new stdClass(); } $incRaw = $input->get('incraw', true); $incData = $input->get('inctabledata', true); $shortKey = FabrikString::shortColName($table->db_primary_key); foreach ($r as $heading => $value) { $found = false; foreach ($groups as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $element = $elementModel->getElement(); $fullName = $elementModel->getFullName(true, false); if ($fullName == $heading || $fullName . '_raw' == $heading) { $found = true; switch ($headingFormat) { default: case '0': $n = $element->name; break; case '1': $n = $elementModel->getFullName(false, false); break; case '2': $n = $elementModel->getListHeading(); break; } /** * $$$ hugh - added next line as special case for a client, do not remove! * (used in conjunction with "Custom QS" option, to allow variable header labels */ $n = $w->parseMessageForPlaceHolder($n, array()); if ($fullName . '_raw' == $heading) { $n .= '_raw'; } if ($incData && JString::substr($n, JString::strlen($n) - 4, JString::strlen($n)) !== '_raw') { if (!in_array($n, $h)) { // Only add heading once $h[] = $n; } else { $h[] = $this->uniqueHeading($n, $h); } } if ($incRaw && JString::substr($n, JString::strlen($n) - 4, strlen($n)) == '_raw') { if (!in_array($n, $h)) { // Only add heading once $h[] = $n; } else { $h[] = $this->uniqueHeading($n, $h); } } } } } if (!$found) { if (!(JString::substr($heading, JString::strlen($heading) - 4, JString::strlen($heading)) == '_raw' && !$incRaw)) { // Stop id getting added to tables when exported with full element name key if ($headingFormat != 1 && $heading != $shortKey) { $h[] = $heading; } } } } if ($input->get('inccalcs') == 1) { array_unshift($h, FText::_('Calculation')); } $h = array_map(array($this, "quote"), $h); return $h; }