<!-- $Id: ls_templates.tt2 4386 2007-05-02 15:52:19Z olivier.salaun $ -->

<h2>[%|loc%]Template edition system[%END%]</h2>

<div id="template_editor">

[%|loc%]This page is suggested in order to edit or create mail or web tt2 templates.[%END%]

[%|loc%]Priority rules for template selection :
<ul>
<li>IF list context defined, apply list template if exist</li>
<li>ELSE apply robot defined template if exist</li>
<li>ELSE apply locally defined template if exist</li>
<li>ELSE apply template included in the distribution (these must not be edited because Sympa's update will over write these files)</li>
</ul>[%END%]
<br />
[%|loc%]First you may list a category of templates; the list should include a default template and may include any templates designated for a particular list. You will then have an oportunity to copy and edit templates for the current robot or the named list.[%END%]<br />

<form action="[% path_cgi %]/ls_templates" method="post">
<fieldset>
<ul>
<li>[%|loc%]Select templates type :[%END%]  
  <input type="radio" name="webormail" value="web"  [% IF webormail == 'web' %]checked="checked"[% END %] />web
  <input type="radio" name="webormail" value="mail" [% IF webormail == 'mail' %]checked="checked"[% END %] />mail
</li>
<li>[%|loc%]Select a list :[%END%]  <input type="text" name="list" value="[% list %]"/></li>
<li><input class="MainMenuLinks" type="submit" name="action_ls_templates" value="[%|loc%]Reload[%END%]" /></li>
</ul>
</fieldset>
</form>

</div>

<p>

[% IF templates %]
<table summary="[%|loc%]This table contain all templates you can copy or see[%END%]" class="ls_template">
<tr class="color4">
<th>[%|loc%]template name[%END%]</th>
<th colspan="[% colspan_per_level.distrib %]">[%|loc%]distrib[%END%]</th>
<th colspan="[% colspan_per_level.site %]">[%|loc%]site[%END%]</th>
<th colspan="[% colspan_per_level.robot %]">[%|loc%]robot[%END%]</th>
<th  colspan="[% colspan_per_level.list %]">[%|loc(list)%]list %1[%END%]</th>
</tr>
[% SET dark = 1 %]
[% END %]
<th>&nbsp;</th>

<!-- print list of languages -->
[% FOREACH lang = lang_per_level.distrib %]
    <th>[% lang.key %]</th>
[% END %]

[% FOREACH lang = lang_per_level.site %]
    <th>[% lang.key %]</th>
[% END %]

 [% FOREACH lang = lang_per_level.robot %]
    <th>[% lang.key %]</th>
 [% END %]

 [% FOREACH lang = lang_per_level.list %]
    <th>[% lang.key %]</th>
 [% END %]

[% FOREACH file = templates %]
  [% IF dark == '1' %]
     <tr>[% SET dark = 0 %]
  [% ELSE %]
     <tr class="color0">[% SET dark=1 %]
  [% END %]
  <td>[% file.key %]</td>

 [% FOREACH lang = file.value.distrib %]
 <td class="text_center">
  [% IF lang.value %]
    <form action="[% path_cgi %]/edit_template" method="post">
    <fieldset>
      <input type="hidden" name="template_path" value="[% lang.value %]" />
      <input type="hidden" name="template_name" value="[% file.key %]" />
      <input type="hidden" name="scope" value="distrib" />
      <input type="hidden" name="tpl_lang" value="default" />
      <input type="hidden" name="webormail" value="[% webormail %]" />
      <input class="MainMenuLinks" type="submit" name="action_view_template" value="[%|loc%]view[% END %]" />
      <input class="MainMenuLinks" type="submit" name="action_copy_template" value="[%|loc%]cp[% END %]" />
    </fieldset>
    </form></li>
    </ul>
  [% END %]
  </td>
[% END %]

[% FOREACH lang = file.value.site %]
  <td class="text_center">
  [% IF lang.value %]
    <form action="[% path_cgi %]/edit_template" method="post">
    <fieldset>
      <input type="hidden" name="template_name" value="[% file.key %]" />
      <input type="hidden" name="template_path" value="[% lang.value %]" />
      <input type="hidden" name="scope" value="site" />
      <input type="hidden" name="tpl_lang" value="[% lang.key %]" />
      <input type="hidden" name="webormail" value="[% webormail %]" />
      <input class="MainMenuLinks" type="submit" name="action_edit_template" value="[%|loc%]edit[% END %]" />
      <input class="MainMenuLinks" type="submit" name="action_copy_template" value="[%|loc%]cp[% END %]" />
      <input class="MainMenuLinks" type="submit" name="action_remove_template" value="[%|loc%]rm[% END %]" onclick="return request_confirm('[% FILTER escape_quote %][%|loc(lang.value)%]Do you really want to remove %1 ?[%END%][%END%]');" />
    </fieldset>
    </form>	
  [% END %]
  </td>
 [% END %]

  [% IF default_robot %]
  <td></td>
  [% ELSE %]
[% FOREACH lang = file.value.robot %]
  <td class="text_center">
  [% IF lang.value %]
    <form action="[% path_cgi %]/edit_template" method="post">
    <fieldset>
      <input type="hidden" name="template_name" value="[% file.key %]" />
      <input type="hidden" name="template_path" value="[% lang.value %]" />
      <input type="hidden" name="scope" value="robot" />
      <input type="hidden" name="tpl_lang" value="[% lang.key %]" />
      <input type="hidden" name="webormail" value="[% webormail %]" />
      <input class="MainMenuLinks" type="submit" name="action_edit_template" value="[%|loc%]edit[% END %]" />
      <input class="MainMenuLinks" type="submit" name="action_copy_template" value="[%|loc%]cp[% END %]" />
      <input class="MainMenuLinks" type="submit" name="action_remove_template" value="[%|loc%]rm[% END %]" onclick="return request_confirm('[% FILTER escape_quote %][%|loc(lang.value)%]Do you really want to remove %1 ?[%END%][%END%]');"/>
    </fieldset>
    </form>
  [% END %]
  </td>
 [% END %]
  [%END%]

  [% IF list %]
    [% FOREACH lang = file.value.list %]
    <td class="text_center">
    [% IF lang.value %]
    <form action="[% path_cgi %]/edit_template" method="post">
    <fieldset>
      <input type="hidden" name="template_name" value="[% file.key %]" />
      <input type="hidden" name="template_path" value="[% lang.value %]" />
      <input type="hidden" name="scope" value="list" />
      <input type="hidden" name="tpl_lang" value="[% lang.key %]" />
      <input type="hidden" name="list" value="[% list %]" />
      <input type="hidden" name="webormail" value="[% webormail %]" />
      <input class="MainMenuLinks" type="submit" name="action_edit_template" value="[%|loc%]edit[% END %]" />
      <input class="MainMenuLinks" type="submit" name="action_copy_template" value="[%|loc%]cp[% END %]" />
      <input class="MainMenuLinks" type="submit" name="action_remove_template" value="[%|loc%]rm[% END %]" onclick="return request_confirm('[% FILTER escape_quote %][%|loc(lang.value)%]Do you really want to remove %1 ?[%END%][%END%]');"/>
    </fieldset>
    </form>
    [% END %]
    </td>
    [%END%]
  [% ELSE %]
  <td></td>
  [% END %]
[% END %]
[% IF templates %]
</td></tr>
</table>
[% END %]
</p>
