{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=BlogTemplateEditor title=$locale->tr("BlogTemplateEditor")}
<SCRIPT type="text/javascript"> var copyToMessage = '{$locale->tr("templateeditor_enter_new_templatefile_name")}'; </SCRIPT>
{literal}
<SCRIPT type="text/javascript">
function copyTemplateFileTo( objId , templateId, subFolderId) {
    copyToName = prompt(copyToMessage, 'new_' + objId);
    url = document.getElementById(objId);
    if (copyToName != '' && copyToName != null) {
        originUrl = url.getAttribute('href');
        newUrl = encodeURI(originUrl + '&newFileId=' + copyToName);
        url.setAttribute('href', newUrl);
    } else {
        url.setAttribute('href', '?op=blogTemplatesList&templateId=' + templateId + '&subFolderId=' + subFolderId);
    }
}

function openImagePreviewWindow( destUrl )
{
	PreviewWindow = window.open( destUrl, 'ImagePreview','scrollbars=yes,resizable=yes,toolbar=no,height=480,width=640');
}
</SCRIPT>
{/literal}
<div id="list_nav_bar">
 <div id="list_nav_select">
  <form id="viewTemplateSets" action="admin.php" method="post">
   <fieldset>
    <legend>{$locale->tr("show_by")}</legend>
    <div class="list_nav_option">
     <label for="templateId">{$locale->tr("template")}</label>
	 <br />
	 <select name="templateId" id="templateId">
      {foreach from=$templateSets item=templateSet}
       <option value="{$templateSet->getName()}" {if $currentTemplate == $templateSet->getName()} selected="selected" {/if}>{$templateSet->getName()}</option>
      {/foreach}
     </select>
    </div>
    <div class="list_nav_option">
     <br />
     <input type="hidden" name="op" value="blogTemplatesList">
     <input type="submit" name="Show" value="{$locale->tr("show")}">
    </div>
   </fieldset> 
  </form> 
 </div>
 <br style="clear:both">
</div>

<div id="list_nav_bar">
 <div id="list_nav_select">
  <form name="addResource" action="admin.php" method="post" enctype="multipart/form-data">
   <fieldset>
    <legend>{$locale->tr("newResource")}</legend>
    <div class="list_nav_option">    
     <label for="resourceFile">{$locale->tr("file")}</label>
	 <br />
	 <input style="width:680px;" type="file" name="resourceFile" id="resourceFile" />
    </div>    
    <div class="list_nav_option">
     <br />
     <input type="hidden" name="op" value="blogUploadTemplateFile">
     <input type="hidden" name="templateId" value="{$currentTemplate}">
     <input type="hidden" name="subFolderId" value="{$currentSubFolder}">
     <input type="submit" name="Add" value="{$locale->tr("add")}">
    </div>
   </fieldset> 
  </form> 
 </div>
 <br style="clear:both">
</div>

<form id="blogTemplatesList" method="post" action="admin.php">
 <div id="list">
  {include file="$admintemplatepath/successmessage.template"}
  {include file="$admintemplatepath/errormessage.template"}
  <table class="info">
   <thead>
    <tr>
      <th style="width:10px;"><input class="checkbox" type="checkbox" class="check" name="all" id="all" value="1" onclick="toggleAllChecks('blogTemplatesList');" /></th>
      <th style="width:520px;">{$locale->tr("file")}</th>
      <th style="width:150px;">{$locale->tr("size")} ({$locale->tr("bytes")})</th>
      <th style="width:95px;">{$locale->tr("actions")}</th>
    </tr>
  </thead>
  <tbody>

  <tr class="{cycle values="odd,even"}">
   <td>
    <div align="center"><span style="background-color: #CCCCCC">&nbsp;&nbsp;&nbsp;</span></div>
   </td>
   <td  class="col_highlighted">
    <a href="?op=blogTemplatesList&amp;templateId={$currentTemplate}">
     <img src="imgs/admin/icon_folderopen-16.png" />
     ..
    </a>
   </td>
   <td>
   </td>    
   <td>
   </td>
  </tr>  
  
  {foreach from=$templateFiles item=file}
   <tr class="{cycle values="odd,even"}">
    <td>
       <input class="checkbox" type="checkbox" name="fileIds[{counter}]" value="{$file.name}" />
    </td>
    <td  class="col_highlighted">
     {if $file.isEditable}
      <a href="?op=blogEditTemplateFile&amp;templateId={$currentTemplate}&amp;subFolderId={$currentSubFolder}&amp;fileId={$file.name}">
       <img src="imgs/admin/icon_template-16.png" />
       {$file.name}
      </a>
     {elseif $file.isImage}
      <a href="javascript:openImagePreviewWindow('{$url->getUrl($file.url)}');">
       <img src="imgs/admin/icon_photo-16.png" />
	   {$file.name}
	  </a>
	 {else}
	  <img src="imgs/admin/icon_other-16.png" />
	  {$file.name}
     {/if}      
    </td>
    <td>
     {$file.size}
    </td>    
    <td>
     <div class="list_action_button">
      {if $file.isEditable}
       <a href="?op=blogEditTemplateFile&amp;templateId={$currentTemplate}&amp;subFolderId={$currentSubFolder}&amp;fileId={$file.name}">
        <img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
       </a>
      {else}
       <img src="imgs/admin/icon_empty-16.png" />
      {/if}     
      <a href="?op=blogDeleteTemplateFile&amp;templateId={$currentTemplate}&amp;subFolderId={$currentSubFolder}&amp;fileId={$file.name}">
       <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
      </a>
      {if $file.isEditable}
       <a href="?op=blogCopyTemplateFile&amp;templateId={$currentTemplate}&amp;subFolderId={$currentSubFolder}&amp;fileId={$file.name}" id="{$file.name}" onClick="copyTemplateFileTo(this.id, '{$currentTemplate}', '{$currentSubFolder}')" >
        <img src="imgs/admin/icon_copy-16.png" alt="{$locale->tr("copy")}" />
       </a>
      {else}
       <img src="imgs/admin/icon_empty-16.png" />
      {/if}      
      {if $file.isImage}
	   <a href="javascript:openImagePreviewWindow('{$url->getUrl($file.url)}');">
		<img src="imgs/admin/icon_image-16.png" alt="Preview" />
	   </a>      
      {/if}         
     </div>
    </td>
   </tr>
  {/foreach}
  </tbody>
 </table>
 </div>
 <div id="list_action_bar">
   <input type="hidden" name="templateId" value="{$currentTemplate}" />
   <input type="hidden" name="subFolderId" value="{$currentSubFolder}" />
   <input type="hidden" name="op" value="blogDeleteTemplateFiles" class="submit" />
   <input type="submit" name="{$locale->tr("delete")}" value="{$locale->tr("delete")}"/>
 </div>
</form>
 
{include file="$admintemplatepath/footernavigation.template"}
{include file="$admintemplatepath/footer.template"}
