From e4f389ef1728a0f86164a0e4b88626be9860dabb Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 26 May 2011 14:23:33 +0300 Subject: media version saving --- inc/changelog.php | 19 ++++++++++++++----- inc/init.php | 2 ++ inc/media.php | 27 +++++++++++++++++++++++++++ inc/pageutils.php | 22 ++++++++++++++++++++-- 4 files changed, 63 insertions(+), 7 deletions(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index 15cd46d77..0bbb77540 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -138,6 +138,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', // add changelog lines $logline = implode("\t", $logline)."\n"; io_saveFile($conf['media_changelog'],$logline,true); //global media changelog cache + io_saveFile(mediaMetaFN($id,'.changes'),$logline,true); //media file's changelog } /** @@ -301,7 +302,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ * * @author Ben Coburn */ -function getRevisionInfo($id, $rev, $chunk_size=8192) { +function getRevisionInfo($id, $rev, $chunk_size=8192, $media=false) { global $cache_revinfo; $cache =& $cache_revinfo; if (!isset($cache[$id])) { $cache[$id] = array(); } @@ -312,7 +313,11 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) { return $cache[$id][$rev]; } - $file = metaFN($id, '.changes'); + if ($media) { + $file = mediaMetaFN($id, '.changes'); + } else { + $file = metaFN($id, '.changes'); + } if (!@file_exists($file)) { return false; } if (filesize($file)<$chunk_size || $chunk_size==0) { // read whole file @@ -398,7 +403,7 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) { * * @author Ben Coburn */ -function getRevisions($id, $first, $num, $chunk_size=8192) { +function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) { global $cache_revinfo; $cache =& $cache_revinfo; if (!isset($cache[$id])) { $cache[$id] = array(); } @@ -406,11 +411,15 @@ function getRevisions($id, $first, $num, $chunk_size=8192) { $revs = array(); $lines = array(); $count = 0; - $file = metaFN($id, '.changes'); + if ($media) { + $file = mediaMetaFN($id, '.changes'); + } else { + $file = metaFN($id, '.changes'); + } $num = max($num, 0); $chunk_size = max($chunk_size, 0); if ($first<0) { $first = 0; } - else if (@file_exists(wikiFN($id))) { + else if (!$media && @file_exists(wikiFN($id)) || $media && @file_exists(mediaFN($id))) { // skip current revision if the page exists $first = max($first+1, 0); } diff --git a/inc/init.php b/inc/init.php index 819d92bdc..e82e26efd 100644 --- a/inc/init.php +++ b/inc/init.php @@ -230,7 +230,9 @@ function init_paths(){ $paths = array('datadir' => 'pages', 'olddir' => 'attic', 'mediadir' => 'media', + 'mediaolddir' => 'media_attic', 'metadir' => 'meta', + 'mediametadir' => 'media_meta', 'cachedir' => 'cache', 'indexdir' => 'index', 'lockdir' => 'locks', diff --git a/inc/media.php b/inc/media.php index 3c9340d51..6be66dedc 100644 --- a/inc/media.php +++ b/inc/media.php @@ -346,6 +346,13 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov global $conf; global $lang; + $old = @filemtime($fn); + // + if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn)) { + // add old revision to the attic if missing + saveOldMediaRevision($id); + } + // prepare directory io_createNamespace($id, 'media'); @@ -368,6 +375,26 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov } } +/** + * moves the current version to the media_attic and returns its + * revision date + */ +function saveOldMediaRevision($id, $move = 'copy'){ + global $conf; + $oldf = mediaFN($id); + if(!@file_exists($oldf)) return ''; + $date = filemtime($oldf); + $newf = mediaFN($id,$date); + io_makeFileDir($newf); + if($move($oldf, $newf)) { + // Set the correct permission here. + // Always chmod media because they may be saved with different permissions than expected from the php umask. + // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) + chmod($newf, $conf['fmode']); + } + return $date; +} + /** * This function checks if the uploaded content is really what the * mimetype says it is. We also do spam checking for text types here. diff --git a/inc/pageutils.php b/inc/pageutils.php index c9bf60135..51567191e 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -307,6 +307,19 @@ function metaFN($id,$ext){ return $fn; } +/** + * returns the full path to the media's meta file specified by ID and extension + * + * The filename is URL encoded to protect Unicode chars + */ +function mediaMetaFN($id,$ext){ + global $conf; + $id = cleanID($id); + $id = str_replace(':','/',$id); + $fn = $conf['mediametadir'].'/'.utf8_encodeFN($id).$ext; + return $fn; +} + /** * returns an array of full paths to all metafiles of a given ID * @@ -327,11 +340,16 @@ function metaFiles($id){ * * @author Andreas Gohr */ -function mediaFN($id){ +function mediaFN($id, $rev=''){ global $conf; $id = cleanID($id); $id = str_replace(':','/',$id); - $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); + if(empty($rev)){ + $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); + }else{ + list($name, $ext) = explode(".", $id); + $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.$rev.'.'.utf8_encodeFN($ext); + } return $fn; } -- cgit v1.2.3 From cbe26ad6152c998c9a3290b0d321030c61dc7f1b Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 4 Jun 2011 19:12:06 +0300 Subject: media version saving fix --- inc/media.php | 20 +++++++++++++------- inc/pageutils.php | 10 +++++----- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index ac65603f1..be55f8044 100644 --- a/inc/media.php +++ b/inc/media.php @@ -341,16 +341,18 @@ function _media_upload_action($data) { * * @author Andreas Gohr * @author Michael Klier + * @author Kate Arzamastseva */ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'move_uploaded_file') { global $conf; global $lang; $old = @filemtime($fn); - // - if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn)) { + $oldRev = getRevisions($id, -1, 1, 1024, true); // from changelog + $oldRev = (int)(empty($oldRev)?0:$oldRev[0]); + if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn) && $old>=$oldRev) { // add old revision to the attic if missing - saveOldMediaRevision($id); + media_saveOldRevision($id); } // prepare directory @@ -376,17 +378,21 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov } /** - * moves the current version to the media_attic and returns its - * revision date + * Moves the current version of media file to the media_attic + * directory + * + * @author Kate Arzamastseva + * @param string $id + * @return int - revision date */ -function saveOldMediaRevision($id, $move = 'copy'){ +function media_saveOldRevision($id){ global $conf; $oldf = mediaFN($id); if(!@file_exists($oldf)) return ''; $date = filemtime($oldf); $newf = mediaFN($id,$date); io_makeFileDir($newf); - if($move($oldf, $newf)) { + if(copy($oldf, $newf)) { // Set the correct permission here. // Always chmod media because they may be saved with different permissions than expected from the php umask. // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) diff --git a/inc/pageutils.php b/inc/pageutils.php index 51567191e..37b15a498 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -295,8 +295,6 @@ function wikiLockFN($id) { /** * returns the full path to the meta file specified by ID and extension * - * The filename is URL encoded to protect Unicode chars - * * @author Steven Danz */ function metaFN($id,$ext){ @@ -310,7 +308,7 @@ function metaFN($id,$ext){ /** * returns the full path to the media's meta file specified by ID and extension * - * The filename is URL encoded to protect Unicode chars + * @author Kate Arzamastseva */ function mediaMetaFN($id,$ext){ global $conf; @@ -339,6 +337,7 @@ function metaFiles($id){ * The filename is URL encoded to protect Unicode chars * * @author Andreas Gohr + * @author Kate Arzamastseva */ function mediaFN($id, $rev=''){ global $conf; @@ -347,8 +346,9 @@ function mediaFN($id, $rev=''){ if(empty($rev)){ $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); }else{ - list($name, $ext) = explode(".", $id); - $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.$rev.'.'.utf8_encodeFN($ext); + $ext = mimetype($id); + $name = substr($id, 0, strrpos($id, '.')); + $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.(int)$rev.'.'.utf8_encodeFN($ext[0]); } return $fn; } -- cgit v1.2.3 From 29778747fefc70b9f318ba91b47e9207aebc1a95 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 4 Jun 2011 19:19:27 +0300 Subject: media revisions in recent changes --- inc/changelog.php | 50 ++++++++++++++++++++++++++++++++++++++++---------- inc/common.php | 1 + 2 files changed, 41 insertions(+), 10 deletions(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index 0bbb77540..d21c31198 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -152,6 +152,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_INCLUDE_MEDIA - return both media changes and page changes * * @param int $first number of first entry returned (for paginating * @param int $num return $num entries @@ -159,6 +160,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * @param bool $flags see above * * @author Ben Coburn + * @author Kate Arzamastseva */ function getRecents($first,$num,$ns='',$flags=0){ global $conf; @@ -174,20 +176,46 @@ function getRecents($first,$num,$ns='',$flags=0){ } else { $lines = @file($conf['changelog']); } + $lines_position = count($lines)-1; + + if ($flags & RECENTS_INCLUDE_MEDIA) { + $media_lines = @file($conf['media_changelog']); + $media_lines_position = count($media_lines)-1; + } - // handle lines $seen = array(); // caches seen lines, _handleRecent() skips them - for($i = count($lines)-1; $i >= 0; $i--){ - $rec = _handleRecent($lines[$i], $ns, $flags, $seen); - if($rec !== false) { - if(--$first >= 0) continue; // skip first entries - $recent[] = $rec; - $count++; - // break when we have enough entries - if($count >= $num){ break; } + + // handle lines + while ($lines_position >= 0 || (($flags & RECENTS_INCLUDE_MEDIA) && $media_lines_position >=0)) { + if (empty($rec) && $lines_position >= 0) { + $rec = _handleRecent(@$lines[$lines_position], $ns, $flags, $seen); + if (!$rec) { + $lines_position --; + continue; + } + } + if (($flags & RECENTS_INCLUDE_MEDIA) && empty($media_rec) && $media_lines_position >= 0) { + $media_rec = _handleRecent(@$media_lines[$media_lines_position], $ns, $flags, $seen); + if (!$media_rec) { + $media_lines_position --; + continue; + } } + if (($flags & RECENTS_INCLUDE_MEDIA) && @$media_rec['date'] >= @$rec['date']) { + $media_lines_position--; + $x = $media_rec; + $media_rec = false; + } else { + $lines_position--; + $x = $rec; + $rec = false; + } + if(--$first >= 0) continue; // skip first entries + $recent[] = $x; + $count++; + // break when we have enough entries + if($count >= $num){ break; } } - return $recent; } @@ -301,6 +329,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ * requested changelog line is read. * * @author Ben Coburn + * @author Kate Arzamastseva */ function getRevisionInfo($id, $rev, $chunk_size=8192, $media=false) { global $cache_revinfo; @@ -402,6 +431,7 @@ function getRevisionInfo($id, $rev, $chunk_size=8192, $media=false) { * lines are recieved. * * @author Ben Coburn + * @author Kate Arzamastseva */ function getRevisions($id, $first, $num, $chunk_size=8192, $media=false) { global $cache_revinfo; diff --git a/inc/common.php b/inc/common.php index 7522095ab..e0405a735 100644 --- a/inc/common.php +++ b/inc/common.php @@ -15,6 +15,7 @@ define('RECENTS_SKIP_DELETED',2); define('RECENTS_SKIP_MINORS',4); define('RECENTS_SKIP_SUBSPACES',8); define('RECENTS_MEDIA_CHANGES',16); +define('RECENTS_INCLUDE_MEDIA',32); /** * Wrapper around htmlspecialchars() -- cgit v1.2.3 From 61f1aad8f877bdf33a160812d88b60c56aed1040 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 5 Jun 2011 21:00:51 +0300 Subject: media version saving fixes --- inc/changelog.php | 10 +++++----- inc/common.php | 2 +- inc/pageutils.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index d21c31198..937214a6a 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -151,7 +151,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_SKIP_PAGES - return media changes instead of page changes * RECENTS_INCLUDE_MEDIA - return both media changes and page changes * * @param int $first number of first entry returned (for paginating @@ -171,7 +171,7 @@ function getRecents($first,$num,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_MEDIA_CHANGES) { + if ($flags & RECENTS_SKIP_PAGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); @@ -229,7 +229,7 @@ function getRecents($first,$num,$ns='',$flags=0){ * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_SKIP_PAGES - return media changes instead of page changes * * @param int $from date of the oldest entry to return * @param int $to date of the newest entry to return (for pagination, optional) @@ -247,7 +247,7 @@ function getRecentsSince($from,$to=null,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_MEDIA_CHANGES) { + if ($flags & RECENTS_SKIP_PAGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); @@ -314,7 +314,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ if ($recent['perms'] < AUTH_READ) return false; // check existance - $fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); + $fn = (($flags & RECENTS_SKIP_PAGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false; return $recent; diff --git a/inc/common.php b/inc/common.php index e0405a735..acd3609d6 100644 --- a/inc/common.php +++ b/inc/common.php @@ -14,7 +14,7 @@ if(!defined('DOKU_INC')) die('meh.'); define('RECENTS_SKIP_DELETED',2); define('RECENTS_SKIP_MINORS',4); define('RECENTS_SKIP_SUBSPACES',8); -define('RECENTS_MEDIA_CHANGES',16); +define('RECENTS_SKIP_PAGES',16); define('RECENTS_INCLUDE_MEDIA',32); /** diff --git a/inc/pageutils.php b/inc/pageutils.php index 37b15a498..09a23cbdd 100644 --- a/inc/pageutils.php +++ b/inc/pageutils.php @@ -347,8 +347,8 @@ function mediaFN($id, $rev=''){ $fn = $conf['mediadir'].'/'.utf8_encodeFN($id); }else{ $ext = mimetype($id); - $name = substr($id, 0, strrpos($id, '.')); - $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name).'.'.(int)$rev.'.'.utf8_encodeFN($ext[0]); + $name = substr($id,0, -1*strlen($ext[0])); + $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name .'.'.( (int) $rev ).'.'.$ext[0]); } return $fn; } -- cgit v1.2.3 From 8d40b4b6e74029367996c169aa3e67507a4cdfe1 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 5 Jun 2011 21:05:23 +0300 Subject: type of recent changes selection --- inc/html.php | 36 +++++++++++++++++++++++++++++++++--- inc/template.php | 3 ++- 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 6e187ebe1..e8d6b98a5 100644 --- a/inc/html.php +++ b/inc/html.php @@ -567,8 +567,9 @@ function html_revisions($first=0){ * @author Andreas Gohr * @author Matthias Grimm * @author Ben Coburn + * @author Kate Arzamastseva */ -function html_recent($first=0){ +function html_recent($first=0, $show_changes){ global $conf; global $lang; global $ID; @@ -576,10 +577,14 @@ function html_recent($first=0){ * decide if this is the last page or is there another one. * This is the cheapest solution to get this information. */ - $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); + $flags = RECENTS_INCLUDE_MEDIA; + if ($show_changes == 'mediafiles') $flags = RECENTS_SKIP_PAGES; + if ($show_changes == 'pages') $flags = 0; + + $recents = getRecents($first,$conf['recent'] + 1,getNS($ID),$flags); if(count($recents) == 0 && $first != 0){ $first=0; - $recents = getRecents($first,$conf['recent'] + 1,getNS($ID)); + $recents = getRecents($first,$conf['recent'] + 1,getNS($ID),$flags); } $hasNext = false; if (count($recents)>$conf['recent']) { @@ -596,6 +601,31 @@ function html_recent($first=0){ $form->addHidden('sectok', null); $form->addHidden('do', 'recent'); $form->addHidden('id', $ID); + + $form->addElement(form_makeOpenTag('div', array('class' => 'changestypenav'))); + $attrs = array('name' => 'show_changes', + 'value' => 'pages', + '_text' => $lang['pages_changes']); + if ($show_changes == 'pages') $attrs['checked'] = 'checked'; + $form->addElement(form_radiofield($attrs)); + $attrs = array('name' => 'show_changes', + 'value' => 'mediafiles', + '_text' => $lang['media_changes']); + if ($show_changes == 'mediafiles') $attrs['checked'] = 'checked'; + $form->addElement(form_radiofield($attrs)); + $attrs = array('name' => 'show_changes', + 'value' => 'both', + '_text' => $lang['both_changes'] ); + if (empty($show_changes) || $show_changes == 'both') $attrs['checked'] = 'checked'; + $form->addElement(form_radiofield($attrs)); + $form->addElement(form_makeTag('input', array( + 'type' => 'submit', + 'value' => $lang['btn_apply'], + 'title' => $lang['btn_apply'], + 'class' => 'button' + ))); + $form->addElement(form_makeCloseTag('div')); + $form->addElement(form_makeOpenTag('ul')); foreach($recents as $recent){ diff --git a/inc/template.php b/inc/template.php index b9b3951ff..d2d66220c 100644 --- a/inc/template.php +++ b/inc/template.php @@ -89,7 +89,8 @@ function tpl_content_core(){ $_REQUEST['first'] = $_REQUEST['first'][0]; } $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; - html_recent($first); + $show_changes = $_REQUEST['show_changes']; + html_recent($first, $show_changes); break; case 'index': html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? -- cgit v1.2.3 From 0739a638a982a263e933052cdb31594f6bf378e6 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 5 Jun 2011 21:09:26 +0300 Subject: type of recent changes selection fix --- inc/html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index e8d6b98a5..06e9f3b0c 100644 --- a/inc/html.php +++ b/inc/html.php @@ -569,7 +569,7 @@ function html_revisions($first=0){ * @author Ben Coburn * @author Kate Arzamastseva */ -function html_recent($first=0, $show_changes){ +function html_recent($first=0, $show_changes='both'){ global $conf; global $lang; global $ID; -- cgit v1.2.3 From d9162c6cd87643d7e7af8e37cd93aa48b8aecb96 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 9 Jun 2011 14:04:50 +0300 Subject: fullscreen media manager --- inc/actions.php | 2 +- inc/media.php | 401 +++++++++++++++++++++++++++++++++++++++++++++++++++---- inc/template.php | 89 +++++++++++- 3 files changed, 459 insertions(+), 33 deletions(-) (limited to 'inc') diff --git a/inc/actions.php b/inc/actions.php index ecf09036f..1a0ae4028 100644 --- a/inc/actions.php +++ b/inc/actions.php @@ -227,7 +227,7 @@ function act_clean($act){ 'preview','search','show','check','index','revisions', 'diff','recent','backlink','admin','subscribe','revert', 'unsubscribe','profile','resendpwd','recover', - 'draftdel','subscribens','unsubscribens','sitemap')) && substr($act,0,7) != 'export_' ) { + 'draftdel','subscribens','unsubscribens','sitemap','media')) && substr($act,0,7) != 'export_' ) { msg('Command unknown: '.htmlspecialchars($act),-1); return 'show'; } diff --git a/inc/media.php b/inc/media.php index be55f8044..d98e225b9 100644 --- a/inc/media.php +++ b/inc/media.php @@ -74,8 +74,9 @@ function media_metasave($id,$auth,$data){ * Display the form to edit image meta data * * @author Andreas Gohr + * @author Kate Arzamastseva */ -function media_metaform($id,$auth){ +function media_metaform($id,$auth,$fullscreen = false){ if($auth < AUTH_UPLOAD) return false; global $lang, $config_cascade; @@ -96,8 +97,13 @@ function media_metaform($id,$auth){ $src = mediaFN($id); // output - echo '

'.hsc(noNS($id)).'

'.NL; - echo '
'.NL; + if (!$fullscreen) { + echo '

'.hsc(noNS($id)).'

'.NL; + echo ''.NL; + } else { + echo ''.NL; + } formSecurityToken(); foreach($fields as $key => $field){ // get current value @@ -132,8 +138,11 @@ function media_metaform($id,$auth){ } echo '
'.NL; echo ''.NL; - echo ''.NL; + if (!$fullscreen) echo ''.NL; echo '
'.NL; @@ -476,7 +485,7 @@ function media_notify($id,$file,$mime){ /** * List all files in a given Media namespace */ -function media_filelist($ns,$auth=null,$jump=''){ +function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false){ global $conf; global $lang; $ns = cleanID($ns); @@ -484,13 +493,13 @@ function media_filelist($ns,$auth=null,$jump=''){ // check auth our self if not given (needed for ajax calls) if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); - echo '

:'.hsc($ns).'

'.NL; + if (!$fullscreenview) echo '

:'.hsc($ns).'

'.NL; if($auth < AUTH_READ){ // FIXME: print permission warning here instead? echo '
'.$lang['nothingfound'].'
'.NL; }else{ - media_uploadform($ns, $auth); + if (!$fullscreenview) media_uploadform($ns, $auth); $dir = utf8_encodeFN(str_replace(':','/',$ns)); $data = array(); @@ -500,10 +509,248 @@ function media_filelist($ns,$auth=null,$jump=''){ if(!count($data)){ echo '
'.$lang['nothingfound'].'
'.NL; }else foreach($data as $item){ - media_printfile($item,$auth,$jump); + if (!$fullscreenview) media_printfile($item,$auth,$jump); + else if ($fullscreenview == 'thumbs') media_printfile_thumbs($item,$auth,$jump); + } + } + if (!$fullscreenview) media_searchform($ns); +} + +/** + * Prints tabs for files list actions + * + * @author Kate Arzamastseva + * @param string $selected - opened tab + */ +function media_tabs_files($selected=false){ + global $lang; + + echo '
'; + $tab = 'Files'; + echo $tab; + + $tab = 'Upload'; + echo $tab; + + $tab = 'Search'; + echo $tab; + + echo '
 
'; + echo '
'; +} + +/** + * Prints tabs for files details actions + * + * @author Kate Arzamastseva + * @param string $selected - opened tab + */ +function media_tabs_details($selected=false){ + global $lang; + + echo '
'; + $tab = 'View'; + echo $tab; + + $tab = 'Edit'; + echo $tab; + + $tab = 'History'; + echo $tab; + + echo '
 
'; + echo '
'; +} + +/** + * Prints options for the tab that displays a list of all files + * + * @author Kate Arzamastseva + */ +function media_tab_files_options(){ + global $lang; + + echo '
'; + echo '
'; + echo ' + Thumbs'; + echo 'List'; + + echo '
'; + echo '
Sort'; + //select + echo '
'; + echo '
 
'; + echo '
'; +} + +/** + * Prints tab that displays a list of all files + * + * @author Kate Arzamastseva + */ +function media_tab_files($ns,$auth=null,$jump='') { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '
'; + media_tab_files_options(); + echo '
'; + + $view = $_REQUEST['view']; + if($auth < AUTH_READ){ + echo '
'.$lang['nothingfound'].'
'.NL; + }else{ + if ($view == 'list') { + echo '
'; + echo '
'; + } else { + echo '
'; + media_filelist($ns,$auth,$jump,'thumbs'); + echo '
'; } } - media_searchform($ns); + echo '
'; + echo '
'; +} + +/** + * Prints tab that displays uploading form + * + * @author Kate Arzamastseva + */ +function media_tab_upload($ns,$auth=null,$jump='') { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '
'; + echo '
'; + echo $lang['mediaupload']; + echo '
'; + + echo '
'; + media_uploadform($ns, $auth, true); + echo '
'; + echo '
'; +} + +/** + * Prints tab that displays search form + * + * @author Kate Arzamastseva + */ +function media_tab_search($ns,$auth=null) { + global $lang; + + $do = $_REQUEST['mediado']; + $query = $_REQUEST['q']; + if (!$query) $query = ''; + + echo ''; +} + +/** + * Prints tab that displays mediafile details + * + * @author Kate Arzamastseva + */ +function media_tab_view($image, $ns, $auth=null) { + global $lang, $conf; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '
'; + echo '
'; + echo 'Preview of image'; + echo '
'; + + echo '
'; + if($auth < AUTH_READ) return false; + + $info = new JpegMeta(mediaFN($image)); + $w = (int) $info->getField('File.Width'); + $src = ml($image); + echo ''; + echo '
'; + echo '
'; +} + +/** + * Prints tab that displays form for editing mediafile metadata + * + * @author Kate Arzamastseva + */ +function media_tab_edit($image, $ns, $auth=null) { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '
'; + echo '
'; + echo 'Edit'; + echo '
'; + + echo '
'; + media_metaform($image,$auth,true); + echo '
'; + echo '
'; +} + +/** + * Prints tab that displays mediafile revisions + * + * @author Kate Arzamastseva + */ +function media_tab_history($image, $ns, $auth=null) { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '
'; + echo '
'; + echo 'History'; + echo '
'; + + echo '
'; + + echo '
'; + echo '
'; } /** @@ -511,9 +758,10 @@ function media_filelist($ns,$auth=null,$jump=''){ * * @author Tobias Sarnowski * @author Andreas Gohr + * @author Kate Arzamastseva * @triggers MEDIA_SEARCH */ -function media_searchlist($query,$ns,$auth=null){ +function media_searchlist($query,$ns,$auth=null,$fullscreen=false){ global $conf; global $lang; $ns = cleanID($ns); @@ -538,13 +786,16 @@ function media_searchlist($query,$ns,$auth=null){ unset($evt); } - echo '

'.sprintf($lang['searchmedia_in'],hsc($ns).':*').'

'.NL; - media_searchform($ns,$query); + if (!$fullscreen) { + echo '

'.sprintf($lang['searchmedia_in'],hsc($ns).':*').'

'.NL; + media_searchform($ns,$query); + } if(!count($evdata['data'])){ echo '
'.$lang['nothingfound'].'
'.NL; }else foreach($evdata['data'] as $item){ - media_printfile($item,$item['perm'],'',true); + if (!$fullscreen) media_printfile($item,$item['perm'],'',true); + else media_printfile_thumbs($item,$item['perm'],'',true); } } @@ -552,7 +803,7 @@ function media_searchlist($query,$ns,$auth=null){ * Print action links for a file depending on filetype * and available permissions */ -function media_fileactions($item,$auth){ +function media_fileactions($item,$auth,$fullscreen=false){ global $lang; // view button @@ -565,15 +816,20 @@ function media_fileactions($item,$auth){ // delete button if($auth >= AUTH_DELETE){ - echo ' '. + if (!$fullscreen) $link = DOKU_BASE.'lib/exe/mediamanager.php?delete='.rawurlencode($item['id']). + '&sectok='.getSecurityToken(); + else $link = media_managerURL(array('delete' => $item['id'], + 'sectok' => getSecurityToken())); + echo ' '. ''.$lang['btn_delete'].''; } // edit button if($auth >= AUTH_UPLOAD && $item['isimg'] && $item['meta']->getField('File.Mime') == 'image/jpeg'){ - echo ' '. + if (!$fullscreen) $link = DOKU_BASE.'lib/exe/mediamanager.php?edit='.rawurlencode($item['id']); + else $link = media_managerURL(array('edit' => $item['id'])); + echo ' '. ''.$lang['metaedit'].''; } @@ -637,15 +893,50 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ echo ''.NL; } +/** + * Formats and prints one file in the list in the thumbnails view + * + * @author Kate Arzamastseva + */ +function media_printfile_thumbs($item,$auth,$jump){ + global $lang; + global $conf; + + // Prepare filename + $file = utf8_decodeFN($item['file']); + + // Prepare info + $info = ''; + if($item['isimg']){ + $info .= (int) $item['meta']->getField('File.Width'); + $info .= '×'; + $info .= (int) $item['meta']->getField('File.Height'); + $info .= '
'; + } + $info .= ''.dformat($item['mtime']).'
'; + $info .= filesize_h($item['size']); + + // output + echo '
'; + if($item['isimg']) media_printimgdetail($item, true); + echo '
'.hsc($file).'
'; + echo ''.$info.'
'; + media_fileactions($item,$auth,true); + echo '
'.NL; +} + /** * Prints a thumbnail and metainfos */ -function media_printimgdetail($item){ +function media_printimgdetail($item, $fullscreen=false){ // prepare thumbnail + if (!$fullscreen) $size = 120; + else $size = 90; $w = (int) $item['meta']->getField('File.Width'); $h = (int) $item['meta']->getField('File.Height'); - if($w>120 || $h>120){ - $ratio = $item['meta']->getResizeRatio(120); + if($w>$size || $h>$size){ + $ratio = $item['meta']->getResizeRatio($size); $w = floor($w * $ratio); $h = floor($h * $ratio); } @@ -658,6 +949,13 @@ function media_printimgdetail($item){ $att = buildAttributes($p); // output + if ($fullscreen) { + echo ''; + echo ''; + echo ''; + return 1; + } + echo '
'; echo ''; } +/** + * Build link based on the current, adding/rewriting + * parameters + * + * @author Kate Arzamastseva + * @param array $params + * @param string $amp - separator + * @return string - link + */ +function media_managerURL($params=false, $amp='&') { + global $conf; + global $ID; + + $url = $_SERVER['REQUEST_URI']; + + $urlArray = explode('?', $url, 2); + $gets = @$urlArray[1]; + parse_str($gets, $gets); + + if ($gets['edit']) $gets['image'] = $gets['edit']; + unset($gets['edit']); + unset($gets['sectok']); + unset($gets['delete']); + + if ($params) { + foreach ($params as $k => $v) { + $gets[$k] = $v; + } + } + unset($gets['id']); + + return wl($ID,$gets,false,$amp); +} + /** * Print the media upload form if permissions are correct * * @author Andreas Gohr + * @author Kate Arzamastseva */ -function media_uploadform($ns, $auth){ +function media_uploadform($ns, $auth, $fullscreen = false){ global $lang; if($auth < AUTH_UPLOAD) return; //fixme print info on missing permissions? // The default HTML upload form - $form = new Doku_Form(array('id' => 'dw__upload', - 'action' => DOKU_BASE.'lib/exe/mediamanager.php', - 'enctype' => 'multipart/form-data')); - $form->addElement('
' . $lang['mediaupload'] . '
'); + $params = array('id' => 'dw__upload', + 'enctype' => 'multipart/form-data'); + if (!$fullscreen) $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; + else $params['action'] = media_managerURL(array('tab_files' => 'files')); + + $form = new Doku_Form($params); + if (!$fullscreen) $form->addElement('
' . $lang['mediaupload'] . '
'); $form->addElement(formSecurityToken()); $form->addHidden('ns', hsc($ns)); $form->addElement(form_makeOpenTag('p')); @@ -757,16 +1093,21 @@ function media_uploadform($ns, $auth){ * Print the search field form * * @author Tobias Sarnowski + * @author Kate Arzamastseva */ -function media_searchform($ns,$query=''){ +function media_searchform($ns,$query='',$fullscreen=false){ global $lang; // The default HTML search form - $form = new Doku_Form(array('id' => 'dw__mediasearch', 'action' => DOKU_BASE.'lib/exe/mediamanager.php')); - $form->addElement('
' . $lang['mediasearch'] . '
'); + $params = array('id' => 'dw__mediasearch'); + if (!$fullscreen) $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; + else $params['action'] = media_managerURL(); + $form = new Doku_Form($params); + if (!$fullscreen) $form->addElement('
' . $lang['mediasearch'] . '
'); $form->addElement(formSecurityToken()); $form->addHidden('ns', $ns); - $form->addHidden('do', 'searchlist'); + if (!$fullscreen) $form->addHidden('do', 'searchlist'); + else $form->addHidden('mediado', 'searchlist'); $form->addElement(form_makeOpenTag('p')); $form->addElement(form_makeTextField('q', $query,$lang['searchmedia'],'','',array('title'=>sprintf($lang['searchmedia_in'],hsc($ns).':*')))); $form->addElement(form_makeButton('submit', '', $lang['btn_search'])); @@ -820,7 +1161,9 @@ function media_nstree_item($item){ if(!$item['label']) $item['label'] = $label; $ret = ''; + if (!($_REQUEST['do'] == 'media')) $ret .= '
'; + else $ret .= ''; $ret .= $item['label']; $ret .= ''; return $ret; diff --git a/inc/template.php b/inc/template.php index d2d66220c..4bbb501fc 100644 --- a/inc/template.php +++ b/inc/template.php @@ -123,6 +123,9 @@ function tpl_content_core(){ case 'subscribe': tpl_subscribe(); break; + case 'media': + tpl_media(); + break; default: $evt = new Doku_Event('TPL_ACT_UNKNOWN',$ACT); if ($evt->advise_before()) @@ -1123,6 +1126,56 @@ function tpl_mediaContent($fromajax=false){ } +/** + * Prints the central column in full-screen media manager + * Depending on the opened tab this may be a list of + * files in a namespace, upload form or search form + * + * @author Kate Arzamastseva + */ +function tpl_fileList(){ + global $AUTH; + global $NS; + global $JUMPTO; + + $opened_tab = $_REQUEST['tab_files']; + if (!$opened_tab) $opened_tab = 'files'; + + media_tabs_files($opened_tab); + if ($opened_tab == 'files') media_tab_files($NS,$AUTH,$JUMPTO); + if ($opened_tab == 'upload') media_tab_upload($NS,$AUTH,$JUMPTO); + if ($opened_tab == 'search') media_tab_search($NS,$AUTH); + +} + +/** + * Prints the third column in full-screen media manager + * Depending on the opened tab this may be details of the + * selected file, the meta editing dialog or + * list of file revisions + * + * @author Kate Arzamastseva + */ +function tpl_fileDetails(){ + global $AUTH; + global $NS; + global $IMG; + + $opened_tab = $_REQUEST['tab_details']; + if (!$opened_tab) $opened_tab = 'view'; + if ($_REQUEST['edit']) $opened_tab = 'edit'; + media_tabs_details($opened_tab); + + $image = $_REQUEST['image']; + if (!$image && !$IMG) return false; + if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH); + if ($opened_tab == 'edit') { + if ($IMG) media_tab_edit($IMG, $NS, $AUTH); + else if ($image) media_tab_edit($image, $NS, $AUTH); + } + if ($opened_tab == 'history') media_tab_history($image,$NS,$AUTH); +} + /** * prints the namespace tree in the mediamanger popup * @@ -1130,10 +1183,10 @@ function tpl_mediaContent($fromajax=false){ * * @author Andreas Gohr */ -function tpl_mediaTree(){ +function tpl_mediaTree($fullscreen = false){ global $NS; - - ptln('
'); + if ($fullscreen) ptln('
'); + else ptln('
'); media_nstree($NS); ptln('
'); } @@ -1359,6 +1412,36 @@ function tpl_getFavicon($abs=false) { return DOKU_TPL.'images/favicon.ico'; } +/** + * Prints full-screen media manager + * + * @author Kate Arzamastseva + */ +function tpl_media() { + // + global $DEL, $NS, $IMG, $AUTH, $JUMPTO; + require_once(DOKU_INC.'lib/exe/mediamanager.php'); + + echo '
'; + echo '
'; + echo '
'; + html_msgarea(); + echo hsc('Namespaces:'); + echo '

'; + echo '
'; + tpl_mediaTree(true); + echo '
'; + echo '
'; + echo '
'; + tpl_fileList(); + echo '
'; + echo '
'; + tpl_fileDetails(); + echo '
'; + echo '
 
'; + echo '
'; + echo '
'; +} //Setup VIM: ex: et ts=4 : -- cgit v1.2.3 From 0b926329daf6b9cd03c01a4e5b26b968d6cb16a8 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 10 Jun 2011 13:19:28 +0300 Subject: recent changes fix --- inc/changelog.php | 20 ++++++++++---------- inc/common.php | 4 ++-- inc/html.php | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'inc') diff --git a/inc/changelog.php b/inc/changelog.php index 937214a6a..e9b271363 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -151,8 +151,8 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_SKIP_PAGES - return media changes instead of page changes - * RECENTS_INCLUDE_MEDIA - return both media changes and page changes + * RECENTS_MEDIA_CHANGES - return media changes instead of page changes + * RECENTS_MEDIA_PAGES_MIXED - return both media changes and page changes * * @param int $first number of first entry returned (for paginating * @param int $num return $num entries @@ -171,14 +171,14 @@ function getRecents($first,$num,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_SKIP_PAGES) { + if ($flags & RECENTS_MEDIA_CHANGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); } $lines_position = count($lines)-1; - if ($flags & RECENTS_INCLUDE_MEDIA) { + if ($flags & RECENTS_MEDIA_PAGES_MIXED) { $media_lines = @file($conf['media_changelog']); $media_lines_position = count($media_lines)-1; } @@ -186,7 +186,7 @@ function getRecents($first,$num,$ns='',$flags=0){ $seen = array(); // caches seen lines, _handleRecent() skips them // handle lines - while ($lines_position >= 0 || (($flags & RECENTS_INCLUDE_MEDIA) && $media_lines_position >=0)) { + while ($lines_position >= 0 || (($flags & RECENTS_MEDIA_PAGES_MIXED) && $media_lines_position >=0)) { if (empty($rec) && $lines_position >= 0) { $rec = _handleRecent(@$lines[$lines_position], $ns, $flags, $seen); if (!$rec) { @@ -194,14 +194,14 @@ function getRecents($first,$num,$ns='',$flags=0){ continue; } } - if (($flags & RECENTS_INCLUDE_MEDIA) && empty($media_rec) && $media_lines_position >= 0) { + if (($flags & RECENTS_MEDIA_PAGES_MIXED) && empty($media_rec) && $media_lines_position >= 0) { $media_rec = _handleRecent(@$media_lines[$media_lines_position], $ns, $flags, $seen); if (!$media_rec) { $media_lines_position --; continue; } } - if (($flags & RECENTS_INCLUDE_MEDIA) && @$media_rec['date'] >= @$rec['date']) { + if (($flags & RECENTS_MEDIA_PAGES_MIXED) && @$media_rec['date'] >= @$rec['date']) { $media_lines_position--; $x = $media_rec; $media_rec = false; @@ -229,7 +229,7 @@ function getRecents($first,$num,$ns='',$flags=0){ * RECENTS_SKIP_DELETED - don't include deleted pages * RECENTS_SKIP_MINORS - don't include minor changes * RECENTS_SKIP_SUBSPACES - don't include subspaces - * RECENTS_SKIP_PAGES - return media changes instead of page changes + * RECENTS_MEDIA_CHANGES - return media changes instead of page changes * * @param int $from date of the oldest entry to return * @param int $to date of the newest entry to return (for pagination, optional) @@ -247,7 +247,7 @@ function getRecentsSince($from,$to=null,$ns='',$flags=0){ return $recent; // read all recent changes. (kept short) - if ($flags & RECENTS_SKIP_PAGES) { + if ($flags & RECENTS_MEDIA_CHANGES) { $lines = @file($conf['media_changelog']); } else { $lines = @file($conf['changelog']); @@ -314,7 +314,7 @@ function _handleRecent($line,$ns,$flags,&$seen){ if ($recent['perms'] < AUTH_READ) return false; // check existance - $fn = (($flags & RECENTS_SKIP_PAGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); + $fn = (($flags & RECENTS_MEDIA_CHANGES) ? mediaFN($recent['id']) : wikiFN($recent['id'])); if((!@file_exists($fn)) && ($flags & RECENTS_SKIP_DELETED)) return false; return $recent; diff --git a/inc/common.php b/inc/common.php index acd3609d6..6d707e704 100644 --- a/inc/common.php +++ b/inc/common.php @@ -14,8 +14,8 @@ if(!defined('DOKU_INC')) die('meh.'); define('RECENTS_SKIP_DELETED',2); define('RECENTS_SKIP_MINORS',4); define('RECENTS_SKIP_SUBSPACES',8); -define('RECENTS_SKIP_PAGES',16); -define('RECENTS_INCLUDE_MEDIA',32); +define('RECENTS_MEDIA_CHANGES',16); +define('RECENTS_MEDIA_PAGES_MIXED',32); /** * Wrapper around htmlspecialchars() diff --git a/inc/html.php b/inc/html.php index 06e9f3b0c..29e40174c 100644 --- a/inc/html.php +++ b/inc/html.php @@ -577,8 +577,8 @@ function html_recent($first=0, $show_changes='both'){ * decide if this is the last page or is there another one. * This is the cheapest solution to get this information. */ - $flags = RECENTS_INCLUDE_MEDIA; - if ($show_changes == 'mediafiles') $flags = RECENTS_SKIP_PAGES; + if (!$show_changes || $show_changes == 'both') $flags = RECENTS_MEDIA_PAGES_MIXED; + if ($show_changes == 'mediafiles') $flags = RECENTS_MEDIA_CHANGES; if ($show_changes == 'pages') $flags = 0; $recents = getRecents($first,$conf['recent'] + 1,getNS($ID),$flags); -- cgit v1.2.3 From 8e69fd30702f1101a9c70dbe6eac6f45f9af3970 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 13 Jun 2011 20:23:18 +0300 Subject: media manager --- inc/html.php | 52 ++++++++++++++++++++++++++++++++++------------------ inc/lang/en/lang.php | 16 ++++++++++++++++ inc/media.php | 50 +++++++++++++++++++++++++------------------------- inc/pageutils.php | 2 +- 4 files changed, 76 insertions(+), 44 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 29e40174c..738ee6d75 100644 --- a/inc/html.php +++ b/inc/html.php @@ -415,20 +415,28 @@ function html_locked(){ * * @author Andreas Gohr * @author Ben Coburn + * @author Kate Arzamastseva */ -function html_revisions($first=0){ +function html_revisions($first=0, $media_id = false){ global $ID; global $INFO; global $conf; global $lang; + $id = $ID; /* we need to get one additionally log entry to be able to * decide if this is the last page or is there another one. * see html_recent() */ - $revisions = getRevisions($ID, $first, $conf['recent']+1); + if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1); + else { + $revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true); + $id = $media_id; + } + if(count($revisions)==0 && $first!=0){ $first=0; - $revisions = getRevisions($ID, $first, $conf['recent']+1);; + if (!$media_id) $revisions = getRevisions($ID, $first, $conf['recent']+1); + else $revisions = getRevisions($media_id, $first, $conf['recent']+1, 8192, true); } $hasNext = false; if (count($revisions)>$conf['recent']) { @@ -436,14 +444,19 @@ function html_revisions($first=0){ array_pop($revisions); // remove extra log entry } - $date = dformat($INFO['lastmod']); + if (!$media_id) $date = dformat($INFO['lastmod']); + else $date = dformat(@filemtime(mediaFN($id))); - print p_locale_xhtml('revisions'); + if (!$media_id) print p_locale_xhtml('revisions'); $form = new Doku_Form(array('id' => 'page__revisions')); $form->addElement(form_makeOpenTag('ul')); - if($INFO['exists'] && $first==0){ - if (isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) + + if (!$media_id) $exists = $INFO['exists']; + else $exists = @file_exists(mediaFN($id)); + + if($exists && $first==0){ + if (!$media_id && isset($INFO['meta']) && isset($INFO['meta']['last_change']) && $INFO['meta']['last_change']['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); else $form->addElement(form_makeOpenTag('li')); @@ -461,8 +474,8 @@ function html_revisions($first=0){ $form->addElement(form_makeOpenTag('a', array( 'class' => 'wikilink1', - 'href' => wl($ID)))); - $form->addElement($ID); + 'href' => wl($id)))); + $form->addElement($id); $form->addElement(form_makeCloseTag('a')); $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); @@ -471,6 +484,7 @@ function html_revisions($first=0){ $form->addElement(form_makeCloseTag('span')); $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); + /// $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor'])); $form->addElement(form_makeCloseTag('span')); @@ -481,8 +495,9 @@ function html_revisions($first=0){ foreach($revisions as $rev){ $date = dformat($rev); - $info = getRevisionInfo($ID,$rev,true); - $exists = page_exists($ID,$rev); + $info = getRevisionInfo($id,$rev,true); + if (!$media_id) $exists = page_exists($id,$rev); + else $exists = @file_exists(mediaFN($id,$rev)); if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); @@ -503,7 +518,8 @@ function html_revisions($first=0){ $form->addElement(form_makeCloseTag('span')); if($exists){ - $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link'))); + /// + $form->addElement(form_makeOpenTag('a', array('href' => wl($id,"rev=$rev,do=diff", false, '&'), 'class' => 'diff_link'))); $form->addElement(form_makeTag('img', array( 'src' => DOKU_BASE.'lib/images/diff.png', 'width' => 15, @@ -511,13 +527,13 @@ function html_revisions($first=0){ 'title' => $lang['diff'], 'alt' => $lang['diff']))); $form->addElement(form_makeCloseTag('a')); - - $form->addElement(form_makeOpenTag('a', array('href' => wl($ID,"rev=$rev",false,'&'), 'class' => 'wikilink1'))); - $form->addElement($ID); + /// + $form->addElement(form_makeOpenTag('a', array('href' => wl($id,"rev=$rev",false,'&'), 'class' => 'wikilink1'))); + $form->addElement($id); $form->addElement(form_makeCloseTag('a')); }else{ $form->addElement(''); - $form->addElement($ID); + $form->addElement($id); } $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); @@ -549,12 +565,12 @@ function html_revisions($first=0){ $first -= $conf['recent']; if ($first < 0) $first = 0; print ''; } if ($hasNext) { print ''; } print '
'; diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 51fd8f645..5dca273c3 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -48,6 +48,7 @@ $lang['btn_recover'] = 'Recover draft'; $lang['btn_draftdel'] = 'Delete draft'; $lang['btn_revert'] = 'Restore'; $lang['btn_register'] = 'Register'; +$lang['btn_apply'] = 'Apply'; $lang['loggedinas'] = 'Logged in as'; $lang['user'] = 'Username'; @@ -179,6 +180,9 @@ $lang['external_edit'] = 'external edit'; $lang['summary'] = 'Edit summary'; $lang['noflash'] = 'The Adobe Flash Plugin is needed to display this content.'; $lang['download'] = 'Download Snippet'; +$lang['pages_changes'] = 'Show pages changes'; +$lang['media_changes'] = 'Show media files changes'; +$lang['both_changes'] = 'Show both'; $lang['mail_newpage'] = 'page added:'; $lang['mail_changed'] = 'page changed:'; @@ -318,5 +322,17 @@ $lang['seconds'] = '%d seconds ago'; $lang['wordblock'] = 'Your change was not saved because it contains blocked text (spam).'; +$lang['media_uploadtab'] = 'Upload'; +$lang['media_searchtab'] = 'Search'; +$lang['media_viewtab'] = 'View'; +$lang['media_edittab'] = 'Edit'; +$lang['media_historytab'] = 'History'; +$lang['media_thumbsview'] = 'Thumnails'; +$lang['media_listview'] = 'List'; +$lang['media_sort'] = 'Sort'; +$lang['media_search'] = 'Search'; +$lang['media_view'] = 'View'; +$lang['media_edit'] = 'Edit'; +$lang['media_history'] = 'These are the older revisons of the file.'; //Setup VIM: ex: et ts=2 : diff --git a/inc/media.php b/inc/media.php index d98e225b9..5f443a1f7 100644 --- a/inc/media.php +++ b/inc/media.php @@ -357,9 +357,7 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov global $lang; $old = @filemtime($fn); - $oldRev = getRevisions($id, -1, 1, 1024, true); // from changelog - $oldRev = (int)(empty($oldRev)?0:$oldRev[0]); - if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn) && $old>=$oldRev) { + if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn)) { // add old revision to the attic if missing media_saveOldRevision($id); } @@ -530,21 +528,21 @@ function media_tabs_files($selected=false){ '" rel=".mediamanager-tab-files"'; if (!empty($selected) && $selected == 'files') $class = 'files selected'; else $class = 'files'; - $tab .= ' class="'.$class.'" >Files'; + $tab .= ' class="'.$class.'" >'.$lang['mediaselect'].''; echo $tab; $tab = 'Upload'; + $tab .= ' class="'.$class.'" >'.$lang['media_uploadtab'].''; echo $tab; $tab = 'Search'; + $tab .= ' class="'.$class.'" >'.$lang['media_searchtab'].''; echo $tab; echo '
 
'; @@ -565,21 +563,21 @@ function media_tabs_details($selected=false){ '" rel=".mediamanager-tab-view"'; if (!empty($selected) && $selected == 'view') $class = 'view selected'; else $class = 'view'; - $tab .= ' class="'.$class.'" >View'; + $tab .= ' class="'.$class.'" >'.$lang['media_viewtab'].''; echo $tab; $tab = 'Edit'; + $tab .= ' class="'.$class.'" >'.$lang['media_edittab'].''; echo $tab; $tab = 'History'; + $tab .= ' class="'.$class.'" >'.$lang['media_historytab'].''; echo $tab; echo '
 
'; @@ -597,14 +595,14 @@ function media_tab_files_options(){ echo '
'; echo '
'; echo ' - Thumbs'; + rel=".mediamanager-files-thumbnails-tab" class="mediamanager-link-thumbnails">'. + $lang['media_thumbsview'].''; echo 'List'; + title="View as list">'.$lang['media_listview'].''; echo '
'; - echo '
Sort'; + echo '
'.$lang['media_sort']; //select echo '
'; echo '
 
'; @@ -675,7 +673,7 @@ function media_tab_search($ns,$auth=null) { echo ''; } @@ -732,7 +722,11 @@ function media_tab_edit($image, $ns, $auth=null) { echo '
'; echo '
'; - if ($image) media_metaform($image,$auth,true); + if ($image) { + $info = new JpegMeta(mediaFN($image)); + if ($info->getField('File.Mime') == 'image/jpeg') + media_metaform($image,$auth,true); + } echo '
'; echo '
'; } @@ -758,6 +752,68 @@ function media_tab_history($image, $ns, $auth=null) { echo '
'; } +/** + * Prints mediafile details + * + * @author Kate Arzamastseva + */ +function media_preview($image, $auth) { + global $lang; + if ($auth >= AUTH_READ && $image) { + $info = new JpegMeta(mediaFN($image)); + $w = (int) $info->getField('File.Width'); + + $rev = $_REQUEST['rev']; + $more = ''; + if (isset($rev)) $more = "rev=$rev"; + $src = ml($image, $more); + + echo '

'; + + $link = ml($image,'',true); + echo $image.' '; + + // delete button + if($auth >= AUTH_DELETE){ + $link = media_managerURL(array('delete' => $image,'sectok' => getSecurityToken())); + echo ' '. + ''.$lang['btn_delete'].''; + } + + echo '

'; + + $tags = array( + array('simple.title','img_title','text'), + array('Date.EarliestTime','img_date','date'), + array('File.Name','img_fname','text'), + array(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit'),'img_artist','text'), + array(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright'),'img_copyr','text'), + array('File.Format','img_format','text'), + array('File.NiceSize','img_fsize','text'), + array('Simple.Camera','img_camera','text'), + array(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject'),'img_keywords','text') + ); + + $src = mediaFN($image); + echo '
'; + foreach($tags as $key => $tag){ + $t = $tag[0]; + if (!is_array($t)) $t = array($tag[0]); + $value = tpl_img_getTag($t,'',$src); + $value = cleanText($value); + if ($value) { + echo '
'.$lang[$tag[1]].':
'; + if ($tag[2] == 'text') echo hsc($value); + if ($tag[2] == 'date') echo dformat($value); + echo '
'; + } + } + echo '
'; + } +} + /** * List all files found by the search request * @@ -809,7 +865,7 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false){ * Print action links for a file depending on filetype * and available permissions */ -function media_fileactions($item,$auth,$fullscreen=false){ +function media_fileactions($item,$auth){ global $lang; // view button @@ -822,10 +878,8 @@ function media_fileactions($item,$auth,$fullscreen=false){ // delete button if($auth >= AUTH_DELETE){ - if (!$fullscreen) $link = DOKU_BASE.'lib/exe/mediamanager.php?delete='.rawurlencode($item['id']). + $link = DOKU_BASE.'lib/exe/mediamanager.php?delete='.rawurlencode($item['id']). '&sectok='.getSecurityToken(); - else $link = media_managerURL(array('delete' => $item['id'], - 'sectok' => getSecurityToken())); echo ' '. ''.$lang['btn_delete'].''; @@ -833,8 +887,7 @@ function media_fileactions($item,$auth,$fullscreen=false){ // edit button if($auth >= AUTH_UPLOAD && $item['isimg'] && $item['meta']->getField('File.Mime') == 'image/jpeg'){ - if (!$fullscreen) $link = DOKU_BASE.'lib/exe/mediamanager.php?edit='.rawurlencode($item['id']); - else $link = media_managerURL(array('edit' => $item['id'])); + $link = DOKU_BASE.'lib/exe/mediamanager.php?edit='.rawurlencode($item['id']); echo ' '. ''.$lang['metaedit'].''; @@ -928,7 +981,6 @@ function media_printfile_thumbs($item,$auth,$jump){ echo '
'.hsc($file).'
'; echo ''.$info.'
'; - media_fileactions($item,$auth,true); echo '
'.NL; } @@ -956,7 +1008,8 @@ function media_printimgdetail($item, $fullscreen=false){ // output if ($fullscreen) { - echo ''; + echo ''; echo ''; echo ''; return 1; @@ -1019,6 +1072,10 @@ function media_managerURL($params=false, $amp='&') { } } unset($gets['id']); + if ($gets['delete']) { + unset($gets['image']); + unset($gets['tab_details']); + } return wl($ID,$gets,false,$amp); } diff --git a/inc/template.php b/inc/template.php index 4bbb501fc..1fb5490f5 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1161,13 +1161,14 @@ function tpl_fileDetails(){ global $NS; global $IMG; + $image = $_REQUEST['image']; + if (!isset($IMG) && !isset($image)) return ''; + $opened_tab = $_REQUEST['tab_details']; if (!$opened_tab) $opened_tab = 'view'; if ($_REQUEST['edit']) $opened_tab = 'edit'; media_tabs_details($opened_tab); - $image = $_REQUEST['image']; - if (!$image && !$IMG) return false; if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH); if ($opened_tab == 'edit') { if ($IMG) media_tab_edit($IMG, $NS, $AUTH); -- cgit v1.2.3 From b9eb2e61ea959c1f8b3a5c58ad50a0f9c8c855ad Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 20 Jun 2011 10:51:48 +0300 Subject: media manager button --- inc/lang/en/lang.php | 5 +++-- inc/template.php | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 5dca273c3..dbd3ae9be 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -49,6 +49,7 @@ $lang['btn_draftdel'] = 'Delete draft'; $lang['btn_revert'] = 'Restore'; $lang['btn_register'] = 'Register'; $lang['btn_apply'] = 'Apply'; +$lang['btn_media'] = 'Media Manager'; $lang['loggedinas'] = 'Logged in as'; $lang['user'] = 'Username'; @@ -327,12 +328,12 @@ $lang['media_searchtab'] = 'Search'; $lang['media_viewtab'] = 'View'; $lang['media_edittab'] = 'Edit'; $lang['media_historytab'] = 'History'; -$lang['media_thumbsview'] = 'Thumnails'; +$lang['media_thumbsview'] = 'Thumbnails'; $lang['media_listview'] = 'List'; $lang['media_sort'] = 'Sort'; $lang['media_search'] = 'Search'; $lang['media_view'] = 'View'; $lang['media_edit'] = 'Edit'; -$lang['media_history'] = 'These are the older revisons of the file.'; +$lang['media_history'] = 'These are the older revisions of the file.'; //Setup VIM: ex: et ts=2 : diff --git a/inc/template.php b/inc/template.php index 1fb5490f5..31320c876 100644 --- a/inc/template.php +++ b/inc/template.php @@ -630,6 +630,8 @@ function tpl_get_action($type) { // Superseded by subscribe/subscription return ''; break; + case 'media': + break; default: return '[unknown %s type]'; break; -- cgit v1.2.3 From 2e55802c049a2388811419cc4acd287b29279928 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 20 Jun 2011 11:02:46 +0300 Subject: media history --- inc/html.php | 9 ++- inc/lang/en/lang.php | 2 + inc/media.php | 181 +++++++++++++++++++++++++++++++++++++-------------- 3 files changed, 140 insertions(+), 52 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index cf0b00397..809db30bd 100644 --- a/inc/html.php +++ b/inc/html.php @@ -533,7 +533,7 @@ function html_revisions($first=0, $media_id = false){ if($exists){ if (!$media_id) $href = wl($id,"rev=$rev,do=diff", false, '&'); - else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev)); + else $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff')); $form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'diff_link'))); $form->addElement(form_makeTag('img', array( 'src' => DOKU_BASE.'lib/images/diff.png', @@ -572,7 +572,12 @@ function html_revisions($first=0, $media_id = false){ $form->addElement(form_makeCloseTag('li')); } $form->addElement(form_makeCloseTag('ul')); - if (!$media_id) $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); + if (!$media_id) { + $form->addElement(form_makeButton('submit', 'diff', $lang['diff2'])); + } else { + $form->addHidden('mediado', 'diff'); + $form->addElement(form_makeButton('submit', '', $lang['diff2'])); + } html_form('revisions', $form); print ''; echo '
'; - media_preview($image, $auth); + $rev = (int) $_REQUEST['rev']; + media_preview($image, $auth, $rev); + media_details($image, $auth, $rev); echo '
'; echo ''; } @@ -739,6 +741,7 @@ function media_tab_edit($image, $ns, $auth=null) { function media_tab_history($image, $ns, $auth=null) { global $lang; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + $do = $_REQUEST['mediado']; echo '
'; echo '
'; @@ -746,8 +749,14 @@ function media_tab_history($image, $ns, $auth=null) { echo '
'; echo '
'; - $first = isset($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; - html_revisions($first, $image); + if ($auth >= AUTH_READ && $image) { + if ($do == 'diff'){ + media_diff($image, $ns, $auth); + } else { + $first = isset($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; + html_revisions($first, $image); + } + } echo '
'; echo '
'; } @@ -757,61 +766,132 @@ function media_tab_history($image, $ns, $auth=null) { * * @author Kate Arzamastseva */ -function media_preview($image, $auth) { +function media_preview($image, $auth, $rev=false) { global $lang; - if ($auth >= AUTH_READ && $image) { - $info = new JpegMeta(mediaFN($image)); - $w = (int) $info->getField('File.Width'); + if ($auth < AUTH_READ || !$image) return ''; + $info = new JpegMeta(mediaFN($image)); + $w = (int) $info->getField('File.Width'); - $rev = $_REQUEST['rev']; - $more = ''; - if (isset($rev)) $more = "rev=$rev"; - $src = ml($image, $more); + $more = ''; + if ($rev) $more = "rev=$rev"; + $src = ml($image, $more); - echo '

'; + echo '

'; - $link = ml($image,'',true); - echo $image.' '; + $link = ml($image,$more,true); + echo $image.' '; - // delete button - if($auth >= AUTH_DELETE){ - $link = media_managerURL(array('delete' => $image,'sectok' => getSecurityToken())); - echo ' '. - ''.$lang['btn_delete'].''; - } + // delete button + if($auth >= AUTH_DELETE && !$rev){ + $link = media_managerURL(array('delete' => $image,'sectok' => getSecurityToken())); + echo ' '. + ''.$lang['btn_delete'].''; + } - echo '

'; - - $tags = array( - array('simple.title','img_title','text'), - array('Date.EarliestTime','img_date','date'), - array('File.Name','img_fname','text'), - array(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit'),'img_artist','text'), - array(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright'),'img_copyr','text'), - array('File.Format','img_format','text'), - array('File.NiceSize','img_fsize','text'), - array('Simple.Camera','img_camera','text'), - array(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject'),'img_keywords','text') - ); - - $src = mediaFN($image); - echo '
'; - foreach($tags as $key => $tag){ - $t = $tag[0]; - if (!is_array($t)) $t = array($tag[0]); - $value = tpl_img_getTag($t,'',$src); - $value = cleanText($value); - if ($value) { - echo '
'.$lang[$tag[1]].':
'; - if ($tag[2] == 'text') echo hsc($value); - if ($tag[2] == 'date') echo dformat($value); - echo '
'; - } +} + +/** + * Prints mediafile tags + * + * @author Kate Arzamastseva + */ +function media_details($image, $auth, $rev=false) { + global $lang; + + $tags = array( + array('simple.title','img_title','text'), + array('Date.EarliestTime','img_date','date'), + array('File.Name','img_fname','text'), + array(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit'),'img_artist','text'), + array(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright'),'img_copyr','text'), + array('File.Format','img_format','text'), + array('File.NiceSize','img_fsize','text'), + array('File.Width','img_width','text'), + array('File.Height','img_height','text'), + array('Simple.Camera','img_camera','text'), + array(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject'),'img_keywords','text') + ); + + $src = mediaFN($image, $rev); + echo '
'; + foreach($tags as $key => $tag){ + $t = $tag[0]; + if (!is_array($t)) $t = array($tag[0]); + $value = media_getTag($t,$src); + $value = cleanText($value); + if (!$value) $value='-'; + echo '
'.$lang[$tag[1]].':
'; + if ($tag[2] == 'text') echo hsc($value); + if ($tag[2] == 'date') echo dformat($value); + echo '
'; + } + echo '
'; +} + +/** + * Returns the requested EXIF/IPTC tag from the current image + * + */ +function media_getTag($tags,$src,$alt=''){ + $meta = new JpegMeta($src); + if($meta === false) return $alt; + $info = $meta->getField($tags); + if($info == false) return $alt; + return $info; +} + +/** + * Shows difference between two revisions of file + * + * @author Kate Arzamastseva + */ +function media_diff($image, $ns, $auth) { + global $lang; + global $conf; + + $rev1 = (int) $_REQUEST['rev']; + + if(is_array($_REQUEST['rev2'])){ + $rev1 = (int) $_REQUEST['rev2'][0]; + $rev2 = (int) $_REQUEST['rev2'][1]; + + if(!$rev1){ + $rev1 = $rev2; + unset($rev2); + } + }else{ + $rev2 = (int) $_REQUEST['rev2']; + } + if($rev1 && $rev2){ // two specific revisions wanted + // make sure order is correct (older on the left) + if($rev1 < $rev2){ + $l_rev = $rev1; + $r_rev = $rev2; + }else{ + $l_rev = $rev2; + $r_rev = $rev1; } - echo '
'; + }elseif($rev1){ // single revision given, compare to current + $r_rev = ''; + $l_rev = $rev1; + }else{ // no revision was given, compare previous to current + $r_rev = ''; + $revs = getRevisions($image, 0, 1, 8192, true); + $l_rev = $revs[0]; } + echo ''; + echo ''; + echo '
'; + media_preview($image, $auth, $l_rev); + echo ''; + media_preview($image, $auth, $r_rev); + echo '
'; + media_details($image, $auth, $l_rev); + echo ''; + media_details($image, $auth, $r_rev); + echo '
'; } /** @@ -1065,6 +1145,7 @@ function media_managerURL($params=false, $amp='&') { unset($gets['sectok']); unset($gets['delete']); unset($gets['rev']); + unset($gets['mediado']); if ($params) { foreach ($params as $k => $v) { -- cgit v1.2.3 From 030dd1d963bb7a0ab824b823d777a58fc105b1e5 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 20 Jun 2011 19:16:09 +0300 Subject: thumbnails and list view --- inc/media.php | 45 ++++++++++++++++++++++----------------------- inc/template.php | 2 +- 2 files changed, 23 insertions(+), 24 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index 1bcb6a7b2..b4b62d2c5 100644 --- a/inc/media.php +++ b/inc/media.php @@ -546,7 +546,7 @@ function media_tabs_files($selected=false){ $tab .= ' class="'.$class.'" >'.$lang['media_searchtab'].''; echo $tab; - echo '
 
'; + echo '
'; echo ''; } @@ -581,7 +581,7 @@ function media_tabs_details($selected=false){ $tab .= ' class="'.$class.'" >'.$lang['media_historytab'].''; echo $tab; - echo '
 
'; + echo '
'; echo ''; } @@ -606,7 +606,7 @@ function media_tab_files_options(){ echo '
'.$lang['media_sort']; //select echo '
'; - echo '
 
'; + echo '
'; echo ''; } @@ -628,13 +628,12 @@ function media_tab_files($ns,$auth=null,$jump='') { echo '
'.$lang['nothingfound'].'
'.NL; }else{ if ($view == 'list') { - echo '
'; - echo '
'; + echo '
    '; } else { - echo '
    '; - media_filelist($ns,$auth,$jump,'thumbs'); - echo '
    '; + echo '
      '; } + media_filelist($ns,$auth,$jump,'thumbs'); + echo '
    '; } echo ''; echo ''; @@ -1044,24 +1043,24 @@ function media_printfile_thumbs($item,$auth,$jump){ // Prepare filename $file = utf8_decodeFN($item['file']); - // Prepare info - $info = ''; + // output + echo '
  • '; + if($item['isimg']) media_printimgdetail($item, true); + echo ''.hsc($file).''; if($item['isimg']){ + $info = ''; $info .= (int) $item['meta']->getField('File.Width'); $info .= '×'; $info .= (int) $item['meta']->getField('File.Height'); - $info .= '
    '; - } - $info .= ''.dformat($item['mtime']).'
    '; - $info .= filesize_h($item['size']); - - // output - echo '
    '; - if($item['isimg']) media_printimgdetail($item, true); - echo '
    '.hsc($file).'
    '; - echo ''.$info.'
    '; - echo '
    '.NL; + echo ''.$info.''; + } + $info = ''.dformat($item['mtime']).''; + echo ''.$info.''; + $info = filesize_h($item['size']); + echo ''.$info.''; + echo '
    '; + echo '
  • '.NL; } /** @@ -1088,7 +1087,7 @@ function media_printimgdetail($item, $fullscreen=false){ // output if ($fullscreen) { - echo ''; echo ''; echo ''; diff --git a/inc/template.php b/inc/template.php index 31320c876..69ed61f7e 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1441,7 +1441,7 @@ function tpl_media() { echo '
    '; tpl_fileDetails(); echo '
    '; - echo '
     
    '; + echo '
    '; echo ''; echo ''; } -- cgit v1.2.3 From 6b467722ce67ad489326798250cc5312efa70dcd Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 22 Jun 2011 23:16:31 +0300 Subject: mediamanager fixes --- inc/media.php | 37 +++++++++++++++++++++++++------------ inc/template.php | 14 ++++++++++---- 2 files changed, 35 insertions(+), 16 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index b4b62d2c5..c16665b13 100644 --- a/inc/media.php +++ b/inc/media.php @@ -697,7 +697,7 @@ function media_tab_view($image, $ns, $auth=null) { echo '
    '; echo '
    '; - echo $lang['media_view']; + echo $image; echo '
    '; echo '
    '; @@ -880,17 +880,17 @@ function media_diff($image, $ns, $auth) { $revs = getRevisions($image, 0, 1, 8192, true); $l_rev = $revs[0]; } - echo ''; - echo ''; - echo '
    '; + echo '
    • '; media_preview($image, $auth, $l_rev); - echo '
    '; + echo ''; + echo '
  • '; media_preview($image, $auth, $r_rev); - echo '
  • '; + echo '
  • '; media_details($image, $auth, $l_rev); - echo '
  • '; + echo ''; + echo '
  • '; media_details($image, $auth, $r_rev); - echo '
  • '; + echo '
'; } /** @@ -1045,7 +1045,14 @@ function media_printfile_thumbs($item,$auth,$jump){ // output echo '
  • '; - if($item['isimg']) media_printimgdetail($item, true); + if($item['isimg']) { + media_printimgdetail($item, true); + } else { + echo ''; + echo ''; + echo ''; + } echo ''.hsc($file).''; if($item['isimg']){ @@ -1054,6 +1061,8 @@ function media_printfile_thumbs($item,$auth,$jump){ $info .= '×'; $info .= (int) $item['meta']->getField('File.Height'); echo ''.$info.''; + } else { + echo ' '; } $info = ''.dformat($item['mtime']).''; echo ''.$info.''; @@ -1073,21 +1082,25 @@ function media_printimgdetail($item, $fullscreen=false){ $w = (int) $item['meta']->getField('File.Width'); $h = (int) $item['meta']->getField('File.Height'); if($w>$size || $h>$size){ - $ratio = $item['meta']->getResizeRatio($size); + if (!$fullscreen) { + $ratio = $item['meta']->getResizeRatio($size); + } else { + $ratio = $item['meta']->getResizeRatio($size,$size); + } $w = floor($w * $ratio); $h = floor($h * $ratio); } $src = ml($item['id'],array('w'=>$w,'h'=>$h)); $p = array(); $p['width'] = $w; - $p['height'] = $h; + if (!$fullscreen) $p['height'] = $h; $p['alt'] = $item['id']; $p['class'] = 'thumb'; $att = buildAttributes($p); // output if ($fullscreen) { - echo ''; echo ''; echo ''; diff --git a/inc/template.php b/inc/template.php index 69ed61f7e..5d29f6950 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1163,8 +1163,9 @@ function tpl_fileDetails(){ global $NS; global $IMG; - $image = $_REQUEST['image']; + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); if (!isset($IMG) && !isset($image)) return ''; + if (isset($NS) && getNS($image) != $NS) return ''; $opened_tab = $_REQUEST['tab_details']; if (!$opened_tab) $opened_tab = 'view'; @@ -1422,15 +1423,20 @@ function tpl_getFavicon($abs=false) { */ function tpl_media() { // - global $DEL, $NS, $IMG, $AUTH, $JUMPTO; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $lang; require_once(DOKU_INC.'lib/exe/mediamanager.php'); echo '
    '; echo '
    '; echo '
    '; html_msgarea(); - echo hsc('Namespaces:'); - echo '

    '; + echo '
    '; + echo ''.hsc($lang['namespaces']).''; + echo '
    '; + echo '
    '; + echo '
    '; + echo hsc($lang['namespaces']); + echo '
    '; echo '
    '; tpl_mediaTree(true); echo '
    '; -- cgit v1.2.3 From cf83278667fc82135e294c35d334a62318a1e39d Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 22 Jun 2011 23:59:11 +0300 Subject: media version saving metadata --- inc/lang/en/lang.php | 23 ++++++++++++----------- inc/media.php | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 12 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index e0e2e6cf5..6fb387a89 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -325,17 +325,18 @@ $lang['seconds'] = '%d seconds ago'; $lang['wordblock'] = 'Your change was not saved because it contains blocked text (spam).'; -$lang['media_uploadtab'] = 'Upload'; -$lang['media_searchtab'] = 'Search'; -$lang['media_viewtab'] = 'View'; -$lang['media_edittab'] = 'Edit'; -$lang['media_historytab'] = 'History'; -$lang['media_thumbsview'] = 'Thumbnails'; +$lang['media_uploadtab'] = 'Upload'; +$lang['media_searchtab'] = 'Search'; +$lang['media_viewtab'] = 'View'; +$lang['media_edittab'] = 'Edit'; +$lang['media_historytab'] = 'History'; +$lang['media_thumbsview'] = 'Thumbnails'; $lang['media_listview'] = 'List'; -$lang['media_sort'] = 'Sort'; -$lang['media_search'] = 'Search'; -$lang['media_view'] = 'View'; -$lang['media_edit'] = 'Edit'; -$lang['media_history'] = 'These are the older revisions of the file.'; +$lang['media_sort'] = 'Sort'; +$lang['media_search'] = 'Search'; +$lang['media_view'] = 'View'; +$lang['media_edit'] = 'Edit'; +$lang['media_history'] = 'These are the older revisions of the file.'; +$lang['media_meta_edited']= 'metadata edited'; //Setup VIM: ex: et ts=2 : diff --git a/inc/media.php b/inc/media.php index c16665b13..68aab5415 100644 --- a/inc/media.php +++ b/inc/media.php @@ -40,6 +40,7 @@ function media_filesinuse($data,$id){ * Handles the saving of image meta data * * @author Andreas Gohr + * @author Kate Arzamastseva */ function media_metasave($id,$auth,$data){ if($auth < AUTH_UPLOAD) return false; @@ -60,8 +61,19 @@ function media_metasave($id,$auth,$data){ } } + $old = @filemtime($src); + if(!@file_exists(mediaFN($id, $old)) && @file_exists($src)) { + // add old revision to the attic + media_saveOldRevision($id); + } + if($meta->save()){ if($conf['fperm']) chmod($src, $conf['fperm']); + + $new = @filemtime($src); + // add a log entry to the media changelog + addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_EDIT, $lang['media_meta_edited']); + msg($lang['metasaveok'],1); return $id; }else{ @@ -834,7 +846,8 @@ function media_details($image, $auth, $rev=false) { * */ function media_getTag($tags,$src,$alt=''){ - $meta = new JpegMeta($src); + //$meta = new JpegMeta($src); + $meta = JpegMeta::Create($src); if($meta === false) return $alt; $info = $meta->getField($tags); if($info == false) return $alt; -- cgit v1.2.3 From 532850ed047e0f35268eb1a5d4cf85c80f228dc5 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 23 Jun 2011 13:13:34 +0300 Subject: media getting metadata fix --- inc/media.php | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index 68aab5415..461a13665 100644 --- a/inc/media.php +++ b/inc/media.php @@ -736,9 +736,8 @@ function media_tab_edit($image, $ns, $auth=null) { echo '
    '; if ($image) { - $info = new JpegMeta(mediaFN($image)); - if ($info->getField('File.Mime') == 'image/jpeg') - media_metaform($image,$auth,true); + list($ext, $mime) = mimetype($image); + if ($mime == 'image/jpeg') media_metaform($image,$auth,true); } echo '
    '; echo '
    '; @@ -780,8 +779,8 @@ function media_tab_history($image, $ns, $auth=null) { function media_preview($image, $auth, $rev=false) { global $lang; if ($auth < AUTH_READ || !$image) return ''; - $info = new JpegMeta(mediaFN($image)); - $w = (int) $info->getField('File.Width'); + $info = getimagesize(mediaFN($image)); + $w = (int) $info[0]; $more = ''; if ($rev) $more = "rev=$rev"; @@ -809,30 +808,29 @@ function media_preview($image, $auth, $rev=false) { * @author Kate Arzamastseva */ function media_details($image, $auth, $rev=false) { - global $lang; + global $lang, $config_cascade;; - $tags = array( - array('simple.title','img_title','text'), - array('Date.EarliestTime','img_date','date'), - array('File.Name','img_fname','text'), - array(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit'),'img_artist','text'), - array(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright'),'img_copyr','text'), - array('File.Format','img_format','text'), - array('File.NiceSize','img_fsize','text'), - array('File.Width','img_width','text'), - array('File.Height','img_height','text'), - array('Simple.Camera','img_camera','text'), - array(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject'),'img_keywords','text') - ); + // load the field descriptions + static $tags = null; + if(is_null($tags)){ + foreach (array('default','local') as $config_group) { + if (empty($config_cascade['mediameta'][$config_group])) continue; + foreach ($config_cascade['mediameta'][$config_group] as $config_file) { + if(@file_exists($config_file)){ + include($config_file); + } + } + } + } $src = mediaFN($image, $rev); + $meta = new JpegMeta($src); echo '
    '; foreach($tags as $key => $tag){ $t = $tag[0]; if (!is_array($t)) $t = array($tag[0]); - $value = media_getTag($t,$src); + $value = media_getTag($t, $meta, '-'); $value = cleanText($value); - if (!$value) $value='-'; echo '
    '.$lang[$tag[1]].':
    '; if ($tag[2] == 'text') echo hsc($value); if ($tag[2] == 'date') echo dformat($value); @@ -842,12 +840,15 @@ function media_details($image, $auth, $rev=false) { } /** - * Returns the requested EXIF/IPTC tag from the current image + * Returns the requested EXIF/IPTC tag from the image meta * + * @author Kate Arzamastseva + * @param array $tags + * @param JpegMeta $meta + * @param string $alt + * @return string */ -function media_getTag($tags,$src,$alt=''){ - //$meta = new JpegMeta($src); - $meta = JpegMeta::Create($src); +function media_getTag($tags,$meta,$alt=''){ if($meta === false) return $alt; $info = $meta->getField($tags); if($info == false) return $alt; -- cgit v1.2.3 From 88a71175e3de9e3ad8b20ca9eb710aaf773cb788 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 23 Jun 2011 14:16:15 +0300 Subject: media manager auth fix --- inc/lang/en/lang.php | 2 ++ inc/media.php | 27 +++++++++++++++++++++++---- inc/template.php | 3 ++- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 6fb387a89..a55981983 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -338,5 +338,7 @@ $lang['media_view'] = 'View'; $lang['media_edit'] = 'Edit'; $lang['media_history'] = 'These are the older revisions of the file.'; $lang['media_meta_edited']= 'metadata edited'; +$lang['media_perm_read'] = 'Sorry, you don\'t have enough rights to read files.'; +$lang['media_perm_upload']= 'Sorry, you don\'t have enough rights to upload files.'; //Setup VIM: ex: et ts=2 : diff --git a/inc/media.php b/inc/media.php index 461a13665..fc7f72941 100644 --- a/inc/media.php +++ b/inc/media.php @@ -89,9 +89,13 @@ function media_metasave($id,$auth,$data){ * @author Kate Arzamastseva */ function media_metaform($id,$auth,$fullscreen = false){ - if($auth < AUTH_UPLOAD) return false; global $lang, $config_cascade; + if($auth < AUTH_UPLOAD) { + echo '
    '.$lang['media_perm_upload'].'
    '.NL; + return false; + } + // load the field descriptions static $fields = null; if(is_null($fields)){ @@ -637,7 +641,7 @@ function media_tab_files($ns,$auth=null,$jump='') { $view = $_REQUEST['view']; if($auth < AUTH_READ){ - echo '
    '.$lang['nothingfound'].'
    '.NL; + echo '
    '.$lang['media_perm_read'].'
    '.NL; }else{ if ($view == 'list') { echo '
      '; @@ -766,6 +770,8 @@ function media_tab_history($image, $ns, $auth=null) { $first = isset($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; html_revisions($first, $image); } + } else { + echo '
      '.$lang['media_perm_read'].'
      '.NL; } echo '
    '; echo '
    '; @@ -778,7 +784,11 @@ function media_tab_history($image, $ns, $auth=null) { */ function media_preview($image, $auth, $rev=false) { global $lang; - if ($auth < AUTH_READ || !$image) return ''; + if (!$image) return ''; + if ($auth < AUTH_READ) { + echo '
    '.$lang['media_perm_read'].'
    '.NL; + return ''; + } $info = getimagesize(mediaFN($image)); $w = (int) $info[0]; @@ -810,6 +820,12 @@ function media_preview($image, $auth, $rev=false) { function media_details($image, $auth, $rev=false) { global $lang, $config_cascade;; + if (!$image) return ''; + if ($auth < AUTH_READ) { + echo '
    '.$lang['media_perm_read'].'
    '.NL; + return ''; + } + // load the field descriptions static $tags = null; if(is_null($tags)){ @@ -1196,7 +1212,10 @@ function media_managerURL($params=false, $amp='&') { function media_uploadform($ns, $auth, $fullscreen = false){ global $lang; - if($auth < AUTH_UPLOAD) return; //fixme print info on missing permissions? + if($auth < AUTH_UPLOAD) { + echo '
    '.$lang['media_perm_upload'].'
    '.NL; + return; + } // The default HTML upload form $params = array('id' => 'dw__upload', diff --git a/inc/template.php b/inc/template.php index 5d29f6950..051679fb9 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1423,7 +1423,8 @@ function tpl_getFavicon($abs=false) { */ function tpl_media() { // - global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $lang; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $lang, $fullscreen; + $fullscreen = true; require_once(DOKU_INC.'lib/exe/mediamanager.php'); echo '
    '; -- cgit v1.2.3 From 70c3cc9a17d47d8986cba0805d943c1a68af1740 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 24 Jun 2011 00:41:47 +0300 Subject: media action buttons --- inc/lang/en/lang.php | 1 + inc/media.php | 37 ++++++++++++++++++++++++++----------- inc/template.php | 10 +++------- 3 files changed, 30 insertions(+), 18 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index a55981983..abe59d0aa 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -340,5 +340,6 @@ $lang['media_history'] = 'These are the older revisions of the file.'; $lang['media_meta_edited']= 'metadata edited'; $lang['media_perm_read'] = 'Sorry, you don\'t have enough rights to read files.'; $lang['media_perm_upload']= 'Sorry, you don\'t have enough rights to upload files.'; +$lang['media_update'] = 'Upload new version'; //Setup VIM: ex: et ts=2 : diff --git a/inc/media.php b/inc/media.php index fc7f72941..19aee0d06 100644 --- a/inc/media.php +++ b/inc/media.php @@ -795,21 +795,27 @@ function media_preview($image, $auth, $rev=false) { $more = ''; if ($rev) $more = "rev=$rev"; $src = ml($image, $more); - + echo '
    '; echo '

    '; - $link = ml($image,$more,true); - echo $image.' '; + $link = ml($image,$more,true,'&'); + + $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank')); + $form->addElement(form_makeButton('submit','',$lang['mediaview'])); + $form->printForm(); // delete button if($auth >= AUTH_DELETE && !$rev){ - $link = media_managerURL(array('delete' => $image,'sectok' => getSecurityToken())); - echo ' '. - ''.$lang['btn_delete'].''; - } + $form = new Doku_Form(array('action'=>media_managerURL(array('delete' => $image)))); + $form->addElement(form_makeButton('submit','',$lang['btn_delete'])); + $form->printForm(); + $form = new Doku_Form(array('action'=>media_managerURL())); + $form->addHidden('mediado','update'); + $form->addElement(form_makeButton('submit','',$lang['media_update'])); + $form->printForm(); + } + echo '
    '; } /** @@ -1217,6 +1223,13 @@ function media_uploadform($ns, $auth, $fullscreen = false){ return; } + $update = false; + $id = ''; + if ($auth >= AUTH_DELETE && $fullscreen && $_REQUEST['mediado'] == 'update') { + $update = true; + $id = cleanID($_REQUEST['image']); + } + // The default HTML upload form $params = array('id' => 'dw__upload', 'enctype' => 'multipart/form-data'); @@ -1231,13 +1244,15 @@ function media_uploadform($ns, $auth, $fullscreen = false){ $form->addElement(form_makeFileField('upload', $lang['txt_upload'].':', 'upload__file')); $form->addElement(form_makeCloseTag('p')); $form->addElement(form_makeOpenTag('p')); - $form->addElement(form_makeTextField('id', '', $lang['txt_filename'].':', 'upload__name')); + $form->addElement(form_makeTextField('id', $id, $lang['txt_filename'].':', 'upload__name')); $form->addElement(form_makeButton('submit', '', $lang['btn_upload'])); $form->addElement(form_makeCloseTag('p')); if($auth >= AUTH_DELETE){ $form->addElement(form_makeOpenTag('p')); - $form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check')); + $attrs = array(); + if ($update) $attrs['checked'] = 'checked'; + $form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check', $attrs)); $form->addElement(form_makeCloseTag('p')); } html_form('upload', $form); diff --git a/inc/template.php b/inc/template.php index 051679fb9..4226c0e52 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1142,6 +1142,7 @@ function tpl_fileList(){ $opened_tab = $_REQUEST['tab_files']; if (!$opened_tab) $opened_tab = 'files'; + if ($_REQUEST['mediado'] == 'update') $opened_tab = 'upload'; media_tabs_files($opened_tab); if ($opened_tab == 'files') media_tab_files($NS,$AUTH,$JUMPTO); @@ -1161,11 +1162,9 @@ function tpl_fileList(){ function tpl_fileDetails(){ global $AUTH; global $NS; - global $IMG; if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); - if (!isset($IMG) && !isset($image)) return ''; - if (isset($NS) && getNS($image) != $NS) return ''; + if (!isset($image) || isset($NS) && getNS($image) != $NS) return ''; $opened_tab = $_REQUEST['tab_details']; if (!$opened_tab) $opened_tab = 'view'; @@ -1173,10 +1172,7 @@ function tpl_fileDetails(){ media_tabs_details($opened_tab); if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH); - if ($opened_tab == 'edit') { - if ($IMG) media_tab_edit($IMG, $NS, $AUTH); - else if ($image) media_tab_edit($image, $NS, $AUTH); - } + if ($opened_tab == 'edit') media_tab_edit($image, $NS, $AUTH); if ($opened_tab == 'history') media_tab_history($image,$NS,$AUTH); } -- cgit v1.2.3 From 322111f0870d88a59b71258ce8410ae378441533 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Tue, 28 Jun 2011 15:52:02 +0300 Subject: css fix --- inc/media.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index f316bc34e..b2d608860 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1093,21 +1093,22 @@ function media_printfile_thumbs($item,$auth,$jump){ echo ''; echo ''; } + //echo ''; echo ''.hsc($file).''; + "h_:'.$item['id'].'" class="name">'.hsc($file).''; if($item['isimg']){ - $info = ''; - $info .= (int) $item['meta']->getField('File.Width'); - $info .= '×'; - $info .= (int) $item['meta']->getField('File.Height'); - echo ''.$info.''; + $size = ''; + $size .= (int) $item['meta']->getField('File.Width'); + $size .= '×'; + $size .= (int) $item['meta']->getField('File.Height'); + echo ''.$size.''; } else { - echo ' '; + echo ' '; } - $info = ''.dformat($item['mtime']).''; - echo ''.$info.''; - $info = filesize_h($item['size']); - echo ''.$info.''; + $date = dformat($item['mtime']); + echo ''.$date.''; + $filesize = filesize_h($item['size']); + echo ''.$filesize.''; echo '
    '; echo '
  • '.NL; } -- cgit v1.2.3 From 3e98e6857f2c48127d4169d02e341d1013c00bac Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 29 Jun 2011 16:59:18 +0300 Subject: media getting metadata fix --- inc/media.php | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index b2d608860..d90a13c81 100644 --- a/inc/media.php +++ b/inc/media.php @@ -99,14 +99,9 @@ function media_metaform($id,$auth,$fullscreen = false){ // load the field descriptions static $fields = null; if(is_null($fields)){ - - foreach (array('default','local') as $config_group) { - if (empty($config_cascade['mediameta'][$config_group])) continue; - foreach ($config_cascade['mediameta'][$config_group] as $config_file) { - if(@file_exists($config_file)){ - include($config_file); - } - } + $config_files = getConfigFiles('mediameta'); + foreach ($config_files as $config_file) { + if(@file_exists($config_file)) include($config_file); } } @@ -123,6 +118,7 @@ function media_metaform($id,$auth,$fullscreen = false){ formSecurityToken(); foreach($fields as $key => $field){ // get current value + if (empty($field[0])) continue; $tags = array($field[0]); if(is_array($field[3])) $tags = array_merge($tags,$field[3]); $value = tpl_img_getTag($tags,'',$src); @@ -837,29 +833,26 @@ function media_details($image, $auth, $rev=false) { } // load the field descriptions - static $tags = null; - if(is_null($tags)){ - foreach (array('default','local') as $config_group) { - if (empty($config_cascade['mediameta'][$config_group])) continue; - foreach ($config_cascade['mediameta'][$config_group] as $config_file) { - if(@file_exists($config_file)){ - include($config_file); - } - } + static $fields = null; + if(is_null($fields)){ + $config_files = getConfigFiles('mediameta'); + foreach ($config_files as $config_file) { + if(@file_exists($config_file)) include($config_file); } } $src = mediaFN($image, $rev); $meta = new JpegMeta($src); echo '
    '; - foreach($tags as $key => $tag){ - $t = $tag[0]; - if (!is_array($t)) $t = array($tag[0]); + foreach($fields as $key => $tag){ + $t = array(); + if (!empty($tag[0])) $t = array($tag[0]); + if(is_array($tag[3])) $t = array_merge($t,$tag[3]); $value = media_getTag($t, $meta, '-'); $value = cleanText($value); echo '
    '.$lang[$tag[1]].':
    '; - if ($tag[2] == 'text') echo hsc($value); if ($tag[2] == 'date') echo dformat($value); + else echo hsc($value); echo '
    '; } echo '
    '; -- cgit v1.2.3 From 98f03b57e3bb6185cbbb815a71d254e28df79912 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 29 Jun 2011 17:04:16 +0300 Subject: media upload fix --- inc/media.php | 20 ++++++++++++-------- inc/template.php | 14 +++++++++----- 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index d90a13c81..cba89b995 100644 --- a/inc/media.php +++ b/inc/media.php @@ -242,7 +242,7 @@ function media_upload($ns,$auth){ global $lang; // get file and id - $id = $_POST['id']; + $id = $_POST['mediaid']; $file = $_FILES['upload']; if(empty($id)) $id = $file['name']; @@ -572,25 +572,25 @@ function media_tabs_files($selected=false){ * @author Kate Arzamastseva * @param string $selected - opened tab */ -function media_tabs_details($selected=false){ +function media_tabs_details($image, $selected=false){ global $lang; echo '
    '; - $tab = ' 'view', 'image' => $image)). '" rel=".mediamanager-tab-view"'; if (!empty($selected) && $selected == 'view') $class = 'view selected'; else $class = 'view'; $tab .= ' class="'.$class.'" >'.$lang['media_viewtab'].''; echo $tab; - $tab = ' 'edit', 'image' => $image)). '" rel=".mediamanager-tab-edit"'; if (!empty($selected) && $selected == 'edit') $class = 'edit selected'; else $class = 'edit'; $tab .= ' class="'.$class.'" >'.$lang['media_edittab'].''; echo $tab; - $tab = ' 'history', 'image' => $image)). '" rel=".mediamanager-tab-history"'; if (!empty($selected) && $selected == 'history') $class = 'history selected'; else $class = 'history'; @@ -1231,8 +1231,12 @@ function media_uploadform($ns, $auth, $fullscreen = false){ // The default HTML upload form $params = array('id' => 'dw__upload', 'enctype' => 'multipart/form-data'); - if (!$fullscreen) $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; - else $params['action'] = media_managerURL(array('tab_files' => 'files')); + if (!$fullscreen) { + $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; + } else { + $params['action'] = media_managerURL(array('tab_files' => 'files', + 'tab_details' => 'view')); + } $form = new Doku_Form($params); if (!$fullscreen) $form->addElement('
    ' . $lang['mediaupload'] . '
    '); @@ -1242,7 +1246,7 @@ function media_uploadform($ns, $auth, $fullscreen = false){ $form->addElement(form_makeFileField('upload', $lang['txt_upload'].':', 'upload__file')); $form->addElement(form_makeCloseTag('p')); $form->addElement(form_makeOpenTag('p')); - $form->addElement(form_makeTextField('id', $id, $lang['txt_filename'].':', 'upload__name')); + $form->addElement(form_makeTextField('mediaid', noNS($id), $lang['txt_filename'].':', 'upload__name')); $form->addElement(form_makeButton('submit', '', $lang['btn_upload'])); $form->addElement(form_makeCloseTag('p')); diff --git a/inc/template.php b/inc/template.php index 4226c0e52..e3d716c25 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1159,17 +1159,17 @@ function tpl_fileList(){ * * @author Kate Arzamastseva */ -function tpl_fileDetails(){ +function tpl_fileDetails($image){ global $AUTH; global $NS; - if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); - if (!isset($image) || isset($NS) && getNS($image) != $NS) return ''; + if (!$image || !file_exists(mediaFN($image))) return ''; + if (isset($NS) && getNS($image) != $NS) return ''; $opened_tab = $_REQUEST['tab_details']; if (!$opened_tab) $opened_tab = 'view'; if ($_REQUEST['edit']) $opened_tab = 'edit'; - media_tabs_details($opened_tab); + media_tabs_details($image, $opened_tab); if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH); if ($opened_tab == 'edit') media_tab_edit($image, $NS, $AUTH); @@ -1423,6 +1423,10 @@ function tpl_media() { $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; + echo '
    '; echo '
    '; echo '
    '; @@ -1442,7 +1446,7 @@ function tpl_media() { tpl_fileList(); echo '
    '; echo '
    '; - tpl_fileDetails(); + tpl_fileDetails($image); echo '
    '; echo '
    '; echo '
    '; -- cgit v1.2.3 From 9c1bd4bc9aa4b9ac3b9981543a14508091cd639a Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 30 Jun 2011 19:44:31 +0300 Subject: restoring old media revisions --- inc/lang/en/lang.php | 1 + inc/media.php | 47 ++++++++++++++++++++++++++++++++++++++++++----- inc/template.php | 10 ++++++---- 3 files changed, 49 insertions(+), 9 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index abe59d0aa..7a2050fac 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -341,5 +341,6 @@ $lang['media_meta_edited']= 'metadata edited'; $lang['media_perm_read'] = 'Sorry, you don\'t have enough rights to read files.'; $lang['media_perm_upload']= 'Sorry, you don\'t have enough rights to upload files.'; $lang['media_update'] = 'Upload new version'; +$lang['media_restore'] = 'Restore this version'; //Setup VIM: ex: et ts=2 : diff --git a/inc/media.php b/inc/media.php index cba89b995..34bdec42b 100644 --- a/inc/media.php +++ b/inc/media.php @@ -367,6 +367,7 @@ function _media_upload_action($data) { function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'move_uploaded_file') { global $conf; global $lang; + global $REV; $old = @filemtime($fn); if(!@file_exists(mediaFN($id, $old)) && @file_exists($fn)) { @@ -378,6 +379,7 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov io_createNamespace($id, 'media'); if($move($fn_tmp, $fn)) { + clearstatcache(true,$fn); $new = @filemtime($fn); // Set the correct permission here. // Always chmod media because they may be saved with different permissions than expected from the php umask. @@ -386,7 +388,9 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov msg($lang['uploadsucc'],1); media_notify($id,$fn,$imime); // add a log entry to the media changelog - if ($overwrite) { + if ($REV){ + addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_REVERT, '', $REV); + } elseif ($overwrite) { addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_EDIT); } else { addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_CREATE, $lang['created']); @@ -707,7 +711,7 @@ function media_tab_search($ns,$auth=null) { * * @author Kate Arzamastseva */ -function media_tab_view($image, $ns, $auth=null) { +function media_tab_view($image, $ns, $auth=null, $rev=false) { global $lang, $conf; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); @@ -717,7 +721,6 @@ function media_tab_view($image, $ns, $auth=null) { echo '
    '; echo '
    '; - $rev = (int) $_REQUEST['rev']; media_preview($image, $auth, $rev); media_details($image, $auth, $rev); echo '
    '; @@ -789,7 +792,7 @@ function media_preview($image, $auth, $rev=false) { echo '
    '.$lang['media_perm_read'].'
    '.NL; return ''; } - $info = getimagesize(mediaFN($image)); + $info = getimagesize(mediaFN($image, $rev)); $w = (int) $info[0]; $more = ''; @@ -810,11 +813,18 @@ function media_preview($image, $auth, $rev=false) { $form->addElement(form_makeButton('submit','',$lang['btn_delete'])); $form->printForm(); - $form = new Doku_Form(array('action'=>media_managerURL())); + $form = new Doku_Form(array('action'=>media_managerURL(array('image' => $image)))); $form->addHidden('mediado','update'); $form->addElement(form_makeButton('submit','',$lang['media_update'])); $form->printForm(); } + if($auth >= AUTH_DELETE && $rev){ + $form = new Doku_Form(array('action'=>media_managerURL(array('image' => $image)))); + $form->addHidden('mediado','restore'); + $form->addHidden('rev',$rev); + $form->addElement(form_makeButton('submit','',$lang['media_restore'])); + $form->printForm(); + } echo '
    '; } @@ -926,6 +936,33 @@ function media_diff($image, $ns, $auth) { echo ''; } +/** + * Restores an old revision of a media file + * + * @param string $image + * @param int $rev + * @param int $auth + * @return string - file's id + * @author Kate Arzamastseva + */ +function media_restore($image, $rev, $auth){ + if ($auth < AUTH_DELETE) return false; + if (!$image || !file_exists(mediaFN($image))) return false; + if (!$rev || !file_exists(mediaFN($image, $rev))) return false; + list($iext,$imime,$dl) = mimetype($image); + $res = media_upload_finish(mediaFN($image, $rev), + mediaFN($image), + $image, + $imime, + true, + 'copy'); + if (is_array($res)) { + msg($res[0], $res[1]); + return false; + } + return $res; +} + /** * List all files found by the search request * diff --git a/inc/template.php b/inc/template.php index e3d716c25..cb5004891 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1159,11 +1159,12 @@ function tpl_fileList(){ * * @author Kate Arzamastseva */ -function tpl_fileDetails($image){ +function tpl_fileDetails($image, $rev){ global $AUTH; global $NS; if (!$image || !file_exists(mediaFN($image))) return ''; + if ($rev && !file_exists(mediaFN($image, $rev))) return ''; if (isset($NS) && getNS($image) != $NS) return ''; $opened_tab = $_REQUEST['tab_details']; @@ -1171,7 +1172,7 @@ function tpl_fileDetails($image){ if ($_REQUEST['edit']) $opened_tab = 'edit'; media_tabs_details($image, $opened_tab); - if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH); + if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH, $rev); if ($opened_tab == 'edit') media_tab_edit($image, $NS, $AUTH); if ($opened_tab == 'history') media_tab_history($image,$NS,$AUTH); } @@ -1419,13 +1420,14 @@ function tpl_getFavicon($abs=false) { */ function tpl_media() { // - global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $lang, $fullscreen; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen; $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; echo '
    '; echo '
    '; @@ -1446,7 +1448,7 @@ function tpl_media() { tpl_fileList(); echo '
    '; echo '
    '; - tpl_fileDetails($image); + tpl_fileDetails($image, $rev); echo '
    '; echo '
    '; echo '
    '; -- cgit v1.2.3 From 23846a98488bec2aaade6d983b4c0b0db13af80c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 3 Jul 2011 19:00:54 +0300 Subject: ajax mediamanager --- inc/media.php | 64 +++++++++++++++++++++++--------------------------------- inc/template.php | 55 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 67 insertions(+), 52 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index 34bdec42b..fd917a5a0 100644 --- a/inc/media.php +++ b/inc/media.php @@ -379,7 +379,7 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov io_createNamespace($id, 'media'); if($move($fn_tmp, $fn)) { - clearstatcache(true,$fn); + @clearstatcache(true,$fn); $new = @filemtime($fn); // Set the correct permission here. // Always chmod media because they may be saved with different permissions than expected from the php umask. @@ -529,7 +529,7 @@ function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false){ echo '
    '.$lang['nothingfound'].'
    '.NL; }else foreach($data as $item){ if (!$fullscreenview) media_printfile($item,$auth,$jump); - else if ($fullscreenview == 'thumbs') media_printfile_thumbs($item,$auth,$jump); + else media_printfile_thumbs($item,$auth,$jump); } } if (!$fullscreenview) media_searchform($ns); @@ -544,9 +544,8 @@ function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false){ function media_tabs_files($selected=false){ global $lang; - echo '
    '; - $tab = ''; + $tab = ''.$lang['mediaselect'].''; @@ -579,7 +578,7 @@ function media_tabs_files($selected=false){ function media_tabs_details($image, $selected=false){ global $lang; - echo '
    '; + echo '
    '; $tab = ''; - echo '
    '; + echo '
    '; echo ''. $lang['media_thumbsview'].''; @@ -639,24 +638,22 @@ function media_tab_files($ns,$auth=null,$jump='') { global $lang; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); - echo '
    '; media_tab_files_options(); - echo '
    '; + echo '
    '; $view = $_REQUEST['view']; if($auth < AUTH_READ){ echo '
    '.$lang['media_perm_read'].'
    '.NL; }else{ if ($view == 'list') { - echo '
      '; + echo '
        '; } else { - echo '
          '; + echo '
            '; } - media_filelist($ns,$auth,$jump,'thumbs'); + media_filelist($ns,$auth,$jump,true); echo '
          '; } echo '
    '; - echo '
    '; } /** @@ -668,7 +665,6 @@ function media_tab_upload($ns,$auth=null,$jump='') { global $lang; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); - echo '
    '; echo '
    '; echo $lang['mediaupload']; echo '
    '; @@ -676,7 +672,6 @@ function media_tab_upload($ns,$auth=null,$jump='') { echo '
    '; media_uploadform($ns, $auth, true); echo '
    '; - echo '
    '; } /** @@ -691,7 +686,6 @@ function media_tab_search($ns,$auth=null) { $query = $_REQUEST['q']; if (!$query) $query = ''; - echo ''; - echo '
    '; } /** @@ -715,7 +715,6 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { global $lang, $conf; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); - echo '
    '; echo '
    '; echo $image; echo '
    '; @@ -724,7 +723,6 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { media_preview($image, $auth, $rev); media_details($image, $auth, $rev); echo '
    '; - echo '
    '; } /** @@ -736,7 +734,6 @@ function media_tab_edit($image, $ns, $auth=null) { global $lang; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); - echo '
    '; echo '
    '; echo $lang['media_edit']; echo '
    '; @@ -747,7 +744,6 @@ function media_tab_edit($image, $ns, $auth=null) { if ($mime == 'image/jpeg') media_metaform($image,$auth,true); } echo '
    '; - echo '
    '; } /** @@ -760,7 +756,6 @@ function media_tab_history($image, $ns, $auth=null) { if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); $do = $_REQUEST['mediado']; - echo '
    '; echo '
    '; echo $lang['media_history']; echo '
    '; @@ -777,7 +772,6 @@ function media_tab_history($image, $ns, $auth=null) { echo '
    '.$lang['media_perm_read'].'
    '.NL; } echo '
    '; - echo '
    '; } /** @@ -1006,7 +1000,7 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false){ echo '
    '.$lang['nothingfound'].'
    '.NL; }else foreach($evdata['data'] as $item){ if (!$fullscreen) media_printfile($item,$item['perm'],'',true); - else media_printfile_thumbs($item,$item['perm'],'',true); + else media_printfile_thumbs($item,$item['perm']); } } @@ -1106,7 +1100,7 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ * * @author Kate Arzamastseva */ -function media_printfile_thumbs($item,$auth,$jump){ +function media_printfile_thumbs($item,$auth,$jump=false){ global $lang; global $conf; @@ -1217,18 +1211,11 @@ function media_managerURL($params=false, $amp='&') { global $conf; global $ID; - $url = $_SERVER['REQUEST_URI']; - - $urlArray = explode('?', $url, 2); - $gets = @$urlArray[1]; - parse_str($gets, $gets); - - if ($gets['edit']) $gets['image'] = $gets['edit']; - unset($gets['edit']); - unset($gets['sectok']); - unset($gets['delete']); - unset($gets['rev']); - unset($gets['mediado']); + $gets = array('do' => 'media'); + $media_manager_params = array('tab_files', 'tab_details', 'image', 'ns', 'view'); + foreach ($media_manager_params as $x) { + if (isset($_REQUEST[$x])) $gets[$x] = $_REQUEST[$x]; + } if ($params) { foreach ($params as $k => $v) { @@ -1407,7 +1394,8 @@ function media_nstree_item($item){ $ret = ''; if (!($_REQUEST['do'] == 'media')) $ret .= ''; - else $ret .= ''; + else $ret .= ''; $ret .= $item['label']; $ret .= ''; return $ret; diff --git a/inc/template.php b/inc/template.php index cb5004891..c3b705421 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1135,7 +1135,7 @@ function tpl_mediaContent($fromajax=false){ * * @author Kate Arzamastseva */ -function tpl_fileList(){ +function tpl_fileList($fromajax=false){ global $AUTH; global $NS; global $JUMPTO; @@ -1144,10 +1144,23 @@ function tpl_fileList(){ if (!$opened_tab) $opened_tab = 'files'; if ($_REQUEST['mediado'] == 'update') $opened_tab = 'upload'; - media_tabs_files($opened_tab); - if ($opened_tab == 'files') media_tab_files($NS,$AUTH,$JUMPTO); - if ($opened_tab == 'upload') media_tab_upload($NS,$AUTH,$JUMPTO); - if ($opened_tab == 'search') media_tab_search($NS,$AUTH); + if(!$fromajax) media_tabs_files($opened_tab); + + if ($opened_tab == 'files') { + if (!$fromajax) echo '
    '; + media_tab_files($NS,$AUTH,$JUMPTO); + if (!$fromajax) echo '
    '; + + } elseif ($opened_tab == 'upload') { + if (!$fromajax) echo '
    '; + media_tab_upload($NS,$AUTH,$JUMPTO); + if (!$fromajax) echo '
    '; + + } elseif ($opened_tab == 'search') { + if (!$fromajax) echo ''; + } } @@ -1159,22 +1172,37 @@ function tpl_fileList(){ * * @author Kate Arzamastseva */ -function tpl_fileDetails($image, $rev){ +function tpl_fileDetails($image, $rev, $fromajax=false){ global $AUTH; global $NS; if (!$image || !file_exists(mediaFN($image))) return ''; if ($rev && !file_exists(mediaFN($image, $rev))) return ''; if (isset($NS) && getNS($image) != $NS) return ''; + $do = $_REQUEST['mediado']; $opened_tab = $_REQUEST['tab_details']; if (!$opened_tab) $opened_tab = 'view'; if ($_REQUEST['edit']) $opened_tab = 'edit'; - media_tabs_details($image, $opened_tab); + if ($do == 'restore') $opened_tab = 'view'; - if ($opened_tab == 'view') media_tab_view($image, $NS, $AUTH, $rev); - if ($opened_tab == 'edit') media_tab_edit($image, $NS, $AUTH); - if ($opened_tab == 'history') media_tab_history($image,$NS,$AUTH); + if(!$fromajax) media_tabs_details($image, $opened_tab); + + if ($opened_tab == 'view') { + if (!$fromajax) echo '
    '; + media_tab_view($image, $NS, $AUTH, $rev); + if (!$fromajax) echo '
    '; + + } elseif ($opened_tab == 'edit') { + if (!$fromajax) echo '
    '; + media_tab_edit($image, $NS, $AUTH); + if (!$fromajax) echo '
    '; + + } elseif ($opened_tab == 'history') { + if (!$fromajax) echo '
    '; + media_tab_history($image,$NS,$AUTH); + if (!$fromajax) echo '
    '; + } } /** @@ -1186,8 +1214,7 @@ function tpl_fileDetails($image, $rev){ */ function tpl_mediaTree($fullscreen = false){ global $NS; - if ($fullscreen) ptln('
    '); - else ptln('
    '); + ptln('
    '); media_nstree($NS); ptln('
    '); } @@ -1444,10 +1471,10 @@ function tpl_media() { tpl_mediaTree(true); echo '
    '; echo '
    '; - echo '
    '; + echo '
    '; tpl_fileList(); echo '
    '; - echo '
    '; + echo '
    '; tpl_fileDetails($image, $rev); echo '
    '; echo '
    '; -- cgit v1.2.3 From ed69a2ae06c0707fdd5634e18d569c25f0cda6d5 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 3 Jul 2011 23:56:26 +0300 Subject: ajax mediamanager fix --- inc/media.php | 4 ++-- inc/template.php | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index fd917a5a0..b668e7be2 100644 --- a/inc/media.php +++ b/inc/media.php @@ -807,8 +807,8 @@ function media_preview($image, $auth, $rev=false) { $form->addElement(form_makeButton('submit','',$lang['btn_delete'])); $form->printForm(); - $form = new Doku_Form(array('action'=>media_managerURL(array('image' => $image)))); - $form->addHidden('mediado','update'); + $form = new Doku_Form(array('id' => 'mediamanager__btn_update', + 'action'=>media_managerURL(array('image' => $image, 'mediado' => 'update')))); $form->addElement(form_makeButton('submit','',$lang['media_update'])); $form->printForm(); } diff --git a/inc/template.php b/inc/template.php index c3b705421..70253bb90 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1135,7 +1135,7 @@ function tpl_mediaContent($fromajax=false){ * * @author Kate Arzamastseva */ -function tpl_fileList($fromajax=false){ +function tpl_fileList(){ global $AUTH; global $NS; global $JUMPTO; @@ -1144,22 +1144,22 @@ function tpl_fileList($fromajax=false){ if (!$opened_tab) $opened_tab = 'files'; if ($_REQUEST['mediado'] == 'update') $opened_tab = 'upload'; - if(!$fromajax) media_tabs_files($opened_tab); + media_tabs_files($opened_tab); if ($opened_tab == 'files') { - if (!$fromajax) echo '
    '; + echo '
    '; media_tab_files($NS,$AUTH,$JUMPTO); - if (!$fromajax) echo '
    '; + echo '
    '; } elseif ($opened_tab == 'upload') { - if (!$fromajax) echo '
    '; + echo '
    '; media_tab_upload($NS,$AUTH,$JUMPTO); - if (!$fromajax) echo '
    '; + echo '
    '; } elseif ($opened_tab == 'search') { - if (!$fromajax) echo ''; } } @@ -1172,7 +1172,7 @@ function tpl_fileList($fromajax=false){ * * @author Kate Arzamastseva */ -function tpl_fileDetails($image, $rev, $fromajax=false){ +function tpl_fileDetails($image, $rev){ global $AUTH; global $NS; @@ -1186,22 +1186,22 @@ function tpl_fileDetails($image, $rev, $fromajax=false){ if ($_REQUEST['edit']) $opened_tab = 'edit'; if ($do == 'restore') $opened_tab = 'view'; - if(!$fromajax) media_tabs_details($image, $opened_tab); + media_tabs_details($image, $opened_tab); if ($opened_tab == 'view') { - if (!$fromajax) echo '
    '; + echo '
    '; media_tab_view($image, $NS, $AUTH, $rev); - if (!$fromajax) echo '
    '; + echo '
    '; } elseif ($opened_tab == 'edit') { - if (!$fromajax) echo '
    '; + echo '
    '; media_tab_edit($image, $NS, $AUTH); - if (!$fromajax) echo '
    '; + echo '
    '; } elseif ($opened_tab == 'history') { - if (!$fromajax) echo '
    '; + echo '
    '; media_tab_history($image,$NS,$AUTH); - if (!$fromajax) echo '
    '; + echo '
    '; } } -- cgit v1.2.3 From 7d7ab775ac0252d50835987b276a95b790cd1434 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 4 Jul 2011 22:35:44 +0300 Subject: mediamanager ajax forms --- inc/html.php | 5 ++++- inc/media.php | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 809db30bd..ee0711b6a 100644 --- a/inc/html.php +++ b/inc/html.php @@ -449,7 +449,10 @@ function html_revisions($first=0, $media_id = false){ if (!$media_id) print p_locale_xhtml('revisions'); - $form = new Doku_Form(array('id' => 'page__revisions')); + $params = array('id' => 'page__revisions'); + if ($media_id) $params['action'] = media_managerURL(array('image' => $media_id)); + + $form = new Doku_Form($params); $form->addElement(form_makeOpenTag('ul')); if (!$media_id) $exists = $INFO['exists']; diff --git a/inc/media.php b/inc/media.php index b668e7be2..5a1da55cd 100644 --- a/inc/media.php +++ b/inc/media.php @@ -110,11 +110,12 @@ function media_metaform($id,$auth,$fullscreen = false){ // output if (!$fullscreen) { echo '

    '.hsc(noNS($id)).'

    '.NL; - echo ''.NL; + $action = DOKU_BASE.'lib/exe/mediamanager.php'; } else { - echo ''.NL; + $action = media_managerURL(array('tab_details' => 'view')); } + echo ''.NL; + formSecurityToken(); foreach($fields as $key => $field){ // get current value @@ -150,8 +151,12 @@ function media_metaform($id,$auth,$fullscreen = false){ } echo '
    '.NL; echo ''.NL; - if (!$fullscreen) $do = 'do'; - else $do = 'mediado'; + if (!$fullscreen) { + $do = 'do'; + } else { + echo ''; + $do = 'mediado'; + } echo ''.NL; if (!$fullscreen) @@ -803,7 +808,8 @@ function media_preview($image, $auth, $rev=false) { // delete button if($auth >= AUTH_DELETE && !$rev){ - $form = new Doku_Form(array('action'=>media_managerURL(array('delete' => $image)))); + $form = new Doku_Form(array('id' => 'mediamanager__btn_delete', + 'action'=>media_managerURL(array('delete' => $image)))); $form->addElement(form_makeButton('submit','',$lang['btn_delete'])); $form->printForm(); @@ -813,7 +819,8 @@ function media_preview($image, $auth, $rev=false) { $form->printForm(); } if($auth >= AUTH_DELETE && $rev){ - $form = new Doku_Form(array('action'=>media_managerURL(array('image' => $image)))); + $form = new Doku_Form(array('id' => 'mediamanager__btn_restore', + 'action'=>media_managerURL(array('image' => $image)))); $form->addHidden('mediado','restore'); $form->addHidden('rev',$rev); $form->addElement(form_makeButton('submit','',$lang['media_restore'])); -- cgit v1.2.3 From 6183fb05112cd318d9a6885d9405cff9917ee82f Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 8 Jul 2011 13:54:15 +0300 Subject: mediamanager fix --- inc/html.php | 2 +- inc/lang/en/lang.php | 4 ++-- inc/media.php | 27 +++++++++++++++++---------- 3 files changed, 20 insertions(+), 13 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index ee0711b6a..59b4cb6a9 100644 --- a/inc/html.php +++ b/inc/html.php @@ -450,7 +450,7 @@ function html_revisions($first=0, $media_id = false){ if (!$media_id) print p_locale_xhtml('revisions'); $params = array('id' => 'page__revisions'); - if ($media_id) $params['action'] = media_managerURL(array('image' => $media_id)); + if ($media_id) $params['action'] = media_managerURL(array('image' => $media_id), '&'); $form = new Doku_Form($params); $form->addElement(form_makeOpenTag('ul')); diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 7a2050fac..ea6bf2646 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -225,6 +225,7 @@ $lang['js']['linkwiz'] = 'Link Wizard'; $lang['js']['linkto'] = 'Link to:'; $lang['js']['del_confirm']= 'Really delete selected item(s)?'; +$lang['js']['restore_confirm']= 'Really restore this version?'; $lang['admin_register']= 'Add new user'; $lang['metaedit'] = 'Edit Metadata'; @@ -333,8 +334,7 @@ $lang['media_historytab'] = 'History'; $lang['media_thumbsview'] = 'Thumbnails'; $lang['media_listview'] = 'List'; $lang['media_sort'] = 'Sort'; -$lang['media_search'] = 'Search'; -$lang['media_view'] = 'View'; +$lang['media_search'] = 'Search in the %s namespace.'; $lang['media_edit'] = 'Edit'; $lang['media_history'] = 'These are the older revisions of the file.'; $lang['media_meta_edited']= 'metadata edited'; diff --git a/inc/media.php b/inc/media.php index 5a1da55cd..fbbca401c 100644 --- a/inc/media.php +++ b/inc/media.php @@ -112,7 +112,7 @@ function media_metaform($id,$auth,$fullscreen = false){ echo '

    '.hsc(noNS($id)).'

    '.NL; $action = DOKU_BASE.'lib/exe/mediamanager.php'; } else { - $action = media_managerURL(array('tab_details' => 'view')); + $action = media_managerURL(array('tab_details' => 'view'), '&'); } echo ''.NL; @@ -204,6 +204,7 @@ define('DOKU_MEDIA_EMPTY_NS', 8); DOKU_MEDIA_INUSE */ function media_delete($id,$auth){ + global $lang; if($auth < AUTH_DELETE) return DOKU_MEDIA_NOT_AUTH; if(media_inuse($id)) return DOKU_MEDIA_INUSE; @@ -219,9 +220,15 @@ function media_delete($id,$auth){ $data['del'] = false; $evt = new Doku_Event('MEDIA_DELETE_FILE',$data); if ($evt->advise_before()) { + $old = @filemtime($file); + if(!@file_exists(mediaFN($id, $old)) && @file_exists($file)) { + // add old revision to the attic + media_saveOldRevision($id); + } + $data['unl'] = @unlink($file); if($data['unl']){ - addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE); + addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE, $lang['deleted']); $data['del'] = io_sweepNS($id,'mediadir'); } } @@ -394,7 +401,7 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov media_notify($id,$fn,$imime); // add a log entry to the media changelog if ($REV){ - addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_REVERT, '', $REV); + addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_REVERT, $lang['restored'], $REV); } elseif ($overwrite) { addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_EDIT); } else { @@ -692,7 +699,7 @@ function media_tab_search($ns,$auth=null) { if (!$query) $query = ''; echo '
    '; - echo $lang['media_search']; + echo sprintf($lang['media_search'], $ns); echo'
    '; echo '
    '; @@ -809,18 +816,18 @@ function media_preview($image, $auth, $rev=false) { // delete button if($auth >= AUTH_DELETE && !$rev){ $form = new Doku_Form(array('id' => 'mediamanager__btn_delete', - 'action'=>media_managerURL(array('delete' => $image)))); + 'action'=>media_managerURL(array('delete' => $image), '&'))); $form->addElement(form_makeButton('submit','',$lang['btn_delete'])); $form->printForm(); $form = new Doku_Form(array('id' => 'mediamanager__btn_update', - 'action'=>media_managerURL(array('image' => $image, 'mediado' => 'update')))); + 'action'=>media_managerURL(array('image' => $image, 'mediado' => 'update'), '&'))); $form->addElement(form_makeButton('submit','',$lang['media_update'])); $form->printForm(); } if($auth >= AUTH_DELETE && $rev){ $form = new Doku_Form(array('id' => 'mediamanager__btn_restore', - 'action'=>media_managerURL(array('image' => $image)))); + 'action'=>media_managerURL(array('image' => $image), '&'))); $form->addHidden('mediado','restore'); $form->addHidden('rev',$rev); $form->addElement(form_makeButton('submit','',$lang['media_restore'])); @@ -1214,7 +1221,7 @@ function media_printimgdetail($item, $fullscreen=false){ * @param string $amp - separator * @return string - link */ -function media_managerURL($params=false, $amp='&') { +function media_managerURL($params=false, $amp='&') { global $conf; global $ID; @@ -1266,7 +1273,7 @@ function media_uploadform($ns, $auth, $fullscreen = false){ $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; } else { $params['action'] = media_managerURL(array('tab_files' => 'files', - 'tab_details' => 'view')); + 'tab_details' => 'view'), '&'); } $form = new Doku_Form($params); @@ -1339,7 +1346,7 @@ function media_searchform($ns,$query='',$fullscreen=false){ // The default HTML search form $params = array('id' => 'dw__mediasearch'); if (!$fullscreen) $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; - else $params['action'] = media_managerURL(); + else $params['action'] = media_managerURL(array(), '&'); $form = new Doku_Form($params); if (!$fullscreen) $form->addElement('
    ' . $lang['mediasearch'] . '
    '); $form->addElement(formSecurityToken()); -- cgit v1.2.3 From 96dedb921014ef9601187c762d3070f46a0005bb Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 9 Jul 2011 21:02:14 +0300 Subject: mediamanager without cache --- inc/media.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index fbbca401c..ced88f82a 100644 --- a/inc/media.php +++ b/inc/media.php @@ -802,7 +802,12 @@ function media_preview($image, $auth, $rev=false) { $w = (int) $info[0]; $more = ''; - if ($rev) $more = "rev=$rev"; + if ($rev) { + $more = "rev=$rev"; + } else { + $t = @filemtime(mediaFN($image)); + $more = "t=$t"; + } $src = ml($image, $more); echo '
    '; echo '

    '; @@ -1169,7 +1174,7 @@ function media_printimgdetail($item, $fullscreen=false){ $w = floor($w * $ratio); $h = floor($h * $ratio); } - $src = ml($item['id'],array('w'=>$w,'h'=>$h)); + $src = ml($item['id'],array('w'=>$w,'h'=>$h,'t'=>$item['mtime'])); $p = array(); $p['width'] = $w; if (!$fullscreen) $p['height'] = $h; -- cgit v1.2.3 From de11c42f80968ac41dc4164829845c1e5dae25c2 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 9 Jul 2011 23:21:50 +0300 Subject: media-manager fixes --- inc/html.php | 6 +++--- inc/media.php | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 59b4cb6a9..df28a2096 100644 --- a/inc/html.php +++ b/inc/html.php @@ -476,7 +476,7 @@ function html_revisions($first=0, $media_id = false){ $form->addElement(''); if (!$media_id) $href = wl($id); - else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view')); + else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&'); $form->addElement(form_makeOpenTag('a', array( 'class' => 'wikilink1', 'href' => $href))); @@ -536,7 +536,7 @@ function html_revisions($first=0, $media_id = false){ if($exists){ if (!$media_id) $href = wl($id,"rev=$rev,do=diff", false, '&'); - else $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff')); + else $href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff'), '&'); $form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'diff_link'))); $form->addElement(form_makeTag('img', array( 'src' => DOKU_BASE.'lib/images/diff.png', @@ -546,7 +546,7 @@ function html_revisions($first=0, $media_id = false){ 'alt' => $lang['diff']))); $form->addElement(form_makeCloseTag('a')); if (!$media_id) $href = wl($id,"rev=$rev",false,'&'); - else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev)); + else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&'); $form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'wikilink1'))); $form->addElement($id); $form->addElement(form_makeCloseTag('a')); diff --git a/inc/media.php b/inc/media.php index ced88f82a..341692f5f 100644 --- a/inc/media.php +++ b/inc/media.php @@ -621,10 +621,11 @@ function media_tabs_details($image, $selected=false){ * * @author Kate Arzamastseva */ -function media_tab_files_options(){ +function media_tab_files_options($ns){ global $lang; echo '
    '; + echo $ns; echo '
    '; echo ''. @@ -650,7 +651,7 @@ function media_tab_files($ns,$auth=null,$jump='') { global $lang; if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); - media_tab_files_options(); + media_tab_files_options($ns); echo '
    '; $view = $_REQUEST['view']; -- cgit v1.2.3 From dd9ba38e965cfc3c06fbb80fed65556dbfbfda1c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 14 Jul 2011 11:36:48 +0300 Subject: mediamanager tabs, upload form fix --- inc/lang/en/lang.php | 3 +- inc/media.php | 101 ++++++++++++++++++++++++++------------------------- 2 files changed, 54 insertions(+), 50 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index ea6bf2646..93f0f4ce7 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -334,7 +334,8 @@ $lang['media_historytab'] = 'History'; $lang['media_thumbsview'] = 'Thumbnails'; $lang['media_listview'] = 'List'; $lang['media_sort'] = 'Sort'; -$lang['media_search'] = 'Search in the %s namespace.'; +$lang['media_upload'] = 'Upload to the %s namespace.'; +$lang['media_search'] = 'Search in the %s namespace.'; $lang['media_edit'] = 'Edit'; $lang['media_history'] = 'These are the older revisions of the file.'; $lang['media_meta_edited']= 'metadata edited'; diff --git a/inc/media.php b/inc/media.php index 341692f5f..d72b228d4 100644 --- a/inc/media.php +++ b/inc/media.php @@ -557,30 +557,30 @@ function media_tabs_files($selected=false){ global $lang; echo '
    '; - $tab = ''.$lang['mediaselect'].''; - echo $tab; - - $tab = ''.$lang['media_uploadtab'].''; - echo $tab; - $tab = ''.$lang['media_searchtab'].''; - echo $tab; + media_tab(media_managerURL(array('tab_files' => 'files')), 'files', $lang['mediaselect'], $selected); + media_tab(media_managerURL(array('tab_files' => 'upload')), 'upload', $lang['media_uploadtab'], $selected); + media_tab(media_managerURL(array('tab_files' => 'search')), 'search', $lang['media_searchtab'], $selected); echo '
    '; echo '
    '; } +/** + * Prints mediamanager tab + * + * @author Kate Arzamastseva + * @param string $link + * @param string $class + * @param string $name + * @param string $selected + */ +function media_tab($link, $class, $name, $selected=false) { + if (!empty($selected) && $selected == $class) $class .= ' selected'; + $tab = ''.$name.''; + echo $tab; +} + /** * Prints tabs for files details actions * @@ -591,26 +591,14 @@ function media_tabs_details($image, $selected=false){ global $lang; echo '
    '; - $tab = ''.$lang['media_viewtab'].''; - echo $tab; - $tab = ''.$lang['media_edittab'].''; - echo $tab; + media_tab(media_managerURL(array('tab_details' => 'view')), 'view', $lang['media_viewtab'], $selected); - $tab = ''.$lang['media_historytab'].''; - echo $tab; + list($ext, $mime) = mimetype($image); + if ($mime == 'image/jpeg') { + media_tab(media_managerURL(array('tab_details' => 'edit')), 'edit', $lang['media_edittab'], $selected); + } + media_tab(media_managerURL(array('tab_details' => 'history')), 'history', $lang['media_historytab'], $selected); echo '
    '; echo '
    '; @@ -679,10 +667,11 @@ function media_tab_upload($ns,$auth=null,$jump='') { if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); echo '
    '; - echo $lang['mediaupload']; + echo sprintf($lang['media_upload'], $ns); echo '
    '; echo '
    '; + if ($auth >= AUTH_UPLOAD) echo '
    ' . $lang['mediaupload'] . '
    '; media_uploadform($ns, $auth, true); echo '
    '; } @@ -733,8 +722,9 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { echo '
    '; echo '
    '; - media_preview($image, $auth, $rev); - media_details($image, $auth, $rev); + $meta = new JpegMeta(mediaFN($image, $rev)); + media_preview($image, $auth, $rev, $meta); + media_details($image, $auth, $rev, $meta); echo '
    '; } @@ -792,7 +782,7 @@ function media_tab_history($image, $ns, $auth=null) { * * @author Kate Arzamastseva */ -function media_preview($image, $auth, $rev=false) { +function media_preview($image, $auth, $rev=false, $meta=false) { global $lang; if (!$image) return ''; if ($auth < AUTH_READ) { @@ -801,6 +791,7 @@ function media_preview($image, $auth, $rev=false) { } $info = getimagesize(mediaFN($image, $rev)); $w = (int) $info[0]; + $h = (int) $info[1]; $more = ''; if ($rev) { @@ -809,12 +800,20 @@ function media_preview($image, $auth, $rev=false) { $t = @filemtime(mediaFN($image)); $more = "t=$t"; } + $link = ml($image,$more,true,'&'); + + $size = 500; + if($meta && ($w > $size || $h > $size)){ + $ratio = $meta->getResizeRatio($size, $size); + $w = floor($w * $ratio); + $h = floor($h * $ratio); + $more .= "&h=$h&w=$w"; + } + $src = ml($image, $more); echo '
    '; echo '

    '; - $link = ml($image,$more,true,'&'); - $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank')); $form->addElement(form_makeButton('submit','',$lang['mediaview'])); $form->printForm(); @@ -847,7 +846,7 @@ function media_preview($image, $auth, $rev=false) { * * @author Kate Arzamastseva */ -function media_details($image, $auth, $rev=false) { +function media_details($image, $auth, $rev=false, $meta=false) { global $lang, $config_cascade;; if (!$image) return ''; @@ -865,8 +864,8 @@ function media_details($image, $auth, $rev=false) { } } - $src = mediaFN($image, $rev); - $meta = new JpegMeta($src); + if (!$meta) $meta = new JpegMeta(mediaFN($image, $rev)); + echo '
    '; foreach($fields as $key => $tag){ $t = array(); @@ -937,16 +936,20 @@ function media_diff($image, $ns, $auth) { $revs = getRevisions($image, 0, 1, 8192, true); $l_rev = $revs[0]; } + + $l_meta = new JpegMeta(mediaFN($image, $l_rev)); + $r_meta = new JpegMeta(mediaFN($image, $r_rev)); + echo '
    • '; - media_preview($image, $auth, $l_rev); + media_preview($image, $auth, $l_rev, $l_meta); echo '
    • '; echo '
    • '; - media_preview($image, $auth, $r_rev); + media_preview($image, $auth, $r_rev, $r_meta); echo '
    • '; - media_details($image, $auth, $l_rev); + media_details($image, $auth, $l_rev, $l_meta); echo '
    • '; echo '
    • '; - media_details($image, $auth, $r_rev); + media_details($image, $auth, $r_rev, $r_meta); echo '
    '; } -- cgit v1.2.3 From 23786fd7ff0ff9c41ba627bc43ba6a45d3b779cc Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 14 Jul 2011 23:37:38 +0300 Subject: mediamanager icons --- inc/media.php | 58 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 18 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index d72b228d4..ebdde0ec9 100644 --- a/inc/media.php +++ b/inc/media.php @@ -718,7 +718,10 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); echo '
    '; - echo $image; + list($ext,$mime,$dl) = mimetype($image,false); + $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext); + $class = 'select mediafile mf_'.$class; + echo ''.$image.''; echo '
    '; echo '
    '; @@ -789,9 +792,8 @@ function media_preview($image, $auth, $rev=false, $meta=false) { echo '
    '.$lang['media_perm_read'].'
    '.NL; return ''; } - $info = getimagesize(mediaFN($image, $rev)); - $w = (int) $info[0]; - $h = (int) $info[1]; + + echo '
    '; $more = ''; if ($rev) { @@ -802,17 +804,22 @@ function media_preview($image, $auth, $rev=false, $meta=false) { } $link = ml($image,$more,true,'&'); - $size = 500; - if($meta && ($w > $size || $h > $size)){ - $ratio = $meta->getResizeRatio($size, $size); - $w = floor($w * $ratio); - $h = floor($h * $ratio); - $more .= "&h=$h&w=$w"; - } + if (preg_match("/\.(jpe?g|gif|png)$/", $image)) { + $info = getimagesize(mediaFN($image, $rev)); + $w = (int) $info[0]; + $h = (int) $info[1]; + + $size = 500; + if($meta && ($w > $size || $h > $size)){ + $ratio = $meta->getResizeRatio($size, $size); + $w = floor($w * $ratio); + $h = floor($h * $ratio); + $more .= "&h=$h&w=$w"; + } - $src = ml($image, $more); - echo '
    '; - echo '

    '; + $src = ml($image, $more); + echo '

    '; + } $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank')); $form->addElement(form_makeButton('submit','',$lang['mediaview'])); @@ -1118,6 +1125,19 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ echo '
    '.NL; } +function media_printicon($filename){ + list($ext,$mime,$dl) = mimetype(mediaFN($filename),false); + + if (@file_exists(DOKU_INC.'lib/images/fileicons/'.$ext.'.png')) { + $icon = DOKU_BASE.'lib/images/fileicons/'.$ext.'.png'; + } else { + $icon = DOKU_BASE.'lib/images/fileicons/file.png'; + } + + echo ''.$filename.''; + +} + /** * Formats and prints one file in the list in the thumbnails view * @@ -1132,13 +1152,15 @@ function media_printfile_thumbs($item,$auth,$jump=false){ // output echo '
  • '; + if($item['isimg']) { media_printimgdetail($item, true); + } else { echo ''; - echo ''; - echo ''; + media_managerURL(array('image' => hsc($item['id']))).'">
    '; + media_printicon($item['id']); + echo '
    '; } //echo ''; echo ''; - echo ''; + echo '
    '; echo '
    '; return 1; } -- cgit v1.2.3 From 59e81a438d23d92b656fe57878dab0e4b1560b73 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 14 Jul 2011 23:55:03 +0300 Subject: media diff event --- inc/media.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index ebdde0ec9..e0bf9bd62 100644 --- a/inc/media.php +++ b/inc/media.php @@ -722,6 +722,7 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext); $class = 'select mediafile mf_'.$class; echo ''.$image.''; + //echo ''.$image.''; echo '
    '; echo '
    '; @@ -854,7 +855,7 @@ function media_preview($image, $auth, $rev=false, $meta=false) { * @author Kate Arzamastseva */ function media_details($image, $auth, $rev=false, $meta=false) { - global $lang, $config_cascade;; + global $lang, $config_cascade; if (!$image) return ''; if ($auth < AUTH_READ) { @@ -944,6 +945,32 @@ function media_diff($image, $ns, $auth) { $l_rev = $revs[0]; } + // prepare event data + $data[0] = $image; + $data[1] = $l_rev; + $data[2] = $r_rev; + $data[3] = $ns; + $data[4] = $auth; + + // trigger event + return trigger_event('MEDIA_DIFF', $data, '_media_image_diff', true); + +} + +function _media_image_diff($data) { + if(is_array($data) && count($data)===5) { + return media_image_diff($data[0], $data[1], $data[2], $data[3], $data[4]); + } else { + return false; + } +} + +/** + * Shows difference between two revisions of image + * + * @author Kate Arzamastseva + */ +function media_image_diff($image, $l_rev, $r_rev, $ns, $auth){ $l_meta = new JpegMeta(mediaFN($image, $l_rev)); $r_meta = new JpegMeta(mediaFN($image, $r_rev)); -- cgit v1.2.3 From c439558b00bf5429e11461bc999b63a22f066ac1 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 15 Jul 2011 00:15:55 +0300 Subject: merging --- inc/media.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index e0bf9bd62..b4a0ad114 100644 --- a/inc/media.php +++ b/inc/media.php @@ -722,7 +722,6 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { $class = preg_replace('/[^_\-a-z0-9]+/i','_',$ext); $class = 'select mediafile mf_'.$class; echo ''.$image.''; - //echo ''.$image.''; echo '
    '; echo '
    '; -- cgit v1.2.3 From e136d6cc09a2c32050ecc37d7b0deebd0979c15d Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 16 Jul 2011 23:48:48 +0300 Subject: mediamanager image diff --- inc/media.php | 279 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 226 insertions(+), 53 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index 138eb26c2..5e12ac8a6 100644 --- a/inc/media.php +++ b/inc/media.php @@ -725,9 +725,15 @@ function media_tab_view($image, $ns, $auth=null, $rev=false) { echo '
    '; echo '
    '; - $meta = new JpegMeta(mediaFN($image, $rev)); - media_preview($image, $auth, $rev, $meta); - media_details($image, $auth, $rev, $meta); + if ($image && $auth >= AUTH_READ) { + $meta = new JpegMeta(mediaFN($image, $rev)); + media_preview($image, $auth, $rev, $meta); + media_preview_buttons($image, $auth, $rev); + media_details($image, $auth, $rev, $meta); + + } else { + echo '
    '.$lang['media_perm_read'].'
    '; + } echo '
    '; } @@ -787,12 +793,37 @@ function media_tab_history($image, $ns, $auth=null) { */ function media_preview($image, $auth, $rev=false, $meta=false) { global $lang; - if (!$image) return ''; - if ($auth < AUTH_READ) { - echo '
    '.$lang['media_perm_read'].'
    '.NL; - return ''; + + echo '
    '; + + $size = media_image_preview_size($image, $rev, $meta); + + if ($size) { + $more = ''; + if ($rev) { + $more = "rev=$rev"; + } else { + $t = @filemtime(mediaFN($image)); + $more = "t=$t"; + } + + $more .= '&w='.$size[0].'&h='.$size[1]; + + $src = ml($image, $more); + echo ''; } + echo '
    '; +} + +/** + * Prints mediafile action buttons + * + * @author Kate Arzamastseva + */ +function media_preview_buttons($image, $auth, $rev=false) { + global $lang; + echo '
    '; $more = ''; @@ -804,40 +835,29 @@ function media_preview($image, $auth, $rev=false, $meta=false) { } $link = ml($image,$more,true,'&'); - if (preg_match("/\.(jpe?g|gif|png)$/", $image)) { - $info = getimagesize(mediaFN($image, $rev)); - $w = (int) $info[0]; - $h = (int) $info[1]; - - $size = 500; - if($meta && ($w > $size || $h > $size)){ - $ratio = $meta->getResizeRatio($size, $size); - $w = floor($w * $ratio); - $h = floor($h * $ratio); - $more .= "&h=$h&w=$w"; - } - - $src = ml($image, $more); - echo '

    '; - } - + // view original file button $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank')); $form->addElement(form_makeButton('submit','',$lang['mediaview'])); $form->printForm(); - // delete button if($auth >= AUTH_DELETE && !$rev){ + + // delete button $form = new Doku_Form(array('id' => 'mediamanager__btn_delete', 'action'=>media_managerURL(array('delete' => $image), '&'))); $form->addElement(form_makeButton('submit','',$lang['btn_delete'])); $form->printForm(); + // upload new version button $form = new Doku_Form(array('id' => 'mediamanager__btn_update', 'action'=>media_managerURL(array('image' => $image, 'mediado' => 'update'), '&'))); $form->addElement(form_makeButton('submit','',$lang['media_update'])); $form->printForm(); } + if($auth >= AUTH_DELETE && $rev){ + + // restore button $form = new Doku_Form(array('id' => 'mediamanager__btn_restore', 'action'=>media_managerURL(array('image' => $image), '&'))); $form->addHidden('mediado','restore'); @@ -845,22 +865,19 @@ function media_preview($image, $auth, $rev=false, $meta=false) { $form->addElement(form_makeButton('submit','',$lang['media_restore'])); $form->printForm(); } + echo '
    '; } /** - * Prints mediafile tags + * Returns mediafile tags * * @author Kate Arzamastseva + * @param JpegMeta $meta + * @return array */ -function media_details($image, $auth, $rev=false, $meta=false) { - global $lang, $config_cascade; - - if (!$image) return ''; - if ($auth < AUTH_READ) { - echo '
    '.$lang['media_perm_read'].'
    '.NL; - return ''; - } +function media_file_tags($meta) { + global $config_cascade; // load the field descriptions static $fields = null; @@ -871,19 +888,39 @@ function media_details($image, $auth, $rev=false, $meta=false) { } } - if (!$meta) $meta = new JpegMeta(mediaFN($image, $rev)); + $tags = array(); - echo '
    '; foreach($fields as $key => $tag){ $t = array(); if (!empty($tag[0])) $t = array($tag[0]); if(is_array($tag[3])) $t = array_merge($t,$tag[3]); - $value = media_getTag($t, $meta, '-'); - $value = cleanText($value); - echo '
    '.$lang[$tag[1]].':
    '; - if ($tag[2] == 'date') echo dformat($value); - else echo hsc($value); - echo '
    '; + $value = media_getTag($t, $meta); + $tags[] = array('tag' => $tag, 'value' => $value); + } + + return $tags; +} + +/** + * Prints mediafile tags + * + * @author Kate Arzamastseva + */ +function media_details($image, $auth, $rev=false, $meta=false) { + global $lang; + + if (!$meta) $meta = new JpegMeta(mediaFN($image, $rev)); + $tags = media_file_tags($meta); + + echo '
    '; + foreach($tags as $tag){ + if ($tag['value']) { + $value = cleanText($tag['value']); + echo '
    '.$lang[$tag['tag'][1]].':
    '; + if ($tag['tag'][2] == 'date') echo dformat($value); + else echo hsc($value); + echo '
    '; + } } echo '
    '; } @@ -970,20 +1007,156 @@ function _media_image_diff($data) { * @author Kate Arzamastseva */ function media_image_diff($image, $l_rev, $r_rev, $ns, $auth){ - $l_meta = new JpegMeta(mediaFN($image, $l_rev)); - $r_meta = new JpegMeta(mediaFN($image, $r_rev)); + global $lang, $config_cascade; - echo '
    • '; + echo '
        '; + + echo '
      • '; media_preview($image, $auth, $l_rev, $l_meta); - echo '
    • '; - echo '
    • '; + echo '
    • '; + + echo '
    • '; media_preview($image, $auth, $r_rev, $r_meta); - echo '
  • '; - media_details($image, $auth, $l_rev, $l_meta); - echo '
  • '; - echo '
  • '; - media_details($image, $auth, $r_rev, $r_meta); - echo '
  • '; + echo ''; + + echo '
  • '; + media_preview_buttons($image, $auth, $l_rev); + echo '
  • '; + + echo '
  • '; + media_preview_buttons($image, $auth, $r_rev); + echo '
  • '; + + $l_meta = new JpegMeta(mediaFN($image, $l_rev)); + $r_meta = new JpegMeta(mediaFN($image, $r_rev)); + + $l_tags = media_file_tags($l_meta); + $r_tags = media_file_tags($r_meta); + foreach ($l_tags as $key => $l_tag) { + if ($l_tag['value'] != $r_tags[$key]['value']) { + $r_tags[$key]['class'] = 'highlighted'; + $l_tags[$key]['class'] = 'highlighted'; + } else if (!$l_tag['value'] || !$r_tags[$key]['value']) { + unset($r_tags[$key]); + unset($l_tags[$key]); + } + } + + foreach(array($l_tags,$r_tags) as $tags){ + echo '
  • '; + + echo '
    '; + foreach($tags as $tag){ + $value = cleanText($tag['value']); + if (!$value) $value = '-'; + echo '
    '.$lang[$tag['tag'][1]].':
    '; + echo '
    '; + if ($tag['tag'][2] == 'date') echo dformat($value); + else echo hsc($value); + echo '
    '; + } + echo '
    '; + + echo '
  • '; + } + + echo ''; + + media_image_diff_opacity($image, $l_rev, $r_rev, $l_meta); + media_image_diff_portions($image, $l_rev, $r_rev, $l_meta); +} + +/** + * Returns image width and height for mediamanager preview panel + * + * @author Kate Arzamastseva + * @param string $image + * @param int $rev + * @param JpegMeta $meta + * @return array + */ +function media_image_preview_size($image, $rev, $meta) { + if (!preg_match("/\.(jpe?g|gif|png)$/", $image)) return false; + + $info = getimagesize(mediaFN($image, $rev)); + $w = (int) $info[0]; + $h = (int) $info[1]; + + $size = 500; + if($meta && ($w > $size || $h > $size)){ + $ratio = $meta->getResizeRatio($size, $size); + $w = floor($w * $ratio); + $h = floor($h * $ratio); + } + return array($w, $h); +} + +/** + * Prints two images side by side + * and slider to change the opacity + * of one of the images + * + * @author Kate Arzamastseva + * @param string $image + * @param int $l_rev + * @param int $r_rev + * @param JpegMeta $meta + */ +function media_image_diff_opacity($image, $l_rev, $r_rev, $meta) { + $l_size = media_image_preview_size($image, $l_rev, $meta); + $r_size = media_image_preview_size($image, $r_rev, $meta); + + if (!$l_size || !$r_size || $l_size != $r_size || $l_size[0] < 30) return ''; + + echo '
    '; + + $l_more = 'rev='.$l_rev.'&h='.$l_size[1].'&w='.$l_size[0]; + $r_more = 'rev='.$r_rev.'&h='.$l_size[1].'&w='.$l_size[0]; + + $l_src = ml($image, $l_more); + $r_src = ml($image, $r_more); + + echo '
    '; + echo '
    '; + echo '
    '; + echo '
    '; + + echo '
    '; + echo '
    '; +} + +/** + * Prints two images side by side + * and slider to change the width + * of one of the images + * + * @author Kate Arzamastseva + * @param string $image + * @param int $l_rev + * @param int $r_rev + * @param JpegMeta $meta + */ +function media_image_diff_portions($image, $l_rev, $r_rev, $meta) { + $l_size = media_image_preview_size($image, $l_rev, $meta); + $r_size = media_image_preview_size($image, $r_rev, $meta); + + if (!$l_size || !$r_size || $l_size != $r_size || $l_size[0] < 30) return ''; + + echo '
    '; + + $l_more = 'rev='.$l_rev.'&h='.$l_size[1].'&w='.$l_size[0]; + $r_more = 'rev='.$r_rev.'&h='.$l_size[1].'&w='.$l_size[0]; + + $l_src = ml($image, $l_more); + $r_src = ml($image, $r_more); + + echo '
    '; + echo '
    '; + echo '
    '; + echo '
    '; + + echo '
    '; + echo '
    '; } /** -- cgit v1.2.3 From fa8e5c7713944541c907aea2b81c6a44382a15f0 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 17 Jul 2011 18:42:43 +0300 Subject: mediamanager html, css reworking --- inc/media.php | 208 ++++++++++++++++++++++++------------------------------- inc/template.php | 28 ++++---- 2 files changed, 105 insertions(+), 131 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index 5e12ac8a6..141ba8c2c 100644 --- a/inc/media.php +++ b/inc/media.php @@ -547,6 +547,21 @@ function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false){ if (!$fullscreenview) media_searchform($ns); } +/** + * Prints mediamanager tab + * + * @author Kate Arzamastseva + * @param string $link + * @param string $class + * @param string $name + * @param string $selected + */ +function media_tab($link, $class, $name, $selected=false) { + if (!empty($selected) && $selected == $class) $class .= ' selected'; + $tab = ''.$name.''; + echo $tab; +} + /** * Prints tabs for files list actions * @@ -566,21 +581,6 @@ function media_tabs_files($selected=false){ echo '
    '; } -/** - * Prints mediamanager tab - * - * @author Kate Arzamastseva - * @param string $link - * @param string $class - * @param string $name - * @param string $selected - */ -function media_tab($link, $class, $name, $selected=false) { - if (!empty($selected) && $selected == $class) $class .= ' selected'; - $tab = ''.$name.''; - echo $tab; -} - /** * Prints tabs for files details actions * @@ -614,18 +614,23 @@ function media_tab_files_options($ns){ echo '
    '; echo $ns; - echo '
    '; - echo ''. - $lang['media_thumbsview'].''; - echo ''.$lang['media_listview'].''; + + echo ''; - echo '
    '.$lang['media_sort']; - //select + + echo '
    '; + echo $lang['media_sort']; echo '
    '; + echo '
    '; echo '
    '; } @@ -647,9 +652,9 @@ function media_tab_files($ns,$auth=null,$jump='') { echo '
    '.$lang['media_perm_read'].'
    '.NL; }else{ if ($view == 'list') { - echo '
      '; + echo '
        '; } else { - echo '
          '; + echo '
            '; } media_filelist($ns,$auth,$jump,true); echo '
          '; @@ -698,9 +703,9 @@ function media_tab_search($ns,$auth=null) { if($do == 'searchlist'){ $view = $_REQUEST['view']; if ($view == 'list') { - echo '
            '; + echo '
              '; } else { - echo '
                '; + echo '
                  '; } media_searchlist($query,$ns,$auth,true); echo '
                '; @@ -794,7 +799,7 @@ function media_tab_history($image, $ns, $auth=null) { function media_preview($image, $auth, $rev=false, $meta=false) { global $lang; - echo '
                '; + echo '
                '; $size = media_image_preview_size($image, $rev, $meta); @@ -810,7 +815,7 @@ function media_preview($image, $auth, $rev=false, $meta=false) { $more .= '&w='.$size[0].'&h='.$size[1]; $src = ml($image, $more); - echo ''; + echo ''.$image.''; } echo '
                '; @@ -824,7 +829,7 @@ function media_preview($image, $auth, $rev=false, $meta=false) { function media_preview_buttons($image, $auth, $rev=false) { global $lang; - echo '
                '; + echo '
                '; $more = ''; if ($rev) { @@ -869,6 +874,47 @@ function media_preview_buttons($image, $auth, $rev=false) { echo '
                '; } +/** + * Returns image width and height for mediamanager preview panel + * + * @author Kate Arzamastseva + * @param string $image + * @param int $rev + * @param JpegMeta $meta + * @return array + */ +function media_image_preview_size($image, $rev, $meta) { + if (!preg_match("/\.(jpe?g|gif|png)$/", $image)) return false; + + $info = getimagesize(mediaFN($image, $rev)); + $w = (int) $info[0]; + $h = (int) $info[1]; + + $size = 500; + if($meta && ($w > $size || $h > $size)){ + $ratio = $meta->getResizeRatio($size, $size); + $w = floor($w * $ratio); + $h = floor($h * $ratio); + } + return array($w, $h); +} + +/** + * Returns the requested EXIF/IPTC tag from the image meta + * + * @author Kate Arzamastseva + * @param array $tags + * @param JpegMeta $meta + * @param string $alt + * @return string + */ +function media_getTag($tags,$meta,$alt=''){ + if($meta === false) return $alt; + $info = $meta->getField($tags); + if($info == false) return $alt; + return $info; +} + /** * Returns mediafile tags * @@ -925,22 +971,6 @@ function media_details($image, $auth, $rev=false, $meta=false) { echo '
    '; } -/** - * Returns the requested EXIF/IPTC tag from the image meta - * - * @author Kate Arzamastseva - * @param array $tags - * @param JpegMeta $meta - * @param string $alt - * @return string - */ -function media_getTag($tags,$meta,$alt=''){ - if($meta === false) return $alt; - $info = $meta->getField($tags); - if($info == false) return $alt; - return $info; -} - /** * Shows difference between two revisions of file * @@ -989,13 +1019,13 @@ function media_diff($image, $ns, $auth) { $data[4] = $auth; // trigger event - return trigger_event('MEDIA_DIFF', $data, '_media_image_diff', true); + return trigger_event('MEDIA_DIFF', $data, '_media_file_diff', true); } -function _media_image_diff($data) { +function _media_file_diff($data) { if(is_array($data) && count($data)===5) { - return media_image_diff($data[0], $data[1], $data[2], $data[3], $data[4]); + return media_file_diff($data[0], $data[1], $data[2], $data[3], $data[4]); } else { return false; } @@ -1006,10 +1036,10 @@ function _media_image_diff($data) { * * @author Kate Arzamastseva */ -function media_image_diff($image, $l_rev, $r_rev, $ns, $auth){ +function media_file_diff($image, $l_rev, $r_rev, $ns, $auth){ global $lang, $config_cascade; - echo '
      '; + echo '
        '; echo '
      • '; media_preview($image, $auth, $l_rev, $l_meta); @@ -1062,73 +1092,13 @@ function media_image_diff($image, $l_rev, $r_rev, $ns, $auth){ echo '
      '; - media_image_diff_opacity($image, $l_rev, $r_rev, $l_meta); - media_image_diff_portions($image, $l_rev, $r_rev, $l_meta); -} - -/** - * Returns image width and height for mediamanager preview panel - * - * @author Kate Arzamastseva - * @param string $image - * @param int $rev - * @param JpegMeta $meta - * @return array - */ -function media_image_preview_size($image, $rev, $meta) { - if (!preg_match("/\.(jpe?g|gif|png)$/", $image)) return false; - - $info = getimagesize(mediaFN($image, $rev)); - $w = (int) $info[0]; - $h = (int) $info[1]; - - $size = 500; - if($meta && ($w > $size || $h > $size)){ - $ratio = $meta->getResizeRatio($size, $size); - $w = floor($w * $ratio); - $h = floor($h * $ratio); - } - return array($w, $h); -} - -/** - * Prints two images side by side - * and slider to change the opacity - * of one of the images - * - * @author Kate Arzamastseva - * @param string $image - * @param int $l_rev - * @param int $r_rev - * @param JpegMeta $meta - */ -function media_image_diff_opacity($image, $l_rev, $r_rev, $meta) { - $l_size = media_image_preview_size($image, $l_rev, $meta); - $r_size = media_image_preview_size($image, $r_rev, $meta); - - if (!$l_size || !$r_size || $l_size != $r_size || $l_size[0] < 30) return ''; - - echo '
      '; - - $l_more = 'rev='.$l_rev.'&h='.$l_size[1].'&w='.$l_size[0]; - $r_more = 'rev='.$r_rev.'&h='.$l_size[1].'&w='.$l_size[0]; - - $l_src = ml($image, $l_more); - $r_src = ml($image, $r_more); - - echo '
      '; - echo '
      '; - echo '
      '; - echo '
      '; - - echo '
      '; - echo '
      '; + media_image_diff($image, $l_rev, $r_rev, $l_meta, 'opacity'); + media_image_diff($image, $l_rev, $r_rev, $l_meta, 'portions'); } /** * Prints two images side by side - * and slider to change the width - * of one of the images + * and slider * * @author Kate Arzamastseva * @param string $image @@ -1136,7 +1106,7 @@ function media_image_diff_opacity($image, $l_rev, $r_rev, $meta) { * @param int $r_rev * @param JpegMeta $meta */ -function media_image_diff_portions($image, $l_rev, $r_rev, $meta) { +function media_image_diff($image, $l_rev, $r_rev, $meta, $type) { $l_size = media_image_preview_size($image, $l_rev, $meta); $r_size = media_image_preview_size($image, $r_rev, $meta); @@ -1150,12 +1120,12 @@ function media_image_diff_portions($image, $l_rev, $r_rev, $meta) { $l_src = ml($image, $l_more); $r_src = ml($image, $r_more); - echo '
      '; - echo '
      '; + echo '
      '; + echo '
      '; echo '
      '; echo '
      '; - echo '
      '; + echo '
      '; echo '
      '; } diff --git a/inc/template.php b/inc/template.php index 81b3795ac..13cec438c 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1146,17 +1146,17 @@ function tpl_fileList(){ media_tabs_files($opened_tab); if ($opened_tab == 'files') { - echo '
      '; + echo '
      '; media_tab_files($NS,$AUTH,$JUMPTO); echo '
      '; } elseif ($opened_tab == 'upload') { - echo '
      '; + echo '
      '; media_tab_upload($NS,$AUTH,$JUMPTO); echo '
      '; } elseif ($opened_tab == 'search') { - echo '
    '; + if ($is_img && !$fromajax) echo '
    '; if ($is_img) echo '
    '; } -- cgit v1.2.3 From 50fc55fe69fc348d3679981cc088c57b35c47571 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 6 Aug 2011 17:00:19 +0300 Subject: issue #48 alternative diff views for images with different size --- inc/media.php | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index bc80f64d6..ce3f797e6 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1094,9 +1094,16 @@ function _media_file_diff($data) { */ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ global $lang, $config_cascade; - $is_img = preg_match("/\.(jpe?g|gif|png)$/", $image); + $l_meta = new JpegMeta(mediaFN($image, $l_rev)); + $r_meta = new JpegMeta(mediaFN($image, $r_rev)); + + $is_img = preg_match("/\.(jpe?g|gif|png)$/", $image); if ($is_img) { + $l_size = media_image_preview_size($image, $l_rev, $l_meta); + $r_size = media_image_preview_size($image, $r_rev, $r_meta); + $is_img = ($l_size && $r_size && ($l_size[0] >= 30 || $r_size[0] >= 30)); + $difftype = $_REQUEST['difftype']; if (!$fromajax) { @@ -1110,19 +1117,14 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ echo '
    '; } - $l_meta = new JpegMeta(mediaFN($image, $l_rev)); - $r_meta = new JpegMeta(mediaFN($image, $r_rev)); - if ($difftype == 'opacity' || $difftype == 'portions') { - media_image_diff($image, $l_rev, $r_rev, $l_meta, $difftype); + media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $difftype); if (!$fromajax) echo '
    '; return ''; } - - echo '
    '; - } + echo '
    '; echo '
      '; echo '
    • '; @@ -1141,9 +1143,6 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ media_preview_buttons($image, $auth, $r_rev); echo '
    • '; - $l_meta = new JpegMeta(mediaFN($image, $l_rev)); - $r_meta = new JpegMeta(mediaFN($image, $r_rev)); - $l_tags = media_file_tags($l_meta); $r_tags = media_file_tags($r_meta); foreach ($l_tags as $key => $l_tag) { @@ -1175,9 +1174,9 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ } echo '
    '; + echo '
    '; if ($is_img && !$fromajax) echo '
    '; - if ($is_img) echo '
    '; } /** @@ -1188,13 +1187,16 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ * @param string $image * @param int $l_rev * @param int $r_rev - * @param JpegMeta $meta + * @param array $l_size + * @param array $r_size + * @param string $type */ -function media_image_diff($image, $l_rev, $r_rev, $meta, $type) { - $l_size = media_image_preview_size($image, $l_rev, $meta); - $r_size = media_image_preview_size($image, $r_rev, $meta); - - if (!$l_size || !$r_size || $l_size != $r_size || $l_size[0] < 30) return ''; +function media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $type) { + if ($l_size != $r_size) { + if ($r_size[0] > $l_size[0]) { + $l_size = $r_size; + } + } echo '
    '; -- cgit v1.2.3 From 92c93223d0fce2c5de1f4d3d134be56d1d9f3bc0 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 7 Aug 2011 15:12:12 +0300 Subject: issue #44 new fileuploader completely replaces the old one --- inc/media.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index ce3f797e6..acffc4759 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1599,10 +1599,14 @@ function media_uploadform($ns, $auth, $fullscreen = false){ $form->addElement(form_makeCheckboxField('ow', 1, $lang['txt_overwrt'], 'dw__ow', 'check', $attrs)); $form->addElement(form_makeCloseTag('p')); } + if ($fullscreen) { + echo '
    '; return ''; } -- cgit v1.2.3 From f517998ad64483b6394211a971db2d3a660518c6 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 7 Aug 2011 22:14:10 +0300 Subject: issue #45 browser testing --- inc/media.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index acffc4759..16defc7af 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1422,9 +1422,9 @@ function media_printfile_thumbs($item,$auth,$jump=false){ } else { echo '
    '; + media_managerURL(array('image' => hsc($item['id']))).'">'; echo media_printicon($item['id']); - echo '
    '; + echo ''; } //echo ''; echo ''; - echo '
    '; + echo ''; echo '
    '; } } -- cgit v1.2.3 From 6bdff0836f4bc1eee19aa8c30d03ba4bfc876733 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 8 Aug 2011 19:37:09 +0300 Subject: issue #44 overwrite checkbox added to uploader --- inc/media.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index 16defc7af..768026b54 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1600,13 +1600,13 @@ function media_uploadform($ns, $auth, $fullscreen = false){ $form->addElement(form_makeCloseTag('p')); } if ($fullscreen) { - echo '
    '; return ''; } -- cgit v1.2.3 From 2d6cc64fdb73879f54aa25b2122f36631c654e3c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 12 Aug 2011 12:50:34 +0300 Subject: issue #44, #52 media_upload reused, error handling --- inc/media.php | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index 768026b54..abdb33bcb 100644 --- a/inc/media.php +++ b/inc/media.php @@ -242,6 +242,43 @@ function media_delete($id,$auth){ return $data['unl'] ? DOKU_MEDIA_DELETED : 0; } +/** + * Handle file uploads via XMLHttpRequest + * + * @return mixed false on error, id of the new file on success + */ +function media_upload_xhr($ns,$auth){ + $id = $_GET['qqfile']; + list($ext,$mime,$dl) = mimetype($id); + $input = fopen("php://input", "r"); + $temp = tmpfile(); + $realSize = stream_copy_to_stream($input, $temp); + fclose($input); + if ($realSize != (int)$_SERVER["CONTENT_LENGTH"]) return false; + if (!($tmp = io_mktmpdir())) return false; + $path = $tmp.'/'.$id; + $target = fopen($path, "w"); + fseek($temp, 0, SEEK_SET); + stream_copy_to_stream($temp, $target); + fclose($target); + $res = media_save( + array('name' => $path, + 'mime' => $mime, + 'ext' => $ext), + $ns.':'.$id, + (($_REQUEST['ow'] == 'true') ? true : false), + $auth, + 'copy' + ); + unlink($path); + if ($tmp) dir_delete($tmp); + if (is_array($res)) { + msg($res[0], $res[1]); + return false; + } + return $res; +} + /** * Handles media file uploads * @@ -249,13 +286,13 @@ function media_delete($id,$auth){ * @author Michael Klier * @return mixed false on error, id of the new file on success */ -function media_upload($ns,$auth){ +function media_upload($ns,$auth,$file=false){ if(!checkSecurityToken()) return false; global $lang; // get file and id $id = $_POST['mediaid']; - $file = $_FILES['upload']; + if (!$file) $file = $_FILES['upload']; if(empty($id)) $id = $file['name']; // check for errors (messages are done in lib/exe/mediamanager.php) -- cgit v1.2.3 From 44d638d049d687159666813023108e0fa9f32181 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 12 Aug 2011 14:18:03 +0300 Subject: issue #50 partly styling the new uploader --- inc/lang/en/lang.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index ba80c493c..4f5367ecf 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -353,4 +353,10 @@ $lang['js']['media_diff_both'] = 'Both images'; $lang['js']['media_diff_opacity'] = 'Changeable opacity of images'; $lang['js']['media_diff_portions'] = 'Portions of images'; +$lang['js']['media_select'] = 'Select files'; +$lang['js']['media_upload_btn'] = 'Start uploading'; +$lang['js']['media_drop'] = 'Drop files here to upload'; +$lang['js']['media_cancel'] = 'remove'; +$lang['js']['media_overwrt'] = 'Overwrite existing files'; + //Setup VIM: ex: et ts=2 : -- cgit v1.2.3 From e9eba4b18be81444014e59c83ee6c5cf004a7ad7 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 12 Aug 2011 17:04:27 +0300 Subject: issue #51 link from detail view to fullscreen manager --- inc/lang/en/lang.php | 1 + 1 file changed, 1 insertion(+) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 4f5367ecf..f06315a77 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -246,6 +246,7 @@ $lang['img_camera'] = 'Camera'; $lang['img_keywords']= 'Keywords'; $lang['img_width'] = 'Width'; $lang['img_height'] = 'Height'; +$lang['img_manager'] = 'View in media manager'; $lang['subscr_subscribe_success'] = 'Added %s to subscription list for %s'; $lang['subscr_subscribe_error'] = 'Error adding %s to subscription list for %s'; -- cgit v1.2.3 From 873cd06e1bda38e0decce16d6ec7d3bdaece612e Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 15 Aug 2011 14:22:19 +0300 Subject: issue #50 styling the new uploader --- inc/lang/en/lang.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index f06315a77..d10f523ef 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -354,7 +354,7 @@ $lang['js']['media_diff_both'] = 'Both images'; $lang['js']['media_diff_opacity'] = 'Changeable opacity of images'; $lang['js']['media_diff_portions'] = 'Portions of images'; -$lang['js']['media_select'] = 'Select files'; +$lang['js']['media_select'] = 'Select files...'; $lang['js']['media_upload_btn'] = 'Start uploading'; $lang['js']['media_drop'] = 'Drop files here to upload'; $lang['js']['media_cancel'] = 'remove'; -- cgit v1.2.3 From 5b9353fa4e818ffe50c9fbc1094b01fe30b96758 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 15 Aug 2011 16:29:14 +0300 Subject: mediamanager html bug fixes --- inc/lang/en/lang.php | 6 ++-- inc/media.php | 86 +++++++++++++++++++++++++++++----------------------- 2 files changed, 51 insertions(+), 41 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index d10f523ef..88fbadbd2 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -350,9 +350,9 @@ $lang['media_update'] = 'Upload new version'; $lang['media_restore'] = 'Restore this version'; $lang['js']['media_diff'] = 'View differences:'; -$lang['js']['media_diff_both'] = 'Both images'; -$lang['js']['media_diff_opacity'] = 'Changeable opacity of images'; -$lang['js']['media_diff_portions'] = 'Portions of images'; +$lang['js']['media_diff_both'] = 'Side by Side'; +$lang['js']['media_diff_opacity'] = 'Overlay'; +$lang['js']['media_diff_portions'] = 'Slider'; $lang['js']['media_select'] = 'Select files...'; $lang['js']['media_upload_btn'] = 'Start uploading'; diff --git a/inc/media.php b/inc/media.php index abdb33bcb..b8aa4d04e 100644 --- a/inc/media.php +++ b/inc/media.php @@ -595,9 +595,23 @@ function media_filelist($ns,$auth=null,$jump='',$fullscreenview=false,$sort=fals if(!count($data)){ echo '
    '.$lang['nothingfound'].'
    '.NL; - }else foreach($data as $item){ - if (!$fullscreenview) media_printfile($item,$auth,$jump); - else media_printfile_thumbs($item,$auth,$jump); + }else { + if ($fullscreenview) { + $view = $_REQUEST['view']; + if ($view == 'list') { + echo '
      '; + } else { + echo '
        '; + } + } + foreach($data as $item){ + if (!$fullscreenview) { + media_printfile($item,$auth,$jump); + } else { + media_printfile_thumbs($item,$auth,$jump); + } + } + if ($fullscreenview) echo '
      '; } } if (!$fullscreenview) media_searchform($ns); @@ -721,18 +735,10 @@ function media_tab_files($ns,$auth=null,$jump='') { media_tab_files_options($ns, $sort); echo '
      '; - $view = $_REQUEST['view']; - if($auth < AUTH_READ){ echo '
      '.$lang['media_perm_read'].'
      '.NL; }else{ - if ($view == 'list') { - echo '
        '; - } else { - echo '
          '; - } media_filelist($ns,$auth,$jump,true,$sort); - echo '
        '; } echo '
      '; } @@ -774,17 +780,7 @@ function media_tab_search($ns,$auth=null) { echo '
      '; media_searchform($ns, $query, true); - - if($do == 'searchlist'){ - $view = $_REQUEST['view']; - if ($view == 'list') { - echo '
        '; - } else { - echo '
          '; - } - media_searchlist($query,$ns,$auth,true); - echo '
        '; - } + if ($do == 'searchlist') media_searchlist($query,$ns,$auth,true); echo '
      '; } @@ -874,21 +870,21 @@ function media_tab_history($image, $ns, $auth=null) { function media_preview($image, $auth, $rev=false, $meta=false) { global $lang; - echo '
      '; + echo '
      '; $size = media_image_preview_size($image, $rev, $meta); if ($size) { - $more = ''; + $more = array(); if ($rev) { - $more = "rev=$rev"; + $more['rev'] = $rev; } else { $t = @filemtime(mediaFN($image)); - $more = "t=$t"; + $more['t'] = $t; } - $more .= '&w='.$size[0].'&h='.$size[1]; - + $more['w'] = $size[0]; + $more['h'] = $size[1]; $src = ml($image, $more); echo ''.$image.''; } @@ -904,7 +900,7 @@ function media_preview($image, $auth, $rev=false, $meta=false) { function media_preview_buttons($image, $auth, $rev=false) { global $lang, $conf; - echo '
      '; + echo '
      '; $more = ''; if ($rev) { @@ -1146,8 +1142,8 @@ function media_file_diff($image, $l_rev, $r_rev, $ns, $auth, $fromajax){ if (!$fromajax) { $form = new Doku_Form(array('action'=>media_managerURL(array(), '&'), 'id' => 'mediamanager__form_diffview')); - $form->addElement(''); - $form->addElement(''); + $form->addElement(''); + $form->addElement(''); $form->addHidden('mediado', 'diff'); $form->printForm(); @@ -1237,8 +1233,8 @@ function media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $type) { echo '
      '; - $l_more = 'rev='.$l_rev.'&h='.$l_size[1].'&w='.$l_size[0]; - $r_more = 'rev='.$r_rev.'&h='.$l_size[1].'&w='.$l_size[0]; + $l_more = array('rev' => $l_rev, 'h' => $l_size[1], 'w' => $l_size[0]); + $r_more = array('rev' => $r_rev, 'h' => $l_size[1], 'w' => $l_size[0]); $l_src = ml($image, $l_more); $r_src = ml($image, $r_more); @@ -1249,10 +1245,10 @@ function media_image_diff($image, $l_rev, $r_rev, $l_size, $r_size, $type) { // two image's in div's echo '
      '; echo '
      '; - echo ''; + echo ''; echo '
      '; echo '
      '; - echo ''; + echo ''; echo '
      '; echo '
      '; @@ -1329,9 +1325,20 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false){ if(!count($evdata['data'])){ echo '
      '.$lang['nothingfound'].'
      '.NL; - }else foreach($evdata['data'] as $item){ - if (!$fullscreen) media_printfile($item,$item['perm'],'',true); - else media_printfile_thumbs($item,$item['perm']); + }else { + if ($fullscreen) { + $view = $_REQUEST['view']; + if ($view == 'list') { + echo '
        '; + } else { + echo '
          '; + } + } + foreach($evdata['data'] as $item){ + if (!$fullscreen) media_printfile($item,$item['perm'],'',true); + else media_printfile_thumbs($item,$item['perm']); + } + if ($fullscreen) echo '
        '; } } @@ -1736,6 +1743,9 @@ function media_nstree($ns){ 'label' => '['.$lang['mediaroot'].']')); echo html_buildlist($data,'idx','media_nstree_item','media_nstree_li'); + echo ''; + + echo '
      '; } /** -- cgit v1.2.3 From 7e6b49bbbfd05509233484c1cddc2352e9246b94 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 15 Aug 2011 19:30:48 +0300 Subject: media revisions form less/more recent buttons fix --- inc/html.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index c58fd64ad..60189d4fe 100644 --- a/inc/html.php +++ b/inc/html.php @@ -598,12 +598,22 @@ function html_revisions($first=0, $media_id = false){ $first -= $conf['recent']; if ($first < 0) $first = 0; print ''; } if ($hasNext) { print ''; } print '
      '; -- cgit v1.2.3 From db738de5fbc2a3f983d224a151fde8dab8f87b3c Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Mon, 15 Aug 2011 21:01:17 +0300 Subject: issue #55 Search results are clickable now --- inc/media.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/media.php b/inc/media.php index b8aa4d04e..abd817767 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1336,7 +1336,7 @@ function media_searchlist($query,$ns,$auth=null,$fullscreen=false){ } foreach($evdata['data'] as $item){ if (!$fullscreen) media_printfile($item,$item['perm'],'',true); - else media_printfile_thumbs($item,$item['perm']); + else media_printfile_thumbs($item,$item['perm'],false,true); } if ($fullscreen) echo '
    '; } @@ -1451,7 +1451,7 @@ function media_printicon($filename){ * * @author Kate Arzamastseva */ -function media_printfile_thumbs($item,$auth,$jump=false){ +function media_printfile_thumbs($item,$auth,$jump=false,$display_namespace=false){ global $lang; global $conf; @@ -1466,13 +1466,19 @@ function media_printfile_thumbs($item,$auth,$jump=false){ } else { echo ''; + media_managerURL(array('image' => hsc($item['id']), 'ns' => getNS($item['id']))).'">'; echo media_printicon($item['id']); echo ''; } //echo ''; - echo ''.hsc($file).''; + if (!$display_namespace) { + $name = hsc($file); + } else { + $name = hsc($item['id']); + } + echo ''.$name.''; + if($item['isimg']){ $size = ''; $size .= (int) $item['meta']->getField('File.Width'); @@ -1525,7 +1531,7 @@ function media_printimgdetail($item, $fullscreen=false){ // output if ($fullscreen) { echo ''; + media_managerURL(array('image' => hsc($item['id']), 'ns' => getNS($item['id']))).'">'; echo ''; echo ''; } -- cgit v1.2.3 From da45d8839c94444f8e89f45ef290516542976ee8 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Thu, 18 Aug 2011 15:03:33 +0300 Subject: issue #50 styling uploader --- inc/lang/en/lang.php | 6 +++--- inc/media.php | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'inc') diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 88fbadbd2..58a7d56ed 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -129,7 +129,7 @@ $lang['js']['hidedetails'] = 'Hide Details'; $lang['mediausage'] = 'Use the following syntax to reference this file:'; $lang['mediaview'] = 'View original file'; $lang['mediaroot'] = 'root'; -$lang['mediaupload'] = 'Upload a file to the current namespace here. To create subnamespaces, prepend them to your "Upload as" filename separated by colons.'; +$lang['mediaupload'] = 'Upload a file to the current namespace here. To create subnamespaces, prepend them to your "Upload as" filename separated by colons. Files also can be selected by drag and drop.'; $lang['mediaextchange'] = 'Filextension changed from .%s to .%s!'; $lang['js']['mediatitle'] = 'Link settings'; @@ -354,8 +354,8 @@ $lang['js']['media_diff_both'] = 'Side by Side'; $lang['js']['media_diff_opacity'] = 'Overlay'; $lang['js']['media_diff_portions'] = 'Slider'; -$lang['js']['media_select'] = 'Select files...'; -$lang['js']['media_upload_btn'] = 'Start uploading'; +$lang['js']['media_select'] = 'Select files…'; +$lang['js']['media_upload_btn'] = 'Upload'; $lang['js']['media_drop'] = 'Drop files here to upload'; $lang['js']['media_cancel'] = 'remove'; $lang['js']['media_overwrt'] = 'Overwrite existing files'; diff --git a/inc/media.php b/inc/media.php index abd817767..8ef075f17 100644 --- a/inc/media.php +++ b/inc/media.php @@ -248,6 +248,8 @@ function media_delete($id,$auth){ * @return mixed false on error, id of the new file on success */ function media_upload_xhr($ns,$auth){ + if(!checkSecurityToken()) return false; + $id = $_GET['qqfile']; list($ext,$mime,$dl) = mimetype($id); $input = fopen("php://input", "r"); @@ -685,7 +687,7 @@ function media_tab_files_options($ns, $sort){ global $lang; echo '
    '; - echo $ns; + echo $ns ? $ns : '['.$lang['mediaroot'].']'; echo '
    '; @@ -753,7 +755,7 @@ function media_tab_upload($ns,$auth=null,$jump='') { if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); echo '
    '; - echo sprintf($lang['media_upload'], $ns); + echo sprintf($lang['media_upload'], $ns ? $ns : '['.$lang['mediaroot'].']'); echo '
    '; echo '
    '; @@ -775,7 +777,7 @@ function media_tab_search($ns,$auth=null) { if (!$query) $query = ''; echo '
    '; - echo sprintf($lang['media_search'], $ns); + echo sprintf($lang['media_search'], $ns ? $ns : '['.$lang['mediaroot'].']'); echo'
    '; echo '
    '; -- cgit v1.2.3 From 96a7ba82ad21ad7bd7cd5f677d85042da7733605 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 19 Aug 2011 18:48:19 +0300 Subject: issue #56 ajax deleting images --- inc/template.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/template.php b/inc/template.php index 04e3e79cc..d5320c5dd 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1172,10 +1172,10 @@ function tpl_fileList(){ * @author Kate Arzamastseva */ function tpl_fileDetails($image, $rev){ - global $AUTH, $NS, $conf; + global $AUTH, $NS, $conf, $DEL; $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions']); - if (!$image || (!file_exists(mediaFN($image)) && !$removed)) return ''; + if (!$image || (!file_exists(mediaFN($image)) && !$removed) || $DEL) return ''; if ($rev && !file_exists(mediaFN($image, $rev))) $rev = false; if (isset($NS) && getNS($image) != $NS) return ''; $do = $_REQUEST['mediado']; @@ -1209,7 +1209,7 @@ function tpl_fileDetails($image, $rev){ } elseif ($opened_tab == 'history' && $conf['mediarevisions']) { echo '
    '; - media_tab_history($image,$NS,$AUTH); + media_tab_history($image,$NS,$AUTH,$removed); echo '
    '; } } @@ -1465,6 +1465,7 @@ function tpl_media() { if (isset($JUMPTO)) $image = $JUMPTO; if (isset($REV) && !$JUMPTO) $rev = $REV; + echo '
    '; echo '
    '; echo '
    '; -- cgit v1.2.3 From d06c626c5f4a79cb833facf40bff089af2fcaa18 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Fri, 19 Aug 2011 20:49:49 +0300 Subject: html fix --- inc/html.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc') diff --git a/inc/html.php b/inc/html.php index 60189d4fe..1c38104d7 100644 --- a/inc/html.php +++ b/inc/html.php @@ -600,7 +600,7 @@ function html_revisions($first=0, $media_id = false){ print '