Location: PHPKode > scripts > Avatar Tools > views/extensions.php
<?php
/**
 * @version		$Id: coolfeed.php 100 2012-04-14 17:42:51Z hide@address.com $
 * @copyright	JoomAvatar.com
 * @author		Nguyen Quang Trung
 * @link		http://joomavatar.com
 * @license		License GNU General Public License version 2 or later http://www.gnu.org/licenses/gpl-2.0.html
 * @package		Avatar Dream Framework Template
 * @facebook 	http://www.facebook.com/pages/JoomAvatar/120705031368683
 * @twitter	    https://twitter.com/#!/JoomAvatar
 * @support 	http://joomavatar.com/forum/
 */

// no direct access
defined('_JEXEC') or die; 
?>
<script type="text/javascript">
	
	jQuery.noConflict();
	
	(function($) 
	{ 
		$(document).ready( function()
		{	
			var searchExtsRequest;
			
			$('#avatar-tool-extensions-search').keyup(function()
			{
				if (searchExtsRequest !== undefined) {
					searchExtsRequest.abort();
				}
				
				searchExtsRequest = $.ajax({
				  	url: "index.php?option=avatar-tool&controller=ajax&task=extensionsSearch",
				  	type: "POST",
				  	data: $("#avatar-tool-form-extensions").serialize(),
				  	dataType: "json",
				});	
				
				searchExtsRequest.done(function(data) 
				{
					var items = $('#avatar-tool-extensions-search-results');
					var html = '';
					
				  	data.each(function (el, index)
				  	{
				  		index++;
				  		
				  		if (el.enabled == '1') {
				  			publish = 'extension-publish';
				  		} else {
				  			publish = 'extension-unpublish';
				  		}
				  		
				  		html += '<li class="item ' + publish + ' ' + el.type + '">';
				  		html += '<form id="extension-'+ el.extension_id +'">';
				  		html += '<input type="hidden" name="extension_id" value="'+ $.addslashes(el.extension_id) +'">';
				  		html += '<h3 class="title">' + index + ' - ' + el.name + '</h3>';
				  		html += '<div class="details">';
				  		
				  		html += '<span class="action click"><strong><?php echo JText::_('AVATAR_TOOL_PUBLISH', true); ?></strong> <span class="publish state'+ el.enabled +'"></span></span>';
				  		html += '<span class="action click"><strong><?php echo JText::_('AVATAR_TOOL_ACCESS'); ?></strong> <span class="text access">'+ el.access_level +'</span></span>';
				  		html += '<span class="action element"><strong><?php echo JText::_('AVATAR_TOOL_ELEMENT'); ?></strong> <span class="text">'+ el.element +'</span></span>';
				  		html += '<span class="action type"><strong><?php echo JText::_('AVATAR_TOOL_TYPE'); ?></strong> <span class="text">'+ el.type +'</span></span>';
				  		html += '<span style="clear:both;"></span>';
				  		html += '</div>';
				  		
				  		if (el.type == 'plugin') 
				  		{
					  		html += '<div>';
					  		html += '<span class="avatar-tool-button">';
			  				html += '<a href="index.php?option=com_plugins&task=plugin.edit&extension_id='+ el.extension_id +'"><?php echo JText::_('AVATAR_TOOL_BUTTON_EDIT',true); ?></a>';
			  				html += '</span>';
					  		html += '</div>';
				  		}
				  		
				  		html += '</form>';
				  		html += '</li>';
				  	})
				  	
				  	items.html(html);
				  	
				  	var extensionForms 	= $('#avatar-tool-extensions-search-results form');
				  	var buttonPublishs 	= $('#avatar-tool-extensions-search-results .details .publish');
			  		
				  	buttonPublishs.each(function(index)
				  	{
				  		$(this).click(function()
			  			{
			  				var el = $(this);
			  				var state = 0;
			  				
			  				if (el.hasClass('state1')) {
			  					el.removeClass('state1').addClass('state0');
			  					state = 0;
			  				} else if (el.hasClass('state0')) {
			  					el.removeClass('state0').addClass('state1');
			  					state = 1;
			  				};
			  			
			  				request = $.ajax({
							  	url: "index.php?option=avatar-tool&controller=ajax&task=extensionPublish",
							  	type: "POST",
							  	data: $('#' + extensionForms[index].get('id')).serialize() + '&enabled=' + state,
							  	dataType: "json",
							});	
			  			});
				  	})
				  	
				  	var buttonAccess = $('#avatar-tool-extensions-search-results .details .access');
					
				  	buttonAccess.each(function(index)
				  	{
				  		var access = $(this);
				  		access.click(function()
				  		{
				  			$('#avatar-tool-subview-access').dialog({
				  				zIndex: 900,
				  				open: function(event, ui)
				  				{
				  					request = $.ajax({
									  	url: "index.php?option=avatar-tool&controller=ajax&task=accessGet",
									  	type: "GET",
									  	dataType: "json",
									});	
									
									request.done(function(data)
									{
										if ($.isArray(data)) 
										{
											var html = '';
											data.each(function(index)
											{
												html += '<p class="avatar-tool-button button-tag">' + $(index)[0].title;
												html += '<input type="hidden" name="access" value="'+ $.addslashes($(index)[0].id) +'"></p>';
											});
											
											html += '<p style="clear: both;"></p>'
											
											$('#avatar-tool-subview-access').html(html);
											
											$('#avatar-tool-subview-access .button-tag').each(function(el){
												$(this).draggable({
													revert: true,
													stack: "#avatar-tool-subview-access .button-tag",
													helper:'clone',
													appendTo: 'body',
													zIndex: 910,
													start: function(){
														$('#avatar-toolbar .details .access').each(function(index){
															$(this).css('background','#137BAF');
														});
													},
													stop: function(){
														$('#avatar-toolbar .details .access').each(function(index){
															$(this).css('background','');
														});
													}
											    });
												
											});
										}
									})
				  				}
				  			});
				  		});
				  		
				  		access.droppable(
				  		{
				  			accept: "#avatar-tool-subview-access .button-tag",
							drop: function(event, ui) 
							{ 
						   		$(this).html(ui.draggable.html());
						   		 
						   		request = $.ajax({
								  	url: "index.php?option=avatar-tool&controller=ajax&task=extensionAccessUpdate",
								  	type: "POST",
								  	data: $('#' + extensionForms[index].get('id')).serialize(),
								  	dataType: "json",
								});	
							}
						});
				  	});
				});	
			});
		})		
	})(jQuery);
</script>
<div class="avatar-view" id="avatar-view-extensions">
	<form id="avatar-tool-form-extensions" name="avatar-tool-form-extensions">
		<ul class="list-item">
			<li class="item">
				<p class="label"><?php echo JText::_('AVATAR_TOOL_EXTENSIONS_SEARCH'); ?></p>
				<p class="description"><?php echo JText::_('AVATAR_TOOL_EXTENSIONS_SEARCH_DESC') ?></p>
				<input id="avatar-tool-extensions-search" size="50" name="search"/>	
				<p class="description"><?php echo JText::_('AVATAR_TOOL_EXTENSIONS_SEARCH_OPTIONS_DESC') ?></p>
				<input type="text" name="search-options[limit]" value="100" size="5"/> <?php echo JText::_('AVATAR_TOOL_LIMIT'); ?> &nbsp;&nbsp;
				<br/><br/>
				<span class="avatar-tool-button" onclick="AvatarTools.fillter.reset('#avatar-tool-extensions-search-results li');" > <?php echo JText::_('AVATAR_TOOL_ARTICLE_RESET'); ?></span> &nbsp;&nbsp;
				<span class="avatar-tool-button" onclick="AvatarTools.fillter.fillter('extension-publish', '#avatar-tool-extensions-search-results li');" > <?php echo JText::_('AVATAR_TOOL_ARTICLE_PUBLISH'); ?></span> &nbsp;&nbsp;
				<span class="avatar-tool-button" onclick="AvatarTools.fillter.fillter('extension-unpublish', '#avatar-tool-extensions-search-results li');" > <?php echo JText::_('AVATAR_TOOL_ARTICLE_UNPUBLISH'); ?></span> &nbsp;&nbsp;
				<span class="avatar-tool-button" onclick="AvatarTools.fillter.fillter('component', '#avatar-tool-extensions-search-results li');" > <?php echo JText::_('AVATAR_TOOL_COMPONENT'); ?></span> &nbsp;&nbsp;
				<span class="avatar-tool-button" onclick="AvatarTools.fillter.fillter('module', '#avatar-tool-extensions-search-results li');" > <?php echo JText::_('AVATAR_TOOL_MODULE'); ?></span> &nbsp;&nbsp;
				<span class="avatar-tool-button" onclick="AvatarTools.fillter.fillter('plugin', '#avatar-tool-extensions-search-results li');" > <?php echo JText::_('AVATAR_TOOL_PLUGIN'); ?></span> &nbsp;&nbsp;
				<span class="avatar-tool-button" onclick="AvatarTools.fillter.fillter('template', '#avatar-tool-extensions-search-results li');" > <?php echo JText::_('AVATAR_TOOL_TEMPLATE'); ?></span> &nbsp;&nbsp;
			</li>
		</ul>	
	</form>
	
	<ul id="avatar-tool-extensions-search-results" class="list-item">
		
	</ul>	
</div>
Return current item: Avatar Tools