protected function getDataModel($feedId = null) { // re-instantiate DataModel if a different feed is requested. if ($this->dataModel && $feedId !== $this->dataModel->getFeedId()) { $this->dataModel = null; } if ($this->dataModel === null) { $feedData = $this->getCurrentFeed($feedId); $this->dataModel = mapModelFromFeedData($feedData); } return $this->dataModel; }
protected function doSearchByText($query) { $allResults = array(); foreach ($this->feeds as $id => $feedData) { if ($this->feedGroup) { $feedData['group'] = $this->feedGroup; } $controller = mapModelFromFeedData($feedData); if ($controller->canSearch()) { try { $results = $controller->search($query); $allResults = array_merge($allResults, $results); } catch (KurogoDataServerException $e) { Kurogo::log(LOG_WARNING, 'encountered KurogoDataServerException for feed config: ' . print_r($feedData, true) . $e->getMessage(), 'maps'); } } } return $allResults; }
private function getDataModel($feedId = null) { if (!$this->feeds) { $this->loadFeedData(); } // re-instantiate DataModel if a different feed is requested. if ($this->dataModel && $feedId !== $this->dataModel->getFeedId()) { $this->dataModel = null; } $categoryId = $this->getArg('references'); if ($this->dataModel === null) { if ($feedId === null) { $testFeedId = $this->getArg('category'); if (isset($this->feeds[$feedId])) { $feedId = $testFeedId; } else { foreach (explode(MAP_CATEGORY_DELIMITER, $categoryId) as $testId) { if (isset($this->feeds[$testId])) { $feedId = $testId; break; } } } } $feedData = $this->getCurrentFeed($feedId); $this->dataModel = mapModelFromFeedData($feedData); } if (isset($categoryId)) { $category = $this->dataModel->findCategory($categoryId); $categoryArg = $this->getArg('category'); if (strlen($categoryArg)) { $this->dataModel->findCategory($categoryArg); } } return $this->dataModel; }
protected function doSearchByText($query) { $allResults = array(); foreach ($this->feeds as $id => $feedData) { //use aliases to remap search query $aliases = Kurogo::arrayVal($feedData, 'ALIASES', array()); uksort($aliases, array($this, 'sortAliases')); foreach ($aliases as $alias => $map) { if (stripos($query, $alias) !== false) { //use the alias's value for searching $query = $map; break; } } if ($this->feedGroup) { $feedData['group'] = $this->feedGroup; } $controller = mapModelFromFeedData($feedData); if ($controller->canSearch()) { try { $results = $controller->search($query); $allResults = array_merge($allResults, $results); } catch (KurogoDataServerException $e) { Kurogo::log(LOG_WARNING, 'encountered KurogoDataServerException for feed config: ' . print_r($feedData, true) . $e->getMessage(), 'maps'); } } } return $allResults; }