diff options
author | Brett Profitt <brett.profitt@gmail.com> | 2011-09-29 18:16:03 -0700 |
---|---|---|
committer | Brett Profitt <brett.profitt@gmail.com> | 2011-09-29 18:16:03 -0700 |
commit | bfdb9bb8a87a29038ba1ae25355684ae19678fdd (patch) | |
tree | a074e2d6bfa19c17b284c3950b4555cf584eabe2 /mod/embed | |
parent | 7be23080f34a8f92ca1f8d49c3aa0e6ce3472f4c (diff) | |
parent | a458ae4e0f8e5b19884860fead6e5f901b95eca4 (diff) | |
download | elgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.gz elgg-bfdb9bb8a87a29038ba1ae25355684ae19678fdd.tar.bz2 |
Merge branch 'master' of github.com:brettp/Elgg
Diffstat (limited to 'mod/embed')
-rw-r--r-- | mod/embed/languages/en.php | 2 | ||||
-rw-r--r-- | mod/embed/manifest.xml | 4 | ||||
-rw-r--r-- | mod/embed/start.php | 37 | ||||
-rw-r--r-- | mod/embed/views/default/embed/css.php | 2 | ||||
-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 | 4 | ||||
-rw-r--r-- | mod/embed/views/default/js/embed/inline.php | 26 |
12 files changed, 47 insertions, 265 deletions
diff --git a/mod/embed/languages/en.php b/mod/embed/languages/en.php index f3a49e38b..287d34ca1 100644 --- a/mod/embed/languages/en.php +++ b/mod/embed/languages/en.php @@ -15,6 +15,8 @@ $english = array( // messages 'embed:no_upload_content' => 'No upload content!', 'embed:no_section_content' => 'No items found.', + + 'embed:no_sections' => 'No supported embed plugins found. Ask the site administrator to enabled a plugin with embed support.', ); add_translation("en", $english);
\ No newline at end of file diff --git a/mod/embed/manifest.xml b/mod/embed/manifest.xml index f61d27c23..02c012330 100644 --- a/mod/embed/manifest.xml +++ b/mod/embed/manifest.xml @@ -13,6 +13,10 @@ <type>elgg_version</type> <version>2010030101</version> </requires> + <requires> + <type>plugin</type> + <name>file</name> + </requires> <activate_on_install>true</activate_on_install> <admin_interface>advanced</admin_interface> </plugin_manifest> diff --git a/mod/embed/start.php b/mod/embed/start.php index bdd832b4e..6c26163e9 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -74,13 +74,34 @@ function embed_page_handler($page) { // listing // item // default to embed/listing | item if not found. - // @todo trigger for all right now. If we categorize these later we can trigger - // for certain categories. - $sections = elgg_trigger_plugin_hook('embed_get_sections', 'all', NULL, array()); - $upload_sections = elgg_trigger_plugin_hook('embed_get_upload_sections', 'all', NULL, array()); - - elgg_sort_3d_array_by_value($sections, 'name'); - elgg_sort_3d_array_by_value($upload_sections, 'name'); + + // @todo the menu system is good for registering and sorting, but not great for + // displaying tabs. + // Pulling in the menu manually and passing it through the embed/tabs view. + // We should work on making it easier to use tabs through the menu system, then fix + // this mess. + $menus = get_config('menus'); + $menu = $menus['embed:sections']; + + $sections = array(); + $upload_sections = array(); + + foreach ($menu as $item) { + switch ($item->section) { + case 'upload': + $upload_sections[$item->getName()] = array( + 'name' => $item->getText(), + ); + break; + + default: + $sections[$item->getName()] = array( + 'name' => $item->getText(), + ); + break; + } + } + $active_section = get_input('active_section', ''); $active_section = preg_replace('[\W]', '', $active_section); $internal_id = get_input('internal_id', ''); @@ -97,4 +118,4 @@ function embed_page_handler($page) { // exit because this is in a modal display. exit; -} +}
\ No newline at end of file diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 150dc8733..03373da2b 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -8,7 +8,7 @@ .embed-wrapper { width: 730px; min-height: 400px; - margin: 5px; + margin: 15px; } .embed-wrapper h2 { color: #333333; 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..e9e08f9a0 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,6 @@ elgg.embed.init = function() { * @return void */ elgg.embed.insert = function(event) { - 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 |