From 826c37f10cf78859756f246938031b755803d7a7 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 3 Jun 2011 02:09:21 +0000 Subject: Refs #3360 #2911 applying ashleyward's patch for embed plugin - thanks! git-svn-id: http://code.elgg.org/elgg/trunk@9135 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/embed/README.txt | 6 ++--- mod/embed/start.php | 6 ++--- mod/embed/views/default/embed/css.php | 4 --- mod/embed/views/default/embed/embed.php | 32 ++++++++++++++---------- mod/embed/views/default/embed/item/list.php | 24 +++++++++++++----- mod/embed/views/default/embed/js.php | 38 ++++++++++++++++------------- 6 files changed, 64 insertions(+), 46 deletions(-) (limited to 'mod/embed') diff --git a/mod/embed/README.txt b/mod/embed/README.txt index 98948da3f..33c9fff65 100644 --- a/mod/embed/README.txt +++ b/mod/embed/README.txt @@ -171,10 +171,10 @@ CONTENTS: an onClick event via Javascript. Embed provides a helper function for this: - elggEmbedInsertContent(content, textAreaName) + elggEmbedInsertContent(content, textAreaId) Content is the pre-formatted content to insert into the text area, - and textAreaName is the name of the text area. This name is + and textAreaId is the name of the text area. This name is sent via GET as 'internal_name.' @@ -189,7 +189,7 @@ CONTENTS: content into the specific text area. Variables available within this view are: str content The content to insert. - str textAreaName The name of the textarea to receive the content. + str textAreaId The name of the textarea to receive the content. Note: Extend this view; don't override it. It is important to correctly extend this view for compatibility across multiple plugins and textarea diff --git a/mod/embed/start.php b/mod/embed/start.php index 5efd5c8c5..f6f49a53f 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -34,7 +34,7 @@ function embed_longtext_menu($hook, $type, $items, $vars) { $items[] = ElggMenuItem::factory(array( 'name' => 'embed', - 'href' => "embed?{$active_section}internal_name={$vars['name']}", + 'href' => "embed?{$active_section}internal_id={$vars['id']}", 'text' => elgg_echo('media:insert'), 'rel' => 'facebox', 'link_class' => 'elgg-longtext-control', @@ -73,13 +73,13 @@ function embed_page_handler($page) { elgg_sort_3d_array_by_value($sections, 'name'); elgg_sort_3d_array_by_value($upload_sections, 'name'); $active_section = get_input('active_section', NULL); - $internal_name = get_input('internal_name', NULL); + $internal_id = get_input('internal_id', NULL); echo elgg_view('embed/embed', array( 'sections' => $sections, 'active_section' => $active_section, 'upload_sections' => $upload_sections, - 'internal_name' => $internal_name + 'internal_id' => $internal_id )); break; } diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 736c6ae44..44491846b 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -89,9 +89,6 @@ .embed_data .elgg-image-block { border-bottom:none; } -.embed_data:last-child { - border-bottom:1px dotted #CCC; -} .embed_modal_videolist .elgg-image img { width:75px; height:auto; @@ -111,7 +108,6 @@ width:auto; margin-top:15px; margin-left:15px; - float:left; } .embed_data .elgg-image-block { cursor:pointer; diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php index 06d3f48f1..eeeb1d244 100644 --- a/mod/embed/views/default/embed/embed.php +++ b/mod/embed/views/default/embed/embed.php @@ -12,7 +12,7 @@ $sections = elgg_extract('sections', $vars, array()); $active_section = elgg_extract('active_section', $vars, array_shift(array_keys($sections))); $upload_sections = elgg_extract('upload_sections', $vars, array()); -$internal_name = elgg_extract('internal_name', $vars); +$internal_id = elgg_extract('internal_id', $vars); if (!$sections) { $content = elgg_echo('embed:no_sections'); @@ -65,7 +65,7 @@ if (!$sections) { 'limit' => $limit, 'section' => $active_section, 'upload_sections' => $upload_sections, - 'internal_name' => $internal_name + 'internal_id' => $internal_id ); // allow full override for this section @@ -92,8 +92,8 @@ if (!$sections) { } else { $ecml_valid_keyword = FALSE; } - - $items_content = ''; + + $items_content = ''; + $params['content'] = $items_content; $params['count'] = $embed_info['count']; @@ -126,18 +127,25 @@ echo $content; diff --git a/mod/embed/views/default/embed/item/list.php b/mod/embed/views/default/embed/item/list.php index c5c604854..232f0558b 100644 --- a/mod/embed/views/default/embed/item/list.php +++ b/mod/embed/views/default/embed/item/list.php @@ -13,8 +13,9 @@ $item = $vars['item']; $section = $vars['section']; $target = $vars['target']; -$ecml_keyword = (isset($vars['ecml_enabled']) && isset($vars['ecml_keyword'])) ? $vars['ecml_keyword'] : NULL; +$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. @@ -23,6 +24,11 @@ $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 @@ -35,17 +41,23 @@ if ($ecml_keyword) { $embed_code = elgg_view('output/url', array( 'href' => $item->getURL(), 'title' => $title, - 'text' => $title, + 'text' => $icon, 'encode_text' => FALSE )); } -$icon = "getIcon($icon_size)}\" />"; -$info = "

" . htmlentities($title, ENT_QUOTES, 'UTF-8') . "

"; -$info .= "

" . elgg_view_friendly_time($vars['item']->time_created) . "

"; +$item_icon = elgg_view_entity_icon($item, $icon_size); + +$params = array( + 'title' => $title, + 'entity' => $item, + 'subtitle' => $subtitle, + 'tags' => FALSE, +); +$list_body = elgg_view('page/components/summary', $params); // @todo JS 1.8: is this approach better than inline js? -echo "
getGUID()}\">" . elgg_view_listing($icon, $info) . '
'; +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/js.php b/mod/embed/views/default/embed/js.php index f80d7367d..a0a2e8ff5 100644 --- a/mod/embed/views/default/embed/js.php +++ b/mod/embed/views/default/embed/js.php @@ -9,35 +9,39 @@ $(function() { $('a[rel*=facebox]').facebox(); - // fire off the ajax upload - $('#file_embed_upload').submit(function() { - var options = { - success: function(data) { - var info = jQuery.parseJSON(data); - - if (info.status == 'success') { - $('.popup .content').load(elgg.get_site_url() + 'embed/embed?active_section=file'); - } else { - $('.popup .content').find('form').prepend('

' + info.message + '

'); + // Only apply the .live binding after facebox has been displayed + $(document).bind('afterReveal.facebox', function() { + + // fire off the ajax upload + $('#file_embed_upload').live('submit', function() { + var options = { + success: function(data) { + var info = jQuery.parseJSON(data); + + if (info.status == 'success') { + $('.popup .content').load(elgg.get_site_url() + 'embed/embed?active_section=file'); + } else { + $('.popup .content').find('form').prepend('

' + info.message + '

'); + } } - } - }; - $(this).ajaxSubmit(options); - return false; + }; + $(this).ajaxSubmit(options); + return false; + }); }); }); -function elggEmbedInsertContent(content, textAreaName) { +function elggEmbedInsertContent(content, textAreaId) { content = ' ' + content + ' '; // default input. // if this doesn't match anything it won't add anything. - $('textarea[name=' + textAreaName + ']').val($('textarea[name=' + textAreaName + ']').val() + ' ' + content); + $('#' + textAreaId).val($('#' + textAreaId).val() + ' ' + content);