コード例 #1
0
 /**
  * Fill the field values with the page
  */
 public function populate()
 {
     $boostValues = $this->getBoostValues();
     // store the page id without indexing it
     $this->store('page_id', $this->page->get('id'));
     // index the page slug
     $this->index('slug', dmString::unSlugify($this->page->get('slug')), $boostValues['slug']);
     // index the page name
     $this->index('name', $this->page->get('name'), $boostValues['name']);
     // index the page title
     $this->index('title', $this->page->get('title'), $boostValues['title']);
     // index the page h1
     $this->index('h1', $this->page->get('h1'), $boostValues['h1']);
     // index the page description
     $this->index('description', $this->page->get('description'), $boostValues['description']);
     // index keywords only if the project uses them
     if (sfConfig::get('dm_seo_use_keywords')) {
         $this->index('keywords', $this->page->get('keywords'), $boostValues['keywords']);
     }
     // process the page body only if its boost value is not null
     if ($boostValues['body']) {
         $this->index('content_index', $this->getPageContentForIndex(), $boostValues['body']);
     }
     // store page content to display it on search results
     $this->store('content', $this->getPageContentForStore());
 }
コード例 #2
0
ファイル: dmPageNotFoundHandler.php プロジェクト: jdart/diem
 protected function useSearchIndex($slug)
 {
     if (!dmConfig::get('smart_404')) {
         return false;
     }
     try {
         $searchIndex = $this->serviceContainer->get('search_engine')->getCurrentIndex();
         $queryString = str_replace('/', ' ', dmString::unSlugify($slug));
         $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
         $results = $searchIndex->search($query);
         $foundPage = null;
         foreach ($results as $result) {
             if ($result->getScore() > 0.5) {
                 if ($foundPage = $result->getPage()) {
                     break;
                 }
             } else {
                 break;
             }
         }
         if ($foundPage) {
             return $this->serviceContainer->getService('helper')->link($foundPage)->getHref();
         }
     } catch (Exception $e) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Can not use search index to find redirection for slug ' . $slug, sfLogger::ERR)));
         if (sfConfig::get('dm_debug')) {
             throw $e;
         }
     }
 }