diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-08-27 18:54:13 -0700 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-08-27 18:54:13 -0700 |
commit | 146c55ddd745be06f6206e70884cb9e430ba6231 (patch) | |
tree | 8277881f60c3d09f1054997caba0bda5983f798d /mod/embed/views | |
parent | 0179e8c68b0827d77c61a31c8c0d6bf4a277c785 (diff) | |
download | elgg-146c55ddd745be06f6206e70884cb9e430ba6231.tar.gz elgg-146c55ddd745be06f6206e70884cb9e430ba6231.tar.bz2 |
Fixes #2911. Embed plugins works again. Added menu for embed sections. This plugin is painfully messy.
Diffstat (limited to 'mod/embed/views')
-rw-r--r-- | mod/embed/views/default/embed/embed.php | 59 | ||||
-rw-r--r-- | mod/embed/views/default/embed/item/gallery.php | 54 | ||||
-rw-r--r-- | mod/embed/views/default/embed/item/list.php | 63 | ||||
-rw-r--r-- | mod/embed/views/default/embed/layouts/gallery.php | 10 | ||||
-rw-r--r-- | mod/embed/views/default/embed/layouts/list.php | 10 | ||||
-rw-r--r-- | mod/embed/views/default/embed/upload/content.php | 41 | ||||
-rw-r--r-- | mod/embed/views/default/js/embed/embed.php | 5 | ||||
-rw-r--r-- | mod/embed/views/default/js/embed/inline.php | 26 |
8 files changed, 12 insertions, 256 deletions
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 @@ -<?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; -$icon_size = $vars['icon_size']; - -// @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); - -// @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($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 = "<img src=\"{$item->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 "<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 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 @@ -<?php -/** - * Default item view for embed items in list 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. - * - * @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']) && $vars['ecml_enabled'] && isset($vars['ecml_keyword'])) ? $vars['ecml_keyword'] : NULL; -$icon_size = $vars['icon_size']; -$owner = $item->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 = "<img src=\"{$item->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 "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_image_block($item_icon, $list_body) . '</div>'; -echo "<script type=\"text/javascript\"> - $('#embed_{$item->getGUID()}').data('embed_code', " . json_encode($embed_code) . "); -</script>";
\ 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 @@ -<?php -/** - * Embed - Gallery items - * - * @uses string $vars['content'] Pre-formatted content. - * - */ -$active_section = elgg_extract('section', $vars, array()); - -echo "<div class='embed_modal_$active_section'>" . elgg_extract('content', $vars, '') . "</div>"; 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 @@ -<?php -/** - * Embed - List items - * - * @uses string $vars['content'] Pre-formatted content. - * - */ -$active_section = elgg_extract('section', $vars, array()); - -echo "<div class='embed_modal_$active_section'>" . elgg_extract('content', $vars, '') . "</div>";
\ 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 @@ -<?php -/** - * Special upload form - */ -$upload_sections = elgg_extract('upload_sections', $vars, array()); -$active_section = get_input('active_upload_section', array_shift(array_keys($upload_sections))); -$active_section = preg_replace('[\W]', '', $active_section); - -$options = array(); - -if ($upload_sections) { - foreach ($upload_sections as $id => $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 "<div class='mbm'>" . elgg_echo('embed:upload_type') . "$input</div>"; - echo "<div class='embed-upload'>"; - echo $upload_content; - echo "</div>"; - -} 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 @@ +//<script> elgg.provide('elgg.embed'); elgg.embed.init = function() { // inserts the embed content into the textarea - $(".embed-wrapper .elgg-item").live('click', elgg.embed.insert); + $(".embed_data").live('click', elgg.embed.insert); // caches the current textarea id $(".embed-control").live('click', function() { @@ -30,7 +31,7 @@ elgg.embed.init = function() { * @return void */ elgg.embed.insert = function(event) { - +console.log("omfg"); var textAreaId = elgg.embed.textAreaId; var content = $(this).data('embed_code'); diff --git a/mod/embed/views/default/js/embed/inline.php b/mod/embed/views/default/js/embed/inline.php deleted file mode 100644 index 0672a68f8..000000000 --- a/mod/embed/views/default/js/embed/inline.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/** - * Inline embed JavaScript for attaching the insert data to list items - * - * @uses $vars['items'] - */ - -foreach ($vars['items'] as $item) { - - // 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); - - $icon = "<img src=\"{$item->getIcon($icon_size)}\" />" . htmlspecialchars($title, ENT_QUOTES, 'UTF-8', false); - - $embed_code = elgg_view('output/url', array( - 'href' => $item->getURL(), - 'title' => $title, - 'text' => $icon, - 'encode_text' => false, - )); - $embed_code = json_encode($embed_code); - - echo "$('#elgg-object-{$item->getGUID()}').data('embed_code', $embed_code);"; -}
\ No newline at end of file |