/** * When an item is saved, index the record if the item is set public, and * clear an existing record if it is set private. * * @param array $args With `record`. */ public function hookAfterSaveItem($args) { SolrSearch_Utils::ensureView(); $item = $args['record']; $excludes = get_db()->getTable('SolrSearchExclude'); $collection = get_collection_for_item($item); if (!is_null($collection) && $excludes->isExcluded($collection)) { return; } $solr = SolrSearch_Helpers_Index::connect(); // Both public and private items will be indexed $doc = SolrSearch_Helpers_Index::itemToDocument($item); $solr->addDocuments(array($doc)); $solr->commit(); $solr->optimize(); }
<?php /** * @package omeka * @subpackage solr-search * @copyright 2012 Rector and Board of Visitors, University of Virginia * @license http://www.apache.org/licenses/LICENSE-2.0.html */ ?> <ul id="section-nav" class="navigation"> <?php SolrSearch_Utils::nav_li($tab, 'server', url('solr-search/server'), __('Server')); SolrSearch_Utils::nav_li($tab, 'collections', url('solr-search/collections'), __('Collections')); SolrSearch_Utils::nav_li($tab, 'fields', url('solr-search/fields'), __('Fields')); SolrSearch_Utils::nav_li($tab, 'results', url('solr-search/results'), __('Results')); SolrSearch_Utils::nav_li($tab, 'reindex', url('solr-search/reindex'), __('Index')); ?> </ul>
/** * When an item is saved, index the record if the item is set public, and * clear an existing record if it is set private. * * @param array $args With `record`. */ public function hookAfterSaveItem($args) { SolrSearch_Utils::ensureView(); $item = $args['record']; $excludes = get_db()->getTable('SolrSearchExclude'); $collection = get_collection_for_item($item); if (!is_null($collection) && $excludes->isExcluded($collection)) { return; } $solr = SolrSearch_Helpers_Index::connect(); // If the item is public, add/update the Solr document. if ($item['public'] == true) { $doc = SolrSearch_Helpers_Index::itemToDocument($item); $solr->addDocuments(array($doc)); $solr->commit(); $solr->optimize(); } else { $solr->deleteById('Item_' . $item['id']); $solr->commit(); $solr->optimize(); } }