diff options
Diffstat (limited to 'mod/embed/views/default')
| -rw-r--r-- | mod/embed/views/default/embed/addcontentjs.php | 7 | ||||
| -rw-r--r-- | mod/embed/views/default/embed/css.php | 37 | ||||
| -rw-r--r-- | mod/embed/views/default/embed/item.php | 39 | ||||
| -rw-r--r-- | mod/embed/views/default/embed/layout.php | 40 | ||||
| -rw-r--r-- | mod/embed/views/default/embed/list.php | 58 | ||||
| -rw-r--r-- | mod/embed/views/default/js/embed/embed.php | 147 | ||||
| -rw-r--r-- | mod/embed/views/default/navigation/menu/embed.php | 18 | 
7 files changed, 346 insertions, 0 deletions
diff --git a/mod/embed/views/default/embed/addcontentjs.php b/mod/embed/views/default/embed/addcontentjs.php new file mode 100644 index 000000000..ffed211f5 --- /dev/null +++ b/mod/embed/views/default/embed/addcontentjs.php @@ -0,0 +1,7 @@ +<?php  +/** + * Blank for compatibility. + * @deprecated 1.8 + */ + +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 new file mode 100644 index 000000000..034c0fcfe --- /dev/null +++ b/mod/embed/views/default/embed/css.php @@ -0,0 +1,37 @@ +<?php +/** + * Elgg embed CSS - standard across all themes + *  + * @package embed + */ +?> +.embed-wrapper { +	width: 730px; +	min-height: 400px; +	margin: 20px 15px; +} +.embed-wrapper h2 { +	color: #333333; +	margin-bottom: 10px; +} +.embed-wrapper .elgg-item { +	cursor: pointer; +} + +/* *************************************** +	EMBED TABBED PAGE NAVIGATION +*************************************** */ +.embed-wrapper .elgg-tabs a:hover { +	color: #666; +} + +.embed-wrapper p { +	color: #333; +} +.embed-item { +	padding-left: 5px; +	padding-right: 5px; +} +.embed-item:hover { +	background-color: #eee; +} 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/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/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/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));  | 
