Don't escape foldername too much
[squasher.git] / templates / index.tpl
index 51afa03210e68ed1fb20e07487a3186c000ff227..daa4691d92b7861293b8a112d90ff0a488043a38 100644 (file)
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-<link rel=stylesheet href="css/squasher.css">
-<title>Squasher</title>
-<script type="text/javascript" language="JavaScript">{literal}
-   function toggle_id(hideshow){
-    if(document.getElementById(hideshow).style.visibility == 'visible') {
-     document.getElementById(hideshow).style.visibility = 'hidden';
-    }else{
-     document.getElementById(hideshow).style.visibility = 'visible';
-    }
-   }
-   function selectAllList() {
-    var aSelect = document.deletetool["h[]"];
-    var aSelectLen = aSelect.length;
-    for(i = 0; i < aSelectLen; i++) {
-     aSelect.options[i].selected = true;
-    }
-   }
-{/literal}</script>
-</head>
-<body>
-<div class="wrappercontainer">
-
-       <div class="banner">&nbsp;<div class="control">{if $user_level > 99}<a href="?">home</a>&nbsp;|&nbsp;<a href="?tools=access">access</a>&nbsp;|&nbsp;<a href="?tools=users">users</a>&nbsp;|&nbsp;<a href="?tools=logs">logs</a>&nbsp;|{/if}&nbsp;<a href="index.php?tools=logout">logout({$user_name|escape})</a>&nbsp;</div></div>
-
-       <div class="menucontainer">
-
-               <div class="menu">
-       
-                       <div class="menuhead">current folder</div>
-       
-                       {foreach item=crumb key=cookie from=$base}<a href="?path={$cookie|escape:'url'}">{$crumb|escape}</a>{/foreach}
-       
-               </div>
-       
-               <div class="menu">
-       
-                       <div class="menuhead">subfolders</div>
-       
-                       {foreach item=folder key=folderpath from=$subfolders}<a href="?path={$folderpath|escape:'url'}">{$folder|escape}</a>{/foreach}
-       
-               </div>
-       
-       </div>
-       
-       <div class="content">
+{extends file='layout.tpl'}
+
+
+{block extra_head}
+<script>
+       {literal}
+       function toggle_id(hideshow){
+               if(document.getElementById(hideshow).style.visibility == 'visible') {
+                       document.getElementById(hideshow).style.visibility = 'hidden';
+               }else{
+                       document.getElementById(hideshow).style.visibility = 'visible';
+               }
+       }
+       function selectAllList() {
+               var aSelect = document.deletetool["h[]"];
+               var aSelectLen = aSelect.length;
+               for(i = 0; i < aSelectLen; i++) {
+                       aSelect.options[i].selected = true;
+               }
+       }
+       function deleteFolder(foldername) {
+               if (!confirm('Are you sure you want to delete folder '+foldername+' ?'))
+                       return;
+               document.rmdir.submit();
+       }
+       function deleteFolderNotEmpty(foldername) {
+               alert(foldername+' in not empty. Please empty it first');
+       }
+       function createFolder() {
+               var folder = prompt("New folder name");
+               if (folder == null)
+                       return; // canceled
+               if (folder.indexOf('/')>=0 || folder=='.' || folder=='..') {
+                       // detect the most common errors
+                       alert('Invalid name');
+                       return;
+               }
+               document.mkdir.newname.value = folder;
+               document.mkdir.submit();
+       }
+       {/literal}
+</script>
+{/block}
+
+
+{block menu}
+<div class="menu">
+       <div class="menuhead">current folder</div>
+       {foreach item=crumb key=cookie from=$base}<a href="?path={$cookie|escape:'urlpathinfo'}">{$crumb|escape}</a>{/foreach}
+       {if $user_level > 99 AND count($base)>1 }
+               <form name=rmdir method=post>
+               <input type=hidden name=tools value=rmdir>
+               <a href="javascript:deleteFolder{if count($squashed)>0 || count($subfolders)>0}NotEmpty{/if}('{$currentfolder|escape:'javascript'|escape}');" class=tool>delete this folder</a>
+               </form>
+       {/if}
+</div>
+<div class="menu">
+       <div class="menuhead">subfolders</div>
+       {foreach item=folder key=folderpath from=$subfolders}<a href="?path={$folderpath|escape:'urlpathinfo'}">{$folder|escape}</a>{/foreach}
+       {if $user_level > 99}
+               <form name=mkdir method=post>
+               <input type=hidden name=tools value=mkdir>
+               <input type=hidden name=newname>
+               <a href="javascript:createFolder();" class=tool>new subfolder</a>
+               </form>
+       {/if}
+</div>
+{/block}
+
+{block content}
+
+{function nicesize size=0 totalsize=0}
+{if $size==$totalsize || !$totalsize}
+       {if $size > 1024*1024}
+       {math equation="x/1024/1024" x=$size format="%.2f"} MiB
+       {elseif $size > 1024}
+       {math equation="x/1024" x=$size format="%.2f"} KiB
+       {else}
+       {$size|escape} B
+       {/if}
+{else}
+       {if $totalsize > 1024*1024}
+       {math equation="x/1024/1024" x=$size format="%.2f"} / {math equation="x/1024/1024" x=$totalsize format="%.2f"} MiB
+       {elseif $size > 1024}
+       {math equation="x/1024" x=$size format="%.2f"} / {math equation="x/1024" x=$totalsize format="%.2f"} KiB
+       {else}
+       {$size|escape} / {$totalsize|escape} B
+       {/if}
+       ({math equation="pct*100" pct=$size/$totalsize format="%.0f"}%)
+{/if}
+{/function}
+
 {assign var=mass_delete_size value=count($squashed)}
 {foreach item=item key=id from=$squashed}
 {if $item.squashed}{*These items are in chunks / uploaded by the squasher tool*}
 
 {if $item.hidden eq false OR $user_level > 99 }
-               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+<div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
 
-                       <div class="name">{$item.name|escape} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&amp;h={$id|escape:'url'}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&amp;h={$id|escape:'url'}'>hide</a>|</font>{/if}{if $user_level > 100}<font color=red>|<a href='?tools=delete&amp;h={$id|escape:'url'}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name|escape:'quotes'}?')">delete</a>|</font>{/if}{/if}</div>
+       <div class="name">{$item.name|escape} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&amp;h={$id|escape:'url'}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&amp;h={$id|escape:'url'}'>hide</a>|</font>{/if}{if $user_level > 100}<font color=red>|<a href='?tools=delete&amp;h={$id|escape:'url'}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name|escape:'quotes'}?')">delete</a>|</font>{/if}{/if}</div>
 
-                       <div class="status">status: {$item.status|escape}</div>
+       <div class="status">status: {$item.status|escape}</div>
 
-                       <div class="clear"></div>
+       <div class="clear"></div>
 
-                       <div class="added">added: {$item.date|escape}</div>
-               
-                       <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="((x / 1024) / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024) * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.2f"}&nbsp;/&nbsp;{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{math equation="x * (y / z)" x=$item.size y=$item.chunks_finished z=$item.chunks format="%.0f"}&nbsp;/&nbsp;{$item.size|escape}b{/if}({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_finished format="%.0f"}%)</div>
+       <div class="added">added: {$item.date|escape}</div>
 
-                       <div class="clear"></div>
+       <div class="size">size: {nicesize size=$item.size*$item.chunks_finished/$item.chunks totalsize=$item.size}</div>
 
-                       <div class="updated">last updated: {$item.lastchange|escape}</div>
+       <div class="clear"></div>
+
+       <div class="updated">last updated: {$item.lastchange|escape}</div>
 
 
 {if $item.finished==true}
-                       <div class="download"><a href='?f={$id|escape:'url'}'>download</a></div>
+       <div class="download"><a href='?f={$id|escape:'url'}'>download</a></div>
 {/if}
 {if $item.embedable eq true and $item.finished eq false}
        {if $item.mime=='video/mpeg'}
-                       <div class="stream"><a href='?f={$id|escape:'url'}'>download ({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_partial format="%.0f"}%)</a></div>
+       <div class="stream"><a href='?f={$id|escape:'url'}'>download ({math equation="(y / x) * 100" x=$item.chunks y=$item.chunks_partial format="%.0f"}%)</a></div>
        {/if}
 {/if}
 
-                       <div class="clear"></div>
-               </div>
+       <div class="clear"></div>
+</div>
        
-               <div class="clear"></div>
+<div class="clear"></div>
 {/if}
 
 {else}{*These items are plain files / uploaded manually by the user via ftp*}
 
 {if $item.hidden eq false OR $user_level > 99 }
-               <div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
+<div class={if $item.finished==true}"status3"{elseif $item.finished!=true && $item.embedable==true}"status2"{elseif $item.finished!=true && $item.embedable!=true}"status1"{else}"item"{/if}>
 
-                       <div class="name">{$item.name|escape} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&amp;h={$id|escape:'url'}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&amp;h={$id|escape:'url'}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&amp;h={$id|escape:'url'}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name|escape:'quotes'}?')">delete</a>|</font>{/if}{/if}</div>
+       <div class="name">{$item.name|escape} {if $user_level > 99}{if $item.hidden}<font color=red>|<a href='?tools=unhide&amp;h={$id|escape:'url'}'>publish</a>|</font>{else}<font color=green>|<a href='?tools=hide&amp;h={$id|escape:'url'}'>hide</a>|</font>{/if}{if $user_level > 199}<font color=red>|<a href='?tools=delete&amp;h={$id|escape:'url'}' onClick="javascript:return confirm('Are you sure you want to permanently delete {$item.name|escape:'quotes'}?')">delete</a>|</font>{/if}{/if}</div>
 
-                       <div class="status">status: {$item.status|escape}</div>
+       <div class="status">status: {$item.status|escape}</div>
 
-                       <div class="clear"></div>
+       <div class="clear"></div>
 
-                       <div class="added">added: {$item.date|escape}</div>
+       <div class="added">added: {$item.date|escape}</div>
 
-                       <div class="size">size:&nbsp;{if $item.size>(1024*1024)}{math equation="(x / 1024) / 1024" x=$item.size format="%.2f"}mb{elseif $item.size>(1024)}{math equation="(x / 1024)" x=$item.size format="%.2f"}kb{else}{$item.size|escape}b{/if}</div>
+       <div class="size">size: {nicesize size=$item.size}</div>
 
-                       <div class="clear"></div>
+       <div class="clear"></div>
 
-                       <div class="updated">last updated: {$item.lastchange|escape}</div>
+       <div class="updated">last updated: {$item.lastchange|escape}</div>
 
 
 {if $item.finished==true}
-                       <div class="download"><a href='?f={$id|escape:'url'}'>download</a></div>
+       <div class="download"><a href='?f={$id|escape:'url'}'>download</a></div>
 {/if}
 {if $item.embedable eq true and $item.finished eq false}
        {if $item.mime=='video/mpeg'}
-                       <div class="stream"><a href='?f={$id|escape:'url'}'>download (partial)</a></div>
+       <div class="stream"><a href='?f={$id|escape:'url'}'>download (partial)</a></div>
        {/if}
 {/if}
 
-                       <div class="clear"></div>
-               </div>
+       <div class="clear"></div>
+</div>
        
-               <div class="clear"></div>
+<div class="clear"></div>
 {/if}
 {/if}
 {/foreach}
-       </div>
+{/block}
 
-       <div class="filler">
+
+{block filler}
+<div class="filler">
 {if $user_level > 100 and $mass_delete_size > 1}
-               <div class="massdelete"><br>
-                       <div class="deletebox" id="deletebox">
-                               <form name="deletetool" action="?tools=delete&amp;h=multiple" method="post" onSubmit='return confirm("Are you sure you want to delete the selected files? \nThis page may take a while to reload while the files are removed.");'>
-                                       <select multiple="" size="{$mass_delete_size|escape}" id="h" name="h[]" width="300px">
-                                               {foreach item=item key=id from=$squashed}
-                                               <option value="{$id|escape}" title="{$item.name|escape}">{$item.name|truncate:39|escape}</option>
-                                               {/foreach}
-                                       </select>
-                                       <input type="button" value="Select All" OnClick="selectAllList();" ><input type="reset" value="Clear"><input type="submit" value="Delete Selected Items">
-                               </form>
-                       </div>
+       <div class="massdelete"><br>
+               <div class="deletebox" id="deletebox">
+                       <form name="deletetool" action="?tools=delete&amp;h=multiple" method="post" onSubmit='return confirm("Are you sure you want to delete the selected files? \nThis page may take a while to reload while the files are removed.");'>
+                               <select multiple="" size="{$mass_delete_size|escape}" id="h" name="h[]" width="300px">
+                                       {foreach item=item key=id from=$squashed}
+                                       <option value="{$id|escape}" title="{$item.name|escape}">{$item.name|truncate:39|escape}</option>
+                                       {/foreach}
+                               </select>
+                               <input type="button" value="Select All" OnClick="selectAllList();" ><input type="reset" value="Clear"><input type="submit" value="Delete Selected Items">
+                       </form>
                </div>
-{/if}
        </div>
-
-       <div class="bottomimage"></div>
-       <div class="footer">&nbsp;</div>
+{/if}
 </div>
-{if $debug}{debug}{/if}
-</body>
-</html>
+{/block}
+
+
+{* vim: set syntax=smarty ts=4 sw=4 sts=4 sr noet: *}