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();
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 () {
<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>
</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>
{/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}
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;
}
}
-
if ($request->method=="POST"){
if (@$request->POST['new_folder']!='')
@mkdir($dir.$request->POST['new_folder']);
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);
}
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/';
$context = array(
'page_title' => __('File Browser'),
+ 'dirtree' => $dirtree,
'dirs' => $dirs,
- 'files' => $files,
+ 'files' => $files,
'path' => $path,
'upload_url' => $upload_url,
'curr_dir' => $curr_dir,