From 325c7e9562ac271857d7490f978e3ce3c23952d1 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Wed, 18 May 2011 14:28:13 +0300 Subject: Ukrainian language update --- lib/plugins/popularity/lang/uk/submitted.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 lib/plugins/popularity/lang/uk/submitted.txt diff --git a/lib/plugins/popularity/lang/uk/submitted.txt b/lib/plugins/popularity/lang/uk/submitted.txt new file mode 100644 index 000000000..90213858d --- /dev/null +++ b/lib/plugins/popularity/lang/uk/submitted.txt @@ -0,0 +1,2 @@ +====== Відгук популярності ====== +Дані були успішно відправлені. \ No newline at end of file -- cgit v1.2.3 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(-) 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 --- data/media_attic/_dummy | 0 data/media_meta/_dummy | 0 inc/media.php | 20 +++++++++++++------- inc/pageutils.php | 10 +++++----- 4 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 data/media_attic/_dummy create mode 100644 data/media_meta/_dummy diff --git a/data/media_attic/_dummy b/data/media_attic/_dummy new file mode 100644 index 000000000..e69de29bb diff --git a/data/media_meta/_dummy b/data/media_meta/_dummy new file mode 100644 index 000000000..e69de29bb 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 fc4aefb978d8bb0aba588ef2ae2734619ff75ee5 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 4 Jun 2011 19:16:24 +0300 Subject: fetch.php with rev parameter --- lib/exe/fetch.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 3ad4f1937..143d40f22 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -20,6 +20,10 @@ $CACHE = calc_cache($_REQUEST['cache']); $WIDTH = (int) $_REQUEST['w']; $HEIGHT = (int) $_REQUEST['h']; + $REV = (int) @$_REQUEST['rev']; + //sanitize revision + $REV = preg_replace('/[^0-9]/','',$REV); + list($EXT,$MIME,$DL) = mimetype($MEDIA,false); if($EXT === false){ $EXT = 'unknown'; @@ -28,7 +32,7 @@ } // check for permissions, preconditions and cache external files - list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE); + list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE, $REV); // prepare data for plugin events $data = array('media' => $MEDIA, @@ -147,7 +151,7 @@ function sendFile($file,$mime,$dl,$cache){ * @param $file reference to the file variable * @returns array(STATUS, STATUSMESSAGE) */ -function checkFileStatus(&$media, &$file) { +function checkFileStatus(&$media, &$file, $rev='') { global $MIME, $EXT, $CACHE; //media to local file @@ -172,7 +176,7 @@ function checkFileStatus(&$media, &$file) { if(auth_quickaclcheck(getNS($media).':X') < AUTH_READ){ return array( 403, 'Forbidden' ); } - $file = mediaFN($media); + $file = mediaFN($media, $rev); } //check file existance -- 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(-) 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(-) 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 ++- lib/tpl/default/design.css | 12 ++++++++++++ 3 files changed, 47 insertions(+), 4 deletions(-) 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? diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css index 1fdf2bfac..029a5525c 100644 --- a/lib/tpl/default/design.css +++ b/lib/tpl/default/design.css @@ -246,6 +246,18 @@ div.dokuwiki div.pagenav-next { width: 49% } +/* ----------- type of recent changes ------------- */ + +div.dokuwiki div.changestypenav { + border-bottom: 1px solid #8CACBB; + padding-bottom: 10px; + margin-bottom: 10px; +} + +div.dokuwiki div.changestypenav label { + padding-right: 10px; +} + /* --------------- Links ------------------ */ div.dokuwiki a:link, -- 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(-) 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 +++++++++- lib/exe/mediamanager.php | 14 +- lib/tpl/default/style.ini | 1 + 5 files changed, 470 insertions(+), 37 deletions(-) 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 : diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 02fde5a8d..d4ebc2d38 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -76,7 +76,11 @@ } // handle meta saving - if($IMG && $_REQUEST['do']['save']){ + if($IMG && @array_key_exists('save', $_REQUEST['do'])){ + $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); + } + + if($IMG && @array_key_exists('save', $_REQUEST['mediado'])){ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } @@ -102,9 +106,11 @@ msg(sprintf($lang['deletefail'],noNS($DEL)),-1); } } - // finished - start output - header('Content-Type: text/html; charset=utf-8'); - include(template('mediamanager.php')); + + if (!($_REQUEST['do'] == 'media')) { + header('Content-Type: text/html; charset=utf-8'); + include(template('mediamanager.php')); + } /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ diff --git a/lib/tpl/default/style.ini b/lib/tpl/default/style.ini index c5b2c31a5..bc28d1bbc 100644 --- a/lib/tpl/default/style.ini +++ b/lib/tpl/default/style.ini @@ -15,6 +15,7 @@ _mediaoptions.css = screen _admin.css = screen _linkwiz.css = screen _subscription.css = screen +mediamanager.css = screen rtl.css = rtl print.css = print -- 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(-) 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 +- lib/tpl/default/mediamanager.css | 155 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 231 insertions(+), 44 deletions(-) create mode 100644 lib/tpl/default/mediamanager.css 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); diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index 2001bc5f9..bf4513f0c 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -152,4 +152,11 @@ .mediamanager-table tr:hover { background-color: #DEE7EC; -} \ No newline at end of file +} + +form.meta textarea.edit { + height: 8em; + width: 95%; + min-width: 95%; + max-width: 95%; +} -- 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 ++ lib/tpl/default/main.php | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) 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; diff --git a/lib/tpl/default/main.php b/lib/tpl/default/main.php index 94c2322aa..698793ecd 100644 --- a/lib/tpl/default/main.php +++ b/lib/tpl/default/main.php @@ -117,6 +117,7 @@ if (!defined('DOKU_INC')) die();
+ -- 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(-) 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 +- lib/images/icon-list.png | Bin 0 -> 3342 bytes lib/images/icon-sort.png | Bin 0 -> 316 bytes lib/images/icon-thumb.png | Bin 0 -> 969 bytes lib/tpl/default/design.css | 2 +- lib/tpl/default/mediamanager.css | 110 ++++++++++++++++++++++++--------------- 7 files changed, 91 insertions(+), 68 deletions(-) create mode 100644 lib/images/icon-list.png create mode 100644 lib/images/icon-sort.png create mode 100644 lib/images/icon-thumb.png 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 ''; } diff --git a/lib/images/icon-list.png b/lib/images/icon-list.png new file mode 100644 index 000000000..ecfeed92d Binary files /dev/null and b/lib/images/icon-list.png differ diff --git a/lib/images/icon-sort.png b/lib/images/icon-sort.png new file mode 100644 index 000000000..c6403dd3c Binary files /dev/null and b/lib/images/icon-sort.png differ diff --git a/lib/images/icon-thumb.png b/lib/images/icon-thumb.png new file mode 100644 index 000000000..ccc7a101d Binary files /dev/null and b/lib/images/icon-thumb.png differ diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css index 029a5525c..1dee4dc69 100644 --- a/lib/tpl/default/design.css +++ b/lib/tpl/default/design.css @@ -249,7 +249,7 @@ div.dokuwiki div.pagenav-next { /* ----------- type of recent changes ------------- */ div.dokuwiki div.changestypenav { - border-bottom: 1px solid #8CACBB; + border-bottom: 1px solid __border__; padding-bottom: 10px; margin-bottom: 10px; } diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index bf4513f0c..25816e273 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -1,18 +1,3 @@ -.float-image { - float: left; - margin-right: 10px; - margin-bottom: 10px; - width: 100px; - height: 180px; - background-color: #DEE7EC; - padding: 10px; - text-align: center; -} - -.float-image:hover { - background-color: #dadada; -} - /* --- Tree formatting --- */ #media-menu img { @@ -55,35 +40,36 @@ overflow-x: hidden; padding: 0; margin: 0; + text-align: left; } .background-container { - background-color: #DEE7EC; + background-color: __background_alt__; margin-bottom: 10px; padding: 10px; text-align: left; } .mediamanager-link-thumbnails { - background: url('icon-thumb.png') 0 -4px no-repeat; + background: url('/lib/images/icon-thumb.png') 0 -4px no-repeat; padding-left: 30px; display: block; float: left; - /*width: 0;*/ - /*overflow: hidden;*/ + width: 0; + overflow: hidden; } .mediamanager-link-list { - background: url('icon-list.png') 0 -4px no-repeat; + background: url('/lib/images/icon-list.png') 0 -4px no-repeat; padding-left: 30px; display: block; float: left; - /*width: 0;*/ - /*overflow: hidden;*/ + width: 0; + overflow: hidden; } .mediamanager-block-sort { - background: url('icon-sort.png') 0 -4px no-repeat; + background: url('/lib/images/icon-sort.png') 0 -4px no-repeat; padding-left: 30px; display: block; float: right; @@ -95,22 +81,6 @@ margin-right: 10px; } -.mediamanager-clear { - clear: both; - line-height: 0; - font-size: 0; -} - -.mediamanager-link-upload { - background: url('icon-upload.png') 0 -4px no-repeat; - padding-left: 30px; -} - -.mediamanager-link-search { - background: url('icon-search.png') 0 -4px no-repeat; - padding-left: 30px; -} - .mediamanager-tabs a { font-weight: bold; display: block; @@ -130,11 +100,11 @@ } .mediamanager-tabs .selected { - background-color: #DEE7EC; + background-color: __background_alt__; } .mediamanager-tabs a:hover { - background-color: #DEE7EC; + background-color: __background_alt__; opacity: 0.5; } @@ -143,7 +113,7 @@ } .mediamanager-table tr:nth-child(2n+1){ - background-color: #f5f5f5; + background-color: __background_neu__; } .mediamanager-table { @@ -151,7 +121,7 @@ } .mediamanager-table tr:hover { - background-color: #DEE7EC; + background-color: __background_alt__; } form.meta textarea.edit { @@ -160,3 +130,57 @@ form.meta textarea.edit { min-width: 95%; max-width: 95%; } + +.mediamanager-file-list { + padding: 0; + margin: 0 !important; +} + +.mediamanager-thumbs li { + width: 100px; + min-height: 130px; + display: inline-block; + margin: 0; + margin-right: 10px; + margin-bottom: 10px; + background-color: __background_alt__; + padding: 10px; + vertical-align: top; + display: -moz-inline-stack; + text-align: center; +} + +.mediamanager-thumbs li .info { + display: block; +} + +.mediamanager-list li { + display: block; + margin-bottom: 3px; +} + +.mediamanager-list li:nth-child(2n+1) { + background-color: __background_neu__; +} + +.mediamanager-list li .image { + width: 50px; + height: 50px; + overflow: hidden; + float: left; +} + +.mediamanager-list li .image img { + width: 100%; +} + +.mediamanager-list li .info { + overflow: hidden; + float: left; + margin-left: 5px; + width: 20%; +} + +.mediamanager-file-list li:hover { + background-color: #dadada; +} -- 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 +++++-- lib/images/icon-file.png | Bin 0 -> 3363 bytes lib/tpl/default/mediamanager.css | 79 +++++++++++++++++++++++++++++++++++---- 4 files changed, 107 insertions(+), 23 deletions(-) create mode 100644 lib/images/icon-file.png 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 '
    '; diff --git a/lib/images/icon-file.png b/lib/images/icon-file.png new file mode 100644 index 000000000..d350c8c31 Binary files /dev/null and b/lib/images/icon-file.png differ diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index 25816e273..e7c78dbcf 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -24,6 +24,11 @@ overflow-y: auto; } +.mediamanager .clearer { + font-size: 0; + line-height: 0; +} + .mediamanager .mediamanager-slider { width: auto; } @@ -51,7 +56,7 @@ } .mediamanager-link-thumbnails { - background: url('/lib/images/icon-thumb.png') 0 -4px no-repeat; + background: url('../../images/icon-thumb.png') 0 -4px no-repeat; padding-left: 30px; display: block; float: left; @@ -60,7 +65,7 @@ } .mediamanager-link-list { - background: url('/lib/images/icon-list.png') 0 -4px no-repeat; + background: url('../../images/icon-list.png') 0 -4px no-repeat; padding-left: 30px; display: block; float: left; @@ -69,7 +74,7 @@ } .mediamanager-block-sort { - background: url('/lib/images/icon-sort.png') 0 -4px no-repeat; + background: url('../../images/icon-sort.png') 0 -4px no-repeat; padding-left: 30px; display: block; float: right; @@ -148,14 +153,44 @@ form.meta textarea.edit { vertical-align: top; display: -moz-inline-stack; text-align: center; + zoom: 1; + *display: inline; + _height: 130px; + position: relative; +} + +.mediamanager-thumbs li .image { + width: 100%; + height: 90px; + display: block; + overflow: hidden; } .mediamanager-thumbs li .info { display: block; + overflow: hidden; +} + +.mediamanager-thumbs li input[type=checkbox] { + /*position: absolute; + left: 100%; + top: 100%; + margin-left: -20px; + margin-top: -20px;*/ + display: none; +} + +.mediamanager-thumbs li:hover input[type=checkbox], +.mediamanager-thumbs li input[type=checkbox]:checked { + display: inline; } .mediamanager-list li { + list-style: none; display: block; + position: relative; + max-height: 50px; + margin: 0; margin-bottom: 3px; } @@ -164,10 +199,11 @@ form.meta textarea.edit { } .mediamanager-list li .image { - width: 50px; - height: 50px; + width: 10%; + display: block; overflow: hidden; float: left; + height: 40px; } .mediamanager-list li .image img { @@ -177,10 +213,39 @@ form.meta textarea.edit { .mediamanager-list li .info { overflow: hidden; float: left; - margin-left: 5px; - width: 20%; + width: 19%; + margin-left: 1%; +} + +.mediamanager-list li input[type=checkbox] { + position: absolute; + left: 100%; + margin-left: -20px; + margin-top: 3px; + display: none; +} + +.mediamanager-list li:hover input[type=checkbox], +.mediamanager-list li input[type=checkbox]:checked { + display: block; } .mediamanager-file-list li:hover { background-color: #dadada; } + +.mediamanager-table-50 { + padding: 0; + margin: 0 !important; +} + +.mediamanager-table-50 li { + width: 48%; + display: inline-block; + margin: 0; + margin-bottom: 10px; + padding: 2px; + vertical-align: top; + zoom: 1; + *display: inline; +} \ No newline at end of file -- 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(-) 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 --- conf/mediameta.php | 22 ++++++++++++++++++++ inc/media.php | 51 +++++++++++++++++++++++----------------------- lib/tpl/default/detail.php | 46 ++++++++++++++++++++--------------------- 3 files changed, 70 insertions(+), 49 deletions(-) diff --git a/conf/mediameta.php b/conf/mediameta.php index ba7117643..8ad148aec 100644 --- a/conf/mediameta.php +++ b/conf/mediameta.php @@ -55,3 +55,25 @@ $fields = array( array('Exif.Category')), ); + +/** + * This configures which meta data will be shown in details view + * of the media manager. Each field of the array is an array with the + * following contents: + * fieldname - Where data will be saved (EXIF or IPTC fields) + * label - key to lookup in the $lang var, if not found printed as is + * fieldtype - 'text' or 'date' + */ +$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') +); 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; diff --git a/lib/tpl/default/detail.php b/lib/tpl/default/detail.php index 4f42b116e..f61ede043 100644 --- a/lib/tpl/default/detail.php +++ b/lib/tpl/default/detail.php @@ -52,30 +52,28 @@ if (!defined('DOKU_INC')) die();
    '.$lang['img_date'].':
    '.dformat($t).'
    '; - - $t = tpl_img_getTag('File.Name'); - if($t) print '
    '.$lang['img_fname'].':
    '.hsc($t).'
    '; - - $t = tpl_img_getTag(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit')); - if($t) print '
    '.$lang['img_artist'].':
    '.hsc($t).'
    '; - - $t = tpl_img_getTag(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright')); - if($t) print '
    '.$lang['img_copyr'].':
    '.hsc($t).'
    '; - - $t = tpl_img_getTag('File.Format'); - if($t) print '
    '.$lang['img_format'].':
    '.hsc($t).'
    '; - - $t = tpl_img_getTag('File.NiceSize'); - if($t) print '
    '.$lang['img_fsize'].':
    '.hsc($t).'
    '; - - $t = tpl_img_getTag('Simple.Camera'); - if($t) print '
    '.$lang['img_camera'].':
    '.hsc($t).'
    '; - - $t = tpl_img_getTag(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject')); - if($t) print '
    '.$lang['img_keywords'].':
    '.hsc($t).'
    '; - + 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); + } + } + } + } + foreach($tags as $key => $tag){ + $t = $tag[0]; + if (!is_array($t)) $t = array($tag[0]); + $value = tpl_img_getTag($t); + if ($value) { + echo '
    '.$lang[$tag[1]].':
    '; + if ($tag[2] == 'text') echo hsc($value); + if ($tag[2] == 'date') echo dformat($value); + echo '
    '; + } + } ?>
    -- 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 ++- lib/exe/mediamanager.php | 4 ++-- 4 files changed, 29 insertions(+), 7 deletions(-) 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 '
    '; diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index d4ebc2d38..24dd5f911 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -35,7 +35,7 @@ $AUTH = auth_quickaclcheck("$NS:*"); // do not display the manager if user does not have read access - if($AUTH < AUTH_READ) { + if($AUTH < AUTH_READ && !$fullscreen) { header('HTTP/1.0 403 Forbidden'); die($lang['accessdenied']); } @@ -108,7 +108,7 @@ } // finished - start output - if (!($_REQUEST['do'] == 'media')) { + if (!$fullscreen) { header('Content-Type: text/html; charset=utf-8'); include(template('mediamanager.php')); } -- 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 +++------- lib/tpl/default/mediamanager.css | 4 ++++ 4 files changed, 34 insertions(+), 18 deletions(-) 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); } diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index e7c78dbcf..7a85f3c8b 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -248,4 +248,8 @@ form.meta textarea.edit { vertical-align: top; zoom: 1; *display: inline; +} + +.mediamanager-preview { + margin-bottom: 5px; } \ No newline at end of file -- 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 ++++++++++--------- lib/tpl/default/mediamanager.css | 48 +++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 31 deletions(-) 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; } diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index 7a85f3c8b..cceecf7fe 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -24,11 +24,6 @@ overflow-y: auto; } -.mediamanager .clearer { - font-size: 0; - line-height: 0; -} - .mediamanager .mediamanager-slider { width: auto; } @@ -154,10 +149,15 @@ form.meta textarea.edit { display: -moz-inline-stack; text-align: center; zoom: 1; - *display: inline; - _height: 130px; position: relative; } +* html .mediamanager-thumbs li { + display: inline; +} +*+html .mediamanager-thumbs li { + display: inline; + _height: 130px; +} .mediamanager-thumbs li .image { width: 100%; @@ -166,23 +166,23 @@ form.meta textarea.edit { overflow: hidden; } -.mediamanager-thumbs li .info { +.mediamanager-thumbs li .name, +.mediamanager-thumbs li .size, +.mediamanager-thumbs li .filesize, +.mediamanager-thumbs li .date { display: block; overflow: hidden; } .mediamanager-thumbs li input[type=checkbox] { - /*position: absolute; - left: 100%; - top: 100%; - margin-left: -20px; - margin-top: -20px;*/ display: none; + float: left; + margin: 3px; } .mediamanager-thumbs li:hover input[type=checkbox], .mediamanager-thumbs li input[type=checkbox]:checked { - display: inline; + display: block; } .mediamanager-list li { @@ -210,19 +210,25 @@ form.meta textarea.edit { width: 100%; } -.mediamanager-list li .info { +.mediamanager-list li .name, +.mediamanager-list li .size, +.mediamanager-list li .filesize +.mediamanager-list li .date { overflow: hidden; float: left; width: 19%; margin-left: 1%; } +.mediamanager-list li .date, +.mediamanager-thumbs li .date { + font-style: italic; +} + .mediamanager-list li input[type=checkbox] { - position: absolute; - left: 100%; - margin-left: -20px; - margin-top: 3px; display: none; + float: left; + margin: 3px; } .mediamanager-list li:hover input[type=checkbox], @@ -247,7 +253,9 @@ form.meta textarea.edit { padding: 2px; vertical-align: top; zoom: 1; - *display: inline; +} +* html .mediamanager-table-50 li { + display: inline; } .mediamanager-preview { -- 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 --- conf/mediameta.php | 66 +++++++++++++++++++++++++++------------------- inc/media.php | 35 ++++++++++-------------- lib/tpl/default/detail.php | 23 +++++++--------- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/conf/mediameta.php b/conf/mediameta.php index 8ad148aec..0428a4b88 100644 --- a/conf/mediameta.php +++ b/conf/mediameta.php @@ -29,51 +29,63 @@ $fields = array( 'img_title', 'text'), - 20 => array('Iptc.Caption', + 20 => array('', + 'img_date', + 'date', + array('Date.EarliestTime')), + + 30 => array('', + 'img_fname', + 'text', + array('File.Name')), + + 40 => array('Iptc.Caption', 'img_caption', 'textarea', array('Exif.UserComment', 'Exif.TIFFImageDescription', 'Exif.TIFFUserComment')), - 30 => array('Iptc.Byline', + 50 => array('Iptc.Byline', 'img_artist', 'text', array('Exif.TIFFArtist', 'Exif.Artist', 'Iptc.Credit')), - 40 => array('Iptc.CopyrightNotice', + 60 => array('Iptc.CopyrightNotice', 'img_copyr', 'text', array('Exif.TIFFCopyright', 'Exif.Copyright')), - 50 => array('Iptc.Keywords', - 'img_keywords', + 70 => array('', + 'img_format', 'text', - array('Exif.Category')), -); + array('File.Format')), + 80 => array('', + 'img_fsize', + 'text', + array('File.NiceSize')), -/** - * This configures which meta data will be shown in details view - * of the media manager. Each field of the array is an array with the - * following contents: - * fieldname - Where data will be saved (EXIF or IPTC fields) - * label - key to lookup in the $lang var, if not found printed as is - * fieldtype - 'text' or 'date' - */ -$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') + 90 => array('', + 'img_width', + 'text', + array('File.Width')), + + 100 => array('', + 'img_height', + 'text', + array('File.Height')), + + 110 => array('', + 'img_camera', + 'text', + array('Simple.Camera')), + + 120 => array('Iptc.Keywords', + 'img_keywords', + 'text', + array('Exif.Category')), ); 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 '
    '; diff --git a/lib/tpl/default/detail.php b/lib/tpl/default/detail.php index f61ede043..f7bb37a25 100644 --- a/lib/tpl/default/detail.php +++ b/lib/tpl/default/detail.php @@ -52,25 +52,20 @@ if (!defined('DOKU_INC')) die();
    $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 = tpl_img_getTag($t); if ($value) { echo '
    '.$lang[$tag[1]].':
    '; - if ($tag[2] == 'text') echo hsc($value); if ($tag[2] == 'date') echo dformat($value); + else echo hsc($value); 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(-) 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 ++++++---- lib/exe/mediamanager.php | 6 ++++++ 4 files changed, 55 insertions(+), 9 deletions(-) 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 '
    '; diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 24dd5f911..46257a9a7 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -84,6 +84,12 @@ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } + if ($_REQUEST['rev']) $REV = (int) $_REQUEST['rev']; + + if($_REQUEST['mediado'] == 'restore'){ + $JUMPTO = media_restore($_REQUEST['image'], $REV, $AUTH); + } + // handle deletion if($DEL) { $res = 0; -- 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 +++++++++++++++++------- lib/exe/ajax.php | 25 ++++++++++- lib/scripts/media.js | 90 +++++++++++++++++++++++++++++++++++++++- lib/tpl/default/mediamanager.css | 23 +--------- 5 files changed, 181 insertions(+), 76 deletions(-) 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 '
    '; diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 1056a05f8..16efd9ac7 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -210,7 +210,30 @@ function ajax_medialist(){ global $NS; $NS = $_POST['ns']; - tpl_mediaContent(true); + if ($_POST['do'] == 'media') { + tpl_fileList(true); + } else { + tpl_mediaContent(true); + } +} + +/** + * Return the content of the right column + * (image details) for the Mediamanager + * + * @author Kate Arzamastseva + */ +function ajax_mediadetails(){ + global $conf; + global $NS; + + $NS = $_POST['ns']; + $image = $_POST['image']; + if (isset($_POST['full'])) { + tpl_fileDetails($image, false); + } else { + tpl_fileDetails($image, false, true); + } } /** diff --git a/lib/scripts/media.js b/lib/scripts/media.js index ebbee5a78..e03d1cf7b 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -328,7 +328,17 @@ jQuery('div.success, div.info, div.error, div.notify').remove(); - content = $('#media__content'); + if (document.getElementById('media__content')) { + content = $('#media__content'); + } else { + content = $('#mediamanager__files'); + if (link.hasClass('idx_dir')) { + change_tab($('.files'), '#mediamanager__tabs_files'); + $('#mediamanager__layout_detail').empty(); + } else { + change_tab(link, '#mediamanager__tabs_files'); + } + } content.html('...'); // fetch the subtree @@ -345,6 +355,77 @@ }; + /** + * Changes selected tab + * + * @author Kate Arzamastseva + */ + change_tab = function (tab, tab_menu_id) { + $(tab_menu_id + ' a').each(function (i) { + $(this).removeClass('selected'); + }); + tab.addClass('selected'); + }; + + /** + * Changes view of media files list + * + * @author Kate Arzamastseva + */ + list_view = function (event) { + var link, content; + link = $(this); + + event.preventDefault(); + + content = $('#mediamanager__file_list'); + if (link.hasClass('mediamanager-link-thumbnails')) { + content.removeClass('mediamanager-list'); + content.addClass('mediamanager-thumbs'); + } else if (link.hasClass('mediamanager-link-list')) { + content.removeClass('mediamanager-thumbs'); + content.addClass('mediamanager-list'); + } + }; + + /** + * Lists the content of the right column (image details) using AJAX + * + * @author Kate Arzamastseva + */ + details = function (event) { + var link, content, call, full; + link = $(this); + + event.preventDefault(); + + jQuery('div.success, div.info, div.error, div.notify').remove(); + + full=''; + if (document.getElementById('mediamanager__details')) { + content = $('#mediamanager__details'); + } else { + content = $('#mediamanager__layout_detail'); + full = '&full=true'; + } + + if (link.hasClass('name')) { + change_tab($('.view'), '#mediamanager__tabs_details'); + } else { + change_tab(link, '#mediamanager__tabs_details'); + } + content.html('...'); + + $.post( + DOKU_BASE + 'lib/exe/ajax.php', + link[0].search.substr(1)+'&call=mediadetails'+full, + function (data) { + content.html(data); + }, + 'html' + ); + }; + prepare_content = function (content) { // hide syntax example content.find('div.example:visible').hide(); @@ -748,5 +829,12 @@ $('#media__tree').delegate('img', 'click', toggle) .delegate('a', 'click', list); + + $('#mediamanager__tabs_files').delegate('a', 'click', list); + + $('#mediamanager__files').delegate('#mediamanager__tabs_list a', 'click', list_view) + .delegate('#mediamanager__file_list a', 'click', details); + + $('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', details); }); }(jQuery)); diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index cceecf7fe..88e00d8fc 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -1,24 +1,3 @@ -/* --- Tree formatting --- */ - -#media-menu img { - float: left; - padding: 0.5em 0.3em 0 0; -} - -#media-menu ul { - list-style-type: none; - list-style-image: none; - margin-left: 1.5em; -} - -#media-menu li { - clear: left; - list-style-type: none; - list-style-image: none; -} - -/* -------------- */ - .mediamanager { width: 100%; overflow-y: auto; @@ -212,7 +191,7 @@ form.meta textarea.edit { .mediamanager-list li .name, .mediamanager-list li .size, -.mediamanager-list li .filesize +.mediamanager-list li .filesize, .mediamanager-list li .date { overflow: hidden; float: left; -- 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 ++++++++++++------------- lib/exe/ajax.php | 8 ++----- lib/scripts/media.js | 68 ++++++++++++++++++++++++++-------------------------- 4 files changed, 54 insertions(+), 58 deletions(-) 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 '
    '; } } diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 16efd9ac7..8ff0f8eda 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -211,7 +211,7 @@ function ajax_medialist(){ $NS = $_POST['ns']; if ($_POST['do'] == 'media') { - tpl_fileList(true); + tpl_fileList(); } else { tpl_mediaContent(true); } @@ -229,11 +229,7 @@ function ajax_mediadetails(){ $NS = $_POST['ns']; $image = $_POST['image']; - if (isset($_POST['full'])) { - tpl_fileDetails($image, false); - } else { - tpl_fileDetails($image, false, true); - } + tpl_fileDetails($image, false); } /** diff --git a/lib/scripts/media.js b/lib/scripts/media.js index e03d1cf7b..a7574b804 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -11,7 +11,7 @@ * @author Pierre Spring */ (function ($) { - var toggle, list, prepare_content, insert, confirmattach, attachoptions, initpopup, updatehide, setalign, setsize, inSet, outSet, media_manager, hasFlash; + var toggle, list, prepare_content, insert, confirmattach, attachoptions, initpopup, updatehide, setalign, setsize, inSet, outSet, media_manager, hasFlash, form_params, list_view, details; var media_manager = { keepopen: false, @@ -321,7 +321,7 @@ * @author Pierre Spring */ list = function (event) { - var link, content; + var link, content, params; link = $(this); event.preventDefault(); @@ -329,22 +329,33 @@ jQuery('div.success, div.info, div.error, div.notify').remove(); if (document.getElementById('media__content')) { + //popup content = $('#media__content'); + } else { - content = $('#mediamanager__files'); + //fullscreen media manager + content = $('#mediamanager__layout_list'); + if (link.hasClass('idx_dir')) { - change_tab($('.files'), '#mediamanager__tabs_files'); + //changing namespace $('#mediamanager__layout_detail').empty(); - } else { - change_tab(link, '#mediamanager__tabs_files'); } } - content.html('...'); + + params = ''; + + if (link[0].search) { + params = link[0].search.substr(1)+'&call=medialist'; + } else if (link[0].action) { + params = form_params(link)+'&call=medialist'; + } + + $('.scroll-container', content).html('...'); // fetch the subtree $.post( DOKU_BASE + 'lib/exe/ajax.php', - link[0].search.substr(1)+'&call=medialist', + params, function (data) { content.html(data); prepare_content(content); @@ -356,15 +367,16 @@ }; /** - * Changes selected tab + * Returns form parameters * * @author Kate Arzamastseva */ - change_tab = function (tab, tab_menu_id) { - $(tab_menu_id + ' a').each(function (i) { - $(this).removeClass('selected'); - }); - tab.addClass('selected'); + form_params = function (form) { + var elements = form.serialize(); + var action = ''; + var i = form[0].action.indexOf('?'); + if (i >= 0) action = form[0].action.substr(i+1); + return elements+'&'+action; }; /** @@ -394,31 +406,19 @@ * @author Kate Arzamastseva */ details = function (event) { - var link, content, call, full; + var link, content; link = $(this); event.preventDefault(); jQuery('div.success, div.info, div.error, div.notify').remove(); - full=''; - if (document.getElementById('mediamanager__details')) { - content = $('#mediamanager__details'); - } else { - content = $('#mediamanager__layout_detail'); - full = '&full=true'; - } - - if (link.hasClass('name')) { - change_tab($('.view'), '#mediamanager__tabs_details'); - } else { - change_tab(link, '#mediamanager__tabs_details'); - } - content.html('...'); + content = $('#mediamanager__layout_detail'); + $('.scroll-container', content).html('...'); $.post( DOKU_BASE + 'lib/exe/ajax.php', - link[0].search.substr(1)+'&call=mediadetails'+full, + link[0].search.substr(1)+'&call=mediadetails', function (data) { content.html(data); }, @@ -830,11 +830,11 @@ $('#media__tree').delegate('img', 'click', toggle) .delegate('a', 'click', list); - $('#mediamanager__tabs_files').delegate('a', 'click', list); - - $('#mediamanager__files').delegate('#mediamanager__tabs_list a', 'click', list_view) + $('#mediamanager__layout_list').delegate('#mediamanager__tabs_files a', 'click', list) + .delegate('#mediamanager__tabs_list a', 'click', list_view) .delegate('#mediamanager__file_list a', 'click', details); - $('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', details); + $('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', details) + .delegate('#mediamanager__btn_update', 'submit', list); }); }(jQuery)); -- 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 ++++++++++++------ lib/exe/ajax.php | 15 ++++++++----- lib/exe/mediamanager.php | 4 ++-- lib/scripts/media.js | 55 +++++++++++++++++++++++++++++++++--------------- 5 files changed, 68 insertions(+), 32 deletions(-) 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'])); diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 8ff0f8eda..59953ddc3 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -224,12 +224,17 @@ function ajax_medialist(){ * @author Kate Arzamastseva */ function ajax_mediadetails(){ - global $conf; - global $NS; + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen; + $fullscreen = true; + require_once(DOKU_INC.'lib/exe/mediamanager.php'); - $NS = $_POST['ns']; - $image = $_POST['image']; - tpl_fileDetails($image, false); + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + if (isset($IMG)) $image = $IMG; + if (isset($JUMPTO)) $image = $JUMPTO; + if (isset($REV) && !$JUMPTO) $rev = $REV; + + html_msgarea(); + tpl_fileDetails($image, $rev); } /** diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 46257a9a7..77eb2facb 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -80,7 +80,7 @@ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } - if($IMG && @array_key_exists('save', $_REQUEST['mediado'])){ + if($IMG && $_REQUEST['mediado'] == 'save') { $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } @@ -98,7 +98,7 @@ } if ($res & DOKU_MEDIA_DELETED) { $msg = sprintf($lang['deletesucc'], noNS($DEL)); - if ($res & DOKU_MEDIA_EMPTY_NS) { + if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) { // current namespace was removed. redirecting to root ns passing msg along send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='. rawurlencode($msg).'&edid='.$_REQUEST['edid']); diff --git a/lib/scripts/media.js b/lib/scripts/media.js index a7574b804..245519cbc 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -11,7 +11,7 @@ * @author Pierre Spring */ (function ($) { - var toggle, list, prepare_content, insert, confirmattach, attachoptions, initpopup, updatehide, setalign, setsize, inSet, outSet, media_manager, hasFlash, form_params, list_view, details; + var toggle, list, prepare_content, insert, confirmattach, attachoptions, initpopup, updatehide, setalign, setsize, inSet, outSet, media_manager, hasFlash, form_params, list_view, details, update_content; var media_manager = { keepopen: false, @@ -331,6 +331,7 @@ if (document.getElementById('media__content')) { //popup content = $('#media__content'); + content.html('...'); } else { //fullscreen media manager @@ -340,6 +341,8 @@ //changing namespace $('#mediamanager__layout_detail').empty(); } + + $('.scroll-container', content).html('...'); } params = ''; @@ -350,19 +353,8 @@ params = form_params(link)+'&call=medialist'; } - $('.scroll-container', content).html('...'); - // fetch the subtree - $.post( - DOKU_BASE + 'lib/exe/ajax.php', - params, - function (data) { - content.html(data); - prepare_content(content); - updatehide(); - }, - 'html' - ); + update_content(content, params); }; @@ -406,7 +398,7 @@ * @author Kate Arzamastseva */ details = function (event) { - var link, content; + var link, content, params, update_list; link = $(this); event.preventDefault(); @@ -416,9 +408,32 @@ content = $('#mediamanager__layout_detail'); $('.scroll-container', content).html('...'); + params = ''; + + if (link[0].search) { + params = link[0].search.substr(1)+'&call=mediadetails'; + } else { + params = form_params(link)+'&call=mediadetails'; + } + + update_content(content, params); + + update_list = (link[0].id == 'mediamanager__btn_delete' || link[0].id == 'mediamanager__btn_restore'); + if (update_list) { + var link1, content1, params1; + link1 = $('a.files'); + params1 = link1[0].search.substr(1)+'&call=medialist'; + content1 = $('#mediamanager__layout_list'); + $('.scroll-container', content1).html('...'); + + update_content(content1, params1); + } + }; + + update_content = function (content, params) { $.post( DOKU_BASE + 'lib/exe/ajax.php', - link[0].search.substr(1)+'&call=mediadetails', + params, function (data) { content.html(data); }, @@ -832,9 +847,15 @@ $('#mediamanager__layout_list').delegate('#mediamanager__tabs_files a', 'click', list) .delegate('#mediamanager__tabs_list a', 'click', list_view) - .delegate('#mediamanager__file_list a', 'click', details); + .delegate('#mediamanager__file_list a', 'click', details) + .delegate('#dw__mediasearch', 'submit', list); $('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', details) - .delegate('#mediamanager__btn_update', 'submit', list); + .delegate('#mediamanager__btn_update', 'submit', list) + .delegate('#page__revisions', 'submit', details) + .delegate('#page__revisions a', 'click', details) + .delegate('#mediamanager__save_meta', 'submit', details) + .delegate('#mediamanager__btn_delete', 'submit', details) + .delegate('#mediamanager__btn_restore', 'submit', details); }); }(jQuery)); -- 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 +++++++++++++++++---------- lib/exe/mediamanager.php | 2 +- lib/scripts/media.js | 3 +++ 5 files changed, 24 insertions(+), 14 deletions(-) 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()); diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 77eb2facb..939b5a053 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -80,7 +80,7 @@ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } - if($IMG && $_REQUEST['mediado'] == 'save') { + if($IMG && ($_REQUEST['mediado'] == 'save' || @array_key_exists('save', $_REQUEST['mediado']))) { $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 245519cbc..4eb1e7b63 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -405,6 +405,9 @@ jQuery('div.success, div.info, div.error, div.notify').remove(); + if (link[0].id == 'mediamanager__btn_delete' && !confirm(LANG['del_confirm'])) return false; + if (link[0].id == 'mediamanager__btn_restore' && !confirm(LANG['restore_confirm'])) return false; + content = $('#mediamanager__layout_detail'); $('.scroll-container', content).html('...'); -- 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(-) 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 f6f771ca288974ca7d259cf35f0d416fef44ef6e Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sat, 9 Jul 2011 21:04:18 +0300 Subject: media.js fix --- lib/scripts/media.js | 102 +++++++++++++++++++++++++-------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 4eb1e7b63..8c68fa569 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -321,8 +321,8 @@ * @author Pierre Spring */ list = function (event) { - var link, content, params; - link = $(this); + var $link, $content, params; + $link = jQuery(this); event.preventDefault(); @@ -330,31 +330,31 @@ if (document.getElementById('media__content')) { //popup - content = $('#media__content'); - content.html('...'); + $content = jQuery('#media__content'); + $content.html('...'); } else { //fullscreen media manager - content = $('#mediamanager__layout_list'); + $content = jQuery('#mediamanager__layout_list'); - if (link.hasClass('idx_dir')) { + if ($link.hasClass('idx_dir')) { //changing namespace - $('#mediamanager__layout_detail').empty(); + jQuery('#mediamanager__layout_detail').empty(); } - $('.scroll-container', content).html('...'); + jQuery('.scroll-container', $content).html('...'); } params = ''; - if (link[0].search) { - params = link[0].search.substr(1)+'&call=medialist'; - } else if (link[0].action) { - params = form_params(link)+'&call=medialist'; + if ($link[0].search) { + params = $link[0].search.substr(1)+'&call=medialist'; + } else if ($link[0].action) { + params = form_params($link)+'&call=medialist'; } // fetch the subtree - update_content(content, params); + update_content($content, params); }; @@ -363,11 +363,11 @@ * * @author Kate Arzamastseva */ - form_params = function (form) { - var elements = form.serialize(); + form_params = function ($form) { + var elements = $form.serialize(); var action = ''; - var i = form[0].action.indexOf('?'); - if (i >= 0) action = form[0].action.substr(i+1); + var i = $form[0].action.indexOf('?'); + if (i >= 0) action = $form[0].action.substr(i+1); return elements+'&'+action; }; @@ -377,18 +377,18 @@ * @author Kate Arzamastseva */ list_view = function (event) { - var link, content; - link = $(this); + var $link, $content; + $link = jQuery(this); event.preventDefault(); - content = $('#mediamanager__file_list'); - if (link.hasClass('mediamanager-link-thumbnails')) { - content.removeClass('mediamanager-list'); - content.addClass('mediamanager-thumbs'); - } else if (link.hasClass('mediamanager-link-list')) { - content.removeClass('mediamanager-thumbs'); - content.addClass('mediamanager-list'); + $content = jQuery('#mediamanager__file_list'); + if ($link.hasClass('mediamanager-link-thumbnails')) { + $content.removeClass('mediamanager-list'); + $content.addClass('mediamanager-thumbs'); + } else if ($link.hasClass('mediamanager-link-list')) { + $content.removeClass('mediamanager-thumbs'); + $content.addClass('mediamanager-list'); } }; @@ -398,43 +398,43 @@ * @author Kate Arzamastseva */ details = function (event) { - var link, content, params, update_list; - link = $(this); + var $link, $content, params, update_list; + $link = jQuery(this); event.preventDefault(); jQuery('div.success, div.info, div.error, div.notify').remove(); - if (link[0].id == 'mediamanager__btn_delete' && !confirm(LANG['del_confirm'])) return false; - if (link[0].id == 'mediamanager__btn_restore' && !confirm(LANG['restore_confirm'])) return false; + if ($link[0].id == 'mediamanager__btn_delete' && !confirm(LANG['del_confirm'])) return false; + if ($link[0].id == 'mediamanager__btn_restore' && !confirm(LANG['restore_confirm'])) return false; - content = $('#mediamanager__layout_detail'); - $('.scroll-container', content).html('...'); + $content = $('#mediamanager__layout_detail'); + jQuery('.scroll-container', $content).html('...'); params = ''; - if (link[0].search) { - params = link[0].search.substr(1)+'&call=mediadetails'; + if ($link[0].search) { + params = $link[0].search.substr(1)+'&call=mediadetails'; } else { - params = form_params(link)+'&call=mediadetails'; + params = form_params($link)+'&call=mediadetails'; } - update_content(content, params); + update_content($content, params); - update_list = (link[0].id == 'mediamanager__btn_delete' || link[0].id == 'mediamanager__btn_restore'); + update_list = ($link[0].id == 'mediamanager__btn_delete' || $link[0].id == 'mediamanager__btn_restore'); if (update_list) { - var link1, content1, params1; - link1 = $('a.files'); - params1 = link1[0].search.substr(1)+'&call=medialist'; - content1 = $('#mediamanager__layout_list'); - $('.scroll-container', content1).html('...'); + var $link1, $content1, params1; + $link1 = jQuery('a.files'); + params1 = $link1[0].search.substr(1)+'&call=medialist'; + $content1 = jQuery('#mediamanager__layout_list'); + jQuery('.scroll-container', $content1).html('...'); - update_content(content1, params1); + update_content($content1, params1); } }; - update_content = function (content, params) { - $.post( + update_content = function ($content, params) { + jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', params, function (data) { @@ -831,29 +831,29 @@ }; $(function () { - var content = $('#media__content'); - prepare_content(content); + var $content = jQuery('#media__content'); + prepare_content($content); attachoptions(); initpopup(); // add the action to autofill the "upload as" field - content.delegate('#upload__file', 'change', suggest) + $content.delegate('#upload__file', 'change', suggest) // Attach the image selector action to all links .delegate('a.select', 'click', select) // Attach deletion confirmation dialog to the delete buttons .delegate('#media__content a.btn_media_delete', 'click', confirmattach); - $('#media__tree').delegate('img', 'click', toggle) + jQuery('#media__tree').delegate('img', 'click', toggle) .delegate('a', 'click', list); - $('#mediamanager__layout_list').delegate('#mediamanager__tabs_files a', 'click', list) + jQuery('#mediamanager__layout_list').delegate('#mediamanager__tabs_files a', 'click', list) .delegate('#mediamanager__tabs_list a', 'click', list_view) .delegate('#mediamanager__file_list a', 'click', details) .delegate('#dw__mediasearch', 'submit', list); - $('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', details) + jQuery('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', details) .delegate('#mediamanager__btn_update', 'submit', list) .delegate('#page__revisions', 'submit', details) .delegate('#page__revisions a', 'click', details) -- 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 +++-- lib/scripts/media.js | 4 ++++ lib/tpl/default/mediamanager.css | 5 +++++ 4 files changed, 15 insertions(+), 5 deletions(-) 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']; diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 8c68fa569..f261bd2d5 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -340,6 +340,10 @@ if ($link.hasClass('idx_dir')) { //changing namespace jQuery('#mediamanager__layout_detail').empty(); + jQuery('#media__tree .selected').each(function(){ + $(this).removeClass('selected'); + }); + $link.addClass('selected'); } jQuery('.scroll-container', $content).html('...'); diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index 88e00d8fc..eea62ea46 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -232,6 +232,7 @@ form.meta textarea.edit { padding: 2px; vertical-align: top; zoom: 1; + color: black !important; } * html .mediamanager-table-50 li { display: inline; @@ -239,4 +240,8 @@ form.meta textarea.edit { .mediamanager-preview { margin-bottom: 5px; +} + +.idx .selected { + color: red !important; } \ No newline at end of file -- cgit v1.2.3 From e1dc10a4aab705171d34c7bde642ed77032c95c7 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 10 Jul 2011 15:36:01 +0300 Subject: media.js fixes --- lib/scripts/media.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 3f263f42a..36c06a3aa 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -253,7 +253,7 @@ var dw_mediamanager = { //changing namespace jQuery('#mediamanager__layout_detail').empty(); jQuery('#media__tree .selected').each(function(){ - $(this).removeClass('selected'); + jQuery(this).removeClass('selected'); }); $link.addClass('selected'); } @@ -272,7 +272,7 @@ var dw_mediamanager = { // fetch the subtree dw_mediamanager.update_content($content, params); - }; + }, /** * Returns form parameters @@ -324,7 +324,7 @@ var dw_mediamanager = { if ($link[0].id == 'mediamanager__btn_delete' && !confirm(LANG['del_confirm'])) return false; if ($link[0].id == 'mediamanager__btn_restore' && !confirm(LANG['restore_confirm'])) return false; - $content = $('#mediamanager__layout_detail'); + $content = jQuery('#mediamanager__layout_detail'); jQuery('.scroll-container', $content).html('...'); params = ''; @@ -354,7 +354,7 @@ var dw_mediamanager = { DOKU_BASE + 'lib/exe/ajax.php', params, function (data) { - content.html(data); + $content.html(data); dw_mediamanager.prepare_content($content); dw_mediamanager.updatehide(); }, @@ -604,7 +604,7 @@ var dw_mediamanager = { var allowed = bind(dw_mediamanager.allowedOpt, opt); // Current value - if (dw_mediamanager[opt] !== false && allowed(dw_mediamanager[opt]) { + if (dw_mediamanager[opt] !== false && allowed(dw_mediamanager[opt])) { return dw_mediamanager[opt]; } -- cgit v1.2.3 From 4928b6eb7137cb1e8727ca7a7fc99db614b0df88 Mon Sep 17 00:00:00 2001 From: Kate Arzamastseva Date: Sun, 10 Jul 2011 16:38:04 +0300 Subject: mediamanager resizable --- lib/scripts/media.js | 33 +++++++++++++++++++++++++++++++++ lib/tpl/default/mediamanager.css | 19 +++++++++++-------- 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 36c06a3aa..af5346cbe 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -354,14 +354,43 @@ var dw_mediamanager = { DOKU_BASE + 'lib/exe/ajax.php', params, function (data) { + jQuery('.ui-resizable').each(function(){ + jQuery(this).resizable('destroy'); + }); + $content.html(data); dw_mediamanager.prepare_content($content); dw_mediamanager.updatehide(); + dw_mediamanager.update_resizable(0); }, 'html' ); }, + update_resizable: function (count_width) { + jQuery(".layout").resizable({ handles: 'e' }); + jQuery(".layout").bind("resize", function(event, ui) { + var w = 0; + jQuery(".layout").each(function() { + w += jQuery(this).width(); + }); + jQuery('#id-mediamanager-layout').width(w+30); + }); + + var w = 0; + jQuery(".layout").each(function() { + if (count_width) jQuery(this).width(jQuery(this).width()); + w += jQuery(this).width(); + }); + jQuery('#id-mediamanager-layout').width(w+30); + + var windowHeight = jQuery(window).height(); + var height = windowHeight - 300; + jQuery('.scroll-container').each(function (i) { + jQuery(this).height(height); + }); + }, + prepare_content: function ($content) { // hide syntax example $content.find('div.example:visible').hide(); @@ -642,4 +671,8 @@ function hasFlash(version){ return ver >= version; } +jQuery(document).ready(function() { + dw_mediamanager.update_resizable(1); +}); + jQuery(dw_mediamanager.init); diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index eea62ea46..55ac39fd2 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -1,20 +1,19 @@ .mediamanager { width: 100%; - overflow-y: auto; + overflow-x: auto; } .mediamanager .mediamanager-slider { - width: auto; + } .mediamanager .mediamanager-slider .layout { - float: left; margin-left: 5px; margin-right: 5px; + float: left; } .mediamanager .scroll-container { - /*height: 0px;*/ overflow-y: auto; overflow-x: hidden; padding: 0; @@ -32,17 +31,17 @@ .mediamanager-link-thumbnails { background: url('../../images/icon-thumb.png') 0 -4px no-repeat; padding-left: 30px; - display: block; - float: left; + display: inline-block; width: 0; overflow: hidden; + + margin-left: 10px; } .mediamanager-link-list { background: url('../../images/icon-list.png') 0 -4px no-repeat; padding-left: 30px; - display: block; - float: left; + display: inline-block; width: 0; overflow: hidden; } @@ -242,6 +241,10 @@ form.meta textarea.edit { margin-bottom: 5px; } +.ui-resizable-e:hover { + background-color: #dadada; +} + .idx .selected { color: red !important; } \ No newline at end of file -- 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 ++++++++++++++++++++------------------- lib/scripts/media.js | 6 ++- lib/tpl/default/mediamanager.css | 7 ++- 4 files changed, 65 insertions(+), 52 deletions(-) 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 '
    '; } diff --git a/lib/scripts/media.js b/lib/scripts/media.js index af5346cbe..de3d03dfe 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -64,7 +64,8 @@ var dw_mediamanager = { jQuery('#mediamanager__layout_list').delegate('#mediamanager__tabs_files a', 'click', dw_mediamanager.list) .delegate('#mediamanager__tabs_list a', 'click', dw_mediamanager.list_view) .delegate('#mediamanager__file_list a', 'click', dw_mediamanager.details) - .delegate('#dw__mediasearch', 'submit', dw_mediamanager.list); + .delegate('#dw__mediasearch', 'submit', dw_mediamanager.list) + .delegate('#upload__file', 'change', dw_mediamanager.suggest); jQuery('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', dw_mediamanager.details) .delegate('#mediamanager__btn_update', 'submit', dw_mediamanager.list) @@ -216,6 +217,9 @@ var dw_mediamanager = { $file = jQuery(this); $name = jQuery('#upload__name'); + + if ($name.val() != '') return; + if(!$file.length || !$name.length) { return; } diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index 55ac39fd2..e87473687 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -246,5 +246,10 @@ form.meta textarea.edit { } .idx .selected { - color: red !important; + background-color: __highlight__; + font-weight: bold; +} + +.mediamanager div.upload { + padding-bottom: 0.5em; } \ No newline at end of file -- 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 +++++++++++++++++++++++++++------------- lib/scripts/media.js | 6 ++++- lib/tpl/default/mediamanager.css | 35 +++++++++++++++++++++--- 3 files changed, 77 insertions(+), 22 deletions(-) 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; } diff --git a/lib/scripts/media.js b/lib/scripts/media.js index de3d03dfe..62cc1e7bb 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -329,7 +329,11 @@ var dw_mediamanager = { if ($link[0].id == 'mediamanager__btn_restore' && !confirm(LANG['restore_confirm'])) return false; $content = jQuery('#mediamanager__layout_detail'); - jQuery('.scroll-container', $content).html('...'); + if (jQuery('.scroll-container', $content).length) { + jQuery('.scroll-container', $content).html('...'); + } else { + jQuery($content).html('...'); + } params = ''; diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index e87473687..df2b961b6 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -134,7 +134,7 @@ form.meta textarea.edit { } *+html .mediamanager-thumbs li { display: inline; - _height: 130px; + height: 130px; } .mediamanager-thumbs li .image { @@ -144,12 +144,20 @@ form.meta textarea.edit { overflow: hidden; } +.mediamanager-thumbs li .image div { + vertical-align: middle; + display: table-cell; + width: 100px; + height: 90px; +} + .mediamanager-thumbs li .name, .mediamanager-thumbs li .size, .mediamanager-thumbs li .filesize, .mediamanager-thumbs li .date { display: block; overflow: hidden; + white-space: nowrap; } .mediamanager-thumbs li input[type=checkbox] { @@ -186,6 +194,7 @@ form.meta textarea.edit { .mediamanager-list li .image img { width: 100%; + vertical-align: middle; } .mediamanager-list li .name, @@ -196,11 +205,26 @@ form.meta textarea.edit { float: left; width: 19%; margin-left: 1%; + white-space: nowrap; } .mediamanager-list li .date, .mediamanager-thumbs li .date { font-style: italic; + white-space: normal; +} + +.mediamanager-list .icon { + max-width: 16px; + max-height: 16px; +} + +.mediamanager-list li .image div { + vertical-align: middle; + text-align: center; + display: table-cell; + width: 100px; + height: 40px; } .mediamanager-list li input[type=checkbox] { @@ -231,8 +255,9 @@ form.meta textarea.edit { padding: 2px; vertical-align: top; zoom: 1; - color: black !important; + color: black; } + * html .mediamanager-table-50 li { display: inline; } @@ -252,4 +277,8 @@ form.meta textarea.edit { .mediamanager div.upload { padding-bottom: 0.5em; -} \ No newline at end of file +} + +.background-container .icon { + margin-right: 5px; +} -- 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(-) 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(-) 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 +++++++++++++++++++++++++++++++-------- lib/scripts/media.js | 29 ++++ lib/tpl/default/mediamanager.css | 33 +++++ 3 files changed, 288 insertions(+), 53 deletions(-) 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 '
    '; } /** diff --git a/lib/scripts/media.js b/lib/scripts/media.js index 777eb4825..8500166dc 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -369,6 +369,9 @@ var dw_mediamanager = { dw_mediamanager.prepare_content($content); dw_mediamanager.updatehide(); dw_mediamanager.update_resizable(0); + dw_mediamanager.opacity_slider(); + dw_mediamanager.portions_slider(); + }, 'html' ); @@ -398,6 +401,30 @@ var dw_mediamanager = { }); }, + opacity_slider: function () { + var $slider = jQuery( "#mediamanager__opacity_slider" ); + $slider.slider(); + $slider.slider("option", "min", 0); + $slider.slider("option", "max", 0.999); + $slider.slider("option", "step", 0.001); + $slider.slider("option", "value", 0.5); + $slider.bind("slide", function(event, ui) { + jQuery('#mediamanager__diff_opacity_image2').css({ opacity: $slider.slider("option", "value")}); + }); + }, + + portions_slider: function () { + var $slider = jQuery( "#mediamanager__portions_slider" ); + $slider.slider(); + $slider.slider("option", "min", 0); + $slider.slider("option", "max", 100); + $slider.slider("option", "step", 1); + $slider.slider("option", "value", 50); + $slider.bind("slide", function(event, ui) { + jQuery('#mediamanager__diff_portions_image2').css({ width: $slider.slider("option", "value")+'%'}); + }); + }, + prepare_content: function ($content) { // hide syntax example $content.find('div.example:visible').hide(); @@ -680,6 +707,8 @@ function hasFlash(version){ jQuery(document).ready(function() { dw_mediamanager.update_resizable(1); + dw_mediamanager.opacity_slider(); + dw_mediamanager.portions_slider(); }); jQuery(dw_mediamanager.init); diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css index df2b961b6..6c4b64d3e 100644 --- a/lib/tpl/default/mediamanager.css +++ b/lib/tpl/default/mediamanager.css @@ -263,6 +263,7 @@ form.meta textarea.edit { } .mediamanager-preview { + text-align: center; margin-bottom: 5px; } @@ -282,3 +283,35 @@ form.meta textarea.edit { .background-container .icon { margin-right: 5px; } + +.mediamanager dl.img_tags dd.highlighted{ + background-color: __highlight__; +} + +#mediamanager__diff_opacity_image1, +#mediamanager__diff_portions_image1 { + width: 99%; + position: relative; +} + +#mediamanager__diff_opacity_image2 { + width: 100%; + position: absolute; + top: 0; + left: 0; + opacity: 0.5; +} + +#mediamanager__diff_portions_image2 { + width: 50%; + position: absolute; + top: 0; + left: 0; + border-right: 1px solid red; +} + +#mediamanager__opacity_slider, +#mediamanager__portions_slider { + margin: 10px; + width: 99%; +} -- 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 +++--- lib/scripts/media.js | 6 +- lib/tpl/default/mediamanager.css | 184 +++++++++++++++++++--------------- 4 files changed, 214 insertions(+), 212 deletions(-) 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 '