Omeka_View_Helper_FileMarkup

Package: View\Helper

class Omeka_View_Helper_FileMarkup

extends Zend_View_Helper_Abstract

View Helper for displaying files through Omeka.

This will determine how to display any given file based on the MIME type (Internet media type) of that file. Individual rendering agents are defined by callbacks that are either contained within this class or defined by plugins. Callbacks defined by plugins will override native class methods if defined for existing MIME types. In order to define a rendering callback that should be in the core of Omeka, define a method in this class and then make sure that it responds to all the correct MIME types by modifying other properties in this class.

constant Omeka_View_Helper_FileMarkup::GENERIC_FALLBACK_IMAGE

Fallback image used when no other fallbacks are appropriate.

property Omeka_View_Helper_FileMarkup::$_callbacks

protected array

Array of MIME types and the callbacks that can process it.

Example: array(‘video/avi’=>’wmv’);

property Omeka_View_Helper_FileMarkup::$_callbackOptions

protected array

The array consists of the default options which are passed to the callback.

property Omeka_View_Helper_FileMarkup::$_fallbackImages

protected array

Images to show when a file has no derivative.

Omeka_View_Helper_FileMarkup::addMimeTypes($fileIdentifiers, $callback, $defaultOptions = array())

Add MIME types and/or file extensions and associated callbacks to the list.

This allows plugins to override/define ways of displaying specific files. The most obvious example of where this would come in handy is to define ways of displaying uncommon files, such as QTVR, or novel ways of displaying more common files, such as using iPaper to display PDFs.

Parameters:
  • $fileIdentifiers (array|string) – Set of MIME types (Internet media types) and/or file extensions that this specific callback will respond to. Accepts the following: <ul> <li>A string containing one MIME type: <code>’application/msword’</code></li> <li>A simple array containing MIME types: <code>array(‘application/msword’, ‘application/doc’)</code></li> <li>A keyed array containing MIME types: <code>array(‘mimeTypes’ => array(‘application/msword’, ‘application/doc’))</code></li> <li>A keyed array containing file extensions: <code>array(‘fileExtensions’ => array(‘doc’, ‘docx’’DOC’, ‘DOCX’))</code></li> <li>A keyed array containing MIME types and file extensions: <code> array( ‘mimeTypes’ => array( ‘application/msword’, ‘application/doc’, ‘application/vnd.openxmlformats-officedocument.wordprocessingml.document’, ), ‘fileExtensions’ => array(‘doc’, ‘docx’, ‘DOC’, ‘DOCX’), ) </code></li> </ul> Note that file extensions are case sensitive.

  • $callback

  • $defaultOptions (array) –

Omeka_View_Helper_FileMarkup::addFallbackImage($mimeType, $image)

Add a fallback image for the given mime type or type family.

Parameters:
  • $mimeType (string) – The mime type this fallback is for, or the mime “prefix” it is for (video, audio, etc.)

  • $image (string) – The name of the image to use, as would be passed to img()

Omeka_View_Helper_FileMarkup::defaultDisplay($file, $options = array())

Default display for MIME types that do not have a valid rendering callback.

This wraps the original filename in a link to download that file, with a class of “download-file”. Any behavior more complex than that should be processed with a valid callback.

Parameters:
  • $file (File) –

  • $options (array) –

Returns:

string HTML

Omeka_View_Helper_FileMarkup::_linkToFile($file, $options, $html = null)

Add a link for the file based on the given set of options.

If the ‘linkToMetadata’ option is true, then link to the file metadata page (files/show). If ‘linkToFile’ is true, link to the original file, and if ‘linkToFile’ is a string, try to link to that specific derivative. Otherwise just return the $html without wrapping in a link.

The attributes for the link will be based off the ‘linkAttributes’ option, which should be an array.

If $html is null, it defaults to original filename of the file.

Parameters:
  • $file (File) –

  • $options (array) –

  • $html (string) –

Returns:

string

Omeka_View_Helper_FileMarkup::video($file, $options = array())

Retrieve valid XHTML for displaying Quicktime video files

Parameters:
  • $file (File) –

  • $options (array) – The set of default options for this includes: width, height, autoplay, controller, loop

Returns:

string

Omeka_View_Helper_FileMarkup::audio($file, $options)

Default display of audio files via <audio> tag.

Parameters:
  • $file (File) –

  • $options (array) – The set of default options for this includes: width, height, autoplay, controller, loop

Returns:

string

Omeka_View_Helper_FileMarkup::_media($type, $file, $options)
Parameters:
  • $type

  • $file

  • $options

Omeka_View_Helper_FileMarkup::icon($file, $options = array())

Default display of an icon to represent a file.

Example usage:

echo files_for_item(array( ‘showFilename’=>false, ‘linkToFile’=>false, ‘linkAttributes’=>array(‘rel’=>’lightbox’), ‘filenameAttributes’=>array(‘class’=>’error’), ‘imgAttributes’=>array(‘id’=>’foobar’), ‘icons’ => array(‘audio/mpeg’=>img(‘audio.gif’))));

Parameters:
  • $file

  • $options (array) – Available options include: ‘showFilename’ => boolean, ‘linkToFile’ => boolean, ‘linkAttributes’ => array, ‘filenameAttributes’ => array (for the filename div), ‘imgAttributes’ => array, ‘icons’ => array.

Returns:

string

Omeka_View_Helper_FileMarkup::derivativeImage($file, $options = array())

Returns valid XHTML markup for displaying an image that has been stored in Omeka.

Parameters:
  • $file (File) – Options for customizing the display of images. Current options include: ‘imageSize’

  • $options

Returns:

string HTML for display

Omeka_View_Helper_FileMarkup::getCallback($file, $options)
Parameters:
  • $file

  • $options

Omeka_View_Helper_FileMarkup::getDefaultOptions($callback)
Parameters:
  • $callback (mixed) –

Returns:

array

Omeka_View_Helper_FileMarkup::getHtml($file, $renderer, $options)

Retrieve the HTML for a given file from the callback.

Parameters:
  • $file (File) –

  • $renderer (callback) – Any valid callback that will display the HTML.

  • $options (array) – Set of options passed to the rendering callback.

Returns:

string HTML for displaying the file.

Omeka_View_Helper_FileMarkup::fileMarkup($file, $props = array(), $wrapperAttributes = array())

Bootstrap for the helper class. This will retrieve the HTML for displaying the file and by default wrap it in a <div class=”item-file”>.

Parameters:
  • $file (File) –

  • $props (array) – Set of options passed by a theme writer to the customize the display of any given callback.

  • $wrapperAttributes (array) –

Returns:

string HTML

Omeka_View_Helper_FileMarkup::image_tag($record, $props, $format)

Return a valid img tag for an image.

Parameters:
  • $record (Omeka_Record_AbstractRecord) –

  • $props (array) – Image tag attributes

  • $format (string) – Derivative image type (thumbnail, etc.)

Returns:

string

Omeka_View_Helper_FileMarkup::_getFallbackImage($file)

Get the name of a fallback image to use for this file.

The fallback used depends on the file’s mime type.

Parameters:
  • $file (File) – The file to get a fallback for.

Returns:

string Name of the image to use.

Omeka_View_Helper_FileMarkup::_getCallbackKey($callback)

Get a string key to represent a given callback.

This key can be used to store and retrieve data about the callback, like default options.

Parameters:
  • $callback (callback) –

Returns:

string