summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/ajax.php92
-rw-r--r--lib/exe/css.php4
-rw-r--r--lib/exe/fetch.php10
-rw-r--r--lib/exe/js.php2
-rw-r--r--lib/exe/mediamanager.php24
5 files changed, 120 insertions, 12 deletions
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index 2bfa3680c..a6e45c4de 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -208,7 +208,97 @@ function ajax_medialist(){
global $NS;
$NS = $_POST['ns'];
- tpl_mediaContent(true);
+ if ($_POST['do'] == 'media') {
+ tpl_mediaFileList();
+ } else {
+ tpl_mediaContent(true);
+ }
+}
+
+/**
+ * Return the content of the right column
+ * (image details) for the Mediamanager
+ *
+ * @author Kate Arzamastseva <pshns@ukr.net>
+ */
+function ajax_mediadetails(){
+ global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf;
+ $fullscreen = true;
+ require_once(DOKU_INC.'lib/exe/mediamanager.php');
+
+ if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']);
+ if (isset($IMG)) $image = $IMG;
+ if (isset($JUMPTO)) $image = $JUMPTO;
+ if (isset($REV) && !$JUMPTO) $rev = $REV;
+
+ html_msgarea();
+ tpl_mediaFileDetails($image, $rev);
+}
+
+/**
+ * Returns image diff representation for mediamanager
+ * @author Kate Arzamastseva <pshns@ukr.net>
+ */
+function ajax_mediadiff(){
+ global $NS;
+
+ if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']);
+ $NS = $_POST['ns'];
+ $auth = auth_quickaclcheck("$ns:*");
+ media_diff($image, $NS, $auth, true);
+}
+
+function ajax_mediaupload(){
+ global $NS, $MSG;
+
+ $NS = $_REQUEST['ns'];
+ $AUTH = auth_quickaclcheck("$NS:*");
+ if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); }
+
+ if ($_FILES['qqfile']['error']) unset($_FILES['qqfile']);
+
+ if ($_FILES['qqfile']['tmp_name']) {
+ $res = media_upload($NS, $AUTH, $_FILES['qqfile']);
+ $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']);
+ }
+ if (isset($_GET['qqfile'])) {
+ $res = media_upload_xhr($NS, $AUTH);
+ $id = $_GET['qqfile'];
+ }
+ $id = cleanID($id, false, true);
+
+ if ($res) $result = array('success' => true,
+ 'link' => media_managerURL(array('ns' => $NS, 'image' => $NS.':'.$id), '&'),
+ 'id' => $NS.':'.$id, 'ns' => $NS);
+
+ if (!$result) {
+ $error = '';
+ if (isset($MSG)) {
+ foreach($MSG as $msg) $error .= $msg['msg'];
+ }
+ $result = array('error' => $msg['msg'], 'ns' => $NS);
+ }
+ echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
+}
+
+function dir_delete($path) {
+ if (!is_string($path) || $path == "") return false;
+
+ if (is_dir($path) && !is_link($path)) {
+ if (!$dh = @opendir($path)) return false;
+
+ while ($f = readdir($dh)) {
+ if ($f == '..' || $f == '.') continue;
+ dir_delete("$path/$f");
+ }
+
+ closedir($dh);
+ return @rmdir($path);
+ } else {
+ return @unlink($path);
+ }
+
+ return false;
}
/**
diff --git a/lib/exe/css.php b/lib/exe/css.php
index 8f86f2433..81f47d8fa 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -189,7 +189,7 @@ function css_interwiki(){
function css_filetypes(){
// default style
- echo 'a.mediafile {';
+ echo '.mediafile {';
echo ' background: transparent url('.DOKU_BASE.'lib/images/fileicons/file.png) 0px 1px no-repeat;';
echo ' padding-left: 18px;';
echo ' padding-bottom: 1px;';
@@ -212,7 +212,7 @@ function css_filetypes(){
}
foreach($exts as $ext=>$type){
$class = preg_replace('/[^_\-a-z0-9]+/','_',$ext);
- echo "a.mf_$class {";
+ echo ".mf_$class {";
echo ' background-image: url('.DOKU_BASE.'lib/images/fileicons/'.$ext.$type.')';
echo '}';
}
diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php
index 3ad4f1937..143d40f22 100644
--- a/lib/exe/fetch.php
+++ b/lib/exe/fetch.php
@@ -20,6 +20,10 @@
$CACHE = calc_cache($_REQUEST['cache']);
$WIDTH = (int) $_REQUEST['w'];
$HEIGHT = (int) $_REQUEST['h'];
+ $REV = (int) @$_REQUEST['rev'];
+ //sanitize revision
+ $REV = preg_replace('/[^0-9]/','',$REV);
+
list($EXT,$MIME,$DL) = mimetype($MEDIA,false);
if($EXT === false){
$EXT = 'unknown';
@@ -28,7 +32,7 @@
}
// check for permissions, preconditions and cache external files
- list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE);
+ list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE, $REV);
// prepare data for plugin events
$data = array('media' => $MEDIA,
@@ -147,7 +151,7 @@ function sendFile($file,$mime,$dl,$cache){
* @param $file reference to the file variable
* @returns array(STATUS, STATUSMESSAGE)
*/
-function checkFileStatus(&$media, &$file) {
+function checkFileStatus(&$media, &$file, $rev='') {
global $MIME, $EXT, $CACHE;
//media to local file
@@ -172,7 +176,7 @@ function checkFileStatus(&$media, &$file) {
if(auth_quickaclcheck(getNS($media).':X') < AUTH_READ){
return array( 403, 'Forbidden' );
}
- $file = mediaFN($media);
+ $file = mediaFN($media, $rev);
}
//check file existance
diff --git a/lib/exe/js.php b/lib/exe/js.php
index e96d45ee6..33f8c695d 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -43,6 +43,8 @@ function js_out(){
DOKU_INC."lib/scripts/jquery/jquery$min.js",
DOKU_INC.'lib/scripts/jquery/jquery.cookie.js',
DOKU_INC."lib/scripts/jquery/jquery-ui$min.js",
+ DOKU_INC."lib/scripts/fileuploader.js",
+ DOKU_INC."lib/scripts/fileuploaderextended.js",
DOKU_INC.'lib/scripts/helpers.js',
DOKU_INC.'lib/scripts/delay.js',
DOKU_INC.'lib/scripts/cookie.js',
diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php
index 02fde5a8d..5f09fe1f8 100644
--- a/lib/exe/mediamanager.php
+++ b/lib/exe/mediamanager.php
@@ -35,7 +35,7 @@
$AUTH = auth_quickaclcheck("$NS:*");
// do not display the manager if user does not have read access
- if($AUTH < AUTH_READ) {
+ if($AUTH < AUTH_READ && !$fullscreen) {
header('HTTP/1.0 403 Forbidden');
die($lang['accessdenied']);
}
@@ -76,10 +76,20 @@
}
// handle meta saving
- if($IMG && $_REQUEST['do']['save']){
+ if($IMG && @array_key_exists('save', $_REQUEST['do'])){
$JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
}
+ if($IMG && ($_REQUEST['mediado'] == 'save' || @array_key_exists('save', $_REQUEST['mediado']))) {
+ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
+ }
+
+ if ($_REQUEST['rev'] && $conf['mediarevisions']) $REV = (int) $_REQUEST['rev'];
+
+ if($_REQUEST['mediado'] == 'restore' && $conf['mediarevisions']){
+ $JUMPTO = media_restore($_REQUEST['image'], $REV, $AUTH);
+ }
+
// handle deletion
if($DEL) {
$res = 0;
@@ -88,7 +98,7 @@
}
if ($res & DOKU_MEDIA_DELETED) {
$msg = sprintf($lang['deletesucc'], noNS($DEL));
- if ($res & DOKU_MEDIA_EMPTY_NS) {
+ if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) {
// current namespace was removed. redirecting to root ns passing msg along
send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='.
rawurlencode($msg).'&edid='.$_REQUEST['edid']);
@@ -102,9 +112,11 @@
msg(sprintf($lang['deletefail'],noNS($DEL)),-1);
}
}
-
// finished - start output
- header('Content-Type: text/html; charset=utf-8');
- include(template('mediamanager.php'));
+
+ if (!$fullscreen) {
+ header('Content-Type: text/html; charset=utf-8');
+ include(template('mediamanager.php'));
+ }
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */