{* Error and confirmation messages *}
{include file="messages.tpl"}

{strip}
{php}
   $this->assign('opt_bool', array(1 => $this->translate('Yes'), 0 => $this->translate('No')));
{/php}

{if $show_cache_msg eq 1}
<div class="error block">{l}It is strongly advised that you rebuild the category cache now. Please click here{/l}: <a href="{$smarty.const.DOC_ROOT}/dir_categs.php?action=rebuild_cache" title="{l}Rebuild Category Cache{/l}">{l}Rebuild Category Cache{/l}</a></div>
{/if}
{if $posted}
   <div class="success block">
      {l}Settings updated.{/l}
   </div>
{/if}

<div class="block">
   <form method="post" action="{if isset($conf_group)}{$smarty.const.DOC_ROOT}/conf_settings.php?c={$conf_group}{/if}">
   <table class="formPage">
      <thead>
         <tr>
            <th colspan="2">{if !empty($conf_categs.$conf_group)}{$conf_categs.$conf_group|escape|trim}{else}{l}Configuration options{/l}{/if}</th>
         </tr>
      </thead>

      <tbody>
      {assign var="categ" value="0"}
      {foreach from=$conf item=row}
         {if $categ ne $row.CONFIG_GROUP}
            {assign var="categ" value=$row.CONFIG_GROUP}
         {/if}

         <tr class="{cycle values="odd,even"}">
            <td  class="label{if $row.REQUIRED eq 1} required{/if}"><label for="{$row.ID}">{$row.NAME|escape}:</label></td>
            <td  class="smallDesc">
               {if $row.TYPE eq 'STR'}
                  <input type="text" id="{$row.ID}" name="{$row.ID}" value="{$row.VALUE|escape|trim}" class="text" />
                  {validate form="conf_settings" id="v_`$row.ID`" message=$smarty.capture.field_char_required}
	{elseif $row.TYPE eq 'CONTENT'}   
	{if isset ($useRTE) and $useRTE eq 1}
{literal}
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "exact",
		elements: "MAINCONTENT,DISABLE_REASON,SUBMIT_TERMS,DISABLE_ARTICLE_REASON",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

		convert_urls : false,
		// Theme options
		theme_advanced_buttons1 : "code,save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,image,|,insertdate,inserttime,preview,|,forecolor,backcolor|,ltr,rtl,|,sub,sup",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,charmap,emotions,iespell,media,advhr,|,print,|,fullscreen",
		//theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css"
	});
</script>
{/literal}
<textarea id="MAINCONTENT" name="MAINCONTENT" rows="15" cols="80" style="width: 100%">{$row.VALUE}
</textarea>	
            {else}          
<textarea rows="5" cols="20"id="{$row.ID}" name="{$row.ID}" class="text" />{$row.VALUE}</textarea>
  {/if}
  {elseif $row.TYPE eq 'TERMS'}   
	{if isset ($useRTE) and $useRTE eq 1}
	<textarea id="SUBMIT_TERMS" name="SUBMIT_TERMS" rows="15" cols="80" style="width: 100%">{$row.VALUE}
	</textarea>	
            {else}          
<textarea rows="5" cols="20"id="{$row.ID}" name="{$row.ID}" class="text" />{$row.VALUE}</textarea>
  {/if}
  {elseif $row.TYPE eq 'DISABLE_REASON'} 
  
	{if isset ($useRTE) and $useRTE eq 1}
	{literal}
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "exact",
		elements: "MAINCONTENT,DISABLE_REASON,SUBMIT_TERMS,DISABLE_ARTICLE_REASON",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		convert_urls : false,
		// Theme options
		theme_advanced_buttons1 : "code,save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,image,|,insertdate,inserttime,preview,|,forecolor,backcolor|,ltr,rtl,|,sub,sup",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,charmap,emotions,iespell,media,advhr,|,print,|,fullscreen",
		//theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css"
	});
</script>
{/literal}

	<textarea id="DISABLE_REASON" name="DISABLE_REASON" rows="15" cols="80" style="width: 100%">{$row.VALUE}
	</textarea>
            {else}          
<textarea rows="5" cols="20"id="{$row.ID}" name="{$row.ID}" class="text" />{$row.VALUE}</textarea>
  {/if}
  {elseif $row.TYPE eq 'DISABLE_ARTICLE_REASON'}   
	{if isset ($useRTE) and $useRTE eq 1}
	{literal}
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "exact",
		elements: "MAINCONTENT,DISABLE_REASON,SUBMIT_TERMS,DISABLE_ARTICLE_REASON",
		theme : "advanced",
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		convert_urls : false,
		// Theme options
		theme_advanced_buttons1 : "code,save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,image,|,insertdate,inserttime,preview,|,forecolor,backcolor|,ltr,rtl,|,sub,sup",
		theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,charmap,emotions,iespell,media,advhr,|,print,|,fullscreen",
		//theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,

		// Example content CSS (should be your site CSS)
		content_css : "css/content.css"
	});
</script>
{/literal}

	<textarea id="DISABLE_ARTICLE_REASON" name="DISABLE_ARTICLE_REASON" rows="15" cols="80" style="width: 100%">{$row.VALUE}
	</textarea>
            {else}          
<textarea rows="5" cols="20"id="{$row.ID}" name="{$row.ID}" class="text" />{$row.VALUE}</textarea>
  {/if}
               {elseif $row.TYPE eq 'PAS'}
                  <input type="password" id="{$row.ID}" name="{$row.ID}" value="{$row.VALUE|escape|trim}" class="text" />
                  {validate form="conf_settings" id="v_`$row.ID`" message=$smarty.capture.field_pass_required}
               {elseif $row.TYPE eq 'URL'}
                  <input type="text" id="{$row.ID}" name="{$row.ID}" value="{$row.VALUE|escape|trim}" class="text" />
                  {validate form="conf_settings" id="v_`$row.ID`" message=$smarty.capture.invalid_url}
               {elseif $row.TYPE eq 'INT'}
                  <input type="text" id="{$row.ID}" name="{$row.ID}" value="{$row.VALUE|escape|trim}" class="text" />
                  {validate form="conf_settings" id="v_`$row.ID`" message=$smarty.capture.field_integer_required}
               {elseif $row.TYPE eq 'NUM'}
                  <input type="text" id="{$row.ID}" name="{$row.ID}" value="{$row.VALUE|escape|trim}" class="text" />
                  {validate form="conf_settings" id="v_`$row.ID`" message=$smarty.capture.field_num_required}
               {elseif $row.TYPE eq 'LOG'}
                  {html_options options=$opt_bool selected=$row.VALUE name=$row.ID id=$row.ID}
                  {validate form="conf_settings" id="v_`$row.ID`" message=$smarty.capture.field_char_required}
               {elseif $row.TYPE eq 'LKP'}
                  {html_options options=$row.OPTIONS selected=$row.VALUE name=$row.ID id=$row.ID}
                  {validate form="conf_settings" id="v_`$row.ID`" message=$smarty.capture.field_char_required}
               {/if}

               {if isset($row.DESCRIPTION) and !empty($row.DESCRIPTION)}
                  <div class="description">
                     {if is_array($row.DESCRIPTION)}
                        <ul>
                        {foreach from=$row.DESCRIPTION item=DescItem}
                           <li>{$DescItem}</li>
                        {/foreach}
                        </ul>
                     {else}
                        {$row.DESCRIPTION}
                     {/if}
                  </div>
               {/if}

               {if isset($row.NOTICE) and !empty($row.NOTICE)}
                  <div class="notice">
                     {if is_array($row.NOTICE)}
                        <ul>
                        {foreach from=$row.NOTICE item=NoticeItem}
                           <li>{$NoticeItem}</li>
                        {/foreach}
                        </ul>
                     {else}
                        {$row.NOTICE}
                     {/if}
                  </div>
               {/if}

               {if isset($row.WARNING) and !empty($row.WARNING)}
                  <div class="warning">
                     {if is_array($row.WARNING)}
                        <ul>
                        {foreach from=$row.WARNING item=WarningItem}
                           <li>{$WarningItem}</li>
                        {/foreach}
                        </ul>
                     {else}
                        {$row.WARNING}
                     {/if}
                  </div>
               {/if}
            </td>
         </tr>
      {/foreach}
      </tbody>

      <tfoot>
         <tr>
            <td><input type="reset" id="reset-conf-submit" name="reset" value="{l}Reset{/l}" alt="{l}Reset form{/l}" title="{l}Reset form{/l}" class="button" /></td>
            <td><input type="submit" id="send-conf-submit" name="submit" value="{l}Save{/l}" alt="{l}Save form{/l}" title="{l}Save settings{/l}" class="button" /></td>
         </tr>
      </tfoot>
   </table>
   </form>
</div>
{/strip}