{* $Id: tiki-admin_integrator_rules.tpl 54796 2015-03-28 21:01:43Z lindonb $ *}

{title help="Integrator"}{tr}Edit Rules for Repository:{/tr} {$name}{/title}

<div class="t_navbar margin-bottom-md">
	{button href="tiki-admin_integrator.php" class="btn btn-default" _icon_name="cog" _text="{tr}Configure Repositories{/tr}"}
	{button href="tiki-list_integrator_repositories.php" class="btn btn-default" _icon_name="list" _text="{tr}List Repositories{/tr}</a>"}
	{assign var=thisrepID value=$repID|escape}
	{button href="tiki-admin_integrator.php?action=edit&amp;repID=$thisrepID" class="btn btn-default" _icon_name="wrench" _text="{tr}Configure this Repository{/tr}"}
	{button href="tiki-integrator.php?repID=$thisrepID" _text="{tr}View this Repository{/tr}" _icon_name="view" class="btn btn-default"}
	{button href="tiki-admin_integrator_rules.php?repID=$thisrepID" _text="{tr}New Rule{/tr}" _icon_name="create" class="btn btn-default"}
	{if count($reps) gt 0}
		{button _onclick="javascript:flip('rules-copy-panel');" _text="{tr}Copy Rules{/tr}" _icon_name="copy" _title="{tr}view/hide copy rules dialog{/tr}"}
	{/if}
</div>

{if count($reps) gt 0}
	<div id="rules-copy-panel">
		<form action="tiki-admin_integrator_rules.php?repID={$repID|escape}" method="post">
			<table class="formcolor">
				<tr>
					<td>{tr}Source repository{/tr}</td>
					<td>
						<select name="srcrep">{html_options options=$reps}</select> &nbsp; &nbsp;
						<input type="submit" class="btn btn-default btn-sm" name="copy" value="{tr}Copy{/tr}">
					</td>
				</tr>
			</table>
		</form>
		<br><br>
	</div>
{/if}

{* Add form *}
<form action="tiki-admin_integrator_rules.php?repID={$repID|escape}" method="post">
	<input type="hidden" name="ruleID" value="{$ruleID|escape}">
	<input type="hidden" name="repID" value="{$repID|escape}">

	<table class="formcolor">
		<tr>
			<td><span title="{tr}According this order rules will be applied ('0' or empty = auto){/tr}">{tr}Rule order{/tr}</span></td>
			<td><input type="text" maxlength="2" size="2" name="ord" value="{$ord|escape}" title="{tr}According this order rules will be applied ('0' or empty = auto){/tr}"></td>
		</tr><tr>
			<td><span title="{tr}Text to search for{/tr}">{tr}Search{/tr}</span></td>
			<td><input type="text" name="srch" value="{$srch|escape}" title="{tr}Text to search for{/tr}"></td>
		</tr><tr>
			<td><span title="{tr}Text to replace{/tr}">{tr}Replace{/tr}</span></td>
			<td><input type="text" name="repl" value="{$repl|escape}" title="{tr}Text to replace{/tr}"></td>
		</tr><tr>
			<td><span title="{tr}Is this regular expression or simple search/replacer{/tr}">{tr}Regex{/tr}</span></td>
			<td><input type="checkbox" name="type" {if $type eq 'y'}checked="checked"{/if} title="{tr}Is this regular expression or simple search/replacer{/tr}"></td>
		</tr><tr>
			<td><span title="{tr}Is case sensitive (for simple replacer){/tr}">{tr}Case sensitive{/tr}</td>
			<td><input type="checkbox" name="casesense" {if $casesense eq 'y'}checked="checked"{/if} title="{tr}Is case sensitive (for simple replacer){/tr}"></td>
		</tr><tr>
			<td><span title="{tr}subset of chars: imsxeADSXUu, which is regex modifiers{/tr}">{tr}Regex modifiers{/tr}</span></td>
			<td><input type="text" maxlength="20" size="20" name="rxmod" value="{$rxmod|escape}" title="{tr}subset of chars: imsxeADSXUu, which is regex modifiers{/tr}"></td>
		</tr><tr>
			<td><span title="{tr}Human-readable text description of rule{/tr}">{tr}Description{/tr}</td>
			<td><textarea name="description" rows="4" title="{tr}Human-readable text description of rule{/tr}">{$description|escape}</textarea></td>
		</tr><tr>
			<td>&nbsp;</td>
			<td>
				<input type="submit" class="btn btn-primary btn-sm" name="save" value="{tr}Save{/tr}">&nbsp;&nbsp;
				<input type="checkbox" name="enabled" {if $enabled eq 'y'}checked="checked"{/if} title="{tr}Check to enable this rule{/tr}">&nbsp;
				{tr}Enabled{/tr}
			</td>
		</tr><tr>
			<td colspan="2">{tr}Preview options{/tr}</td>
		</tr><tr>
			<td><span title="{tr}Apply all rules or just this to generate preview{/tr}">{tr}Apply all rules{/tr}</td>
			<td><input type="checkbox" name="all" {if $all eq 'y'}checked="checked"{/if} title="{tr}Apply all rules or just this to generate preview{/tr}"></td>
		</tr><tr>
			<td><span title="{tr}View source code after rules applied{/tr}">{tr}Code preview{/tr}</td>
			<td><input type="checkbox" name="code" {if $code eq 'y'}checked="checked"{/if} title="{tr}View source code after rules applied{/tr}"></td>
		</tr><tr>
			<td><span title="{tr}Generate HTML preview{/tr}">{tr}HTML preview{/tr}</td>
			<td><input type="checkbox" name="html" {if $html eq 'y'}checked="checked"{/if} title="{tr}Generate HTML preview{/tr}"></td>
		</tr><tr>
			<td><span title="{tr}Test file from repository to generate preview for (empty = configured start page){/tr}">{tr}File{/tr}</td>
			<td><input type="text" name="file" value="{$file|escape}" title="{tr}Test file from repository to generate preview for (empty = configured start page){/tr}"></td>
		</tr><tr>
			<td>&nbsp;</td>
			<td><input type="submit" class="btn btn-default btn-sm" name="preview" value="{tr}Preview{/tr}"></td>
		</tr>
	</table>
</form>

{if (($html eq 'y') or ($code eq 'y')) and (strlen($preview_data) gt 0)}
	<h2>{tr}Preview Results{/tr}</h2>
	{if strlen($css_file) > 0}
		<link rel="StyleSheet" href="{$css_file}" type="text/css">
	{/if}
	<div class="integration_preview">
		{if $code eq 'y'}
			<div class="codelisting"><pre>{$preview_data|escape:"html"|wordwrap:120:"\n"}</pre></div>
		{/if}
		{if $html eq 'y'}
				<div class="integrated-page">{$preview_data}</div>
		{/if}
	</div>
{/if}

<h2>{tr}Rules List{/tr}</h2>

{* Table with list of repositories *}
<div class="table-responsive">
	<table class="table normal table-striped table-hover" id="integrator_rules">
		<tr>
			<th rowspan="2"><span title="{tr}Rule order{/tr}">#</span></th>
			<th>{tr}Search{/tr}</th>
			<th>{tr}Replace{/tr}</th>
			<th>{tr}Regex{/tr}</th>
			<th>{tr}Case{/tr}</th>
			<th></th>
		</tr><tr>
			<th colspan="5">{tr}Description{/tr}</th>
		</tr>

		{section name=rule loop=$rules}
			<tr>
				<td{if (strlen($rules[rule].description) > 0)} rowspan="2"{/if}>
					{if $rules[rule].enabled ne 'y'}<s>{$rules[rule].ord|escape}</s>
					{else}{$rules[rule].ord|escape}
					{/if}
				</td>
				<td class="text">{$rules[rule].srch|escape}</td>
				<td class="text">{$rules[rule].repl|escape}</td>
				<td class="text">{$rules[rule].type|escape}</td>
				<td class="text">{$rules[rule].casesense|escape}</td>
				<td class="action">
					{capture name=integrator_rules_actions}
						{strip}
							<a href="tiki-admin_integrator_rules.php?action=edit&amp;repID={$repID|escape}&amp;ruleID={$rules[rule].ruleID|escape}">
								{icon name='edit' _menu_text='y' _menu_icon='y' alt="{tr}Edit{/tr}"}
							</a>
							<a href="tiki-admin_integrator_rules.php?action=rm&amp;repID={$repID|escape}&amp;ruleID={$rules[rule].ruleID|escape}">
								{icon name='remove' _menu_text='y' _menu_icon='y' alt="{tr}Remove{/tr}"}
							</a>
						{/strip}
					{/capture}
					<a class="tips"
					   title="{tr}Actions{/tr}"
					   href="#" {popup delay="0|2000" fullhtml="1" center=true text=$smarty.capture.integrator_rules_actions|escape:"javascript"|escape:"html"}
					   style="padding:0; margin:0; border:0"
							>
						{icon name='wrench'}
					</a>
				</td>

				{* Show description as colspaned row if it is not an empty *}
				{if (strlen($rules[rule].description) > 0)}
					</tr><tr>
						<td colspan="5" class="text">{$rules[rule].description|escape}</td>
				{/if}
			</tr>
		{/section}
	</table>
</div>
