diff options
Diffstat (limited to 'mod/embed')
28 files changed, 585 insertions, 1071 deletions
diff --git a/mod/embed/README.txt b/mod/embed/README.txt index 17f867d7a..51b120d96 100644 --- a/mod/embed/README.txt +++ b/mod/embed/README.txt @@ -1,10 +1,76 @@ Embed plugin -(c) 2009 Curverider Ltd -Released under the GNU Public License version 2 -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. +CONTENTS: + 1. Overview + 2. Adding a Tab + 3. Populating a Select Tab + 4. Populating an Upload Tab + 5. Other WYSIWYG Editors and Embed -It makes use of the jQuery form plugin, available at: -http://malsup.com/jquery/form/
\ No newline at end of file + +1. Overview + The Embed plugin is a simple way to allow users to link to or embed + their personal network content or third party resources in any text area. + + The Embed plugin adds a menu item to the longtext menu. Clicking on this + link pops up a lightbox. The lightbox supports lists of content for insertion + and uploading new content. + + +2. Adding a Tab + The Embed plugin uses the menu system to manage its tabs. Use + elgg_register_menu_item() for the embed menu to add a new tab like this: + + $item = ElggMenuItem::factory(array( + 'name' => 'file', + 'text' => elgg_echo('file'), + 'priority' => 10, + 'data' => array( + 'options' => array( + 'type' => 'object', + 'subtype' => 'file', + ), + ), + )); + elgg_register_menu_item('embed', $item); + + Parameters: + name: The unique name of the tab. + text: The text shown on the tab + priority: Placement of the tab. + data: An array of parameters for creating the tab and its content. + When listing content using the embed list view, pass the options for the + elgg_list_entities() function as 'options'. + When using a custom view for listing content or for uploading new + content, pass the view name as 'view'. + + See the file plugin for examples of registering both tab types. + + +3. Populating a Content Select Tab + Nothing should be required other than setting the options parameter array + when registering the tab. See the view embed/item to see how an entity is + rendered. + + If creating a custom list, the <li> elements must have a class of .embed-item. + The HTML content that is inserted must use the class .embed-insert. + + +4. Populating an Upload Tab + The view that is registered must be defined. It must include a form for + uploading the content. The form must .elgg-form-embed. Somewhere in the view + must be a hidden input field with the name embed_hidden with its value be + the name of the tab to forward the user to when uploading is complete. + + See the view embed/file_upload/content for an example + + +5. Other WYSIWYG Editors and Embed + Embed ships with support for the default input/longtext textarea. + Plugins replacing this view are expected to include JaVascript to + allow embed to work with the new editors. + + To add custom JavaScript into the Embed plugin's elgg.embed.insert() function, + override the view embed/custom_insert_js. The textarea jQuery object is + available as the variable textArea and the content to be inserted is the + variable content. See the TinyMCE plugin for an example of this view.
\ No newline at end of file diff --git a/mod/embed/embed.php b/mod/embed/embed.php deleted file mode 100644 index 358547491..000000000 --- a/mod/embed/embed.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php -// This page can only be run from within the Elgg framework - 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')); - - 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, - )); - -?>
\ No newline at end of file diff --git a/mod/embed/images/close_button.gif b/mod/embed/images/close_button.gif Binary files differdeleted file mode 100644 index 822ea8527..000000000 --- a/mod/embed/images/close_button.gif +++ /dev/null diff --git a/mod/embed/languages/en.php b/mod/embed/languages/en.php index ca57f4a9b..6ae99a56f 100644 --- a/mod/embed/languages/en.php +++ b/mod/embed/languages/en.php @@ -1,18 +1,21 @@ <?php +/** + * Embed English language strings + * + */ - $english = array( - - 'media:insert' => 'Embed / upload media', - - 'embed:instructions' => 'Click on any file to embed it into your content.', - - 'embed:media' => 'Embed media', - 'upload:media' => 'Upload media', - - 'embed:file:required' => 'No file upload facilities were found. The system administrator may need to upload the file plugin or similar.', - - ); - - add_translation("en",$english); +$english = array( + 'embed:embed' => 'Embed', + 'embed:media' => 'Embed content', + 'embed:instructions' => 'Click on any file to embed it into your content.', + 'embed:upload' => 'Upload media', + 'embed:upload_type' => 'Upload type: ', -?>
\ No newline at end of file + // 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 a14e99b4b..81ca9194e 100644 --- a/mod/embed/manifest.xml +++ b/mod/embed/manifest.xml @@ -1,10 +1,22 @@ <?xml version="1.0" encoding="UTF-8"?> -<plugin_manifest> - <field key="author" value="Curverider" /> - <field key="version" value="1.7" /> - <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" /> - <field key="licence" value="GNU Public License version 2" /> - <field key="elgg_version" value="2010030101" /> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>Embed</name> + <author>Core developers</author> + <version>1.8.1</version> + <category>bundled</category> + <category>enhancement</category> + <description>Allows users to easily upload and embed media into text areas.</description> + <website>http://www.elgg.org/</website> + <copyright>See COPYRIGHT.txt</copyright> + <license>GNU General Public License version 2</license> + <requires> + <type>elgg_release</type> + <version>1.8</version> + </requires> + <requires> + <type>plugin</type> + <name>file</name> + <version>1.8.1</version> + </requires> + <activate_on_install>true</activate_on_install> </plugin_manifest> diff --git a/mod/embed/start.php b/mod/embed/start.php index d6bdcc0c9..1da35aa46 100644 --- a/mod/embed/start.php +++ b/mod/embed/start.php @@ -1,49 +1,165 @@ <?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> - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.com/ */ + +elgg_register_event_handler('init', 'system', 'embed_init'); + /** * Init function + */ +function embed_init() { + elgg_extend_view('css/elgg', 'embed/css'); + elgg_extend_view('css/admin', 'embed/css'); + + if (elgg_is_logged_in()) { + elgg_register_plugin_hook_handler('register', 'menu:longtext', 'embed_longtext_menu'); + } + elgg_register_plugin_hook_handler('register', 'menu:embed', 'embed_select_tab', 1000); + + // Page handler for the modal media embed + elgg_register_page_handler('embed', 'embed_page_handler'); + + $embed_js = elgg_get_simplecache_url('js', 'embed/embed'); + elgg_register_simplecache_view('js/embed/embed'); + elgg_register_js('elgg.embed', $embed_js, 'footer'); +} + +/** + * Add the embed menu item to the long text menu * + * @param string $hook + * @param string $type + * @param array $items + * @param array $vars + * @return array */ - 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',10); - - // Page handler for the modal media embed - register_page_handler('embed','embed_page_handler'); - +function embed_longtext_menu($hook, $type, $items, $vars) { + + if (elgg_get_context() == 'embed') { + return $items; } + + $url = 'embed'; + + $page_owner = elgg_get_page_owner_entity(); + if (elgg_instanceof($page_owner, 'group') && $page_owner->isMember()) { + $url = 'embed?container_guid=' . $page_owner->getGUID(); + } + + $items[] = ElggMenuItem::factory(array( + 'name' => 'embed', + 'href' => $url, + 'text' => elgg_echo('embed:media'), + 'rel' => "embed-lightbox-{$vars['id']}", + 'link_class' => "elgg-longtext-control elgg-lightbox embed-control embed-control-{$vars['id']}", + 'priority' => 10, + )); + + elgg_load_js('lightbox'); + elgg_load_css('lightbox'); + elgg_load_js('jquery.form'); + elgg_load_js('elgg.embed'); + return $items; +} + +/** + * Select the correct embed tab for display + * + * @param string $hook + * @param string $type + * @param array $items + * @param array $vars + */ +function embed_select_tab($hook, $type, $items, $vars) { + + // can this ba called from page handler instead? + $page = get_input('page'); + $tab_name = array_pop(explode('/', $page)); + foreach ($items as $item) { + if ($item->getName() == $tab_name) { + $item->setSelected(); + elgg_set_config('embed_tab', $item); + } + } + + if (!elgg_get_config('embed_tab') && count($items) > 0) { + $items[0]->setSelected(); + elgg_set_config('embed_tab', $items[0]); + } +} + /** - * Runs the 'embed' script + * Serves the content for the embed lightbox * + * @param array $page URL segments */ - 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) { + + $container_guid = (int)get_input('container_guid'); + if ($container_guid) { + $container = get_entity($container_guid); + + if (elgg_instanceof($container, 'group') && $container->isMember()) { + // embedding inside a group so save file to group files + elgg_set_page_owner_guid($container_guid); } - } -// Register the init action - register_elgg_event_handler('init','system','embed_init',10); + echo elgg_view('embed/layout'); + + // exit because this is in a modal display. + exit; +} + +/** + * A special listing function for selectable content + * + * This calls a custom list view for entities. + * + * @param array $entities Array of ElggEntity objects + * @param array $vars Display parameters + * @return string + */ +function embed_list_items($entities, $vars = array()) { + + $defaults = array( + 'items' => $entities, + 'list_class' => 'elgg-list-entity', + ); + + $vars = array_merge($defaults, $vars); + + return elgg_view('embed/list', $vars); +} + +/** + * Set the options for the list of embedable content + * + * @param array $options + * @return array + */ +function embed_get_list_options($options = array()) { + + $container_guids = array(elgg_get_logged_in_user_guid()); + if (elgg_get_page_owner_guid()) { + $page_owner_guid = elgg_get_page_owner_guid(); + if ($page_owner_guid != elgg_get_logged_in_user_guid()) { + $container_guids[] = $page_owner_guid; + } + } + + $defaults = array( + 'limit' => 6, + 'container_guids' => $container_guids, + 'item_class' => 'embed-item', + ); + + $options = array_merge($defaults, $options); -?> + return $options; +} diff --git a/mod/embed/upload.php b/mod/embed/upload.php deleted file mode 100644 index 21a24786d..000000000 --- a/mod/embed/upload.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - - // This page can only be run from within the Elgg framework - if (!is_callable('elgg_view')) exit; - - // Get the name of the form field we need to inject into - $internalname = get_input('internalname'); - - global $SESSION; - - // Echo the embed view - echo elgg_view('embed/upload', array( - 'entities' => $entities, - 'internalname' => $internalname, - )); - -?>
\ 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..ffed211f5 100644 --- a/mod/embed/views/default/embed/addcontentjs.php +++ b/mod/embed/views/default/embed/addcontentjs.php @@ -1,4 +1,7 @@ +<?php +/** + * Blank for compatibility. + * @deprecated 1.8 + */ - var entity; - $('textarea[name='+entityname+']').val($('textarea[name='+entityname+']').val() + ' ' + content); - +elgg_deprecated_notice("The view 'embed/addcontentjs' has been deprecated.", 1.8); diff --git a/mod/embed/views/default/embed/css.php b/mod/embed/views/default/embed/css.php index 1b4f3ca80..034c0fcfe 100644 --- a/mod/embed/views/default/embed/css.php +++ b/mod/embed/views/default/embed/css.php @@ -3,192 +3,35 @@ * Elgg embed CSS - standard across all themes * * @package embed - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Curverider <info@elgg.com> - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.org/ */ ?> - -#facebox { - position: absolute; - top: 0; - left: 0; - z-index: 10000; - text-align: left; -} -#facebox .popup { - position: relative; -} -#facebox .body { - padding: 10px; - background-color: white; +.embed-wrapper { width: 730px; - -webkit-border-radius: 12px; - -moz-border-radius: 12px; -} -#facebox .loading { - text-align: center; - padding: 100px 10px 100px 10px; -} -#facebox .image { - text-align: center; -} -#facebox .footer { - float: right; - width:22px; - height:22px; - margin:0; - padding:0; -} -#facebox .footer img.close_image { - background: url(<?php echo $vars['url']; ?>mod/embed/images/close_button.gif) no-repeat left top; + min-height: 400px; + margin: 20px 15px; } -#facebox .footer img.close_image:hover { - background: url(<?php echo $vars['url']; ?>mod/embed/images/close_button.gif) no-repeat left -31px; +.embed-wrapper h2 { + color: #333333; + margin-bottom: 10px; } -#facebox_overlay { - position: fixed; - top: 0px; - left: 0px; - height:100%; - width:100%; -} -.facebox_hide { - z-index:-100; -} -.facebox_overlayBG { - background-color: #000000; - z-index: 9999; -} -* html #facebox_overlay { /* ie6 hack */ - position: absolute; - height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); +.embed-wrapper .elgg-item { + cursor: pointer; } -/* entity listing overrides */ -#media_upload, -#media_embed { - margin:0 5px 10px 5px; - padding:10px; - border:2px solid #dedede; - -webkit-border-radius: 8px; - -moz-border-radius: 8px; - background: #dedede; -} -#media_embed .entity_listing { - margin:0; - padding:0; - background-color: white; -} -#media_embed .entity_listing_info { - width:610px; -} -#media_upload .input_textarea { - height:100px; - width:682px; -} -#media_embed .embed_instructions { - margin:10px 0 5px 0; -} -a.embed_media { - margin:0; - float:right; - display:block; - text-align: right; - font-weight: normal; -} -label a.embed_media { - font-size:0.8em; +/* *************************************** + EMBED TABBED PAGE NAVIGATION +*************************************** */ +.embed-wrapper .elgg-tabs a:hover { + color: #666; } - -/* modal tabs */ -#embed_media_tabs { - margin:10px 0 0 10px; - padding:0; -} -#embed_media_tabs ul { - list-style: none; - padding-left: 0; -} -#embed_media_tabs ul li { - float: left; - margin:0; - background:white; -} -#embed_media_tabs ul li a { - font-weight: bold; - font-size:1.2em; - text-align: center; - text-decoration: none; - color:#b6b6b6; - background: white; - display: block; - padding: 3px 10px 0 10px; - margin:0 10px 0 10px; - height:20px; - width:auto; - border-top:2px solid #dedede; - border-left:2px solid #dedede; - border-right:2px solid #dedede; - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; -} -#embed_media_tabs ul li a:hover { - background:#b6b6b6; - color:white; - border-top:2px solid #b6b6b6; - border-left:2px solid #b6b6b6; - border-right:2px solid #b6b6b6; -} -#embed_media_tabs ul li a.embed_tab_selected { - border-top:2px solid #dedede; - border-left:2px solid #dedede; - border-right:2px solid #dedede; - -webkit-border-top-left-radius: 8px; - -webkit-border-top-right-radius: 8px; - -moz-border-radius-topleft: 8px; - -moz-border-radius-topright: 8px; - background: #dedede; - color:#666666; - position: relative; -} -/* IE6 fix */ -* html #embed_media_tabs ul li a { display: inline; } - - -/* Pagination (override core elgg css defaults) */ -#media_embed .pagination, -#media_upload .pagination { - float:right; - padding:5px; - background-color:white; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; -} -#media_embed .pagination .pagination_number { - border:1px solid #999999; - color:#666666; -} -#media_embed .pagination .pagination_number:hover { - background-color:#aaaaaa; - color:black; +.embed-wrapper p { + color: #333; } -#media_embed .pagination .pagination_previous, -#media_embed .pagination .pagination_next { - border:1px solid #999999; - color:#666666; +.embed-item { + padding-left: 5px; + padding-right: 5px; } -#media_embed .pagination .pagination_previous:hover, -#media_embed .pagination .pagination_next:hover { - background-color:#aaaaaa; - color:black; +.embed-item:hover { + background-color: #eee; } -#media_embed .pagination .pagination_currentpage { - background-color:#666666; - border:1px solid #666666; - color:white; -}
\ No newline at end of file diff --git a/mod/embed/views/default/embed/item.php b/mod/embed/views/default/embed/item.php new file mode 100644 index 000000000..3060de879 --- /dev/null +++ b/mod/embed/views/default/embed/item.php @@ -0,0 +1,39 @@ +<?php +/** + * Embeddable content list item view + * + * @uses $vars['entity'] ElggEntity object + */ + +$entity = $vars['entity']; + +$title = $entity->title; +if (!$title) { + $title = $entity->name; +} + +// different entity types have different title attribute names. +$title = isset($entity->name) ? $entity->name : $entity->title; +// don't let it be too long +$title = elgg_get_excerpt($title); + +$owner = $entity->getOwnerEntity(); +if ($owner) { + $author_text = elgg_echo('byline', array($owner->name)); + $date = elgg_view_friendly_time($entity->time_created); + $subtitle = "$author_text $date"; +} else { + $subtitle = ''; +} + +$params = array( + 'title' => $title, + 'entity' => $entity, + 'subtitle' => $subtitle, + 'tags' => FALSE, +); +$body = elgg_view('object/elements/summary', $params); + +$image = elgg_view_entity_icon($entity, 'small', array('link_class' => 'embed-insert')); + +echo elgg_view_image_block($image, $body); diff --git a/mod/embed/views/default/embed/js.php b/mod/embed/views/default/embed/js.php deleted file mode 100644 index 71120e68f..000000000 --- a/mod/embed/views/default/embed/js.php +++ /dev/null @@ -1,379 +0,0 @@ - - function elggUpdateContent(content, entityname) { - content = ' ' + content + ' '; - <?php - echo elgg_view('embed/addcontentjs'); - ?> - $.facebox.close(); - } - - -/* - * Facebox (for jQuery) - * version: 1.2 (05/05/2008) - * @requires jQuery v1.2 or later - * - * Examples at http://famspam.com/facebox/ - * - * Licensed under the MIT: - * http://www.opensource.org/licenses/mit-license.php - * - * Copyright 2007, 2008 Chris Wanstrath [ chris@ozmm.org ] - * - * Usage: - * - * jQuery(document).ready(function() { - * jQuery('a[rel*=facebox]').facebox() - * }) - * - * <a href="#terms" rel="facebox">Terms</a> - * Loads the #terms div in the box - * - * <a href="terms.html" rel="facebox">Terms</a> - * Loads the terms.html page in the box - * - * <a href="terms.png" rel="facebox">Terms</a> - * Loads the terms.png image in the box - * - * - * 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($) { - * $.get('blah.html', function(data) { $.facebox(data) }) - * }) - * - * The above will show a loading screen before the passed function is called, - * 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' }) - * - * Want to close the facebox? Trigger the 'close.facebox' document event: - * - * jQuery(document).trigger('close.facebox') - * - * Facebox also has a bunch of other hooks: - * - * loading.facebox - * beforeReveal.facebox - * reveal.facebox (aliased as 'afterReveal.facebox') - * init.facebox - * - * Simply bind a function to any of these hooks: - * - * $(document).bind('reveal.facebox', function() { ...stuff to do after the facebox and contents are revealed... }) - * - */ -(function($) { - $.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) - } - - /* - * 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) - - 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 - } - }) - - /* - * Public, $.fn methods - */ - - // 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); - }); - }; -*/ - - $.fn.facebox = function(settings) { - init(settings) - - 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] - - fillFaceboxFromHref(this.href, klass) - return false - } - - 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 - - $(document).trigger('init.facebox') - /* makeCompatible() */ - - var imageTypes = $.facebox.settings.imageTypes.join('|') - $.facebox.settings.imageTypesRegexp = new RegExp('\.' + imageTypes + '$', 'i') - - 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 - 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 .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; - } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode - windowHeight = document.documentElement.clientHeight; - } else if (document.body) { // other Explorers - 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 - } - - - - // 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 - } -*/ - - // 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() - }) - }) - - - - - // Curverider addition - $(window).resize(function(){ - //alert("resized"); - - $('#facebox').css({ - top: getPageScroll()[1] + (getPageHeight() / 10), - left: ((getPageWidth() / 2) - 365) - }) - - - }); - - - - - -})(jQuery); diff --git a/mod/embed/views/default/embed/layout.php b/mod/embed/views/default/embed/layout.php new file mode 100644 index 000000000..1ca263037 --- /dev/null +++ b/mod/embed/views/default/embed/layout.php @@ -0,0 +1,40 @@ +<?php +/** + * Layout of embed panel loaded in lightbox + */ + +$title = elgg_view_title(elgg_echo('embed:media')); + +$menu = elgg_view_menu('embed'); + +$selected = elgg_get_config('embed_tab'); +if ($selected->getData('view')) { + $tab = elgg_view($selected->getData('view'), $vars); +} else { + $tab = elgg_list_entities( + embed_get_list_options($selected->getData('options')), + 'elgg_get_entities', + 'embed_list_items' + ); + if (!$tab) { + $tab = elgg_echo('embed:no_section_content'); + } +} + +$tab .= elgg_view('graphics/ajax_loader', array( + 'class' => 'embed-throbber mtl', +)); + +$container_info = elgg_view('input/hidden', array( + 'name' => 'embed_container_guid', + 'value' => elgg_get_page_owner_guid(), +)); + +echo <<<HTML +<div class="embed-wrapper"> + $title + $menu + $tab + $container_info +</div> +HTML; diff --git a/mod/embed/views/default/embed/link.php b/mod/embed/views/default/embed/link.php deleted file mode 100644 index 0dd77ac99..000000000 --- a/mod/embed/views/default/embed/link.php +++ /dev/null @@ -1 +0,0 @@ -<a class="embed_media small link" href="<?php echo $vars['url'] . 'pg/embed/media'; ?>?internalname=<?php echo $vars['internalname']; ?>" rel="facebox"><?php echo elgg_echo('media:insert'); ?></a><br />
\ No newline at end of file diff --git a/mod/embed/views/default/embed/list.php b/mod/embed/views/default/embed/list.php new file mode 100644 index 000000000..c13639cff --- /dev/null +++ b/mod/embed/views/default/embed/list.php @@ -0,0 +1,58 @@ +<?php +/** + * View a list of embeddable items + * + * @package Elgg + * + * @uses $vars['items'] Array of ElggEntity objects + * @uses $vars['offset'] Index of the first list item in complete list + * @uses $vars['limit'] Number of items per page + * @uses $vars['count'] Number of items in the complete list + * + * @uses $vars['list_class'] Additional CSS class for the <ul> element + * @uses $vars['item_class'] Additional CSS class for the <li> elements + */ + +$items = $vars['items']; +$offset = $vars['offset']; +$limit = $vars['limit']; +$count = $vars['count']; + +$offset_key = elgg_extract('offset_key', $vars, 'offset'); + +$list_class = 'elgg-list'; +if (isset($vars['list_class'])) { + $list_class = "$list_class {$vars['list_class']}"; +} + +$item_class = 'elgg-item'; +if (isset($vars['item_class'])) { + $item_class = "$item_class {$vars['item_class']}"; +} + +$html = ""; +$nav = ""; + +if ($count) { + $nav .= elgg_view('navigation/pagination', array( + 'offset' => $offset, + 'count' => $count, + 'limit' => $limit, + 'offset_key' => $offset_key, + )); +} + +if (is_array($items) && count($items) > 0) { + $html .= "<ul class=\"$list_class\">"; + foreach ($items as $item) { + $id = "elgg-{$item->getType()}-{$item->getGUID()}"; + $html .= "<li id=\"$id\" class=\"$item_class\">"; + $html .= elgg_view('embed/item', array('entity' => $item)); + $html .= '</li>'; + } + $html .= '</ul>'; +} + +$html .= $nav; + +echo $html; diff --git a/mod/embed/views/default/embed/media.php b/mod/embed/views/default/embed/media.php deleted file mode 100644 index 25e63ce7d..000000000 --- a/mod/embed/views/default/embed/media.php +++ /dev/null @@ -1,66 +0,0 @@ -<h2 class="media_modal_title">Embed / Upload Media</h2> -<?php - - echo elgg_view('embed/tabs',array('tab' => 'media', 'internalname' => $vars['internalname'])); -?> - <div id="media_embed"> -<?php - echo elgg_view('embed/pagination',array( - 'offset' => $vars['offset'], - 'baseurl' => $vars['url'] . 'pg/embed/media?internalname=' . $vars['internalname'] . "&simpletype=" . $vars['simpletype'], - '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; - - $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 { - $entview = elgg_view_entity($entity); - } - $entview = str_replace($entity->getURL(),$link,$entview); - echo $entview; - - set_context($context); - - } - } - } - -?> -</div>
\ No newline at end of file diff --git a/mod/embed/views/default/embed/metatags.php b/mod/embed/views/default/embed/metatags.php deleted file mode 100644 index 3c7ab87a9..000000000 --- a/mod/embed/views/default/embed/metatags.php +++ /dev/null @@ -1,5 +0,0 @@ - <script type="text/javascript"> - jQuery(document).ready(function($) { - $('a[rel*=facebox]').facebox() - }); - </script> diff --git a/mod/embed/views/default/embed/pagination.php b/mod/embed/views/default/embed/pagination.php deleted file mode 100644 index b5a741fcd..000000000 --- a/mod/embed/views/default/embed/pagination.php +++ /dev/null @@ -1,130 +0,0 @@ -<?php - - /** - * Elgg pagination - * - * @package Elgg - * @subpackage Core - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Curverider Ltd - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.org/ - * - */ - - if (!isset($vars['offset'])) { - $offset = 0; - } else { - $offset = $vars['offset']; - } - if ((!isset($vars['limit'])) || (!$vars['limit'])) { - $limit = 10; - } else { - $limit = (int)$vars['limit']; - } - if (!isset($vars['count'])) { - $count = 0; - } else { - $count = $vars['count']; - } - if (!isset($vars['word'])) { - $word = "offset"; - } else { - $word = $vars['word']; - } - if (isset($vars['nonefound'])) { - $nonefound = $vars['nonefound']; - } else { - $nonefound = true; - } - - $totalpages = ceil($count / $limit); - $currentpage = ceil($offset / $limit) + 1; - - //only display if there is content to paginate through or if we already have an offset - if (($count > $limit || $offset > 0) && get_context() != 'widget') { - -?> - -<div class="pagination"> -<?php - - if ($offset > 0) { - $prevoffset = $offset - $limit; - if ($prevoffset < 0) { - $prevoffset = 0; - } - - $prevurl = elgg_http_add_url_query_elements($baseurl, array($word => $prevoffset)); - - echo "<a onclick=\"javascript:$('.popup .content').load('{$prevurl}'); return false\" href=\"#\" class=\"pagination_previous\">« ". elgg_echo("previous") ."</a> "; - - } - - if ($offset > 0 || $offset < ($count - $limit)) { - - $currentpage = round($offset / $limit) + 1; - $allpages = ceil($count / $limit); - - $i = 1; - $pagesarray = array(); - while ($i <= $allpages && $i <= 4) { - $pagesarray[] = $i; - $i++; - } - $i = $currentpage - 2; - while ($i <= $allpages && $i <= ($currentpage + 2)) { - if ($i > 0 && !in_array($i,$pagesarray)) - $pagesarray[] = $i; - $i++; - } - $i = $allpages - 3; - while ($i <= $allpages) { - if ($i > 0 && !in_array($i,$pagesarray)) - $pagesarray[] = $i; - $i++; - } - - sort($pagesarray); - - $prev = 0; - foreach($pagesarray as $i) { - - if (($i - $prev) > 1) { - - echo "<span class='pagination_more'>...</span>"; - - } - - $curoffset = (($i - 1) * $limit); - $counturl = elgg_http_add_url_query_elements($base_url, array($word => $curoffset)); - - if ($curoffset != $offset) { - echo " <a onclick=\"javascript:$('.popup .content').load('{$counturl}'); return false\" href=\"#\" class=\"pagination_number\">{$i}</a> "; - } else { - echo "<span class='pagination_currentpage'> {$i} </span>"; - } - $prev = $i; - - } - - } - - if ($offset < ($count - $limit)) { - - $nextoffset = $offset + $limit; - if ($nextoffset >= $count) { - $nextoffset--; - } - - $nexturl = elgg_http_add_url_query_elements($baseurl, array($word => $nextoffset)); - - echo " <a onclick=\"javascript:$('.popup .content').load('{$nexturl}'); return false\" href=\"#\" class=\"pagination_next\">" . elgg_echo("next") . " »</a>"; - - } - -?> -</div> -<?php - } // end of pagination check if statement -?> diff --git a/mod/embed/views/default/embed/simpletype.php b/mod/embed/views/default/embed/simpletype.php deleted file mode 100644 index 790284fd8..000000000 --- a/mod/embed/views/default/embed/simpletype.php +++ /dev/null @@ -1,35 +0,0 @@ -<select name="simpletype" id="embed_simpletype_select"> -<?php - - $all = new stdClass; - $all->tag = "all"; - $vars['simpletypes'][] = $all; - $vars['simpletypes'] = array_reverse($vars['simpletypes']); - - if (isset($vars['simpletypes']) && is_array($vars['simpletypes'])) - foreach($vars['simpletypes'] as $type) { - - if ($vars['simpletype'] == $type->tag || (empty($vars['simpletype']) && $type->tag == 'all')) { - $selected = 'selected = "selected"'; - } else $selected = ''; - $tag = $type->tag; - if ($tag != "all") { - $label = elgg_echo("file:type:" . $tag); - } else { - $tag = ''; - $label = elgg_echo('all'); - } - -?> - <option <?php echo $selected; ?> value="<?php echo $tag; ?>"><?php echo $label; ?></option> -<?php - } -?> -</select> -<script type="text/javascript"> - $('#embed_simpletype_select').change(function(){ - var simpletype = $('#embed_simpletype_select').val(); - var url = '<?php echo $vars['url']; ?>pg/embed/media?simpletype=' + simpletype + '&internalname=<?php echo $vars['internalname']; ?>'; - $('.popup .content').load(url); - }); -</script> diff --git a/mod/embed/views/default/embed/tabs.php b/mod/embed/views/default/embed/tabs.php deleted file mode 100644 index a83bc9b55..000000000 --- a/mod/embed/views/default/embed/tabs.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - - $embedselected = ''; - $uploadselected = ''; - if ($vars['tab'] == 'media') { - $embedselected = 'class="embed_tab_selected"'; - } else { - $uploadselected = 'class="embed_tab_selected"'; - } - -?> - -<div id="embed_media_tabs" class="clearfloat"> - <ul> - <li> - <a href="#" <?php echo $embedselected; ?> onclick="javascript:$('.popup .content').load('<?php echo $vars['url'] . 'pg/embed/media'; ?>?internalname=<?php echo $vars['internalname']; ?>'); return false"><?php echo elgg_echo('embed:media'); ?></a> - </li> - <li> - <a href="#" <?php echo $uploadselected; ?> onclick="javascript:$('.popup .content').load('<?php echo $vars['url'] . 'pg/embed/upload'; ?>?internalname=<?php echo $vars['internalname']; ?>'); return false"><?php echo elgg_echo('upload:media'); ?></a> - </li> - </ul> -</div>
\ No newline at end of file diff --git a/mod/embed/views/default/embed/upload.php b/mod/embed/views/default/embed/upload.php deleted file mode 100644 index d995b4b2b..000000000 --- a/mod/embed/views/default/embed/upload.php +++ /dev/null @@ -1,85 +0,0 @@ -<h2 class="media_modal_title">Embed / Upload Media</h2> -<?php - -echo elgg_view('embed/tabs',array('tab' => 'upload', 'internalname'=>get_input('internalname'))); - -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> - <label for="upload"><?php echo elgg_echo("file:file"); ?><br /> - <?php - echo elgg_view('input/securitytoken'); - echo elgg_view("input/file",array('internalname' => 'upload', 'js' => 'id="upload"')); - - ?> - </label></p> - <p> - <label><?php echo elgg_echo("title"); ?><br /> - <?php - - echo elgg_view("input/text", array( - "internalname" => "title", - "value" => $title, - )); - - ?> - </label> - </p> - <p> - <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 - echo elgg_view("input/tags", array( - "internalname" => "tags", - "value" => $tags, - )); - - ?> - </label> - </p> - <p> - <label> - <?php echo elgg_echo('access'); ?><br /> - <?php echo elgg_view('input/access', array('internalname' => 'access_id','value' => ACCESS_DEFAULT)); ?> - </label> - </p> - - <p> - <?php - - if (isset($vars['container_guid'])) - 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> - -<?php - -} - -?> diff --git a/mod/embed/views/default/group/default/embed.php b/mod/embed/views/default/group/default/embed.php deleted file mode 100644 index 34a0d0c61..000000000 --- a/mod/embed/views/default/group/default/embed.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - if ($vars['entity'] instanceof ElggGroup) { - echo '<a href="'. $vars['entity']->getURL() .'">' . $vars['entity']->title . '</a>'; - } -?>
\ No newline at end of file diff --git a/mod/embed/views/default/js/embed/embed.php b/mod/embed/views/default/js/embed/embed.php new file mode 100644 index 000000000..e84427f24 --- /dev/null +++ b/mod/embed/views/default/js/embed/embed.php @@ -0,0 +1,147 @@ +//<script> +elgg.provide('elgg.embed'); + +elgg.embed.init = function() { + + // inserts the embed content into the textarea + $(".embed-item").live('click', elgg.embed.insert); + + // caches the current textarea id + $(".embed-control").live('click', function() { + var classes = $(this).attr('class'); + var embedClass = classes.split(/[, ]+/).pop(); + var textAreaId = embedClass.substr(embedClass.indexOf('embed-control-') + "embed-control-".length); + elgg.embed.textAreaId = textAreaId; + }); + + // special pagination helper for lightbox + $('.embed-wrapper .elgg-pagination a').live('click', elgg.embed.forward); + + $('.embed-section').live('click', elgg.embed.forward); + + $('.elgg-form-embed').live('submit', elgg.embed.submit); +}; + +/** + * Inserts data attached to an embed list item in textarea + * + * @todo generalize lightbox closing + * + * @param {Object} event + * @return void + */ +elgg.embed.insert = function(event) { + var textAreaId = elgg.embed.textAreaId; + var textArea = $('#' + textAreaId); + + // generalize this based on a css class attached to what should be inserted + var content = ' ' + $(this).find(".embed-insert").parent().html() + ' '; + + // this is a temporary work-around for #3971 + if (content.indexOf('thumbnail.php') != -1) { + content = content.replace('size=small', 'size=medium'); + } + + textArea.val(textArea.val() + content); + textArea.focus(); + +<?php +// See the TinyMCE plugin for an example of this view +echo elgg_view('embed/custom_insert_js'); +?> + + $.fancybox.close(); + + event.preventDefault(); +}; + +/** + * Submit an upload form through Ajax + * + * Requires the jQuery Form Plugin. Because files cannot be uploaded with + * XMLHttpRequest, the plugin uses an invisible iframe. This results in the + * the X-Requested-With header not being set. To work around this, we are + * sending the header as a POST variable and Elgg's code checks for it in + * elgg_is_xhr(). + * + * @param {Object} event + * @return bool + */ +elgg.embed.submit = function(event) { + $('.embed-wrapper .elgg-form-file-upload').hide(); + $('.embed-throbber').show(); + + $(this).ajaxSubmit({ + dataType : 'json', + data : { 'X-Requested-With' : 'XMLHttpRequest'}, + success : function(response) { + if (response) { + if (response.system_messages) { + elgg.register_error(response.system_messages.error); + elgg.system_message(response.system_messages.success); + } + if (response.status >= 0) { + var forward = $('input[name=embed_forward]').val(); + var url = elgg.normalize_url('embed/tab/' + forward); + url = elgg.embed.addContainerGUID(url); + $('.embed-wrapper').parent().load(url); + } else { + // incorrect response, presumably an error has been displayed + $('.embed-throbber').hide(); + $('.embed-wrapper .elgg-form-file-upload').show(); + } + } + + // ie 7 and 8 have a null response because of the use of an iFrame + // so just show the list after upload. + // http://jquery.malsup.com/form/#file-upload claims you can wrap JSON + // in a textarea, but a quick test didn't work, and that is fairly + // intrusive to the rest of the ajax system. + else if (response === undefined && $.browser.msie) { + var forward = $('input[name=embed_forward]').val(); + var url = elgg.normalize_url('embed/tab/' + forward); + url = elgg.embed.addContainerGUID(url); + $('.embed-wrapper').parent().load(url); + } + }, + error : function(xhr, status) { + // @todo nothing for now + } + }); + + // this was bubbling up the DOM causing a submission + event.preventDefault(); + event.stopPropagation(); +}; + +/** + * Loads content within the lightbox + * + * @param {Object} event + * @return void + */ +elgg.embed.forward = function(event) { + // make sure container guid is passed + var url = $(this).attr('href'); + url = elgg.embed.addContainerGUID(url); + + $('.embed-wrapper').parent().load(url); + event.preventDefault(); +}; + +/** + * Adds the container guid to a URL + * + * @param {string} url + * @return string + */ +elgg.embed.addContainerGUID = function(url) { + if (url.indexOf('container_guid=') == -1) { + var guid = $('input[name=embed_container_guid]').val(); + return url + '?container_guid=' + guid; + } else { + return url; + } +}; + +elgg.register_hook_handler('init', 'system', elgg.embed.init); diff --git a/mod/embed/views/default/navigation/menu/embed.php b/mod/embed/views/default/navigation/menu/embed.php new file mode 100644 index 000000000..bca673f59 --- /dev/null +++ b/mod/embed/views/default/navigation/menu/embed.php @@ -0,0 +1,18 @@ +<?php +/** + * Embed tabs + * + * @uses $vars['menu']['default'] + */ + +$tabs = array(); +foreach ($vars['menu']['default'] as $menu_item) { + $tabs[] = array( + 'title' => $menu_item->getText(), + 'url' => 'embed/tab/' . $menu_item->getName(), + 'link_class' => 'embed-section', + 'selected' => $menu_item->getSelected(), + ); +} + +echo elgg_view('navigation/tabs', array('tabs' => $tabs)); diff --git a/mod/embed/views/default/object/default/embed.php b/mod/embed/views/default/object/default/embed.php deleted file mode 100644 index 6f698a157..000000000 --- a/mod/embed/views/default/object/default/embed.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - if ($vars['entity'] instanceof ElggObject) { - echo '<a href="'. $vars['entity']->getURL() .'">' . $vars['entity']->title . '</a>'; - } -?>
\ No newline at end of file diff --git a/mod/embed/views/default/object/file/embed.php b/mod/embed/views/default/object/file/embed.php deleted file mode 100644 index b93c46e5e..000000000 --- a/mod/embed/views/default/object/file/embed.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php - $mime = $vars['entity']->mimetype; - - if (elgg_view_exists('file/specialcontent/' . $mime)) { - $content = elgg_view('file/specialcontent/' . $mime, $vars); - } else if (elgg_view_exists("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default")) { - $content = elgg_view("file/specialcontent/" . substr($mime,0,strpos($mime,'/')) . "/default", $vars); - } - - if (empty($content) || substr_count(strtolower($content),'<embed') || substr_count(strtolower($content),'<object') || substr_count(strtolower($content),'<script')) { - echo elgg_view('object/default/embed',$vars); - } else { - echo $content; - } - -?>
\ No newline at end of file diff --git a/mod/embed/views/default/object/file/embedlist.php b/mod/embed/views/default/object/file/embedlist.php deleted file mode 100644 index 345e69b4b..000000000 --- a/mod/embed/views/default/object/file/embedlist.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - $file = $vars['entity']; - $friendlytime = friendly_time($vars['entity']->time_created); - - $info = "<p class='entity_title'> <a href=\"{$file->getURL()}\">{$file->title}</a></p>"; - $info .= "<p class='entity_subtext'>{$friendlytime}"; - $icon = "<a href=\"{$file->getURL()}\">" . elgg_view("file/icon", array("mimetype" => $file->mimetype, 'thumbnail' => $file->thumbnail, 'file_guid' => $file->guid, 'size' => 'small')) . "</a>"; -?> -<div id="embed_entity_<?php echo $file->guid; ?>"> - <div class="entity_listing clearfloat"> - <div class="entity_listing_icon"> - <?php echo $icon; ?> - </div> - <div class="entity_listing_info"> - <?php echo $info; ?> - </div> - </div> -</div> diff --git a/mod/embed/views/default/site/default/embed.php b/mod/embed/views/default/site/default/embed.php deleted file mode 100644 index 2e8920a9a..000000000 --- a/mod/embed/views/default/site/default/embed.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - if ($vars['entity'] instanceof ElggSite) { - echo '<a href="'. $vars['entity']->getURL() .'">' . $vars['entity']->name . '</a>'; - } -?>
\ No newline at end of file diff --git a/mod/embed/views/default/user/default/embed.php b/mod/embed/views/default/user/default/embed.php deleted file mode 100644 index df538c94c..000000000 --- a/mod/embed/views/default/user/default/embed.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php - if ($vars['entity'] instanceof ElggUser) { - echo '<a href="'. $vars['entity']->getURL() .'">' . $vars['entity']->name . '</a>'; - } -?>
\ No newline at end of file |
