Example #1
0
/**
 * Get an image thumbnail, or dublin core title as fallback. For fedora import items this 
 * returns a thumbnail of the size set in the admin options
 * @package Omeka\Function\View\Item
 * @uses Omeka_View_Helper_FileMarkup::image_tag()
 * @param string $imageType Image size: thumbnail, square thumbnail, fullsize
 * @param array $props HTML attributes for the img tag
 * @param integer $index Which file within the item to use, by order. Default
 *  is the first file.
 * @param Item|null Check for this specific item record (current item if null).
 ************************************************************
 *REVISIONS
 * Ver        Date       Author          Description
 * --------  ----------  --------------  ----------------------
 * 1.0       09/02/2015  mrs175          1. added thumbnail generation for CPH import items
 ************************************************************
 */
function item_image($imageType, $props = array(), $index = 0, $item = null)
{
    if (!$item) {
        $item = get_current_record('item');
    }
    //properly imported fedora item will have an imageID
    $itemTypeElements = $item->getItemTypeElements();
    if (array_key_exists('fedoraImageID', $itemTypeElements) && ($imageIDElementID = $itemTypeElements['fedoraImageID']->id)) {
        return FedoraConnectorPlugin::getThumbnailHTML($imageIDElementID, $item);
    } else {
        if ($item->item_type_id == 1) {
            return '<img id="generic_thumbnail" src="/omeka/files/original/text_thumbnail.png" alt="generic text file thumbnail"/>';
        } else {
            if ($item->Files[0]->mime_type === 'application/pdf' && class_exists('DocsViewerPlugin')) {
                return '<img id="generic_thumbnail" src="/omeka/files/original/pdf_thumbnail.png" alt="generic pdf file thumbnail"/>';
            } else {
                //case it isn't a fedora item
                $imageFile = $item->getFile($index);
                $fileMarkup = new Omeka_View_Helper_FileMarkup();
                return $fileMarkup->image_tag($imageFile, $props, $imageType);
            }
        }
    }
}
 /**
  * Generates the HTML that makes the thumbnails for fedora imported items
  * @param $imageIDElementID  integer the id of the item type element for the fedora image ID
  * @param $item Item the fedora imported item for which a thumbnail sized image is needed
  * @return string HTML img tag containing the link to this fedora item's thumbnail, or either the alt text or an empty string if the image ID can't be found
  */
 public static function getThumbnailHTML($imageIDElementID, $item)
 {
     //find the fedoraImageID (used in the image server URL) by finding the text element that has the
     //same element type ID as the fedoraImageID element type
     foreach ($item->ElementTexts as $elementText) {
         if ($elementText->element_id == $imageIDElementID) {
             if ($fedoraImageID = $elementText->text) {
                 return str_replace('altText', FedoraConnectorPlugin::getAltText($item), str_replace('fedoraImageID', $fedoraImageID, get_option('digitalCaseThumbnailURL')));
             }
         }
     }
     return '';
 }
Example #3
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 cc=80; */
/**
 * @package     omeka
 * @subpackage  fedora-connector
 * @copyright   2012 Rector and Board of Visitors, University of Virginia
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html
 */
if (!defined('FEDORA_DIR')) {
    define('FEDORA_DIR', dirname(__FILE__));
}
// PLUGIN
require_once FEDORA_DIR . '/FedoraConnectorPlugin.php';
// HELPERS
require_once FEDORA_DIR . '/helpers/FedoraConnectorFunctions.php';
require_once FEDORA_DIR . '/helpers/FedoraGateway.php';
// LIBRARIES
require_once FEDORA_DIR . '/libraries/FedoraConnector/Import.php';
require_once FEDORA_DIR . '/libraries/FedoraConnector/Render.php';
require_once FEDORA_DIR . '/libraries/FedoraConnector/Plugins.php';
require_once FEDORA_DIR . '/libraries/FedoraConnector/AbstractImporter.php';
require_once FEDORA_DIR . '/libraries/FedoraConnector/AbstractRenderer.php';
// FORMS
require_once FEDORA_DIR . '/forms/ObjectForm.php';
require_once FEDORA_DIR . '/forms/ServerForm.php';
require_once FEDORA_DIR . '/forms/Validate/isUrl.php';
// Inject the live Fedora adapter.
Zend_Registry::set('gateway', new FedoraGateway());
$fedora = new FedoraConnectorPlugin();
$fedora->setUp();
 /**
  * Output the default HTML format for displaying record metadata.
  * @return string
  ************************************************************
  *REVISIONS
  * Ver        Date       Author          Description
  * --------  ----------  --------------  ----------------------
  * 1.0       09/02/2015  mrs175          1. modified to display fedora import items
  ************************************************************
  */
 protected function _getOutputAsHtml()
 {
     $elementSets = $this->_getElementsBySet();
     $emptyString = html_escape(__($this->_emptyElementString));
     $elementsForDisplay = array();
     //put the text of a plain text item or "story" before its metadata
     if (isset($elementSets['Text Item Type Metadata']) && count($elementSets['Text Item Type Metadata']) == 1) {
         $textElementSet = array($elementSets['Text Item Type Metadata']);
         unset($elementSets['Text Item Type Metadata']);
         $elementSets = array_merge($textElementSet, $elementSets);
     }
     foreach ($elementSets as $setName => $elementsInSet) {
         $setInfo = array();
         foreach ($elementsInSet as $elementName => $element) {
             if ($setName === 'Fedora Image') {
                 //if it is a fedora image the element Texts will be generated by the plugins
                 $elementTexts = array(FedoraConnectorPlugin::getImageHTML($this->_record));
             } else {
                 $elementTexts = $this->_getFormattedElementTexts($this->_record, array($element->set_name, $element->name));
             }
             if (!$this->_elementIsShowable($element, $elementTexts)) {
                 continue;
             }
             $displayInfo = array();
             $displayInfo['element'] = $element;
             if (empty($elementTexts)) {
                 $displayInfo['texts'] = array($emptyString);
             } else {
                 $displayInfo['texts'] = $elementTexts;
             }
             $setInfo[$elementName] = $displayInfo;
         }
         if (!empty($setInfo)) {
             $elementsForDisplay[$setName] = $setInfo;
         }
     }
     // We're done preparing the data for display, so display it.
     return $this->_loadViewPartial(array('elementsForDisplay' => $elementsForDisplay, 'record' => $this->_record, 'showElementSetHeadings' => $this->_showElementSetHeadings));
 }