/** * Liefert den Searcher * * @return tx_rnbase_util_SearchBase */ protected function getSearcher() { tx_rnbase::load('tx_rnbase_util_SearchBase'); $searcher = tx_rnbase_util_SearchBase::getInstance($this->getSearchClass()); if (!$searcher instanceof tx_rnbase_util_SearchBase) { throw new Exception(get_class($this) . '->getSearchClass() has to return a classname' . ' of class which extends tx_rnbase_util_SearchBase!'); } return $searcher; }
/** * * @param tx_rnbase_IParameters $parameters * @param tx_rnbase_configurations $configurations * @param ArrayObject $viewData * @return string error msg or null */ public function handleRequest(&$parameters, &$configurations, &$viewData) { // confIdExtended setzen $this->confIdExtended = $configurations->get($this->getConfId() . 'extendedConfId'); $this->confIdExtended = $this->confIdExtended ? $this->confIdExtended : 'default'; $confId = $this->getExtendedConfId(); // Filter erstellen. /* @var $filter tx_rnbase_filter_BaseFilter */ $filter = tx_rnbase_filter_BaseFilter::createFilter($parameters, $configurations, $viewData, $confId . 'filter.'); $fields = $options = array(); // Searcher instanzieren. Konfiguriert wird er über die options['searchdef'] /* @var $searcher tx_rnbase_util_SearchGeneric */ tx_rnbase::load('tx_rnbase_util_SearchBase'); $searcher = tx_rnbase_util_SearchBase::getInstance('tx_rnbase_util_SearchGeneric'); // Dem Filter den Searcher übergeben, fall er diese Möglichkeit bietet. if (method_exists($filter, 'setSearcher')) { $filter->setSearcher($searcher); } // Suche initialisieren und nur ausführen wenn der Filter es erlaubt. if ($doSearch = $filter->init($fields, $options)) { // Soll ein PageBrowser verwendet werden? if ($configurations->get($confId . 'pagebrowser')) { $pbOptions = array('searchcallback' => array($searcher, 'search')); $cbOptions['pbid'] = ($var = $configurations->get($confId . 'pagebrowser.cbid')) ? $var : 'pb' . $this->confIdExtended; $filter->handlePageBrowser($configurations, $confId . 'pagebrowser', $viewData, $fields, $options, $pbOptions); } // Soll ein CharBrowser verwendet werden? if ($configurations->get($confId . 'charbrowser')) { // optionen sammeln $cbOptions = array('searchcallback' => array($searcher, 'search')); $cbOptions['colname'] = ($var = $configurations->get($confId . 'charbrowser.colname')) ? $var : 'title'; $cbOptions['specials'] = ($var = $configurations->get($confId . 'charbrowser.specials')) ? $var : 'last'; $cbOptions['cbid'] = ($var = $configurations->get($confId . 'charbrowser.cbid')) ? $var : 'cb' . $this->confIdExtended; $filter->handleCharBrowser($configurations, $confId . 'charbrowser', $viewData, $fields, $options, $cbOptions); } // items besorgen. $items = $searcher->search($fields, $options); } else { $items = array(); } $viewData->offsetSet('items', $items); $viewData->offsetSet('searched', $doSearch); return null; }
/** * Return an instantiated dummy model without any content * * This is used only to access several model info methods like * getTableName(), getColumnNames() etc. * * @return Tx_Rnbase_Domain_Model_RecordInterface */ private function getDummyModel() { if (!$this->dummyModel) { $searcher = tx_rnbase_util_SearchBase::getInstance($this->getSearchClass()); $this->dummyModel = tx_rnbase::makeInstance($searcher->getWrapperClass(), array('uid' => 0)); } return $this->dummyModel; }
/** * * @return tx_rnbase_util_SearchBase */ protected function getSearcher() { return tx_rnbase_util_SearchBase::getInstance($this->getSearchClass()); }
/** * Wir verwenden einen alphabetischen Pager. Also muß zunächst ermittelt werden, welche * Buchstaben überhaupt vorkommen. * @param tx_cfcleaguefe_ProfileService $service * @param tx_rnbase_configurations $configurations */ private static function findPagerData($fields, $options, $cfg) { $colName = $cfg['colname']; $searchCallback = $cfg['searchcallback']; if (!$searchCallback) { throw new Exception('No search callback defined!'); } $options['what'] = 'LEFT(UCASE(' . $colName . '),1) As first_char, count(LEFT(UCASE(' . $colName . '),1)) As size'; $options['groupby'] = 'LEFT(UCASE(' . $colName . '),1)'; unset($options['limit']); $rows = call_user_func($searchCallback, $fields, $options); $specials = tx_rnbase_util_SearchBase::getSpecialChars(); $wSpecials = array(); foreach ($specials as $key => $special) { foreach ($special as $char) { $wSpecials[$char] = $key; } } $ret = array(); foreach ($rows as $row) { if (array_key_exists($row['first_char'], $wSpecials)) { $ret[$wSpecials[$row['first_char']]] = intval($ret[$wSpecials[$row['first_char']]]) + $row['size']; } else { $ret[$row['first_char']] = $row['size']; } } if ($cfg['specials'] == 'last' && isset($ret['0-9'])) { $specials = $ret['0-9']; unset($ret['0-9']); $ret['0-9'] = $specials; } $current = 0; if (count($ret)) { $keys = array_keys($ret); $current = $keys[0]; } $data = array(); $data['list'] = $ret; $data['default'] = $current; $data['pointername'] = array_key_exists('cbid', $cfg) && $cfg['cbid'] ? $cfg['cbid'] : 'charpointer'; return $data; }