diff options
-rw-r--r-- | mod/embed/README.txt | 6 | ||||
-rw-r--r-- | mod/embed/start.php | 6 | ||||
-rw-r--r-- | mod/embed/views/default/embed/css.php | 4 | ||||
-rw-r--r-- | mod/embed/views/default/embed/embed.php | 32 | ||||
-rw-r--r-- | mod/embed/views/default/embed/item/list.php | 24 | ||||
-rw-r--r-- | mod/embed/views/default/embed/js.php | 38 | ||||
-rw-r--r-- | mod/tinymce/views/default/tinymce/embed_custom_insert_js.php | 2 |
7 files changed, 65 insertions, 47 deletions
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 = '<ul class="elgg-list">'; foreach ($embed_info['items'] as $item) { $item_params = array( 'section' => $active_section, @@ -103,9 +103,10 @@ if (!$sections) { 'icon_size' => elgg_extract('icon_size', $section_info, 'tiny'), ); - $items_content .= elgg_view($view, $item_params); + $items_content .= '<li class="elgg-list-item">' . elgg_view($view, $item_params) . '</li>'; } - + $items_content .= '</ul>'; + $params['content'] = $items_content; $params['count'] = $embed_info['count']; @@ -126,18 +127,25 @@ echo $content; <?php //@todo: JS 1.8: ugly ?> <script type="text/javascript"> $(function() { - var internal_name = '<?php echo addslashes($internal_name); ?>'; + var internal_id = '<?php echo addslashes($internal_id); ?>'; + + // Remove any existing "live" handlers + $('.embed_data').die('click'); + $('.embed_section').die('click'); + $('#facebox .elgg-pagination a').die('click'); // insert embed codes $('.embed_data').live('click', function() { - var embed_code = $(this).data('embed_code') - elggEmbedInsertContent(embed_code, internal_name); + var embed_code = $(this).data('embed_code'); + elggEmbedInsertContent(embed_code, internal_id); + + return false; }); // tabs $('.embed_section').live('click', function() { var section = $(this).attr('id'); - var url = elgg.config.wwwroot + 'embed/embed?active_section=' + section + '&internal_name=' + internal_name; + var url = elgg.config.wwwroot + 'embed/embed?active_section=' + section + '&internal_id=' + internal_id; $('#facebox .body .content').load(url); return false; @@ -149,9 +157,7 @@ $(function() { return false; } - $('.pagination-number').live('click', elggPaginationClick); - $('.pagination-next').live('click', elggPaginationClick); - $('.pagination-previous').live('click', elggPaginationClick); + $('#facebox .elgg-pagination a').live('click', elggPaginationClick); }); </script> 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 = "<img src=\"{$item->getIcon($icon_size)}\" />"; -$info = "<p class='entity-title'>" . htmlentities($title, ENT_QUOTES, 'UTF-8') . "</p>"; -$info .= "<p class='entity-subtext'>" . elgg_view_friendly_time($vars['item']->time_created) . "</p>"; +$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 "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_listing($icon, $info) . '</div>'; +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/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('<p>' + info.message + '</p>'); + // 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('<p>' + info.message + '</p>'); + } } - } - }; - $(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); <?php // This view includes the guts of the function to do the inserting. // Anything that overrides input/longtext with its own editor // needs to supply its own function here that inserts - // content into textAreaName. + // content into textAreaId. // See TinyMCE as an example. // for compatibility diff --git a/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php b/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php index 84f98c405..d5513cef1 100644 --- a/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php +++ b/mod/tinymce/views/default/tinymce/embed_custom_insert_js.php @@ -1,5 +1,5 @@ if (window.tinyMCE) { - var editor = window.tinyMCE.get(textAreaName); + var editor = window.tinyMCE.get(textAreaId); if (editor) { editor.execCommand("mceInsertContent", true, content); |