diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-01 22:33:58 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-06-01 22:33:58 +0000 |
commit | 60fd7ad6ce1c2fbd140edf1a6185649e47735bbc (patch) | |
tree | 855de166802e76b0a0f7eb1865381c774eb941a4 /mod | |
parent | 14ef2df751f2e507751d76505d978cf77027b545 (diff) | |
download | elgg-60fd7ad6ce1c2fbd140edf1a6185649e47735bbc.tar.gz elgg-60fd7ad6ce1c2fbd140edf1a6185649e47735bbc.tar.bz2 |
First pass at a loosely couple embed plugin using ECML.
git-svn-id: http://code.elgg.org/elgg/trunk@6315 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod')
-rw-r--r-- | mod/embed/README.txt | 3 | ||||
-rw-r--r-- | mod/embed/embed.php | 62 | ||||
-rw-r--r-- | mod/embed/manifest.xml | 2 | ||||
-rw-r--r-- | mod/embed/start.php | 75 | ||||
-rw-r--r-- | mod/embed/views/default/embed/addcontentjs.php | 4 | ||||
-rw-r--r-- | mod/embed/views/default/embed/embed.php | 104 | ||||
-rw-r--r-- | mod/embed/views/default/embed/item/list.php | 49 | ||||
-rw-r--r-- | mod/embed/views/default/embed/js.php | 528 | ||||
-rw-r--r-- | mod/embed/views/default/embed/layouts/gallery.php | 1 | ||||
-rw-r--r-- | mod/embed/views/default/embed/layouts/list.php | 60 | ||||
-rw-r--r-- | mod/embed/views/default/embed/link.php | 5 | ||||
-rw-r--r-- | mod/embed/views/default/embed/media.php | 28 | ||||
-rw-r--r-- | mod/embed/views/default/embed/upload.php | 37 |
13 files changed, 600 insertions, 358 deletions
diff --git a/mod/embed/README.txt b/mod/embed/README.txt index 17f867d7a..f81d5b14a 100644 --- a/mod/embed/README.txt +++ b/mod/embed/README.txt @@ -6,5 +6,4 @@ http://www.gnu.org/licenses/old-licenses/gpl-2.0.html The embed plugin requires Elgg 1.5 (or prior to the Elgg 1.5 release, Elgg revision 2634 or above) and the file plugin. -It makes use of the jQuery form plugin, available at: -http://malsup.com/jquery/form/
\ No newline at end of file +To insert into the active editor, use elggEmbedInsert(html).
\ No newline at end of file diff --git a/mod/embed/embed.php b/mod/embed/embed.php index 358547491..09b3ac29b 100644 --- a/mod/embed/embed.php +++ b/mod/embed/embed.php @@ -1,37 +1,35 @@ <?php // This page can only be run from within the Elgg framework - if (!is_callable('elgg_view')) exit; - +if (!is_callable('elgg_view')) exit; + // Get the name of the form field we need to inject into - $internalname = get_input('internalname'); - - if (!isloggedin()) exit; - - global $SESSION; - - $offset = (int) get_input('offset',0); - $simpletype = get_input('simpletype'); - $entity_types = array('object' => array('file')); +$internalname = get_input('internalname'); - if (empty($simpletype)) { - $count = elgg_get_entities(array('type' => 'object', 'subtype' => 'file', 'owner_guid' => $SESSION['user']->guid, 'count' => TRUE)); - $entities = elgg_get_entities(array('type' => 'object', 'subtype' => 'file', 'owner_guid' => $SESSION['user']->guid, 'limit' => 6, 'offset' => $offset)); - } else { - $count = elgg_get_entities_from_metadata(array('metadata_name' => 'simpletype', 'metadata_value' => $simpletype, 'types' => 'object', 'subtypes' => 'file', 'owner_guid' => $SESSION['user']->guid, 'limit' => 6, 'offset' => $offset, 'count' => TRUE)); - $entities = elgg_get_entities_from_metadata(array('metadata_name' => 'simpletype', 'metadata_value' => $simpletype, 'types' => 'object', 'subtypes' => 'file', 'owner_guid' => $SESSION['user']->guid, 'limit' => 6, 'offset' => $offset)); - } - - $types = get_tags(0,10,'simpletype','object','file',$SESSION['user']->guid); - -// Echo the embed view - echo elgg_view('embed/media', array( - 'entities' => $entities, - 'internalname' => $internalname, - 'offset' => $offset, - 'count' => $count, - 'simpletype' => $simpletype, - 'limit' => 6, - 'simpletypes' => $types, - )); +if (!isloggedin()) exit; + +global $SESSION; + +$offset = (int) get_input('offset',0); +$simpletype = get_input('simpletype'); +$entity_types = array('object' => array('file')); -?>
\ No newline at end of file +if (empty($simpletype)) { + $count = elgg_get_entities(array('type' => 'object', 'subtype' => 'file', 'owner_guid' => $SESSION['user']->guid, 'count' => TRUE)); + $entities = elgg_get_entities(array('type' => 'object', 'subtype' => 'file', 'owner_guid' => $SESSION['user']->guid, 'limit' => 6, 'offset' => $offset)); +} else { + $count = elgg_get_entities_from_metadata(array('metadata_name' => 'simpletype', 'metadata_value' => $simpletype, 'types' => 'object', 'subtypes' => 'file', 'owner_guid' => $SESSION['user']->guid, 'limit' => 6, 'offset' => $offset, 'count' => TRUE)); + $entities = elgg_get_entities_from_metadata(array('metadata_name' => 'simpletype', 'metadata_value' => $simpletype, 'types' => 'object', 'subtypes' => 'file', 'owner_guid' => $SESSION['user']->guid, 'limit' => 6, 'offset' => $offset)); +} + +$types = get_tags(0, 10, 'simpletype', 'object', 'file', $SESSION['user']->guid); + +// Echo the embed view +echo elgg_view('embed/media', array( + 'entities' => $entities, + 'internalname' => $internalname, + 'offset' => $offset, + 'count' => $count, + 'simpletype' => $simpletype, + 'limit' => 6, + 'simpletypes' => $types, + )); diff --git a/mod/embed/manifest.xml b/mod/embed/manifest.xml index f0f82a699..f54de1fa3 100644 --- a/mod/embed/manifest.xml +++ b/mod/embed/manifest.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <plugin_manifest> <field key="author" value="Curverider" /> - <field key="version" value="1.7" /> + <field key="version" value="1.8" /> <field key="description" value="Allows users to easily upload and embed media into text areas." /> <field key="website" value="http://www.elgg.org/" /> <field key="copyright" value="(C) Curverider 2009-2010" /> diff --git a/mod/embed/start.php b/mod/embed/start.php index f98c21245..eb6f6d4a6 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -1,7 +1,7 @@ <?php /** * Elgg media embed plugin - * + * * @package ElggEmbed * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider Ltd <info@elgg.com> @@ -13,37 +13,54 @@ * Init function * */ - function embed_init() { - - // Extend useful views with stuff we need for our embed modal - elgg_extend_view('css','embed/css'); - elgg_extend_view('js/initialise_elgg','embed/js'); - elgg_extend_view('metatags','embed/metatags'); - elgg_extend_view('input/longtext','embed/link',1); - - // Page handler for the modal media embed - register_page_handler('embed','embed_page_handler'); - - } - +function embed_init() { + elgg_extend_view('css', 'embed/css'); + elgg_extend_view('js/initialise_elgg', 'embed/js'); + elgg_extend_view('metatags', 'embed/metatags'); + elgg_extend_view('input/longtext', 'embed/link', 1); + + // Page handler for the modal media embed + register_page_handler('embed', 'embed_page_handler'); +} + /** - * Runs the 'embed' script + * Serves pages for upload and embed. * + * @param $page */ - function embed_page_handler($page) { - - switch($page[0]) { - case 'upload': require_once(dirname(__FILE__) . '/upload.php'); - exit; - break; - default: require_once(dirname(__FILE__) . '/embed.php'); - exit; - break; - } - +function embed_page_handler($page) { + if (!isset($page[0])) { + $page[0] = 'embed'; + } + + switch($page[0]) { + case 'upload': + echo elgg_view('embed/upload'); + + break; + + case 'embed': + default: + // trigger hook to get section tabs + // use views for embed/section/ + // 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 = trigger_plugin_hook('embed_get_sections', 'all', NULL, array()); + asort($sections, SORT_LOCALE_STRING); + $active_section = get_input('active_section', NULL); + + echo elgg_view('embed/embed', array( + 'sections' => $sections, + 'active_section' => $active_section + )); + + break; } -// Register the init action - register_elgg_event_handler('init','system','embed_init',10); + exit; +} -?> +register_elgg_event_handler('init', 'system', 'embed_init');
\ No newline at end of file diff --git a/mod/embed/views/default/embed/addcontentjs.php b/mod/embed/views/default/embed/addcontentjs.php index ee3678b89..f5533c22e 100644 --- a/mod/embed/views/default/embed/addcontentjs.php +++ b/mod/embed/views/default/embed/addcontentjs.php @@ -1,4 +1,2 @@ - var entity; - $('textarea[name='+entityname+']').val($('textarea[name='+entityname+']').val() + ' ' + content); - + $('textarea[name=' + textAreaName + ']').val($('textarea[name=' + textAreaName + ']').val() + ' ' + content);
\ No newline at end of file diff --git a/mod/embed/views/default/embed/embed.php b/mod/embed/views/default/embed/embed.php new file mode 100644 index 000000000..7815c1222 --- /dev/null +++ b/mod/embed/views/default/embed/embed.php @@ -0,0 +1,104 @@ +<?php +/** + * Embed landing page + * + * @uses string $vars['sections'] Array of section_id => Section Display Name + * @uses string $vars['active_section'] Currently selected section_id + */ + +$sections = (isset($vars['sections'])) ? $vars['sections'] : array(); +$active_section = (isset($vars['active_section'])) ? $vars['active_section'] : array_shift(array_keys($sections)); + +if (!$sections) { + $content = elgg_echo('embed:no_sections'); +} else { + $offset = max(0, get_input('offset', 0)); + $limit = get_input('limit', 10); + + $content = elgg_view_title(elgg_echo('embed:embed')); + + // prepare tabbed menu + $tabs = array(); + foreach ($sections as $section_id => $section_info) { + $tab = array( + 'title' => $section_info['name'], + 'url' => '#', + 'url_class' => 'embed_section', + // abusing the js attribute. + 'url_js' => "id=\"$section_id\"" + ); + + if ($section_id == $active_section) { + $tab['selected'] = TRUE; + } + $tabs[] = $tab; + } + + $tabs_html = elgg_view('navigation/tabs', array('tabs' => $tabs)); + $content .= $tabs_html; + + $pagination_vars = array( + + ); + + $content .= elgg_view('navigation/pagination', $pagination_vars); + + if (array_key_exists($active_section, $sections)) { + $section_info = $sections[$active_section]; + $layout = isset($section_info['layout']) ? $section_info['layout'] : 'list'; + + $params = array( + //'type' => $type, + //'subtype' => $subtype, + 'offset' => $offset, + 'limit' => $limit, + 'section' => $active_section + ); + + // 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; + } elseif ($embed_info = trigger_plugin_hook('embed_get_items', $active_section, $params, array('items' => array(), 'count' => 0))) { + $params['items'] = $embed_info['items']; + $params['count'] = $embed_info['count']; + // pagination here. + $content .= elgg_view('navigation/pagination', $params); + $content .= elgg_view("embed/layouts/{$section_info['layout']}", $params); + } else { + $content .= elgg_echo('embed:no_section_content'); + } + } else { + $content .= elgg_echo('embed:invalid_section'); + } + +} +echo $content; +?> + +<script type="text/javascript"> +$(document).ready(function() { + + // insert embed codes + $('.embed_section').click(function() { + var section = $(this).attr('id'); + var url = '<?php echo $vars['url']; ?>pg/embed/embed?active_section=' + section; + $('#facebox .body .content').load(url); + + return false; + }); + + // handle pagination + function elggPaginationClick() { + $('#facebox .body .content').load($(this).attr('href')); + return false; + } + + $('.pagination_number').click(elggPaginationClick); + $('.pagination_next').click(elggPaginationClick); + $('.pagination_previous').click(elggPaginationClick); +}); + +</script> + diff --git a/mod/embed/views/default/embed/item/list.php b/mod/embed/views/default/embed/item/list.php new file mode 100644 index 000000000..259419df4 --- /dev/null +++ b/mod/embed/views/default/embed/item/list.php @@ -0,0 +1,49 @@ +<?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']) && isset($vars['ecml_keyword'])) ? $vars['ecml_keyword'] : NULL; + +// @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_make_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()}\" />" . 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('tiny')}\" />"; +$info = htmlentities($title, ENT_QUOTES, 'UTF-8'); + +// @todo is this approach better than inline js? +echo "<div class=\"embed_data\" id=\"embed_{$item->getGUID()}\">" . elgg_view_listing($icon, $info) . '</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 71120e68f..c98fe63da 100644 --- a/mod/embed/views/default/embed/js.php +++ b/mod/embed/views/default/embed/js.php @@ -1,11 +1,21 @@ +<?php +/** + * JS interface for inserting content into the active editor. + */ - function elggUpdateContent(content, entityname) { - content = ' ' + content + ' '; - <?php - echo elgg_view('embed/addcontentjs'); - ?> - $.facebox.close(); - } +?> +function elggEmbedInsertContent(content, textAreaName) { + content = ' ' + 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. + // See TinyMCE as an example. + echo elgg_view('embed/addcontentjs'); + ?> + $.facebox.close(); +} /* @@ -21,9 +31,9 @@ * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ] * * Usage: - * + * * jQuery(document).ready(function() { - * jQuery('a[rel*=facebox]').facebox() + * jQuery('a[rel*=facebox]').facebox() * }) * * <a href="#terms" rel="facebox">Terms</a> @@ -37,12 +47,12 @@ * * * You can also use it programmatically: - * + * * jQuery.facebox('some html') * * The above will open a facebox with "some html" as the content. - * - * jQuery.facebox(function($) { + * + * jQuery.facebox(function($) { * $.get('blah.html', function(data) { $.facebox(data) }) * }) * @@ -50,7 +60,7 @@ * allowing for a better ajaxy experience. * * The facebox function can also display an ajax page or image: - * + * * jQuery.facebox({ ajax: 'remote.html' }) * jQuery.facebox({ image: 'dude.jpg' }) * @@ -71,305 +81,305 @@ * */ (function($) { - $.facebox = function(data, klass) { - $.facebox.loading() +$.facebox = function(data, klass) { + $.facebox.loading() - if (data.ajax) fillFaceboxFromAjax(data.ajax) - else if (data.image) fillFaceboxFromImage(data.image) - else if (data.div) fillFaceboxFromHref(data.div) - else if ($.isFunction(data)) data.call($) - else $.facebox.reveal(data, klass) - } + if (data.ajax) fillFaceboxFromAjax(data.ajax) + else if (data.image) fillFaceboxFromImage(data.image) + else if (data.div) fillFaceboxFromHref(data.div) + else if ($.isFunction(data)) data.call($) + else $.facebox.reveal(data, klass) +} - /* +/* * Public, $.facebox methods */ - $.extend($.facebox, { - settings: { - opacity : 0.7, - overlay : true, - loadingImage : '<?php echo $vars['url']; ?>_graphics/ajax_loader_bw.gif', - closeImage : '<?php echo $vars['url']; ?>_graphics/spacer.gif', - imageTypes : [ 'png', 'jpg', 'jpeg', 'gif' ], - faceboxHtml : '\ - <div id="facebox" class="hidden"> \ - <div class="popup"> \ - <div class="body"> \ - <div class="footer"> \ - <a href="#" class="close"> \ - <img src="<?php echo $vars['url']; ?>_graphics/spacer.gif" title="close" class="close_image" width="22" height="22" border="0" /> \ - </a> \ - </div> \ - <div class="content"> \ - </div> \ - </div> \ - </div> \ - </div>' - }, - - loading: function() { - init() - if ($('#facebox .loading').length == 1) return true - showOverlay() - - $('#facebox .content').empty() - $('#facebox .body').children().hide().end(). - append('<div class="loading"><br /><br /><img src="'+$.facebox.settings.loadingImage+'"/><br /><br /></div>') - - $('#facebox').css({ - top: getPageScroll()[1] + (getPageHeight() / 10), - // Curverider addition (pagewidth/2 - modalwidth/2) - left: ((getPageWidth() / 2) - ($('#facebox').width() / 2)) - }).show() - - $(document).bind('keydown.facebox', function(e) { - if (e.keyCode == 27) $.facebox.close() - return true - }) - $(document).trigger('loading.facebox') - }, - - reveal: function(data, klass) { - $(document).trigger('beforeReveal.facebox') - if (klass) $('#facebox .content').addClass(klass) - $('#facebox .content').append(data) - +$.extend($.facebox, { + settings: { + opacity : 0.7, + overlay : true, + loadingImage : '<?php echo $vars['url']; ?>_graphics/ajax_loader_bw.gif', + closeImage : '<?php echo $vars['url']; ?>_graphics/spacer.gif', + imageTypes : [ 'png', 'jpg', 'jpeg', 'gif' ], + faceboxHtml : '\ + <div id="facebox" class="hidden"> \ + <div class="popup"> \ + <div class="body"> \ + <div class="footer"> \ + <a href="#" class="close"> \ + <img src="<?php echo $vars['url']; ?>_graphics/spacer.gif" title="close" class="close_image" width="22" height="22" border="0" /> \ + </a> \ + </div> \ + <div class="content"> \ + </div> \ + </div> \ + </div> \ + </div>' + }, + + loading: function() { + init() + if ($('#facebox .loading').length == 1) return true + showOverlay() + + $('#facebox .content').empty() + $('#facebox .body').children().hide().end(). + append('<div class="loading"><br /><br /><img src="'+$.facebox.settings.loadingImage+'"/><br /><br /></div>') + + $('#facebox').css({ + top: getPageScroll()[1] + (getPageHeight() / 10), + // Curverider addition (pagewidth/2 - modalwidth/2) + left: ((getPageWidth() / 2) - ($('#facebox').width() / 2)) + }).show() + + $(document).bind('keydown.facebox', function(e) { + if (e.keyCode == 27) $.facebox.close() + return true + }) + $(document).trigger('loading.facebox') + }, + + reveal: function(data, klass) { + $(document).trigger('beforeReveal.facebox') + if (klass) $('#facebox .content').addClass(klass) + $('#facebox .content').append(data) + setTimeout(function() { - $('#facebox .loading').remove(); - $('#facebox .body').children().fadeIn('slow'); - $('#facebox').css('left', $(window).width() / 2 - ($('#facebox').width() / 2)); - $(document).trigger('reveal.facebox').trigger('afterReveal.facebox'); - }, 100); - - //$('#facebox .loading').remove() - //$('#facebox .body').children().fadeIn('slow') - //$('#facebox').css('left', $(window).width() / 2 - ($('#facebox').width() / 2)) - //$(document).trigger('reveal.facebox').trigger('afterReveal.facebox') - - }, - - close: function() { - $(document).trigger('close.facebox') - return false - } - }) - - /* + $('#facebox .loading').remove(); + $('#facebox .body').children().fadeIn('slow'); + $('#facebox').css('left', $(window).width() / 2 - ($('#facebox').width() / 2)); + $(document).trigger('reveal.facebox').trigger('afterReveal.facebox'); + }, 100); + + //$('#facebox .loading').remove() + //$('#facebox .body').children().fadeIn('slow') + //$('#facebox').css('left', $(window).width() / 2 - ($('#facebox').width() / 2)) + //$(document).trigger('reveal.facebox').trigger('afterReveal.facebox') + + }, + + close: function() { + $(document).trigger('close.facebox') + return false + } +}) + +/* * Public, $.fn methods */ - - // Curverider addition + +// Curverider addition /* $.fn.wait = function(time, type) { - time = time || 3000; - type = type || "fx"; - return this.queue(type, function() { - var self = this; - setTimeout(function() { - //$(self).queue(); - $('#facebox .loading').remove(); - }, time); - }); + time = time || 3000; + type = type || "fx"; + return this.queue(type, function() { + var self = this; + setTimeout(function() { + //$(self).queue(); + $('#facebox .loading').remove(); + }, time); + }); }; */ - $.fn.facebox = function(settings) { - init(settings) +$.fn.facebox = function(settings) { + init(settings) - function clickHandler() { - $.facebox.loading(true) + function clickHandler() { + $.facebox.loading(true) - // support for rel="facebox.inline_popup" syntax, to add a class - // also supports deprecated "facebox[.inline_popup]" syntax - var klass = this.rel.match(/facebox\[?\.(\w+)\]?/) - if (klass) klass = klass[1] + // support for rel="facebox.inline_popup" syntax, to add a class + // also supports deprecated "facebox[.inline_popup]" syntax + var klass = this.rel.match(/facebox\[?\.(\w+)\]?/) + if (klass) klass = klass[1] - fillFaceboxFromHref(this.href, klass) - return false - } + fillFaceboxFromHref(this.href, klass) + return false + } - return this.click(clickHandler) - } + return this.click(clickHandler) +} - /* +/* * Private methods */ - // called one time to setup facebox on this page - function init(settings) { - if ($.facebox.settings.inited) return true - else $.facebox.settings.inited = true +// called one time to setup facebox on this page +function init(settings) { + if ($.facebox.settings.inited) return true + else $.facebox.settings.inited = true - $(document).trigger('init.facebox') - /* makeCompatible() */ + $(document).trigger('init.facebox') + /* makeCompatible() */ - var imageTypes = $.facebox.settings.imageTypes.join('|') - $.facebox.settings.imageTypesRegexp = new RegExp('\.' + imageTypes + '$', 'i') + var imageTypes = $.facebox.settings.imageTypes.join('|') + $.facebox.settings.imageTypesRegexp = new RegExp('\.' + imageTypes + '$', 'i') - if (settings) $.extend($.facebox.settings, settings) - $('body').append($.facebox.settings.faceboxHtml) + if (settings) $.extend($.facebox.settings, settings) + $('body').append($.facebox.settings.faceboxHtml) - var preload = [ new Image(), new Image() ] - preload[0].src = $.facebox.settings.closeImage - preload[1].src = $.facebox.settings.loadingImage + var preload = [ new Image(), new Image() ] + preload[0].src = $.facebox.settings.closeImage + preload[1].src = $.facebox.settings.loadingImage preload.push(new Image()) /* - $('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function() { - preload.push(new Image()) - preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1') - }) + $('#facebox').find('.b:first, .bl, .br, .tl, .tr').each(function() { + preload.push(new Image()) + preload.slice(-1).src = $(this).css('background-image').replace(/url\((.+)\)/, '$1') + }) */ - $('#facebox .close').click($.facebox.close) - $('#facebox .close_image').attr('src', $.facebox.settings.closeImage) - } - - // getPageScroll() by quirksmode.com - function getPageScroll() { - var xScroll, yScroll; - if (self.pageYOffset) { - yScroll = self.pageYOffset; - xScroll = self.pageXOffset; - } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict - yScroll = document.documentElement.scrollTop; - xScroll = document.documentElement.scrollLeft; - } else if (document.body) {// all other Explorers - yScroll = document.body.scrollTop; - xScroll = document.body.scrollLeft; - } - return new Array(xScroll,yScroll) - } + $('#facebox .close').click($.facebox.close) + $('#facebox .close_image').attr('src', $.facebox.settings.closeImage) +} + +// getPageScroll() by quirksmode.com +function getPageScroll() { + var xScroll, yScroll; + if (self.pageYOffset) { + yScroll = self.pageYOffset; + xScroll = self.pageXOffset; + } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict + yScroll = document.documentElement.scrollTop; + xScroll = document.documentElement.scrollLeft; + } else if (document.body) {// all other Explorers + yScroll = document.body.scrollTop; + xScroll = document.body.scrollLeft; + } + return new Array(xScroll,yScroll) +} // Adapted from getPageSize() by quirksmode.com function getPageHeight() { var windowHeight if (self.innerHeight) { // all except Explorer - windowHeight = self.innerHeight; + windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode - windowHeight = document.documentElement.clientHeight; + windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers - windowHeight = document.body.clientHeight; - } + windowHeight = document.body.clientHeight; + } return windowHeight } // Curverider addition function getPageWidth() { - var windowWidth; - if( typeof( window.innerWidth ) == 'number' ) { - windowWidth = window.innerWidth; //Non-IE - } else if( document.documentElement && ( document.documentElement.clientWidth ) ) { - windowWidth = document.documentElement.clientWidth; //IE 6+ in 'standards compliant mode' - } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { - windowWidth = document.body.clientWidth; //IE 4 compatible - } - return windowWidth - } + var windowWidth; + if( typeof( window.innerWidth ) == 'number' ) { + windowWidth = window.innerWidth; //Non-IE + } else if( document.documentElement && ( document.documentElement.clientWidth ) ) { + windowWidth = document.documentElement.clientWidth; //IE 6+ in 'standards compliant mode' + } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { + windowWidth = document.body.clientWidth; //IE 4 compatible + } + return windowWidth + } - // Backwards compatibility +// Backwards compatibility /* - function makeCompatible() { - var $s = $.facebox.settings - - $s.loadingImage = $s.loading_image || $s.loadingImage - $s.closeImage = $s.close_image || $s.closeImage - $s.imageTypes = $s.image_types || $s.imageTypes - $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml - } +function makeCompatible() { + var $s = $.facebox.settings + + $s.loadingImage = $s.loading_image || $s.loadingImage + $s.closeImage = $s.close_image || $s.closeImage + $s.imageTypes = $s.image_types || $s.imageTypes + $s.faceboxHtml = $s.facebox_html || $s.faceboxHtml +} */ - // Figures out what you want to display and displays it - // formats are: - // div: #id - // image: blah.extension - // ajax: anything else - function fillFaceboxFromHref(href, klass) { - // div - if (href.match(/#/)) { - var url = window.location.href.split('#')[0] - var target = href.replace(url,'') - $.facebox.reveal($(target).clone().show(), klass) - - // image - } else if (href.match($.facebox.settings.imageTypesRegexp)) { - fillFaceboxFromImage(href, klass) - // ajax - } else { - fillFaceboxFromAjax(href, klass) - } - } - - function fillFaceboxFromImage(href, klass) { - var image = new Image() - image.onload = function() { - $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass) - } - image.src = href - } - - function fillFaceboxFromAjax(href, klass) { - $.get(href, function(data) { $.facebox.reveal(data, klass) }) - } - - function skipOverlay() { - return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null - } - - function showOverlay() { - if (skipOverlay()) return - - if ($('facebox_overlay').length == 0) - $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>') - - $('#facebox_overlay').hide().addClass("facebox_overlayBG") - .css('opacity', $.facebox.settings.opacity) - /* .click(function() { $(document).trigger('close.facebox') }) */ - .fadeIn(400) - return false - } - - function hideOverlay() { - if (skipOverlay()) return - - $('#facebox_overlay').fadeOut(400, function(){ - $("#facebox_overlay").removeClass("facebox_overlayBG") - $("#facebox_overlay").addClass("facebox_hide") - $("#facebox_overlay").remove() - }) - - return false - } - - /* +// Figures out what you want to display and displays it +// formats are: +// div: #id +// image: blah.extension +// ajax: anything else +function fillFaceboxFromHref(href, klass) { + // div + if (href.match(/#/)) { + var url = window.location.href.split('#')[0] + var target = href.replace(url,'') + $.facebox.reveal($(target).clone().show(), klass) + + // image + } else if (href.match($.facebox.settings.imageTypesRegexp)) { + fillFaceboxFromImage(href, klass) + // ajax + } else { + fillFaceboxFromAjax(href, klass) + } +} + +function fillFaceboxFromImage(href, klass) { + var image = new Image() + image.onload = function() { + $.facebox.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass) + } + image.src = href +} + +function fillFaceboxFromAjax(href, klass) { + $.get(href, function(data) { $.facebox.reveal(data, klass) }) +} + +function skipOverlay() { + return $.facebox.settings.overlay == false || $.facebox.settings.opacity === null +} + +function showOverlay() { + if (skipOverlay()) return + + if ($('facebox_overlay').length == 0) + $("body").append('<div id="facebox_overlay" class="facebox_hide"></div>') + + $('#facebox_overlay').hide().addClass("facebox_overlayBG") + .css('opacity', $.facebox.settings.opacity) + /* .click(function() { $(document).trigger('close.facebox') }) */ + .fadeIn(400) + return false +} + +function hideOverlay() { + if (skipOverlay()) return + + $('#facebox_overlay').fadeOut(400, function(){ + $("#facebox_overlay").removeClass("facebox_overlayBG") + $("#facebox_overlay").addClass("facebox_hide") + $("#facebox_overlay").remove() + }) + + return false +} + +/* * Bindings */ - $(document).bind('close.facebox', function() { - $(document).unbind('keydown.facebox') - $('#facebox').fadeOut(function() { - $('#facebox .content').removeClass().addClass('content') - hideOverlay() - $('#facebox .loading').remove() - }) - }) - - - - +$(document).bind('close.facebox', function() { + $(document).unbind('keydown.facebox') + $('#facebox').fadeOut(function() { + $('#facebox .content').removeClass().addClass('content') + hideOverlay() + $('#facebox .loading').remove() + }) +}) + + + + // Curverider addition $(window).resize(function(){ - //alert("resized"); - - $('#facebox').css({ - top: getPageScroll()[1] + (getPageHeight() / 10), - left: ((getPageWidth() / 2) - 365) - }) - - + //alert("resized"); + + $('#facebox').css({ + top: getPageScroll()[1] + (getPageHeight() / 10), + left: ((getPageWidth() / 2) - 365) + }) + + }); diff --git a/mod/embed/views/default/embed/layouts/gallery.php b/mod/embed/views/default/embed/layouts/gallery.php new file mode 100644 index 000000000..b3d9bbc7f --- /dev/null +++ b/mod/embed/views/default/embed/layouts/gallery.php @@ -0,0 +1 @@ +<?php diff --git a/mod/embed/views/default/embed/layouts/list.php b/mod/embed/views/default/embed/layouts/list.php new file mode 100644 index 000000000..d62d35417 --- /dev/null +++ b/mod/embed/views/default/embed/layouts/list.php @@ -0,0 +1,60 @@ +<?php +/** + * Embed - List items + * + * @todo Yes this is a lot of logic for a view. The Javascript is faily complicated + * and pulling entity views out was making it worse. + * Once plugin deps are working, we'll remove the logic for that. + * + * @uses array $vars['items'] Array of ElggEntities + * @uses string $vars['section'] The section_id. + * + */ + +$items = isset($vars['items']) ? $vars['items'] : array(); +$section = $vars['section']; + +// pull out some common tests +// embed requires ECML, but until we have plugin deps working +// we need to explicitly check and use a fallback. +if ($ecml_enabled = is_plugin_enabled('ecml')){ + $ecml_valid_keyword = ecml_is_valid_keyword($section); +} else { + $ecml_valid_keyword = FALSE; +} + +// check if we have an override for this section type. +$view = "embed/$section/item/list"; +if (!elgg_view_exists($view)) { + $view = "embed/item/list"; +} + +$content = ''; +foreach ($items as $item) { + // sanity checking + if (!elgg_instanceof($item)) { + continue; + } + + $params = array( + 'section' => $section, + 'item' => $item, + 'ecml_enabled' => $ecml_enabled, + 'ecml_keyword' => ($ecml_valid_keyword) ? $section : 'entity' + ); + + $content .= elgg_view($view, $params); +} + +echo $content; + +?> + +<script type="text/javascript"> +$(document).ready(function() { + $('.embed_data').click(function() { + var embed_code = $(this).data('embed_code'); + elggEmbedInsertContent(embed_code); + }); +}); +</script>
\ No newline at end of file diff --git a/mod/embed/views/default/embed/link.php b/mod/embed/views/default/embed/link.php index 14b33d4c2..bd500dfaf 100644 --- a/mod/embed/views/default/embed/link.php +++ b/mod/embed/views/default/embed/link.php @@ -1 +1,6 @@ +<?php +/** + * Displays an "Embed media" link in longtext inputs. + */ +?> <a class="longtext_control small link" href="<?php echo $vars['url'] . 'pg/embed/media'; ?>?internalname=<?php echo $vars['internalname']; ?>" rel="facebox"><?php echo elgg_echo('media:insert'); ?></a>
\ No newline at end of file diff --git a/mod/embed/views/default/embed/media.php b/mod/embed/views/default/embed/media.php index ff0505466..381774618 100644 --- a/mod/embed/views/default/embed/media.php +++ b/mod/embed/views/default/embed/media.php @@ -11,43 +11,43 @@ 'limit' => $vars['limit'], 'count' => $vars['count'] )); - + echo elgg_view('embed/simpletype',array( 'internalname' => $vars['internalname'], 'simpletypes' => $vars['simpletypes'], 'simpletype' => $vars['simpletype'], )); - + $context = get_context(); $entities = $vars['entities']; if (is_array($entities) && !empty($entities)) { - + echo "<p class='embed_instructions'>" . elgg_echo('embed:instructions') . "</p>"; - + foreach($entities as $entity) { if ($entity instanceof ElggEntity) { - $mime = $entity->mimetype; - + $mime = $entity->mimetype; + $enttype = $entity->getType(); $entsubtype = $entity->getSubtype(); - + if (elgg_view_exists($enttype . '/' . $entsubtype . '/embed')) { $content = elgg_view($enttype . '/' . $entsubtype . '/embed', array('entity' => $entity, 'full' => true)); } else { $content = elgg_view($enttype . '/default/embed', array('entity' => $entity, 'full' => true)); } - + $content = str_replace("\n","", $content); $content = str_replace("\r","", $content); //$content = htmlentities($content,null,'utf-8'); $content = htmlentities($content, ENT_COMPAT, "UTF-8"); - + $link = "javascript:elggUpdateContent('{$content}','{$vars['internalname']}');"; if ($entity instanceof ElggObject) { $title = $entity->title; $mime = $entity->mimetype; } else { $title = $entity->name; $mime = ''; } - + set_context('search'); - + if (elgg_view_exists("{$enttype}/{$entsubtype}/embedlist")) { $entview = elgg_view("{$enttype}/{$entsubtype}/embedlist",array('entity' => $entity)); } else { @@ -55,9 +55,9 @@ } $entview = str_replace($entity->getURL(),$link,$entview); echo $entview; - - set_context($context); - + + set_context($context); + } } } diff --git a/mod/embed/views/default/embed/upload.php b/mod/embed/views/default/embed/upload.php index d995b4b2b..5f249c0c7 100644 --- a/mod/embed/views/default/embed/upload.php +++ b/mod/embed/views/default/embed/upload.php @@ -1,5 +1,6 @@ <h2 class="media_modal_title">Embed / Upload Media</h2> <?php +$internalname = get_input('internalname'); echo elgg_view('embed/tabs',array('tab' => 'upload', 'internalname'=>get_input('internalname'))); @@ -7,7 +8,7 @@ if (!elgg_view_exists('file/upload')) { echo "<p>" . elgg_echo('embed:file:required') . "</p>"; } else { $action = 'file/upload'; - + ?> <form id="media_upload" action="<?php echo $vars['url']; ?>action/file/upload" method="post" enctype="multipart/form-data"> <p> @@ -15,7 +16,7 @@ if (!elgg_view_exists('file/upload')) { <?php echo elgg_view('input/securitytoken'); echo elgg_view("input/file",array('internalname' => 'upload', 'js' => 'id="upload"')); - + ?> </label></p> <p> @@ -26,7 +27,7 @@ if (!elgg_view_exists('file/upload')) { "internalname" => "title", "value" => $title, )); - + ?> </label> </p> @@ -34,7 +35,7 @@ if (!elgg_view_exists('file/upload')) { <label for="filedescription"><?php echo elgg_echo("description"); ?><br /> <textarea class="input_textarea" name="description" id="filedescription"></textarea> </label></p> - + <p> <label><?php echo elgg_echo("tags"); ?><br /> <?php @@ -60,26 +61,26 @@ if (!elgg_view_exists('file/upload')) { echo "<input type=\"hidden\" name=\"container_guid\" value=\"{$vars['container_guid']}\" />"; if (isset($vars['entity'])) echo "<input type=\"hidden\" name=\"file_guid\" value=\"{$vars['entity']->getGUID()}\" />"; - + ?> <input type="submit" value="<?php echo elgg_echo("save"); ?>" /> </p> </form> -<script type="text/javascript"> - // bind 'myForm' and provide a simple callback function - $('#media_upload').submit(function() { - var options = { - success: function() { - $('.popup .content').load('<?php echo $vars['url'] . 'pg/embed/media'; ?>?internalname=<?php echo $vars['internalname']; ?>'); - } - }; - $(this).ajaxSubmit(options); - return false; - }); -</script> +<script type="text/javascript"> + // bind 'myForm' and provide a simple callback function + $('#media_upload').submit(function() { + var options = { + success: function() { + $('.popup .content').load('<?php echo $vars['url'] . 'pg/embed/media'; ?>?internalname=<?php echo $internalname; ?>'); + } + }; + $(this).ajaxSubmit(options); + return false; + }); +</script> <?php - + } ?> |