/** {@inheritdoc} */ public function toTwig() { $r = $this->getRequest(); $luceneIndex = Curry_Core::getSearchIndex(); $vars = array(); $vars['Total'] = $luceneIndex->numDocs(); if (isset($r->get['query'])) { $query = trim($r->get['query']); $hits = $luceneIndex->find($query); if ($this->alwaysWildcard && count($hits) === 0) { $hits = $luceneIndex->find($query . '*'); } $tmp = array(); if ($this->onlyThisLanguage) { foreach ($hits as $hit) { try { if ($hit->locale == Curry_Language::getLangCode()) { $tmp[] = $hit; } } catch (Zend_Search_Lucene_Exception $e) { $tmp[] = $hit; } } $hits = $tmp; } $vars['Query'] = $query; $vars['NumHits'] = count($hits); $vars['hits'] = new Curry_Twig_CollectionWrapper($hits, array($this, 'getHitProperties')); } return $vars; }
/** * Get an array of Curry\Module\PageModuleWrapper objects for all modules on the PageRevision we are rendering. * * @return \Curry\Module\PageModuleWrapper[] */ protected function getPageModuleWrappers() { $langcode = (string) \Curry_Language::getLangCode(); $cacheName = md5(__CLASS__ . '_ModuleWrappers_' . $this->pageRevision->getPageRevisionId() . '_' . $langcode); if (($moduleWrappers = $this->app->cache->load($cacheName)) === false) { $moduleWrappers = $this->pageRevision->getPageModuleWrappers($langcode); $this->app->cache->save($moduleWrappers, $cacheName); } return $moduleWrappers; }