From d56c072a940ef3084e6d47b45f62767c939cf5b8 Mon Sep 17 00:00:00 2001 From: brettp Date: Thu, 3 Jun 2010 14:38:18 +0000 Subject: Moved most of the logic for embed viewing into a single place. Added gallery support (still no CSS). git-svn-id: http://code.elgg.org/elgg/trunk@6339 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/embed/views/default/embed/embed.php | 56 +++++++++++++++++------ mod/embed/views/default/embed/item/gallery.php | 53 +++++++++++++++++++++ mod/embed/views/default/embed/layouts/gallery.php | 10 ++++ mod/embed/views/default/embed/layouts/list.php | 55 ++-------------------- 4 files changed, 109 insertions(+), 65 deletions(-) create mode 100644 mod/embed/views/default/embed/item/gallery.php (limited to 'mod/embed/views') diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php index 09a15d7a0..4a14543d3 100644 --- a/mod/embed/views/default/embed/embed.php +++ b/mod/embed/views/default/embed/embed.php @@ -2,6 +2,9 @@ /** * Embed landing page * + * @todo Yes this is a lot of logic for a view. A good bit of it can be moved + * to the page handler + * * @uses string $vars['sections'] Array of section_id => Section Display Name * @uses string $vars['active_section'] Currently selected section_id */ @@ -38,12 +41,7 @@ if (!$sections) { $tabs_html = elgg_view('navigation/tabs', array('tabs' => $tabs)); $content .= $tabs_html; - $pagination_vars = array( - - ); - - $content .= elgg_view('navigation/pagination', $pagination_vars); - + // build the items and layout. if (array_key_exists($active_section, $sections)) { $section_info = $sections[$active_section]; $layout = isset($section_info['layout']) ? $section_info['layout'] : 'list'; @@ -62,11 +60,39 @@ if (!$sections) { // handles its own pagination $content .= $section_content; } elseif ($embed_info = trigger_plugin_hook('embed_get_items', $active_section, $params, array('items' => array(), 'count' => 0))) { - $params['items'] = $embed_info['items']; + // check if we have an override for this section type. + $view = "embed/$section/item/$layout"; + + if (!elgg_view_exists($view)) { + $view = "embed/item/$layout"; + } + + // pull out some common tests + // embed requires ECML, but until we have plugin deps working + // we need to explicitly check and use a fallback. + if ($ecml_enabled = is_plugin_enabled('ecml')){ + $ecml_valid_keyword = ecml_is_valid_keyword($section); + } else { + $ecml_valid_keyword = FALSE; + } + + $items_content = ''; + foreach ($embed_info['items'] as $item) { + $item_params = array( + 'section' => $section, + 'item' => $item, + 'ecml_enabled' => $ecml_enabled, + 'ecml_keyword' => ($ecml_valid_keyword) ? $section : 'entity' + ); + + $items_content .= elgg_view($view, $item_params); + } + + $params['content'] = $items_content; $params['count'] = $embed_info['count']; - // pagination here. + $content .= elgg_view('navigation/pagination', $params); - $content .= elgg_view("embed/layouts/{$section_info['layout']}", $params); + $content .= elgg_view("embed/layouts/$layout", $params); } else { $content .= elgg_echo('embed:no_section_content'); } @@ -80,8 +106,13 @@ echo $content; - + \ No newline at end of file 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 @@ +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 = "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 = "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 "
getGUID()}\">$listing
"; +echo ""; \ No newline at end of file diff --git a/mod/embed/views/default/embed/layouts/gallery.php b/mod/embed/views/default/embed/layouts/gallery.php index b3d9bbc7f..9a923b8a1 100644 --- a/mod/embed/views/default/embed/layouts/gallery.php +++ b/mod/embed/views/default/embed/layouts/gallery.php @@ -1 +1,11 @@ $section, - 'item' => $item, - 'ecml_enabled' => $ecml_enabled, - 'ecml_keyword' => ($ecml_valid_keyword) ? $section : 'entity' - ); - - $content .= elgg_view($view, $params); -} - -echo $content; - -?> +$content = elgg_get_array_value('content', $vars, ''); - \ No newline at end of file +echo $content; \ No newline at end of file -- cgit v1.2.3