/** * Get a link to the collection to which the item belongs. * * The default text displayed for this link will be the name of the collection, * but that can be changed by passing a string argument. * * @package Omeka\Function\View\Navigation * @uses link_to_collection() * @param string|null $text Text for the link. * @param array $props HTML attributes for the <a> tag. * @param string $action 'show' by default. * @return string */ function link_to_collection_for_item($text = null, $props = array(), $action = 'show') { if ($collection = get_collection_for_item()) { return link_to_collection($text, $props, $action, $collection); } return __('No Collection'); }
?> </a> </div> </td> <td> <div id="number-search-cell"> <?php echo __($record->id); ?> </div> </td> <td> <div id="collection-search-cell"> <?php if ($recordType === 'Item' && ($collectionTitle = metadata('item', 'Collection Name'))) { if ($collection = get_collection_for_item()) { echo __(link_to_collection($collectionTitle, array(), 'show', $collection)); } } else { echo 'No Collection'; } ?> </div> </td> <td> <div id="description-search-cell"> <?php if ($recordType === 'Item') { echo __(metadata($record, array('Dublin Core', 'Description'), array('snippet' => 300))); } ?>
<?php if (metadata('item', array('Dublin Core', 'Subject'))) { ?> <div id="item-tags" class="element"><h2>Individuals</h2> <div class="element-text tags"><?php echo metadata('item', array('Dublin Core', 'Subject'), array('delimiter' => '; ')); ?> </div> </div> <?php } ?> <!-- If the item belongs to a collection, the following creates a link to that collection. --> <?php if (get_collection_for_item()) { ?> <div id="collection" class="element"> <h2>Collection</h2> <div class="element-text"><p><?php echo link_to_collection_for_item(); ?> </p></div> </div> <?php } ?> <!-- The following prints a citation for this item. --> <div id="item-citation" class="element"> <h2>Citation</h2>
/** * 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(); }
<div class="title"> <h2><?php echo metadata('item', array('Dublin Core', 'Title')); ?> </h2> <span class="collection"> <!-- Collections: use CollectionTree or fallback to default --> <?php if (metadata('item', 'Collection Name')) { ?> <?php if (plugin_is_active('CollectionTree')) { ?> <?php $collection = get_collection_for_item($item); $collectionTree = get_db()->getTable('CollectionTree')->getCollectionTree($collection->id); echo get_view()->partial('collections/collection-tree-list.php', array('collection_tree' => $collectionTree)); ?> <?php } else { ?> <div class="element-set"> <div id="collection" class="element"> <h3><?php echo __('from'); ?> </h3> <div class="element-text"><?php echo link_to_collection_for_item(); ?>
$file = false; if ($searchText->record_type === 'File') { $file = $record; $fileInfo = pathinfo($file['filename']); $record = get_record_by_id('Item', $record['item_id']); } if (empty($searchText['title'])) { $searchText['title'] = metadata($record, array('Dublin Core', 'Title')); } if ($searchText->record_type == 'ExhibitPage') { $partOf = $record->getExhibit(); if ($partOf) { $partOfTitle = $partOf->title; } } else { $partOf = get_collection_for_item($record); if ($partOf) { $partOfTitle = metadata($partOf, array('Dublin Core', 'Title')); } } ?> <tr> <td> <a href="<?php echo record_url($record, 'show'); ?> "> <?php echo $searchText['title'] ? $searchText['title'] : '[Unknown]'; ?> </a>
/** * Make a conference paper citation * * @param Item $item The item * @param boolean $html Use html formatting * @param boolean $full Full citation * @return string */ function make_paper_citation($item, $html, $full) { global $AUTHOR_ELEMENT, $DATE_ELEMENT, $TITLE_ELEMENT, $BOOK_ELEMENT, $EDITOR_ELEMENT, $PUBLISHER_ELEMENT, $LOCATION_ELEMENT, $PAGES_ELEMENT, $DOI_ELEMENT; $collection = get_collection_for_item($item); $citation = add_element('', safe_metadata($item, $AUTHOR_ELEMENT)); if (!$full) { $citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), $html ? '<em>' : null, $html ? '</em>' : null); } else { $citation = add_element($citation, get_year(safe_metadata($item, $DATE_ELEMENT)), null, null, ' '); $citation = add_element($citation, safe_metadata($item, $TITLE_ELEMENT), '\'', '\''); $conference = safe_metadata($item, $BOOK_ELEMENT); if (!$conference && $collection) { $conference = safe_metadata($collection, $TITLE_ELEMENT); } $citation = add_element($citation, $conference, $html ? __('in') . ' <em>' : null, $html ? '</em>' : null); $editor = safe_metadata($item, $EDITOR_ELEMENT); if (!$editor && $collection) { $editor = safe_metadata($collection, $AUTHOR_ELEMENT); } $citation = add_element($citation, $editor, __('ed. ')); $citation = add_element($citation, safe_metadata($item, $PAGES_ELEMENT)); $publisher = safe_metadata($item, $PUBLISHER_ELEMENT); if (!$publisher && $collection) { $publisher = safe_metadata($collection, $PUBLISHER_ELEMENT); } $citation = add_element($citation, $publisher); $location = safe_metadata($item, $LOCATION_ELEMENT); if (!$location && $collection) { $location = safe_metadata($collection, $LOCATION_ELEMENT); } $citation = add_element($citation, $location); $citation = add_element($citation, safe_metadata($item, $DATE_ELEMENT)); $citation = add_element($citation, safe_metadata($item, $DOI_ELEMENT), $html ? '<span class="citation-url">' : null, $html ? '</span>' : null); } return $citation; }
/** * 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(); } }