public function view($updated = false)
 {
     Loader::library('database_indexed_search');
     if ($this->post('reindex')) {
         IndexedSearch::clearSearchIndex();
         $this->redirect('/dashboard/system/seo/search_index', 'index_cleared');
     } else {
         if ($updated) {
             $this->set('message', t('Search Index Preferences Updated'));
         }
         if ($this->isPost()) {
             if ($this->token->validate('update_search_index')) {
                 $areas = $this->post('arHandle');
                 if (!is_array($areas)) {
                     $areas = array();
                 }
                 Config::save('SEARCH_INDEX_AREA_LIST', serialize($areas));
                 Config::save('SEARCH_INDEX_AREA_METHOD', Loader::helper('security')->sanitizeString($this->post('SEARCH_INDEX_AREA_METHOD')));
                 $this->redirect('/dashboard/system/seo/search_index', 'updated');
             } else {
                 $this->set('error', array($this->token->getErrorMessage()));
             }
         }
         $areas = Area::getHandleList();
         $selectedAreas = array();
         $this->set('areas', $areas);
         $this->set('selectedAreas', IndexedSearch::getSavedSearchableAreas());
     }
 }
示例#2
0
 public function getBodyContentFromPage($c)
 {
     $searchableAreaNamesInitial = $this->getSavedSearchableAreas();
     foreach ($this->searchableAreaNamesManual as $sm) {
         $searchableAreaNamesInitial[] = $sm;
     }
     $searchableAreaNames = array();
     if ($this->getSearchableAreaAction() == 'blacklist') {
         $areas = Area::getHandleList();
         foreach ($areas as $arHandle) {
             if (!in_array($arHandle, $searchableAreaNamesInitial)) {
                 $searchableAreaNames[] = $arHandle;
             }
         }
     } else {
         $searchableAreaNames = $searchableAreaNamesInitial;
     }
     if (count($searchableAreaNames) == 0) {
         return false;
     }
     $text = '';
     $tagsToSpaces = array('<br>', '<br/>', '<br />', '<p>', '</p>', '</ p>', '<div>', '</div>', '</ div>', '&nbsp;');
     $blarray = array();
     $db = Loader::db();
     $r = $db->Execute('select bID, arHandle from CollectionVersionBlocks where cID = ? and cvID = ?', array($c->getCollectionID(), $c->getVersionID()));
     $th = Loader::helper('text');
     while ($row = $r->FetchRow()) {
         if (in_array($row['arHandle'], $searchableAreaNames)) {
             $b = Block::getByID($row['bID'], $c, $row['arHandle']);
             if (!is_object($b)) {
                 continue;
             }
             $bi = $b->getInstance();
             $bi->bActionCID = $c->getCollectionID();
             if (method_exists($bi, 'getSearchableContent')) {
                 $searchableContent = $bi->getSearchableContent();
                 if (strlen(trim($searchableContent))) {
                     $text .= $th->decodeEntities(strip_tags(str_ireplace($tagsToSpaces, ' ', $searchableContent)), ENT_QUOTES, APP_CHARSET) . ' ';
                 }
             }
             unset($b);
             unset($bi);
         }
     }
     $returned_text = Events::fire('on_page_body_index', $c, $text);
     if ($returned_text !== null && $returned_text !== false) {
         $text = $returned_text;
     }
     return $text;
 }
示例#3
0
 public function manage_index()
 {
     Loader::library('database_indexed_search');
     if ($this->isPost()) {
         $areas = $this->post('arHandle');
         if (!is_array($areas)) {
             $areas = array();
         }
         Config::save('SEARCH_INDEX_AREA_LIST', serialize($areas));
         Config::save('SEARCH_INDEX_AREA_METHOD', $this->post('SEARCH_INDEX_AREA_METHOD'));
         $this->redirect('/dashboard/sitemap/search', 'index_settings_updated');
     }
     $areas = Area::getHandleList();
     $selectedAreas = array();
     $this->set('areas', $areas);
     $this->set('selectedAreas', IndexedSearch::getSavedSearchableAreas());
 }