コード例 #1
0
ファイル: index_search.php プロジェクト: ceko/concrete5-1
 public function run()
 {
     Cache::disableAll();
     $is = new IndexedSearch();
     if ($_GET['force'] == 1) {
         $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.') . ' ' . t2('%d page required reindexing.', '%d pages required reindexing.', $result->count, $result->count);
         }
     }
 }
コード例 #2
0
 public function view($updated = false)
 {
     if ($this->post('reindex')) {
         IndexedSearch::clearSearchIndex();
         $this->redirect('/dashboard/system/seo/searchindex', '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('concrete.misc.search_index_area_list', serialize($areas));
                 Config::save('concrete.misc.search_index_area_method', Loader::helper('security')->sanitizeString($this->post('SEARCH_INDEX_AREA_METHOD')));
                 $this->redirect('/dashboard/system/seo/searchindex', 'updated');
             } else {
                 $this->set('error', array($this->token->getErrorMessage()));
             }
         }
         $areas = Area::getHandleList();
         $selectedAreas = array();
         $this->set('areas', $areas);
         $this->set('selectedAreas', IndexedSearch::getSavedSearchableAreas());
     }
 }
コード例 #3
0
ファイル: Collection.php プロジェクト: ceko/concrete5-1
 public function reindex($index = false, $actuallyDoReindex = true)
 {
     if ($this->isAlias() && !$this->isExternalLink()) {
         return false;
     }
     if ($actuallyDoReindex || Config::get('concrete.page.search.always_reindex') == true) {
         $db = Loader::db();
         $attribs = CollectionAttributeKey::getAttributes($this->getCollectionID(), $this->getVersionID(), 'getSearchIndexValue');
         $db->Execute('delete from CollectionSearchIndexAttributes where cID = ?', array($this->getCollectionID()));
         $searchableAttributes = array('cID' => $this->getCollectionID());
         $key = new Key();
         $key->reindex('CollectionSearchIndexAttributes', $searchableAttributes, $attribs);
         if ($index == false) {
             $index = new IndexedSearch();
         }
         $index->reindexPage($this);
         $db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 0), array('cID'), false);
         $cache = PageCache::getLibrary();
         $cache->purge($this);
         // we check to see if this page is referenced in any gatherings
         $c = Page::getByID($this->getCollectionID(), $this->getVersionID());
         $items = PageGatheringItem::getListByItem($c);
         foreach ($items as $it) {
             $it->deleteFeatureAssignments();
             $it->assignFeatureAssignments($c);
         }
     } else {
         $db = Loader::db();
         Config::save('concrete.misc.do_page_reindex_check', true);
         $db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 1), array('cID'), false);
     }
 }
コード例 #4
0
	<form method="post" id="ccm-search-index-manage" action="<?php 
echo $view->action('');
?>
">
			<?php 
echo $this->controller->token->output('update_search_index');
?>
			<fieldset>
			<label class="control-label"><?php 
echo t('Indexing Method');
?>
</label>
			<div class="form-group">
			<?php 
$methods = array('whitelist' => t('Whitelist - only use the selected areas below when searching content.'), 'blacklist' => t('Blacklist - skip the selected areas below when searching content.'));
echo $form->select('SEARCH_INDEX_AREA_METHOD', $methods, IndexedSearch::getSearchableAreaAction(), array('class' => 'xlarge'));
?>
			</div>
			</fieldset>
			<fieldset>
				<label class="control-label"><?php 
echo t('Areas');
?>
</label>
			<div class="form-group">

			<?php 
foreach ($areas as $a) {
    ?>
                <div class="checkbox">
				    <label><?php 
コード例 #5
0
 public function reindex($index = false, $actuallyDoReindex = true)
 {
     if ($this->isAlias() && !$this->isExternalLink()) {
         return false;
     }
     if ($actuallyDoReindex || Config::get('concrete.page.search.always_reindex') == true) {
         // Retrieve the attribute values for the current page
         $category = \Core::make('Concrete\\Core\\Attribute\\Category\\PageCategory');
         $indexer = $category->getSearchIndexer();
         $values = $category->getAttributeValues($this);
         foreach ($values as $value) {
             $indexer->indexEntry($category, $value, $this);
         }
         if ($index == false) {
             $index = new IndexedSearch();
         }
         $index->reindexPage($this);
         $db = \Database::connection();
         $db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 0), array('cID'), false);
         $cache = PageCache::getLibrary();
         $cache->purge($this);
         // we check to see if this page is referenced in any gatherings
         $c = Page::getByID($this->getCollectionID(), $this->getVersionID());
         $items = PageGatheringItem::getListByItem($c);
         foreach ($items as $it) {
             $it->deleteFeatureAssignments();
             $it->assignFeatureAssignments($c);
         }
     } else {
         $db = Loader::db();
         Config::save('concrete.misc.do_page_reindex_check', true);
         $db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 1), array('cID'), false);
     }
 }