Browse Source

Merge pull request #457 from nhart/7.x

allow multiple mime types when getting list of viewers for solution packs
pull/485/merge
Jordan Dukart 11 years ago
parent
commit
3dc58252b8
  1. 14
      includes/solution_packs.inc

14
includes/solution_packs.inc

@ -712,9 +712,8 @@ function islandora_viewers_form($variable_id = NULL, $mimetype = NULL, $model =
* given, than any viewer that supports either the give $mimetype or $model will * given, than any viewer that supports either the give $mimetype or $model will
* be listed. * be listed.
* *
* @param string $mimetype * @param array $mimetype
* Specify a mimetype to return only viewers that support this certain * List of mimetypes that the viewer supports.
* mimetype.
* @param string $content_model * @param string $content_model
* Specify a content model to return only viewers that support the content * Specify a content model to return only viewers that support the content
* model. * model.
@ -722,14 +721,19 @@ function islandora_viewers_form($variable_id = NULL, $mimetype = NULL, $model =
* @return array * @return array
* Viewer definitions, or FALSE if none are found. * Viewer definitions, or FALSE if none are found.
*/ */
function islandora_get_viewers($mimetype = NULL, $content_model = NULL) { function islandora_get_viewers($mimetype = array(), $content_model = NULL) {
$viewers = array(); $viewers = array();
$defined_viewers = module_invoke_all('islandora_viewer_info'); $defined_viewers = module_invoke_all('islandora_viewer_info');
if (!is_array($mimetype)) {
$mimetype = array($mimetype);
}
// Filter viewers by MIME type. // Filter viewers by MIME type.
foreach ($defined_viewers as $key => $value) { foreach ($defined_viewers as $key => $value) {
$value['mimetype'] = isset($value['mimetype']) ? $value['mimetype'] : array(); $value['mimetype'] = isset($value['mimetype']) ? $value['mimetype'] : array();
$value['model'] = isset($value['model']) ? $value['model'] : array(); $value['model'] = isset($value['model']) ? $value['model'] : array();
if (in_array($mimetype, $value['mimetype']) OR in_array($content_model, $value['model'])) { if (array_intersect($mimetype, $value['mimetype']) OR in_array($content_model, $value['model'])) {
$viewers[$key] = $value; $viewers[$key] = $value;
} }
} }

Loading…
Cancel
Save