summaryrefslogtreecommitdiff
path: root/lib/exe
diff options
context:
space:
mode:
Diffstat (limited to 'lib/exe')
-rw-r--r--lib/exe/media.php70
1 files changed, 54 insertions, 16 deletions
diff --git a/lib/exe/media.php b/lib/exe/media.php
index c8db37153..cddf258db 100644
--- a/lib/exe/media.php
+++ b/lib/exe/media.php
@@ -14,8 +14,12 @@
//get namespace to display (either direct or from deletion order)
if($_REQUEST['delete']){
- $DEL = cleanID($_REQUEST['delete']);
+ $DEL = cleanID($_REQUEST['delete']);
$NS = getNS($DEL);
+ }elseif($_REQUEST['edit']){
+ $IMG = cleanID($_REQUEST['edit']);
+ $SRC = mediaFN($IMG);
+ $NS = getNS($IMG);
}else{
$NS = $_REQUEST['ns'];
$NS = cleanID($NS);
@@ -35,9 +39,9 @@
//handle deletion
$mediareferences = array();
if($DEL && $AUTH >= AUTH_DELETE){
- if($conf['refcheck']){
- search($mediareferences,$conf['datadir'],'search_reference',array('query' => $DEL));
- }
+ if($conf['refcheck']){
+ search($mediareferences,$conf['datadir'],'search_reference',array('query' => $DEL));
+ }
if(!count($mediareferences)){
media_delete($DEL);
}elseif(!$conf['refshow']){
@@ -45,6 +49,11 @@
}
}
+ //handle metadatasaving
+ if($UPLOADOK && $SRC && $_REQUEST['save']){
+ media_metasave($SRC,$_REQUEST['meta']);
+ }
+
//handle upload
if($_FILES['upload']['tmp_name'] && $UPLOADOK){
media_upload($NS,$AUTH);
@@ -54,6 +63,8 @@
header('Content-Type: text/html; charset=utf-8');
if($conf['refshow'] && count($mediareferences)){
include(template('mediaref.php'));
+ }elseif($IMG){
+ include(template('mediaedit.php'));
}else{
include(template('media.php'));
}
@@ -87,7 +98,7 @@ function media_delete($delid){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function media_upload($NS,$AUTH){
- require_once(DOKU_INC.'inc/confutils.php');
+ require_once(DOKU_INC.'inc/confutils.php');
global $lang;
global $conf;
@@ -101,24 +112,24 @@ function media_upload($NS,$AUTH){
$fn = mediaFN($id);
// get filetype regexp
- $types = array_keys(getMimeTypes());
- $types = array_map(create_function('$q','return preg_quote($q,"/");'),$types);
+ $types = array_keys(getMimeTypes());
+ $types = array_map(create_function('$q','return preg_quote($q,"/");'),$types);
$regex = join('|',$types);
// we set the umask here but this doesn't really help
// because a temp file was created already
umask($conf['umask']);
if(preg_match('/\.('.$regex.')$/i',$fn)){
- //check for overwrite
- if(@file_exists($fn) && (!$_POST['ow'] || $AUTH < AUTH_DELETE)){
- msg($lang['uploadexist'],0);
- return false;
- }
- // prepare directory
- io_makeFileDir($fn);
+ //check for overwrite
+ if(@file_exists($fn) && (!$_POST['ow'] || $AUTH < AUTH_DELETE)){
+ msg($lang['uploadexist'],0);
+ return false;
+ }
+ // prepare directory
+ io_makeFileDir($fn);
if(move_uploaded_file($file['tmp_name'], $fn)) {
- // set the correct permission here
- chmod($fn, 0777 - $conf['umask']);
+ // set the correct permission here
+ chmod($fn, 0777 - $conf['umask']);
msg($lang['uploadsucc'],1);
return true;
}else{
@@ -146,4 +157,31 @@ function media_html_list_namespaces($item){
return $ret;
}
+/**
+ * Saves image meta data
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function media_metasave($src,$data){
+ global $lang;
+
+ $meta = new JpegMeta($src);
+ $meta->_parseAll();
+
+ foreach($data as $key => $val){
+ $val=trim($val);
+ if(empty($val)){
+ $meta->deleteField($key);
+ }else{
+ $meta->setField($key,$val);
+ }
+ }
+
+ if($meta->save()){
+ msg($lang['metasaveok'],1);
+ }else{
+ msg($lang['metasaveerr'],-1);
+ }
+}
+
?>