]> git.andy128k.dev Git - ipf.git/commitdiff
fm update
authoravl <alex.litovchenko@gmail.com>
Thu, 6 Aug 2009 10:27:11 +0000 (13:27 +0300)
committeravl <alex.litovchenko@gmail.com>
Thu, 6 Aug 2009 10:27:11 +0000 (13:27 +0300)
ipf/admin/templates/admin/filebrowser.html
ipf/admin/views.php

index aa586b3eac188daa75ff41926dae4e78e4c312a1..98a69096e77f557499938c13fa72dde9ee8d9588 100644 (file)
@@ -20,7 +20,17 @@ a:hover{color:black !important;}
 var curr_dir = '{$curr_dir}';
 var upload_url = '{$upload_url}';
 var admin_media_url = '{$ADMIN_MEDIA_URL}';
+var mouseX = 0;
+var mouseY = 0;
 {literal}
+
+$().mousemove( function(e) {
+       mouseX = e.pageX;
+       mouseY = e.pageY;
+       $('#prop').css('top',mouseY+5);
+       $('#prop').css('left',mouseX+10);
+});
+
 function click_file(filename, image, w, h){
        var fname = upload_url+curr_dir+filename;
        $('#picname').show();
@@ -37,6 +47,20 @@ function click_file(filename, image, w, h){
        return false;
 }
 
+function line_over(id, is_dir, is_image, type, size, filename){
+       if (is_image==1){
+               $('#prop').hide();
+               var fname = upload_url+curr_dir+filename;
+               $('#prop').html('<img src="'+fname+'" width="100" />');
+               $('#prop').css('top',mouseY+5);
+               $('#prop').css('left',mouseX+10);
+               $('#prop').show();
+       }
+}
+
+function line_out(id){
+       $('#prop').hide();
+}
 
 var FileBrowserDialogue = {
     init : function () {
@@ -97,8 +121,9 @@ tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);
 
 <form method="post">
        <table cellpadding="0" cellspacing="0"><tr>
+       <input type="hidden" name="action" value="move" />
        <input type="hidden" name="old_name" id="id_old_name2" />
-       <td><select name="move">{foreach $dirs as $dir}<option value="{$dir['name']}">{$dir['name']}</option>{/foreach}</select></td><td>
+       <td><select name="move">{foreach $dirtree as $dir}<option value="{$dir['path']}">{$dir['name']}</option>{/foreach}</select></td><td>
        <div class="submit-row" style="float:left;"><input class="default" type="submit" value="Move To"/></div>
        </td></tr></table>
 </form>
@@ -129,14 +154,14 @@ tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);
 </thead>
 <tbody>
 {foreach $dirs as $dir}
-<tr id="id_">
+<tr id="id_{$dir['id']}" onmouseover="line_over({$dir['id']},1,0,'SUB-DIR',0,'{$dir['name']}')" onmouseout="line_out({$dir['id']})">
        <td><a href="{$dir['name']}">{$dir['name']}</a></td>
        <td colspan="2">SUB-DIR</td>
        <td>{if $dir['name']!='..'}<a href="?delete={$dir['name']}">delete</a>{/if}</td>
 </tr>
 {/foreach}
 {foreach $files as $file}
-<tr>
+<tr id="id_{$file['id']}" onmouseover="line_over({$file['id']},0,{$file['image']}, '{$file['type']}', {$file['size']}, '{$file['name']}')" onmouseout="line_out({$dir['id']})">
        <td><a href="#" onclick="return click_file('{$file['name']}', '{$file['image']}', {$file['zw']}, {$file['zh']})">{$file['name']}</a></td>
        <td>{$file['type']}</td>
        <td>{$file['size']}</td>
@@ -145,7 +170,8 @@ tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);
 {/foreach}
 </tbody>
 </table>
-
 </div>
+
+<div id="prop" style="display:none; position:absolute; left:0; top:0; z-index:400000; background:white; border:2px solid #aaa;">wewfwf</div>
 {/block}
 
index b6edcefdfc8ff176ada5ff4e3b19efa6939473b6..32cc8205537a72db220cda77bb34262e302c5aa5 100644 (file)
@@ -259,6 +259,35 @@ function IPF_Admin_Views_Logout($request, $match){
     return IPF_Shortcuts::RenderToResponse('admin/logout.html', $context, $request);
 }
 
+function cmp($a, $b){
+    if ($a['name'] == $b['name']) {
+        return 0;
+    }
+    return ($a['name'] < $b['name']) ? -1 : 1;
+}
+
+function dir_recursive($dir, $path=DIRECTORY_SEPARATOR, $level=''){
+       $dirtree = array();
+       if ($level=='')
+               $dirtree[] = array('path'=>'', 'name'=>'Root Folder');
+       $dd = array();
+    if ($dh = @opendir($dir)) {
+        while (($file = readdir($dh)) !== false) {
+               if (($file=='.') || ($file=='..')) continue;
+               if (filetype($dir . $file)=='dir')
+                       $dd[] = $file;
+        }
+               closedir($dh);
+       sort($dd);
+       foreach($dd as $file){
+               $dirtree[] = array('path'=>$path.$file, 'name'=>$level.$file);
+               $dirtree = array_merge($dirtree, dir_recursive($dir.$file.DIRECTORY_SEPARATOR, $path.$file.DIRECTORY_SEPARATOR, $level.'--'));
+       }        
+    }
+    return $dirtree;
+       //print_r($dirtree);
+}
+
 function IPF_Admin_Views_FileBrowser($request, $match){
     $ca = IPF_Admin_App::checkAdminAuth($request);
     if ($ca!==true) return $ca;
@@ -280,7 +309,6 @@ function IPF_Admin_Views_FileBrowser($request, $match){
        }
     }
     
-    
     if ($request->method=="POST"){
        if (@$request->POST['new_folder']!='')
                @mkdir($dir.$request->POST['new_folder']);
@@ -288,11 +316,9 @@ function IPF_Admin_Views_FileBrowser($request, $match){
        if (@$request->POST['new_name']!='')
                @rename($dir.$request->POST['old_name'], $dir.$request->POST['new_name']);
                
-       if (@$request->POST['move']!=''){
-               @rename($dir.$request->POST['old_name'], $dir.$request->POST['move'].DIRECTORY_SEPARATOR.$request->POST['old_name']);
+       if (@$request->POST['action']=='move'){
+               @rename($dir.$request->POST['old_name'], $upload_path.$request->POST['move'].DIRECTORY_SEPARATOR.$request->POST['old_name']);
        }
-       
-               
        if (@$_FILES['file']){
                        $uploadfile = $dir . basename($_FILES['file']['name']);
                        @move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile); 
@@ -340,8 +366,11 @@ function IPF_Admin_Views_FileBrowser($request, $match){
         }
         closedir($dh);
     }
-    sort(&$dirs);
+    usort(&$dirs, 'cmp');
+    usort(&$files, 'cmp');
     
+    $dirtree = dir_recursive($upload_path);
+        
     $pth = split(DIRECTORY_SEPARATOR,$curr_dir);
     $path = array();
     $cd = '/admin/filebrowser/';
@@ -352,8 +381,9 @@ function IPF_Admin_Views_FileBrowser($request, $match){
         
     $context = array(
         'page_title' => __('File Browser'),
+        'dirtree' => $dirtree,
         'dirs' => $dirs,
-        'files' => $files,
+       'files' => $files,
        'path' => $path,
         'upload_url' => $upload_url,
        'curr_dir' => $curr_dir,