<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>

<br />

<div style="float: left; width: 49%;">
	<div class="summary-box">
		<div class="title">
			<inp2:m_Phrase name="la_section_Configs"/>
		</div>
		<div class="content">
			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsResetParsedCachedData"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsResetParsedCachedData"/>
					<div class="cache-key">
						<strong><inp2:m_Phrase name="la_hint_SystemToolsCacheKeys"/></strong>: <strong><i><inp2:m_if check="adm_MemoryCacheEnabled">master:</inp2:m_if>configs_parsed</i></strong> (<inp2:m_if check="adm_MemoryCacheEnabled"><inp2:m_Phrase name="la_hint_SystemToolsMemoryCache"/><inp2:m_else/><inp2:m_Phrase name="la_hint_SystemToolsDatabaseCache"/></inp2:m_if>)
					</div>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnResetParsedData');" value="<inp2:m_Phrase name="la_btn_Reset" no_editing="1"/>"/> <inp2:m_Phrase name="la_text_Or"/>
				<input type="button" class="button" onclick="Application.SetVar('validate_configs', 1); submit_event('adm', 'OnResetParsedData'); Application.SetVar('validate_configs', null);" value="<inp2:m_Phrase name="la_btn_ResetAndValidateConfigFiles" no_editing="1"/>"/>
			</div>

			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsResetAdminConsoleSections"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsResetAdminConsoleSections"/>
					<div class="cache-key">
						<strong><inp2:m_Phrase name="la_hint_SystemToolsCacheKeys"/></strong>: <strong><i><inp2:m_if check="adm_MemoryCacheEnabled">master:</inp2:m_if>sections_parsed</i></strong> (<inp2:m_if check="adm_MemoryCacheEnabled"><inp2:m_Phrase name="la_hint_SystemToolsMemoryCache"/><inp2:m_else/><inp2:m_Phrase name="la_hint_SystemToolsDatabaseCache"/></inp2:m_if>)
					</div>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnResetSections');" value="<inp2:m_Phrase name="la_btn_Reset" no_editing="1"/>"/>
			</div>

			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsRebuildMultilingualFields"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsRebuildMultilingualFields"/>
				</div>
				<input type="button" class="button" onclick="submit_event('lang', 'OnReflectMultiLingualFields');" value="<inp2:m_Phrase name="la_btn_Rebuild" no_editing="1"/>"/>
			</div>

			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsShowDatabaseTableStructure"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsShowDatabaseTableStructure"/>
				</div>
				<input type="text" name="table_name" value="" size="30"/>
				<input type="button" class="button" onclick="show_structure('adm', 'OnGenerateTableStructure');" value="<inp2:m_Phrase name="la_btn_ShowStructure" no_editing="1"/>"/>
			</div>

			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsLocateUnitConfigFile"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsLocateUnitConfigFile"/>
				</div>
				<input type="text" name="config_prefix" value="" size="30"/>
				<input type="button" class="button" onclick="check_prefix_config();" value="<inp2:m_Phrase name="la_btn_Locate" no_editing="1"/>"/>
			</div>

			<div class="group last">
				<h4><inp2:m_Phrase name="la_title_SystemToolsResetConfigsAndParsedData"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsResetConfigsAndParsedData"/>
					<div class="cache-key">
						<strong><inp2:m_Phrase name="la_hint_SystemToolsCacheKeys"/></strong>: <strong><i><inp2:m_if check="adm_MemoryCacheEnabled">master:</inp2:m_if>config_files</i></strong>, <strong><i><inp2:m_if check="adm_MemoryCacheEnabled">master:</inp2:m_if>configs_parsed</i></strong> (<inp2:m_if check="adm_MemoryCacheEnabled"><inp2:m_Phrase name="la_hint_SystemToolsMemoryCache"/><inp2:m_else/><inp2:m_Phrase name="la_hint_SystemToolsDatabaseCache"/></inp2:m_if>)
					</div>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnResetConfigsCache');" value="<inp2:m_Phrase name="la_btn_Reset" no_editing="1"/>"/>
			</div>
		</div>
	</div>

	<div class="summary-box">
		<div class="title">
			<inp2:m_Phrase name="la_section_FrontEnd"/>
		</div>
		<div class="content">
			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsResetModRewriteCache"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsResetModRewriteCache"/>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnResetModRwCache');" value="<inp2:m_Phrase name="la_btn_Reset" no_editing="1"/>"/>
			</div>

			<div class="group last">
				<h4><inp2:m_Phrase name="la_title_SystemToolsResetSMSMenuCache"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsResetSMSMenuCache"/>
					<div class="cache-key">
						<strong><inp2:m_Phrase name="la_hint_SystemToolsCacheKeys"/></strong>: <strong><i><inp2:m_if check="adm_MemoryCacheEnabled">master:</inp2:m_if>cms_menu</i></strong>, <strong><i><inp2:m_if check="adm_MemoryCacheEnabled">master:</inp2:m_if>template_mapping</i></strong>, <strong><i><inp2:m_if check="adm_MemoryCacheEnabled">master:</inp2:m_if>StructureTree</i></strong> (<inp2:m_if check="adm_MemoryCacheEnabled"><inp2:m_Phrase name="la_hint_SystemToolsMemoryCache"/><inp2:m_else/><inp2:m_Phrase name="la_hint_SystemToolsDatabaseCache"/></inp2:m_if>)
					</div>
				</div>
				<input type="button" class="button" onclick="submit_event('c', 'OnResetCMSMenuCache');" value="<inp2:m_Phrase name="la_btn_Reset" no_editing="1"/>"/>
			</div>
		</div>
	</div>
</div>

<div style="float: right; width: 49%;">
	<div class="summary-box">
		<div class="title">
			<inp2:m_Phrase name="la_section_ProjectDeployment"/>
		</div>
		<div class="content">
			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsSynchronizeDBRevisions"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsSynchronizeDBRevisions"/>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnSynchronizeDBRevisions');" value="<inp2:m_Phrase name="la_btn_Synchronize" no_editing="1"/>"/>
			</div>

			<div class="group last">
				<h4><inp2:m_Phrase name="la_title_SystemToolsDeploy"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsDeploy"/>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnDeploy');" value="<inp2:m_Phrase name="la_btn_Deploy" no_editing="1"/>"/>
			</div>
		</div>
	</div>

	<div class="summary-box">
		<div class="title">
			<inp2:m_Phrase name="la_section_Templates"/>
		</div>
		<div class="content">
			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsRefreshThemeFiles"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsRefreshThemeFiles"/>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnRebuildThemes');" value="<inp2:m_Phrase name="la_btn_Refresh" no_editing="1"/>"/>
			</div>

			<div class="group">
				<h4><inp2:m_Phrase name="la_title_SystemToolsRecompileTemplates"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsRecompileTemplates"/>
				</div>
				<input type="button" class="button" onclick="compile_templates();" value="<inp2:m_Phrase name="la_btn_Recompile" no_editing="1"/>"/>
			</div>

			<div class="group last">
				<h4><inp2:m_Phrase name="la_title_SystemToolsClearTemplatesCache"/></h4>
				<div class="hint">
					<inp2:m_Phrase name="la_hint_SystemToolsClearTemplatesCache"/>
				</div>
				<input type="button" class="button" onclick="submit_event('adm', 'OnDeleteCompiledTemplates');" value="<inp2:m_Phrase name="la_btn_Clear" no_editing="1"/>"/>
			</div>
		</div>
	</div>

	<inp2:m_if check="adm_MemoryCacheEnabled">
		<div class="summary-box">
			<div class="title">
				<inp2:m_Phrase name="la_section_MemoryCache"/>
			</div>
			<div class="content">
				<div class="group">
					<h4><inp2:m_Phrase name="la_title_SystemToolsResetAllKeys"/></h4>
					<div class="hint">
						<inp2:m_Phrase name="la_hint_SystemToolsResetAllKeys"/>
					</div>
					<input type="button" class="button" onclick="submit_event('adm', 'OnResetMemcache');" value="<inp2:m_Phrase name="la_btn_Reset" no_editing="1"/>"/>
				</div>

				<div class="group">
					<h4><inp2:m_Phrase name="la_title_SystemToolsKeyName"/>:</h4>
					<div class="hint">
						<inp2:m_Phrase name="la_hint_SystemToolsKeyName"/>
					</div>
					<input type="text" id="memory_cache_key_name" style="width: 230px;" value=""/>
					<input type="button" class="button" id="memory_cache_get" value="<inp2:m_Phrase name="la_btn_GetValue" no_editing="1"/>"/>

					<div style="margin-top: 3px;">
						<h4><inp2:m_Phrase name="la_title_SystemToolsCommonlyUsedKeys"/>:</h4>
							<ul>
								<li><a href="#" class="quick-memory-cache-key">master:configs_parsed</a></li>
								<li><a href="#" class="quick-memory-cache-key">master:config_files</a></li>
								<li><a href="#" class="quick-memory-cache-key">master:sections_parsed</a></li>
								<li><a href="#" class="quick-memory-cache-key">master:cms_menu</a></li>
								<li><a href="#" class="quick-memory-cache-key">master:template_mapping</a></li>
								<li><a href="#" class="quick-memory-cache-key">master:StructureTree</a></li>
							</ul>
					</div>
				</div>

				<div class="group last">
					<h4><inp2:m_Phrase name="la_title_SystemToolsKeyValue"/>:</h4>
					<div class="hint">
						<inp2:m_Phrase name="la_hint_SystemToolsKeyValue"/>
					</div>
					<div style="margin-right: 4px; margin-bottom: 3px;">
						<textarea id="memory_cache_key_value" style="width: 100%; height: 200px;"></textarea><br/>
					</div>

					<input type="button" class="button" id="memory_cache_set" value="<inp2:m_Phrase name="la_btn_SetValue" no_editing="1"/>"/>
				</div>
			</div>
		</div>
	</inp2:m_if>
</div>

<div style="clear: both;"></div>

<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"/>