From 146c55ddd745be06f6206e70884cb9e430ba6231 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Sat, 27 Aug 2011 18:54:13 -0700 Subject: Fixes #2911. Embed plugins works again. Added menu for embed sections. This plugin is painfully messy. --- mod/embed/views/default/embed/embed.php | 59 ++++----------------- mod/embed/views/default/embed/item/gallery.php | 54 ------------------- mod/embed/views/default/embed/item/list.php | 63 ----------------------- mod/embed/views/default/embed/layouts/gallery.php | 10 ---- mod/embed/views/default/embed/layouts/list.php | 10 ---- mod/embed/views/default/embed/upload/content.php | 41 --------------- mod/embed/views/default/js/embed/embed.php | 5 +- mod/embed/views/default/js/embed/inline.php | 26 ---------- 8 files changed, 12 insertions(+), 256 deletions(-) delete mode 100644 mod/embed/views/default/embed/item/gallery.php delete mode 100644 mod/embed/views/default/embed/item/list.php delete mode 100644 mod/embed/views/default/embed/layouts/gallery.php delete mode 100644 mod/embed/views/default/embed/layouts/list.php delete mode 100644 mod/embed/views/default/embed/upload/content.php delete mode 100644 mod/embed/views/default/js/embed/inline.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 2d8de1ca4..2bd329690 100644 --- a/mod/embed/views/default/embed/embed.php +++ b/mod/embed/views/default/embed/embed.php @@ -12,7 +12,6 @@ $sections = elgg_extract('sections', $vars, array()); $active_section = elgg_extract('active_section', $vars, array_shift(array_keys($sections)), false); $upload_sections = elgg_extract('upload_sections', $vars, array()); -$internal_id = elgg_extract('internal_id', $vars); if (!$sections) { $content = elgg_echo('embed:no_sections'); @@ -23,57 +22,17 @@ if (!$sections) { $offset = (int)max(0, get_input('offset', 0)); $limit = (int)get_input('limit', 5); - // build the items and layout. - if ($active_section == 'upload' || array_key_exists($active_section, $sections)) { - $section_info = $sections[$active_section]; - $layout = isset($section_info['layout']) ? $section_info['layout'] : 'list'; - - $params = array( - 'offset' => $offset, - 'limit' => $limit, - 'section' => $active_section, - 'upload_sections' => $upload_sections, - 'internal_id' => $internal_id - ); - - // allow full override for this section - // check for standard hook - if ($section_content = elgg_view("embed/$active_section/content", $params)) { - // handles its own pagination - $content .= $section_content; - } else { - // see if anyone has any items to display for the active section - $result = array('items' => array(), 'count' => 0); - $embed_info = elgg_trigger_plugin_hook('embed_get_items', $active_section, $params, $result); + // find the view to display + // @todo make it so you don't have to manually create views for each page + $view = "embed/$active_section/content"; + + $section_content = elgg_view($view, $vars); - // do we use default view or has someone defined "embed/$active_section/item/$layout" - $view = "embed/$active_section/item/$layout"; - if (!elgg_view_exists($view)) { - $view = "embed/item/$layout"; - } - - if (!isset($embed_info['items']) || !is_array($embed_info['items']) || !count($embed_info['items'])) { - $content .= elgg_echo('embed:no_section_content'); - } else { - - elgg_push_context('widgets'); - $content .= elgg_view_entity_list($embed_info['items'], array( - 'full_view' => false, - 'count' => $embed_info['count'], - 'pagination' => true, - 'position' => 'before', - 'offset' => $offset, - 'limit' => $limit, - )); - elgg_pop_context(); - - $js = elgg_view('js/embed/inline', array( - 'items' => $embed_info['items'], - )); - } - } + // build the items and layout. + if ($section_content) { + $content .= $section_content; } else { - $content .= elgg_echo('embed:invalid_section'); + $content .= elgg_echo('embed:no_section_content'); } } diff --git a/mod/embed/views/default/embed/item/gallery.php b/mod/embed/views/default/embed/item/gallery.php deleted file mode 100644 index daee8ee94..000000000 --- a/mod/embed/views/default/embed/item/gallery.php +++ /dev/null @@ -1,54 +0,0 @@ -name) ? $item->name : $item->title; -// don't let it be too long -$title = elgg_get_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($icon_size)}\" />" . 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($icon_size)}\" />"; -$info = htmlentities($title, ENT_QUOTES, 'UTF-8'); - -$listing = elgg_view('entities/gallery_listing', array('icon' => $icon, 'info' => $info)); - -// @todo JS 1.8: no -echo "
getGUID()}\">$listing
"; -echo ""; \ No newline at end of file diff --git a/mod/embed/views/default/embed/item/list.php b/mod/embed/views/default/embed/item/list.php deleted file mode 100644 index 89a2ffb63..000000000 --- a/mod/embed/views/default/embed/item/list.php +++ /dev/null @@ -1,63 +0,0 @@ -getOwnerEntity(); - -// @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_get_excerpt($title); - -$author_text = elgg_echo('byline', array($owner->name)); -$date = elgg_view_friendly_time($item->time_created); - -$subtitle = "$author_text $date"; - -// @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($icon_size)}\" />" . htmlentities($title, ENT_QUOTES, 'UTF-8'); - - $embed_code = elgg_view('output/url', array( - 'href' => $item->getURL(), - 'title' => $title, - 'text' => $icon, - 'encode_text' => FALSE - )); -} - -$item_icon = elgg_view_entity_icon($item, $icon_size); - -$params = array( - 'title' => $title, - 'entity' => $item, - 'subtitle' => $subtitle, - 'tags' => FALSE, -); -$list_body = elgg_view('object/elements/summary', $params); - -// @todo JS 1.8: is this approach better than inline js? -echo "
getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '
'; -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 deleted file mode 100644 index 70b6d33a5..000000000 --- a/mod/embed/views/default/embed/layouts/gallery.php +++ /dev/null @@ -1,10 +0,0 @@ -" . elgg_extract('content', $vars, '') . ""; diff --git a/mod/embed/views/default/embed/layouts/list.php b/mod/embed/views/default/embed/layouts/list.php deleted file mode 100644 index 5d62e572b..000000000 --- a/mod/embed/views/default/embed/layouts/list.php +++ /dev/null @@ -1,10 +0,0 @@ -" . elgg_extract('content', $vars, '') . ""; \ No newline at end of file diff --git a/mod/embed/views/default/embed/upload/content.php b/mod/embed/views/default/embed/upload/content.php deleted file mode 100644 index 8bedf5ad1..000000000 --- a/mod/embed/views/default/embed/upload/content.php +++ /dev/null @@ -1,41 +0,0 @@ - $info) { - $options[$id] = $info['name']; - } - - $input = elgg_view('input/dropdown', array( - 'name' => 'download_section', - 'options_values' => $options, - 'id' => 'embed_upload', - 'value' => $active_section - )); - - // hack this in for now as we clean up this mess - $form_vars = array( - 'enctype' => 'multipart/form-data', - 'class' => 'elgg-form', - ); - $upload_content = elgg_view_form('file/upload', $form_vars); -/* - if (!$upload_content = elgg_view($upload_sections[$active_section]['view'])) { - $upload_content = elgg_echo('embed:no_upload_content'); - } -*/ - echo "
" . elgg_echo('embed:upload_type') . "$input
"; - echo "
"; - echo $upload_content; - echo "
"; - -} else { - echo elgg_echo('embed:no_upload_sections'); -} diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php index ea92ba1fd..5c15cd95a 100644 --- a/mod/embed/views/default/js/embed/embed.php +++ b/mod/embed/views/default/js/embed/embed.php @@ -1,9 +1,10 @@ +//