diff options
Diffstat (limited to 'mod/embed/views/default/embed/item/gallery.php')
-rw-r--r-- | mod/embed/views/default/embed/item/gallery.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mod/embed/views/default/embed/item/gallery.php b/mod/embed/views/default/embed/item/gallery.php new file mode 100644 index 000000000..ed43ca1c3 --- /dev/null +++ b/mod/embed/views/default/embed/item/gallery.php @@ -0,0 +1,53 @@ +<?php +/** + * Default item view for embed items in gallery display. + * + * Why don't we recycle the view/type/subtype views? + * Because we need to have special JavaScript that fires when you click on + * the icon / title. + * + * @todo Yes this is copy and pasted. Pete needs to theme. I'll DRY it up later. + * + * @uses object $vars['item'] The item to display + * @return string A formatted item + */ + +$item = $vars['item']; +$section = $vars['section']; +$target = $vars['target']; +$ecml_keyword = (isset($vars['ecml_enabled']) && isset($vars['ecml_keyword'])) ? $vars['ecml_keyword'] : NULL; + +// @todo add entity checking. + +// different entity types have different title attribute names. +$title = isset($item->name) ? $item->name : $item->title; +// don't let it be too long +$title = elgg_make_excerpt($title); + +// @todo you can disable plugins that are required by other plugins +// (embed requires ecml) so fallback to a hard-coded check to see if ecml is enabled. +// #grumble +if ($ecml_keyword) { + $embed_code = "[$ecml_keyword guid={$item->getGUID()}]"; +} else { + // fallback to inserting a hard link to the object with its icon + $icon = "<img src=\"{$item->getIcon()}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8'); + + $embed_code = elgg_view('output/url', array( + 'href' => $item->getURL(), + 'title' => $title, + 'text' => $title, + 'encode_text' => FALSE + )); +} + +$icon = "<img src=\"{$item->getIcon('tiny')}\" />"; +$info = htmlentities($title, ENT_QUOTES, 'UTF-8'); + +$listing = elgg_view('entities/gallery_listing', array('icon' => $icon, 'info' => $info)); + +// @todo is this approach better than inline js? +echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">$listing</div>"; +echo "<script type=\"text/javascript\"> + $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . "); +</script>";
\ No newline at end of file |