<inp2:m_include t="incs/header"/>
<inp2:m_RenderElement name="combined_header" prefix="adm" section="in-portal:service" title_preset="system_tools"/>

<script type="text/javascript">
	function show_structure($prefix, $event) {
		open_popup('adm', $event, 'table_structure', '800x575');
	}

	function check_prefix_config() {
		open_popup('adm', 'OnCheckPrefixConfig', 'config_check', '800x575');
	}

	function compile_templates()
	{
		openwin('<inp2:m_Link template="tools/compile_templates" m_wid="100"/>', 'compile', 800, 575);
	}
</script>

<inp2:m_DefineElement name="service_elem" event_prefix="adm">
	<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
		<inp2:m_inc param="tab_index" by="1"/>
		<td class="text" style="width: 300px;">
			<inp2:m_param name="title"/>
		</td>
		<td valign="top" colspan="2">
			<input class="button" type="button" onclick="submit_event('<inp2:m_param name="event_prefix"/>', '<inp2:m_param name="event_name"/>');" value="Run">
		</td>
	</tr>
</inp2:m_DefineElement>

<table width="100%" cellspacing="0" cellpadding="4" class="bordered">
	<!--##<inp2:m_RenderElement name="subsection" title="la_section_General"/>##-->
		<inp2:m_RenderElement name="service_elem" title="Reset mod_rewrite Cache" event_name="OnResetModRwCache"/>
		<inp2:m_RenderElement name="service_elem" title="Reset SMS Menu Cache" event_prefix="c" event_name="OnResetCMSMenuCache"/>
		<inp2:m_RenderElement name="service_elem" title="Reset Sections Cache" event_name="OnResetSections"/>
		<inp2:m_RenderElement name="service_elem" title="Reset Configs Cache" event_name="OnResetConfigsCache"/>
		<inp2:m_RenderElement name="service_elem" title="Re-build Multilanguage Fields" event_prefix="lang" event_name="OnReflectMultiLingualFields"/>

	<inp2:m_RenderElement name="subsection" title="la_section_Templates"/>
		<inp2:m_RenderElement name="service_elem" title="Re-build Themes Files" event_name="OnRebuildThemes"/>
		<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
			<inp2:m_inc param="tab_index" by="1"/>
			<td class="text" style="width: 300px;">
				Re-compile Templates
			</td>
			<td valign="top" colspan="2">
				<input class="button" type="button" onclick="compile_templates();" value="Run">
			</td>
		</tr>
		<inp2:m_RenderElement name="service_elem" title="Clear Templates Cache" event_name="OnDeleteCompiledTemplates"/>
	<inp2:m_RenderElement name="subsection" title="la_section_Configs"/>
		<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
			<inp2:m_inc param="tab_index" by="1"/>
			<td class="text" style="width: 300px;">
				Table Structure:
			</td>
			<td valign="top" colspan="2">
				<input type="text" name="table_name" value="" size="30"/>
				<input class="button" type="button" onclick="show_structure('adm', 'OnGenerateTableStructure');" value="Run">
				<span class="small">table name (table prefix is optional) OR "unit config" prefix</span>
			</td>
		</tr>

		<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
			<inp2:m_inc param="tab_index" by="1"/>
			<td class="text" style="width: 300px;">
				Locate Unit Config File:
			</td>
			<td valign="top" colspan="2">
				<input type="text" name="config_prefix" value="" size="30"/>
				<input class="button" type="button" onclick="check_prefix_config();" value="Run">
				<span class="small">unit config prefix</span>
			</td>
		</tr>
	<inp2:m_if check="adm_MemoryCacheEnabled">
		<inp2:m_RenderElement name="subsection" title="la_section_MemoryCache"/>
			<inp2:m_RenderElement name="service_elem" title="Reset All Keys" event_name="OnResetMemcache"/>

			<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
				<inp2:m_inc param="tab_index" by="1"/>
				<td class="text" style="width: 300px;">
					Key Name:
				</td>
				<td valign="top" colspan="2">
					<table cellpadding="0" cellspacing="0">
						<tr>
							<td colspan="2">
								<a href="#" class="quick-memory-cache-key">master:configs_parsed</a>,
								<a href="#" class="quick-memory-cache-key">master:config_files</a>,
								<a href="#" class="quick-memory-cache-key">master:sections_parsed</a>,
								<a href="#" class="quick-memory-cache-key">master:cms_menu</a>,
								<a href="#" class="quick-memory-cache-key">master:template_mapping</a>,
								<a href="#" class="quick-memory-cache-key">master:StructureTree</a>
								<br/>
								<br/>
							</td>
						</tr>
						<tr>
							<td style="width: 440px;">
								<input type="text" id="memory_cache_key_name" value="" style="width: 440px;"/>
							</td>
							<td style="padding-bottom: 2px; padding-left: 4px;">
								<input type="button" class="button" id="memory_cache_get" value="Get Value"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr class="<inp2:m_odd_even odd='table-color1' even='table-color2'/>">
				<inp2:m_inc param="tab_index" by="1"/>
				<td class="text" style="width: 300px;">
					Key Value:
				</td>
				<td valign="top" colspan="2">
					<table cellpadding="0" cellspacing="0">
						<tr>
							<td valign="bottom">
								<textarea id="memory_cache_key_value" style="width: 440px; height: 120px;"></textarea>
							</td>
							<td valign="bottom" style="padding-bottom: 2px; padding-left: 4px;">
								<input type="button" class="button" id="memory_cache_set" value="Set Value"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
	</inp2:m_if>
</table>

<script type="text/javascript">
	<inp2:m_if check="m_Get" name="refresh_tree">
		getFrame('menu').location.reload();
	</inp2:m_if>

	<inp2:m_if check="adm_MemoryCacheEnabled">
		$(document).ready(
			function () {
				$('#memory_cache_get').click(
					function ($e) {
						var $me = $(this);

						$me.attr('disabled', 'disabled').removeClass('button').addClass('button-disabled');

						$.post(
							'<inp2:m_Link template="dummy" pass="m,adm" adm_event="OnMemoryCacheGet" js_escape="1" no_amp="1"/>',
							{
								key: $('#memory_cache_key_name').val()
							},
							function ($data) {
								$data = eval('(' + $data + ')');

								if ($data.code === 0) {
									if (confirm('Data Size: ' + $data.size + '. Type: ' + $data.type + '. Display data?')) {
										$('#memory_cache_key_value').val($data.value);
									}
								}
								else {
									alert($data.message);
								}

								$me.attr('disabled', '').addClass('button').removeClass('button-disabled');
							}
						);

					}
				);

				$('a.quick-memory-cache-key').click(
					function ($e) {
						$('#memory_cache_key_name').val( $(this).text() );
						$('#memory_cache_get').click();

						return false;
					}
				);

				$('#memory_cache_set').click(
					function ($e) {
						var $me = $(this);

						$me.attr('disabled', 'disabled').removeClass('button').addClass('button-disabled');

						$.post(
							'<inp2:m_Link template="dummy" pass="m,adm" adm_event="OnMemoryCacheSet" js_escape="1" no_amp="1"/>',
							{
								key: $('#memory_cache_key_name').val(),
								value: $('#memory_cache_key_value').val()
							},
							function ($data) {
								$data = eval('(' + $data + ')');

								if ($data.code === 0) {
									alert($data.result);
								}
								else {
									alert($data.message);
								}

								$me.attr('disabled', '').addClass('button').removeClass('button-disabled');
							}
						);

					}
				);
			}
		);
	</inp2:m_if>
</script>

<inp2:m_include t="incs/footer"/>