public function run() { Cache::disableCache(); Loader::library('database_indexed_search'); $is = new IndexedSearch(); if ($_GET['force'] == 1) { Loader::model('attribute/categories/collection'); Loader::model('attribute/categories/file'); Loader::model('attribute/categories/user'); $attributes = CollectionAttributeKey::getList(); $attributes = array_merge($attributes, FileAttributeKey::getList()); $attributes = array_merge($attributes, UserAttributeKey::getList()); foreach($attributes as $ak) { $ak->updateSearchIndex(); } $result = $is->reindexAll(true); } else { $result = $is->reindexAll(); } if ($result->count == 0) { return t('Indexing complete. Index is up to date'); } else { if ($result->count == $is->searchBatchSize) { return t('Index partially updated. %s pages indexed (maximum number.) Re-run this job to continue this process.', $result->count); } else { return t('Index updated. %s %s required reindexing.', $result->count, $result->count == 1 ? t('page') : t('pages')); } } }
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()); } }
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()); }
?> "> <div class="ccm-pane-body"> <?php echo $this->controller->token->output('update_search_index'); ?> <h3><?php echo t('Indexing Method'); ?> </h3> <? $methods = array( 'whitelist' => t('Whitelist: Selected areas are only areas indexed.'), 'blacklist' => t('Blacklist: Every area but the selected areas are indexed.') ); print $form->select('SEARCH_INDEX_AREA_METHOD', $methods, IndexedSearch::getSearchableAreaAction(), array('class'=>'xlarge'));?> <h3><?php echo t('Areas'); ?> </h3> <? foreach($areas as $a) { ?> <div><?php echo $form->checkbox('arHandle[]', $a, in_array($a, $selectedAreas)); ?> <?php echo $a; ?> </div> <? } ?>
public function reindex($index = false) { if ($this->isAlias()) { return false; } $db = Loader::db(); Loader::model('attribute/categories/collection'); $attribs = CollectionAttributeKey::getAttributes($this->getCollectionID(), $this->getVersionID(), 'getSearchIndexValue'); $db->Execute('delete from CollectionSearchIndexAttributes where cID = ?', array($this->getCollectionID())); $searchableAttributes = array('cID' => $this->getCollectionID()); $rs = $db->Execute('select * from CollectionSearchIndexAttributes where cID = -1'); AttributeKey::reindex('CollectionSearchIndexAttributes', $searchableAttributes, $attribs, $rs); if ($index == false) { Loader::library('database_indexed_search'); $index = new IndexedSearch(); } $datetime = Loader::helper('date')->getSystemDateTime(); $db->Replace('PageSearchIndex', array( 'cID' => $this->getCollectionID(), 'cName' => $this->getCollectionName(), 'cDescription' => $this->getCollectionDescription(), 'cPath' => $this->getCollectionPath(), 'cDatePublic' => $this->getCollectionDatePublic(), 'content' => $index->getBodyContentFromPage($this), 'cDateLastIndexed' => $datetime ), array('cID'), true); }
</div> <?php } ?> <br/> <h2><?php echo t('Area Indexing Method'); ?> </h2> <?php $methods = array('whitelist' => t('Whitelist: Selected areas are only areas indexed.'), 'blacklist' => t('Blacklist: Every area but the selected areas are indexed.')); ?> <?php print $form->select('SEARCH_INDEX_AREA_METHOD', $methods, IndexedSearch::getSearchableAreaAction()); print '<br/>'; print '<br/>'; $ih = Loader::helper('concrete/interface'); $b1 = $ih->button(t('Cancel'), $this->url('/dashboard/sitemap/search'), 'left'); $b2 = $ih->submit(t('Save'), 'ccm-search-index-manage', 'right'); print $ih->buttons($b1, $b2); ?> </form> </div> <?php } else { ?> <h1><span><?php echo t('Search Pages');
public function reindex($index = false, $actuallyDoReindex = true) { if ($this->isAlias()) { return false; } if ($actuallyDoReindex || ENABLE_PROGRESSIVE_PAGE_REINDEX == false) { $db = Loader::db(); Loader::model('attribute/categories/collection'); $attribs = CollectionAttributeKey::getAttributes($this->getCollectionID(), $this->getVersionID(), 'getSearchIndexValue'); $db->Execute('delete from CollectionSearchIndexAttributes where cID = ?', array($this->getCollectionID())); $searchableAttributes = array('cID' => $this->getCollectionID()); $rs = $db->Execute('select * from CollectionSearchIndexAttributes where cID = -1'); AttributeKey::reindex('CollectionSearchIndexAttributes', $searchableAttributes, $attribs, $rs); if ($index == false) { Loader::library('database_indexed_search'); $index = new IndexedSearch(); } $index->reindexPage($this); $db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 0), array('cID'), false); $cache = PageCache::getLibrary(); $cache->purge($this); } else { $db = Loader::db(); Config::save('DO_PAGE_REINDEX_CHECK', true); $db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 1), array('cID'), false); } }
public function reindex($index = false) { if ($this->isAlias()) { return false; } $db = Loader::db(); Loader::model('attribute/categories/collection'); $attribs = CollectionAttributeKey::getAttributes($this->getCollectionID(), $this->getVersionID(), 'getSearchIndexValue'); $db->Execute('delete from CollectionSearchIndexAttributes where cID = ?', array($this->getCollectionID())); $searchableAttributes = array('cID' => $this->getCollectionID()); $rs = $db->Execute('select * from CollectionSearchIndexAttributes where cID = -1'); AttributeKey::reindex('CollectionSearchIndexAttributes', $searchableAttributes, $attribs, $rs); if ($index == false) { Loader::library('database_indexed_search'); $index = new IndexedSearch(); } $index->reindexPage($this); }