<!-- plugins tpl -->

<div id="update_area" class="hide">
	{include file='blocks'|cat:$smarty.const.RL_DS|cat:'m_block_start.tpl'}
	<div id="update_info">
		{assign var='replace_ver' value=`$smarty.ldelim`version`$smarty.rdelim`}
		{assign var='replace_name' value=`$smarty.ldelim`name`$smarty.rdelim`}
		<div>{$lang.plugin_update_request_hint|replace:$replace_ver:'<b><span id="update_version"></span></b>'|replace:$replace_name:'<span id="update_link"></span>'}</div>
		<input id="start_update" type="button" value="{$lang.update}" />
		<a onclick="$('#update_area').slideUp();" class="cancel" href="javascript:void(0);">{$lang.cancel}</a>
	</div>
	<div id="update_progress" class="hide">
		<div class="dark_12"><b id="plugin_name"></b> {$lang.plugin_is_updating}</div>
		<div class="progress static" style="padding: 5px 0 0;">{$lang.remote_progress_backingup}</div>
	</div>
	{include file='blocks'|cat:$smarty.const.RL_DS|cat:'m_block_end.tpl'}
</div>

<script type="text/javascript">//<![CDATA[
var plugin_updating_phrase = "{$lang.remote_progress_updating}";
var plugin_update_notice = "{$lang.remote_plugin_update_notice}";
var update_plugin_key;
{literal}

$(document).ready(function(){
	$('#start_update').click(function(){
		rlConfirm(plugin_update_notice, 'startUpdate');
	});
});

var startUpdate = function(){
	$('#update_info').fadeOut(function(){
		$('#update_progress').fadeIn();
		xajax_remoteUpdate(update_plugin_key, true);
	});
};

var continueUpdating = function(key){
	$('div#progress div.progress').html(plugin_updating_phrase);
	
	xajax_update(key);
};

var hideProgressBar = function(){
	$('#update_progress').fadeOut();
};

{/literal}
//]]>
</script>

<!-- plugins grid -->
<div id="grid"></div>
<script type="text/javascript">//<![CDATA[
var listingPlansGrid;

{literal}
$(document).ready(function(){
	
	pluginsGrid = new gridObj({
		key: 'plugins',
		id: 'grid',
		ajaxUrl: rlUrlHome + 'controllers/plugins.inc.php?q=ext',
		defaultSortField: 'Name',
		title: lang['ext_plugins_manager'],
		fields: [
			{name: 'ID', mapping: 'ID'},
			{name: 'Name', mapping: 'Name', type: 'string'},
			{name: 'Key', mapping: 'Key'},
			{name: 'Description', mapping: 'Description', type: 'string'},
			{name: 'Version', mapping: 'Version'},
			{name: 'Status', mapping: 'Status'}
		],
		columns: [
			{
				header: lang['ext_name'],
				dataIndex: 'Name',
				width: 30,
				id: 'rlExt_item_bold'
			},{
				header: lang['ext_description'],
				dataIndex: 'Description',
				width: 60
			},{
				header: lang['ext_version'],
				dataIndex: 'Version',
				width: 12
			},{
				header: lang['ext_status'],
				dataIndex: 'Status',
				width: 12,
				editor: new Ext.form.ComboBox({
					store: [
						['active', lang['ext_active']],
						['approval', lang['ext_approval']]
					],
					displayField: 'value',
					valueField: 'key',
					typeAhead: true,
					mode: 'local',
					triggerAction: 'all',
					selectOnFocus:true
				})
			},{
				header: lang['ext_actions'],
				width: 70,
				fixed: true,
				dataIndex: 'Key',
				sortable: false,
				renderer: function(value) {
					var complete = value.split('|');
					var out = "<center>";

					if (complete[1] == 'not_installed')
					{
						out += "<img class='install' title='"+lang['ext_install']+"' src='"+rlUrlHome+"img/blank.gif' onclick='xajax_install(\""+complete[0]+"\");$(this).animate({opacity: 0.5}, \"slow\").attr(\"onclick\", \"\");' />";
					}
					else
					{
						out += "<img class='update' title='"+lang['ext_check_for_update']+"' src='"+rlUrlHome+"img/blank.gif' onclick='xajax_checkForUpdate(\""+complete[0]+"\");' />";
						out += "<img class='uninstall' title='"+lang['ext_uninstall']+"' src='"+rlUrlHome+"img/blank.gif' onclick='rlConfirm( \""+lang['ext_plugin_uninstall']+"\", \"xajax_unInstall\", \""+Array(value)+"\" )' />";
					}
					out += "</center>";
					
					return out;
				}
			}
		]
	});
	
	{/literal}{rlHook name='apTplPluginsGrid'}{literal}
	
	pluginsGrid.init();
	grid.push(pluginsGrid.grid);
	
	pluginsGrid.grid.addListener('beforeedit', function(editEvent)
	{
		if( editEvent.value == 'not_installed' )
		{
			pluginsGrid.store.rejectChanges();
			Ext.MessageBox.alert(lang['ext_notice'], lang['ext_need_install']);
		}
	});
	
});
{/literal}
//]]>
</script>
<!-- plugins grid end -->

{rlHook name='apTplPluginsBottom'}

<!-- plugins tpl end -->