diff options
Diffstat (limited to 'lib/exe/ajax.php')
-rw-r--r-- | lib/exe/ajax.php | 95 |
1 files changed, 94 insertions, 1 deletions
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 2bfa3680c..d4ef8dc11 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -208,7 +208,100 @@ 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; + + if ($_FILES['qqfile']['tmp_name']) { + $id = ((empty($_POST['mediaid'])) ? $_FILES['qqfile']['name'] : $_POST['mediaid']); + } elseif (isset($_GET['qqfile'])) { + $id = $_GET['qqfile']; + } + + $id = cleanID($id, false, true); + + $NS = $_REQUEST['ns']; + $ns = $NS.':'.getNS($id); + + $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']); + if (isset($_GET['qqfile'])) $res = media_upload_xhr($NS, $AUTH); + + 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; } /** |