}
public static function urls(){
return array(
- array('regex'=>'$#', 'func'=>'IPF_Admin_Views_Index'),
+ array('regex'=>'filebrowser(.+)#', 'func'=>'IPF_Admin_Views_FileBrowser'),
+ array('regex'=>'$#', 'func'=>'IPF_Admin_Views_Index'),
array('regex'=>'([\w\_\-]+)/([\w\_\-]+)/$#i', 'func'=>'IPF_Admin_Views_ListItems'),
array('regex'=>'([\w\_\-]+)/([\w\_\-]+)/reorder/$#i', 'func'=>'IPF_Admin_Views_Reorder'),
array('regex'=>'([\w\_\-]+)/([\w\_\-]+)/add/$#i', 'func'=>'IPF_Admin_Views_AddItem'),
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ {block css}
+ <link rel="stylesheet" href="{$ADMIN_MEDIA_URL}css/base.css" />
+ {/block}
+ <link rel="stylesheet" type="text/css" href="{$ADMIN_MEDIA_URL}css/print.css" media="print" />
+ <title>{$page_title} - IPF Administration</title>
+</head>
+
+<body style="padding:0; margin:0;">
+<script language="javascript" type="text/javascript" src="{$ADMIN_MEDIA_URL}js/jquery.js"></script>
+{block breadcrumb}{/block}
+<table cellpadding="0" cellspacing="0" width="100%"><tr>
+<td valign="top" style="width:250px; background:#f0f0f0; border-right:1px dashed #a0a0a0; padding:10px;">{block sidebar}{/block}</td>
+<td valign="top" style="padding:10px;">{block content}{/block}</td>
+</tr></table>
+</body>
+</html>
--- /dev/null
+{extends "admin/base_filebrowser.html"}
+
+{block breadcrumb}
+<div class="breadcrumbs"><a href="/admin/filebrowser/">Home</a>
+{foreach $path as $p}
+ / <a href="{$p['cd']}">{$p['name']}</a>
+{/foreach}
+</div>
+
+<style>
+{literal}
+a{color:#2B6FB6}
+{/literal}
+</style>
+
+<script type="text/javascript" src="{$ADMIN_MEDIA_URL}tiny_mce/tiny_mce_popup.js"></script>
+
+<script type="text/javascript">
+var curr_dir = '{$curr_dir}';
+var upload_url = '{$UPLOAD_URL}';
+var admin_media_url = '{$ADMIN_MEDIA_URL}';
+{literal}
+function click_file(filename, image, w, h){
+ var fname = upload_url+curr_dir+filename;
+ $('#picname').text(filename);
+ if (image=='1')
+ $('#pic').attr('src',fname);
+ else
+ $('#pic').attr('src',admin_media_url+'img/zero.gif');
+ $('#pic').attr('width',w);
+ $('#pic').attr('height',h);
+ return false;
+}
+
+
+var FileBrowserDialogue = {
+ init : function () {
+ // Here goes your code for setting your custom things onLoad.
+ },
+ mySubmit : function () {
+ var URL = upload_url + curr_dir + $('#picname').text();
+ var win = tinyMCEPopup.getWindowArg("window");
+ // insert information now
+ win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = URL;
+ // are we an image browser
+ if (typeof(win.ImageDialog) != "undefined")
+ {
+ // we are, so update image dimensions and preview if necessary
+ if (win.ImageDialog.getImageData) win.ImageDialog.getImageData();
+ if (win.ImageDialog.showPreviewImage) win.ImageDialog.showPreviewImage(URL);
+ }
+ // close popup window
+ tinyMCEPopup.close();
+ }
+}
+tinyMCEPopup.onInit.add(FileBrowserDialogue.init, FileBrowserDialogue);
+
+
+
+{/literal}
+</script>
+
+{/block}
+
+{block sidebar}
+<form method="post">
+<h3>Add Folder</h3>
+<input name="new_folder" />
+<div class="submit-row">
+<input class="default" type="submit" value="Create"/>
+</div>
+</form>
+
+<form method="post" enctype="multipart/form-data">
+<h3 style="border-top:1px dashed #a0a0a0; padding-top:5px;">Upload File</h3>
+<input type="file" name="file" />
+<div class="submit-row">
+<input class="default" type="submit" value="Upload"/>
+</div>
+</form>
+
+<h3 style="border-top:1px dashed #a0a0a0; padding-top:5px;">View File</h3>
+
+<div id="picname"></div>
+<div style="border:2px solid white; width:240px; text-align:center;">
+<img id="pic" src="{$ADMIN_MEDIA_URL}img/zero.gif" width="240" height="150" /></div>
+<div class="submit-row">
+<input type="button" value="Select & Close" onclick="FileBrowserDialogue.mySubmit()" />
+</div>
+
+{/block}
+
+{block content}
+
+<div class="module" id="changelist">
+<table>
+<thead>
+<tr>
+ <th>Filename</th>
+ <th>Type</th>
+ <th>Size</th>
+ <th>delete</th>
+</tr>
+</thead>
+<tbody>
+{foreach $dirs as $dir}
+<tr>
+ <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>
+ <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>
+ <td><a href="?delete={$file['name']}">delete</a></td>
+</tr>
+{/foreach}
+</tbody>
+</table>
+
+</div>
+{/block}
+
);
return IPF_Shortcuts::RenderToResponse('admin/logout.html', $context, $request);
}
+
+function IPF_Admin_Views_FileBrowser($request, $match){
+ $ca = IPF_Admin_App::checkAdminAuth($request);
+ if ($ca!==true) return $ca;
+
+ $curr_dir = urldecode(substr($match[1],1));
+ $dir = IPF::get('upload_path').$curr_dir;
+
+ if ($request->method=="GET"){
+ if (@$request->GET['delete']){
+ $del = $dir.$request->GET['delete'];
+ @IPF_Utils::removeDirectories($del);
+ }
+ }
+
+
+ if ($request->method=="POST"){
+ if (@$request->POST['new_folder']!='')
+ @mkdir($dir.$request->POST['new_folder']);
+
+ if (@$_FILES['file']){
+ $uploadfile = $dir . basename($_FILES['file']['name']);
+ @move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);
+ }
+ }
+
+ $dirs = array();
+ $files = array();
+ if ($dh = @opendir($dir)) {
+ while (($file = readdir($dh)) !== false) {
+ if ($file=='.')
+ continue;
+ if (($curr_dir=='') && ($file=='..'))
+ continue;
+ if (filetype($dir . $file)=='dir')
+ $dirs[] = array('name'=>$file);
+ else{
+
+ $sx = getimagesize($dir.$file);
+ if ($sx){
+ $image = '1';
+ $type = str_replace('image/','',$sx['mime']).' '.$sx[0].'x'.$sx[1];
+ if ($sx[0]<=200){
+ $zw = $sx[0];
+ $zh = $sx[1];
+ }
+ else {
+ $zw = 200;
+ $prop = (float)$sx[1] / (float)$sx[0];
+ $zh = (int)(200.0 * $prop);
+ }
+ }
+ else {
+ $image = '0';
+ $type = 'binary';
+ $zw = 200;
+ $zw = 150;
+ }
+ $files[] = array('name'=>$file, 'image'=>$image, 'type'=>$type, 'zw'=>$zw, 'zh'=>$zh, 'size'=>filesize($dir . $file));
+ }
+ }
+ closedir($dh);
+ }
+
+ $pth = split(DIRECTORY_SEPARATOR,$curr_dir);
+ $path = array();
+ $cd = '/admin/filebrowser/';
+ foreach($pth as $p){
+ $cd.=$p.DIRECTORY_SEPARATOR;
+ $path[] = array('cd'=>$cd, 'name'=>$p);
+ }
+
+ $context = array(
+ 'page_title' => __('File Browser'),
+ 'dirs' => $dirs,
+ 'files' => $files,
+ 'path' => $path,
+ 'curr_dir' => $curr_dir,
+ );
+ return IPF_Shortcuts::RenderToResponse('admin/filebrowser.html', $context, $request);
+}
IPF_Form_Widget_HTMLInput::$js_include = true;
$out .= '<script language="javascript" type="text/javascript" src="'.IPF::get('tiny_mce_url').'tiny_mce.js"></script>'."\n";
$out .='<script language="javascript" type="text/javascript">
- function kfm_for_tiny_mce(field_name, url, type, win){
- window.SetUrl=function(url,width,height,caption){
- win.document.forms[0].elements[field_name].value = url;
- if(caption){
- win.document.forms[0].elements["alt"].value=caption;
- win.document.forms[0].elements["title"].value=caption;
- }
- }
- window.open("/media/tiny_mce/plugins/kfm/index.php?mode=selector&lang=en&type="+type,"kfm","modal,width=800,height=600");
- }
+ function ipf_filebrowser(field_name, url, type, win) {
+ var cmsURL = "/admin/filebrowser/";
+ tinyMCE.activeEditor.windowManager.open({
+ file : cmsURL,
+ title : "IPF File Browser",
+ width : 640,
+ height : 480,
+ resizable : "yes",
+ inline : "yes",
+ close_previous : "no"
+ }, {
+ window : win,
+ input : field_name
+ });
+ return false;
+ }
tinyMCE.init({
theme_advanced_buttons1 : "bold, italic, underline, separator, undo, redo, separator, bullist, numlist, outdent, indent, separator, justifyleft, justifycenter, justifyright, justifyfull, separator, link, unlink, forecolor, backcolor, sub, sup, separator, preview",
theme_advanced_buttons2 : "code, fullscreen, image, charmap, separator, pastetext, pasteword, selectall, removeformat, separator, formatselect, fontselect, fontsizeselect",
relative_urls : false,
remove_script_host : true,
content_css : "/media/tiny_mce/themes/advanced/skins/default/content.css",
- file_browser_callback : "kfm_for_tiny_mce"
+ file_browser_callback : "ipf_filebrowser"
});
</script>';
}
}
return rmdir($folderPath);
} else {
- return false;
+ unlink($folderPath);
}
}