diff options
-rw-r--r-- | conf/mediameta.php | 44 | ||||
-rw-r--r-- | data/media_attic/_dummy | 0 | ||||
-rw-r--r-- | data/media_meta/_dummy | 0 | ||||
-rw-r--r-- | inc/actions.php | 2 | ||||
-rw-r--r-- | inc/changelog.php | 69 | ||||
-rw-r--r-- | inc/common.php | 1 | ||||
-rw-r--r-- | inc/html.php | 122 | ||||
-rw-r--r-- | inc/init.php | 2 | ||||
-rw-r--r-- | inc/lang/en/lang.php | 24 | ||||
-rw-r--r-- | inc/media.php | 718 | ||||
-rw-r--r-- | inc/pageutils.php | 26 | ||||
-rw-r--r-- | inc/template.php | 129 | ||||
-rw-r--r-- | lib/exe/ajax.php | 26 | ||||
-rw-r--r-- | lib/exe/fetch.php | 10 | ||||
-rw-r--r-- | lib/exe/mediamanager.php | 24 | ||||
-rw-r--r-- | lib/images/icon-file.png | bin | 0 -> 3363 bytes | |||
-rw-r--r-- | lib/images/icon-list.png | bin | 0 -> 3342 bytes | |||
-rw-r--r-- | lib/images/icon-sort.png | bin | 0 -> 316 bytes | |||
-rw-r--r-- | lib/images/icon-thumb.png | bin | 0 -> 969 bytes | |||
-rw-r--r-- | lib/plugins/popularity/lang/uk/submitted.txt | 2 | ||||
-rw-r--r-- | lib/scripts/media.js | 132 | ||||
-rw-r--r-- | lib/tpl/default/design.css | 12 | ||||
-rw-r--r-- | lib/tpl/default/detail.php | 41 | ||||
-rw-r--r-- | lib/tpl/default/main.php | 1 | ||||
-rw-r--r-- | lib/tpl/default/mediamanager.css | 247 | ||||
-rw-r--r-- | lib/tpl/default/style.ini | 1 |
26 files changed, 1492 insertions, 141 deletions
diff --git a/conf/mediameta.php b/conf/mediameta.php index ba7117643..0428a4b88 100644 --- a/conf/mediameta.php +++ b/conf/mediameta.php @@ -29,29 +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', + 70 => array('', + 'img_format', + 'text', + array('File.Format')), + + 80 => array('', + 'img_fsize', + 'text', + array('File.NiceSize')), + + 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/data/media_attic/_dummy b/data/media_attic/_dummy new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/data/media_attic/_dummy diff --git a/data/media_meta/_dummy b/data/media_meta/_dummy new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/data/media_meta/_dummy 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/changelog.php b/inc/changelog.php index 15cd46d77..e9b271363 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 } /** @@ -151,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_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 @@ -158,6 +160,7 @@ function addMediaLogEntry($date, $id, $type=DOKU_CHANGE_TYPE_EDIT, $summary='', * @param bool $flags see above * * @author Ben Coburn <btcoburn@silicodon.net> + * @author Kate Arzamastseva <pshns@ukr.net> */ function getRecents($first,$num,$ns='',$flags=0){ global $conf; @@ -173,20 +176,46 @@ function getRecents($first,$num,$ns='',$flags=0){ } else { $lines = @file($conf['changelog']); } + $lines_position = count($lines)-1; + + if ($flags & RECENTS_MEDIA_PAGES_MIXED) { + $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_MEDIA_PAGES_MIXED) && $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_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_MEDIA_PAGES_MIXED) && @$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; } @@ -300,8 +329,9 @@ function _handleRecent($line,$ns,$flags,&$seen){ * requested changelog line is read. * * @author Ben Coburn <btcoburn@silicodon.net> + * @author Kate Arzamastseva <pshns@ukr.net> */ -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 +342,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 @@ -397,8 +431,9 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) { * lines are recieved. * * @author Ben Coburn <btcoburn@silicodon.net> + * @author Kate Arzamastseva <pshns@ukr.net> */ -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 +441,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/common.php b/inc/common.php index 7522095ab..6d707e704 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_MEDIA_PAGES_MIXED',32); /** * Wrapper around htmlspecialchars() diff --git a/inc/html.php b/inc/html.php index 6e187ebe1..df28a2096 100644 --- a/inc/html.php +++ b/inc/html.php @@ -415,20 +415,28 @@ function html_locked(){ * * @author Andreas Gohr <andi@splitbrain.org> * @author Ben Coburn <btcoburn@silicodon.net> + * @author Kate Arzamastseva <pshns@ukr.net> */ -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,22 @@ 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))); + + if (!$media_id) print p_locale_xhtml('revisions'); - print p_locale_xhtml('revisions'); + $params = array('id' => 'page__revisions'); + if ($media_id) $params['action'] = media_managerURL(array('image' => $media_id), '&'); - $form = new Doku_Form(array('id' => 'page__revisions')); + $form = new Doku_Form($params); $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')); @@ -459,19 +475,30 @@ function html_revisions($first=0){ $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); + if (!$media_id) $href = wl($id); + else $href = media_managerURL(array('image' => $id, 'tab_details' => 'view'), '&'); $form->addElement(form_makeOpenTag('a', array( 'class' => 'wikilink1', - 'href' => wl($ID)))); - $form->addElement($ID); + 'href' => $href))); + $form->addElement($id); $form->addElement(form_makeCloseTag('a')); $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); $form->addElement(' – '); - $form->addElement(htmlspecialchars($INFO['sum'])); + if (!$media_id) $form->addElement(htmlspecialchars($INFO['sum'])); $form->addElement(form_makeCloseTag('span')); $form->addElement(form_makeOpenTag('span', array('class' => 'user'))); - $form->addElement((empty($INFO['editor']))?('('.$lang['external_edit'].')'):editorinfo($INFO['editor'])); + if (!$media_id) $editor = $INFO['editor']; + else { + $revinfo = getRevisionInfo($id, @filemtime(fullpath(mediaFN($id))), 1024, true); + if($revinfo['user']){ + $editor = $revinfo['user']; + }else{ + $editor = $revinfo['ip']; + } + } + $form->addElement((empty($editor))?('('.$lang['external_edit'].')'):editorinfo($editor)); $form->addElement(form_makeCloseTag('span')); $form->addElement('('.$lang['current'].')'); @@ -480,9 +507,14 @@ function html_revisions($first=0){ } foreach($revisions as $rev){ - $date = dformat($rev); - $info = getRevisionInfo($ID,$rev,true); - $exists = page_exists($ID,$rev); + $date = dformat($rev); + if (!$media_id) { + $info = getRevisionInfo($id,$rev,true); + $exists = page_exists($id,$rev); + } else { + $info = getRevisionInfo($id,$rev,true,true); + $exists = @file_exists(mediaFN($id,$rev)); + } if ($info['type']===DOKU_CHANGE_TYPE_MINOR_EDIT) $form->addElement(form_makeOpenTag('li', array('class' => 'minor'))); @@ -503,7 +535,9 @@ 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'))); + if (!$media_id) $href = wl($id,"rev=$rev,do=diff", false, '&'); + 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', 'width' => 15, @@ -511,13 +545,14 @@ 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); + if (!$media_id) $href = wl($id,"rev=$rev",false,'&'); + 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')); }else{ $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />'); - $form->addElement($ID); + $form->addElement($id); } $form->addElement(form_makeOpenTag('span', array('class' => 'sum'))); @@ -540,7 +575,12 @@ function html_revisions($first=0){ $form->addElement(form_makeCloseTag('li')); } $form->addElement(form_makeCloseTag('ul')); - $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 '<div class="pagenav">'; @@ -549,12 +589,12 @@ function html_revisions($first=0){ $first -= $conf['recent']; if ($first < 0) $first = 0; print '<div class="pagenav-prev">'; - print html_btn('newer',$ID,"p",array('do' => 'revisions', 'first' => $first)); + print html_btn('newer',$id,"p",array('do' => 'revisions', 'first' => $first)); print '</div>'; } if ($hasNext) { print '<div class="pagenav-next">'; - print html_btn('older',$ID,"n",array('do' => 'revisions', 'first' => $last)); + print html_btn('older',$id,"n",array('do' => 'revisions', 'first' => $last)); print '</div>'; } print '</div>'; @@ -567,8 +607,9 @@ function html_revisions($first=0){ * @author Andreas Gohr <andi@splitbrain.org> * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> * @author Ben Coburn <btcoburn@silicodon.net> + * @author Kate Arzamastseva <pshns@ukr.net> */ -function html_recent($first=0){ +function html_recent($first=0, $show_changes='both'){ global $conf; global $lang; global $ID; @@ -576,10 +617,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)); + 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); 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 +641,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/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/lang/en/lang.php b/inc/lang/en/lang.php index 51fd8f645..ea6bf2646 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -48,6 +48,8 @@ $lang['btn_recover'] = 'Recover draft'; $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'; @@ -179,6 +181,9 @@ $lang['external_edit'] = 'external edit'; $lang['summary'] = 'Edit summary'; $lang['noflash'] = 'The <a href="http://www.adobe.com/products/flashplayer/">Adobe Flash Plugin</a> 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:'; @@ -220,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'; @@ -236,6 +242,8 @@ $lang['img_copyr'] = 'Copyright'; $lang['img_format'] = 'Format'; $lang['img_camera'] = 'Camera'; $lang['img_keywords']= 'Keywords'; +$lang['img_width'] = 'Width'; +$lang['img_height'] = 'Height'; $lang['subscr_subscribe_success'] = 'Added %s to subscription list for %s'; $lang['subscr_subscribe_error'] = 'Error adding %s to subscription list for %s'; @@ -318,5 +326,21 @@ $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_listview'] = 'List'; +$lang['media_sort'] = 'Sort'; +$lang['media_search'] = 'Search in the <b>%s</b> namespace.'; +$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.'; +$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 10da501b0..341692f5f 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 <andi@splitbrain.org> + * @author Kate Arzamastseva <pshns@ukr.net> */ 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{ @@ -74,33 +86,40 @@ function media_metasave($id,$auth,$data){ * Display the form to edit image meta data * * @author Andreas Gohr <andi@splitbrain.org> + * @author Kate Arzamastseva <pshns@ukr.net> */ -function media_metaform($id,$auth){ - if($auth < AUTH_UPLOAD) return false; +function media_metaform($id,$auth,$fullscreen = false){ global $lang, $config_cascade; + if($auth < AUTH_UPLOAD) { + echo '<div class="nothing">'.$lang['media_perm_upload'].'</div>'.NL; + return 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); } } $src = mediaFN($id); // output - echo '<h1>'.hsc(noNS($id)).'</h1>'.NL; - echo '<form action="'.DOKU_BASE.'lib/exe/mediamanager.php" accept-charset="utf-8" method="post" class="meta">'.NL; + if (!$fullscreen) { + echo '<h1>'.hsc(noNS($id)).'</h1>'.NL; + $action = DOKU_BASE.'lib/exe/mediamanager.php'; + } else { + $action = media_managerURL(array('tab_details' => 'view'), '&'); + } + echo '<form action="'.$action.'" id="mediamanager__save_meta" accept-charset="utf-8" method="post" class="meta">'.NL; + 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); @@ -132,8 +151,15 @@ function media_metaform($id,$auth){ } echo '<div class="buttons">'.NL; echo '<input type="hidden" name="img" value="'.hsc($id).'" />'.NL; - echo '<input name="do[save]" type="submit" value="'.$lang['btn_save']. + if (!$fullscreen) { + $do = 'do'; + } else { + echo '<input type="hidden" name="mediado" value="save" />'; + $do = 'mediado'; + } + echo '<input name="'.$do.'[save]" type="submit" value="'.$lang['btn_save']. '" title="'.$lang['btn_save'].' [S]" accesskey="s" class="button" />'.NL; + if (!$fullscreen) echo '<input name="do[cancel]" type="submit" value="'.$lang['btn_cancel']. '" title="'.$lang['btn_cancel'].' [C]" accesskey="c" class="button" />'.NL; echo '</div>'.NL; @@ -178,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; @@ -193,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'); } } @@ -221,7 +254,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']; @@ -341,15 +374,25 @@ function _media_upload_action($data) { * * @author Andreas Gohr <andi@splitbrain.org> * @author Michael Klier <chi@chimeric.de> + * @author Kate Arzamastseva <pshns@ukr.net> */ 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)) { + // add old revision to the attic if missing + media_saveOldRevision($id); + } // prepare directory 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. // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) @@ -357,10 +400,12 @@ 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) { - addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_EDIT); + if ($REV){ + addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_REVERT, $lang['restored'], $REV); + } elseif ($overwrite) { + addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_EDIT); } else { - addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_CREATE); + addMediaLogEntry($new, $id, DOKU_CHANGE_TYPE_CREATE, $lang['created']); } return $id; }else{ @@ -369,6 +414,30 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov } /** + * Moves the current version of media file to the media_attic + * directory + * + * @author Kate Arzamastseva <pshns@ukr.net> + * @param string $id + * @return int - revision date + */ +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(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.) + 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. * @@ -447,7 +516,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); @@ -455,13 +524,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 '<h1 id="media__ns">:'.hsc($ns).'</h1>'.NL; + if (!$fullscreenview) echo '<h1 id="media__ns">:'.hsc($ns).'</h1>'.NL; if($auth < AUTH_READ){ // FIXME: print permission warning here instead? echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; }else{ - media_uploadform($ns, $auth); + if (!$fullscreenview) media_uploadform($ns, $auth); $dir = utf8_encodeFN(str_replace(':','/',$ns)); $data = array(); @@ -471,10 +540,441 @@ function media_filelist($ns,$auth=null,$jump=''){ if(!count($data)){ echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; }else foreach($data as $item){ - media_printfile($item,$auth,$jump); + if (!$fullscreenview) media_printfile($item,$auth,$jump); + else media_printfile_thumbs($item,$auth,$jump); + } + } + if (!$fullscreenview) media_searchform($ns); +} + +/** + * Prints tabs for files list actions + * + * @author Kate Arzamastseva <pshns@ukr.net> + * @param string $selected - opened tab + */ +function media_tabs_files($selected=false){ + global $lang; + + echo '<div class="mediamanager-tabs" id="mediamanager__tabs_files">'; + $tab = '<a href="'.media_managerURL(array('tab_files' => 'files')).'"'; + if (!empty($selected) && $selected == 'files') $class = 'files selected'; + else $class = 'files'; + $tab .= ' class="'.$class.'" >'.$lang['mediaselect'].'</a>'; + echo $tab; + + $tab = '<a href="'.media_managerURL(array('tab_files' => 'upload')). + '" rel=".mediamanager-tab-upload"'; + if (!empty($selected) && $selected == 'upload') $class = 'upload selected'; + else $class = 'upload'; + $tab .= ' class="'.$class.'" >'.$lang['media_uploadtab'].'</a>'; + echo $tab; + + $tab = '<a href="'.media_managerURL(array('tab_files' => 'search')). + '" rel=".mediamanager-tab-search"'; + if (!empty($selected) && $selected == 'search') $class = 'search selected'; + else $class = 'search'; + $tab .= ' class="'.$class.'" >'.$lang['media_searchtab'].'</a>'; + echo $tab; + + echo '<div class="clearer"></div>'; + echo '</div>'; +} + +/** + * Prints tabs for files details actions + * + * @author Kate Arzamastseva <pshns@ukr.net> + * @param string $selected - opened tab + */ +function media_tabs_details($image, $selected=false){ + global $lang; + + echo '<div class="mediamanager-tabs" id="mediamanager__tabs_details">'; + $tab = '<a href="'.media_managerURL(array('tab_details' => 'view', 'image' => $image)). + '" rel=".mediamanager-tab-view"'; + if (!empty($selected) && $selected == 'view') $class = 'view selected'; + else $class = 'view'; + $tab .= ' class="'.$class.'" >'.$lang['media_viewtab'].'</a>'; + echo $tab; + + $tab = '<a href="'.media_managerURL(array('tab_details' => 'edit', 'image' => $image)). + '" rel=".mediamanager-tab-edit"'; + if (!empty($selected) && $selected == 'edit') $class = 'edit selected'; + else $class = 'edit'; + $tab .= ' class="'.$class.'" >'.$lang['media_edittab'].'</a>'; + echo $tab; + + $tab = '<a href="'.media_managerURL(array('tab_details' => 'history', 'image' => $image)). + '" rel=".mediamanager-tab-history"'; + if (!empty($selected) && $selected == 'history') $class = 'history selected'; + else $class = 'history'; + $tab .= ' class="'.$class.'" >'.$lang['media_historytab'].'</a>'; + echo $tab; + + echo '<div class="clearer"></div>'; + echo '</div>'; +} + +/** + * Prints options for the tab that displays a list of all files + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_tab_files_options($ns){ + global $lang; + + echo '<div class="background-container">'; + echo $ns; + echo '<div id="mediamanager__tabs_list" style="display: inline;">'; + echo '<a href="'.media_managerURL(array('view' => 'thumbs')).'" + rel=".mediamanager-files-thumbnails-tab" class="mediamanager-link-thumbnails">'. + $lang['media_thumbsview'].'</a>'; + echo '<a href="'.media_managerURL(array('view' => 'list')).'" + rel=".mediamanager-files-list-tab" class="mediamanager-link-list" + title="View as list">'.$lang['media_listview'].'</a>'; + + echo '</div>'; + echo '<div class="mediamanager-block-sort">'.$lang['media_sort']; + //select + echo '</div>'; + echo '<div class="clearer"></div>'; + echo '</div>'; +} + +/** + * Prints tab that displays a list of all files + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_tab_files($ns,$auth=null,$jump='') { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + media_tab_files_options($ns); + + echo '<div class="scroll-container" >'; + $view = $_REQUEST['view']; + if($auth < AUTH_READ){ + echo '<div class="nothing">'.$lang['media_perm_read'].'</div>'.NL; + }else{ + if ($view == 'list') { + echo '<ul class="mediamanager-file-list mediamanager-list" id="mediamanager__file_list">'; + } else { + echo '<ul class="mediamanager-file-list mediamanager-thumbs" id="mediamanager__file_list">'; + } + media_filelist($ns,$auth,$jump,true); + echo '</ul>'; + } + echo '</div>'; +} + +/** + * Prints tab that displays uploading form + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_tab_upload($ns,$auth=null,$jump='') { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '<div class="background-container">'; + echo $lang['mediaupload']; + echo '</div>'; + + echo '<div class="scroll-container">'; + media_uploadform($ns, $auth, true); + echo '</div>'; +} + +/** + * Prints tab that displays search form + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_tab_search($ns,$auth=null) { + global $lang; + + $do = $_REQUEST['mediado']; + $query = $_REQUEST['q']; + if (!$query) $query = ''; + + echo '<div class="background-container">'; + echo sprintf($lang['media_search'], $ns); + echo'</div>'; + + echo '<div class="scroll-container">'; + media_searchform($ns, $query, true); + + if($do == 'searchlist'){ + $view = $_REQUEST['view']; + if ($view == 'list') { + echo '<ul class="mediamanager-file-list mediamanager-list" id="mediamanager__file_list">'; + } else { + echo '<ul class="mediamanager-file-list mediamanager-thumbs" id="mediamanager__file_list">'; + } + media_searchlist($query,$ns,$auth,true); + echo '</ul>'; + } + echo '</div>'; +} + +/** + * Prints tab that displays mediafile details + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_tab_view($image, $ns, $auth=null, $rev=false) { + global $lang, $conf; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '<div class="background-container">'; + echo $image; + echo '</div>'; + + echo '<div class="scroll-container">'; + media_preview($image, $auth, $rev); + media_details($image, $auth, $rev); + echo '</div>'; +} + +/** + * Prints tab that displays form for editing mediafile metadata + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_tab_edit($image, $ns, $auth=null) { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + + echo '<div class="background-container">'; + echo $lang['media_edit']; + echo '</div>'; + + echo '<div class="scroll-container">'; + if ($image) { + list($ext, $mime) = mimetype($image); + if ($mime == 'image/jpeg') media_metaform($image,$auth,true); + } + echo '</div>'; +} + +/** + * Prints tab that displays mediafile revisions + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_tab_history($image, $ns, $auth=null) { + global $lang; + if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); + $do = $_REQUEST['mediado']; + + echo '<div class="background-container">'; + echo $lang['media_history']; + echo '</div>'; + + echo '<div class="scroll-container">'; + 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); + } + } else { + echo '<div class="nothing">'.$lang['media_perm_read'].'</div>'.NL; + } + echo '</div>'; +} + +/** + * Prints mediafile details + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_preview($image, $auth, $rev=false) { + global $lang; + if (!$image) return ''; + if ($auth < AUTH_READ) { + echo '<div class="nothing">'.$lang['media_perm_read'].'</div>'.NL; + return ''; + } + $info = getimagesize(mediaFN($image, $rev)); + $w = (int) $info[0]; + + $more = ''; + if ($rev) { + $more = "rev=$rev"; + } else { + $t = @filemtime(mediaFN($image)); + $more = "t=$t"; + } + $src = ml($image, $more); + echo '<div class="mediamanager-preview">'; + echo '<img src="'.$src.'" alt="" width="99%" style="max-width: '.$w.'px;" /><br /><br />'; + + $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){ + $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(); + + $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){ + $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'])); + $form->printForm(); + } + echo '</div>'; +} + +/** + * Prints mediafile tags + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_details($image, $auth, $rev=false) { + global $lang, $config_cascade;; + + if (!$image) return ''; + if ($auth < AUTH_READ) { + echo '<div class="nothing">'.$lang['media_perm_read'].'</div>'.NL; + return ''; + } + + // load the field descriptions + 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 '<dl class="img_tags">'; + 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 '<dt>'.$lang[$tag[1]].':</dt><dd>'; + if ($tag[2] == 'date') echo dformat($value); + else echo hsc($value); + echo '</dd>'; + } + echo '</dl>'; +} + +/** + * Returns the requested EXIF/IPTC tag from the image meta + * + * @author Kate Arzamastseva <pshns@ukr.net> + * @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 + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +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; } + }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]; } - media_searchform($ns); + echo '<ul class="mediamanager-table-50"><li><div>'; + media_preview($image, $auth, $l_rev); + echo '</div></li>'; + echo '<li><div>'; + media_preview($image, $auth, $r_rev); + echo '</div></li><li><div>'; + media_details($image, $auth, $l_rev); + echo '</div></li>'; + echo '<li><div>'; + media_details($image, $auth, $r_rev); + echo '</div></li></ul>'; +} + +/** + * 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 <pshns@ukr.net> + */ +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; } /** @@ -482,11 +982,13 @@ function media_filelist($ns,$auth=null,$jump=''){ * * @author Tobias Sarnowski <sarnowski@cosmocode.de> * @author Andreas Gohr <gohr@cosmocode.de> + * @author Kate Arzamastseva <pshns@ukr.net> * @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); if ($query) { @@ -509,13 +1011,16 @@ function media_searchlist($query,$ns,$auth=null){ unset($evt); } - echo '<h1 id="media__ns">'.sprintf($lang['searchmedia_in'],hsc($ns).':*').'</h1>'.NL; - media_searchform($ns,$query); + if (!$fullscreen) { + echo '<h1 id="media__ns">'.sprintf($lang['searchmedia_in'],hsc($ns).':*').'</h1>'.NL; + media_searchform($ns,$query); + } if(!count($evdata['data'])){ echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.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']); } } @@ -536,15 +1041,17 @@ function media_fileactions($item,$auth){ // delete button if($auth >= AUTH_DELETE){ - echo ' <a href="'.DOKU_BASE.'lib/exe/mediamanager.php?delete='.rawurlencode($item['id']). - '&sectok='.getSecurityToken().'" class="btn_media_delete" title="'.$item['id'].'">'. + $link = DOKU_BASE.'lib/exe/mediamanager.php?delete='.rawurlencode($item['id']). + '&sectok='.getSecurityToken(); + echo ' <a href="'.$link.'" class="btn_media_delete" title="'.$item['id'].'">'. '<img src="'.DOKU_BASE.'lib/images/trash.png" alt="'.$lang['btn_delete'].'" '. 'title="'.$lang['btn_delete'].'" class="btn" /></a>'; } // edit button if($auth >= AUTH_UPLOAD && $item['isimg'] && $item['meta']->getField('File.Mime') == 'image/jpeg'){ - echo ' <a href="'.DOKU_BASE.'lib/exe/mediamanager.php?edit='.rawurlencode($item['id']).'">'. + $link = DOKU_BASE.'lib/exe/mediamanager.php?edit='.rawurlencode($item['id']); + echo ' <a href="'.$link.'">'. '<img src="'.DOKU_BASE.'lib/images/pencil.png" alt="'.$lang['metaedit'].'" '. 'title="'.$lang['metaedit'].'" class="btn" /></a>'; } @@ -609,26 +1116,82 @@ function media_printfile($item,$auth,$jump,$display_namespace=false){ } /** + * Formats and prints one file in the list in the thumbnails view + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function media_printfile_thumbs($item,$auth,$jump=false){ + global $lang; + global $conf; + + // Prepare filename + $file = utf8_decodeFN($item['file']); + + // output + echo '<li><div>'; + if($item['isimg']) { + media_printimgdetail($item, true); + } else { + echo '<a name="d_:'.$item['id'].'" class="image" title="'.$item['id'].'" href="'. + media_managerURL(array('image' => hsc($item['id']))).'">'; + echo '<img src="'.DOKU_BASE.'lib/images/icon-file.png" width="90px" />'; + echo '</a>'; + } + //echo '<input type=checkbox />'; + echo '<a href="'.media_managerURL(array('image' => hsc($item['id']))).'" name= + "h_:'.$item['id'].'" class="name">'.hsc($file).'</a>'; + if($item['isimg']){ + $size = ''; + $size .= (int) $item['meta']->getField('File.Width'); + $size .= '×'; + $size .= (int) $item['meta']->getField('File.Height'); + echo '<span class="size">'.$size.'</span>'; + } else { + echo '<span class="size"> </span>'; + } + $date = dformat($item['mtime']); + echo '<span class="date">'.$date.'</span>'; + $filesize = filesize_h($item['size']); + echo '<span class="filesize">'.$filesize.'</span>'; + echo '<div class="clearer"></div>'; + echo '</div></li>'.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){ + 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)); + $src = ml($item['id'],array('w'=>$w,'h'=>$h,'t'=>$item['mtime'])); $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 '<a name="d_:'.$item['id'].'" class="image" title="'.$item['id'].'" href="'. + media_managerURL(array('image' => hsc($item['id']))).'">'; + echo '<img src="'.$src.'" '.$att.' />'; + echo '</a>'; + return 1; + } + echo '<div class="detail">'; echo '<div class="thumb">'; echo '<a name="d_:'.$item['id'].'" class="select">'; @@ -656,33 +1219,86 @@ function media_printimgdetail($item){ } /** + * Build link based on the current, adding/rewriting + * parameters + * + * @author Kate Arzamastseva <pshns@ukr.net> + * @param array $params + * @param string $amp - separator + * @return string - link + */ +function media_managerURL($params=false, $amp='&') { + global $conf; + global $ID; + + $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) { + $gets[$k] = $v; + } + } + unset($gets['id']); + if ($gets['delete']) { + unset($gets['image']); + unset($gets['tab_details']); + } + + return wl($ID,$gets,false,$amp); +} + +/** * Print the media upload form if permissions are correct * * @author Andreas Gohr <andi@splitbrain.org> + * @author Kate Arzamastseva <pshns@ukr.net> */ -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? + if($auth < AUTH_UPLOAD) { + echo '<div class="nothing">'.$lang['media_perm_upload'].'</div>'.NL; + return; + } + + $update = false; + $id = ''; + if ($auth >= AUTH_DELETE && $fullscreen && $_REQUEST['mediado'] == 'update') { + $update = true; + $id = cleanID($_REQUEST['image']); + } // 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('<div class="upload">' . $lang['mediaupload'] . '</div>'); + $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', + 'tab_details' => 'view'), '&'); + } + + $form = new Doku_Form($params); + if (!$fullscreen) $form->addElement('<div class="upload">' . $lang['mediaupload'] . '</div>'); $form->addElement(formSecurityToken()); $form->addHidden('ns', hsc($ns)); $form->addElement(form_makeOpenTag('p')); $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('mediaid', noNS($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); @@ -728,16 +1344,21 @@ function media_uploadform($ns, $auth){ * Print the search field form * * @author Tobias Sarnowski <sarnowski@cosmocode.de> + * @author Kate Arzamastseva <pshns@ukr.net> */ -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('<div class="upload">' . $lang['mediasearch'] . '</div>'); + $params = array('id' => 'dw__mediasearch'); + if (!$fullscreen) $params['action'] = DOKU_BASE.'lib/exe/mediamanager.php'; + else $params['action'] = media_managerURL(array(), '&'); + $form = new Doku_Form($params); + if (!$fullscreen) $form->addElement('<div class="upload">' . $lang['mediasearch'] . '</div>'); $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'])); @@ -791,7 +1412,10 @@ function media_nstree_item($item){ if(!$item['label']) $item['label'] = $label; $ret = ''; + if (!($_REQUEST['do'] == 'media')) $ret .= '<a href="'.DOKU_BASE.'lib/exe/mediamanager.php?ns='.idfilter($item['id']).'" class="idx_dir">'; + else $ret .= '<a href="'.media_managerURL(array('ns' => idfilter($item['id']), 'tab_files' => 'files')) + .'" class="idx_dir">'; $ret .= $item['label']; $ret .= '</a>'; return $ret; diff --git a/inc/pageutils.php b/inc/pageutils.php index c9bf60135..81dcb66e7 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 <steven-danz@kc.rr.com> */ function metaFN($id,$ext){ @@ -308,6 +306,19 @@ function metaFN($id,$ext){ } /** + * returns the full path to the media's meta file specified by ID and extension + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +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 * * @author Esther Brunner <esther@kaffeehaus.ch> @@ -326,12 +337,19 @@ function metaFiles($id){ * The filename is URL encoded to protect Unicode chars * * @author Andreas Gohr <andi@splitbrain.org> + * @author Kate Arzamastseva <pshns@ukr.net> */ -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{ + $ext = mimetype($id); + $name = substr($id,0, -1*strlen($ext[0])-1); + $fn = $conf['mediaolddir'].'/'.utf8_encodeFN($name .'.'.( (int) $rev ).'.'.$ext[0]); + } return $fn; } diff --git a/inc/template.php b/inc/template.php index a476e78ab..81b3795ac 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? @@ -122,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()) @@ -626,6 +630,8 @@ function tpl_get_action($type) { // Superseded by subscribe/subscription return ''; break; + case 'media': + break; default: return '[unknown %s type]'; break; @@ -1122,15 +1128,91 @@ 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 <pshns@ukr.net> + */ +function tpl_fileList(){ + global $AUTH; + global $NS; + global $JUMPTO; + + $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') { + echo '<div class="mediamanager-tab-files" id="mediamanager__files">'; + media_tab_files($NS,$AUTH,$JUMPTO); + echo '</div>'; + + } elseif ($opened_tab == 'upload') { + echo '<div class="mediamanager-tab-upload" id="mediamanager__files">'; + media_tab_upload($NS,$AUTH,$JUMPTO); + echo '</div>'; + + } elseif ($opened_tab == 'search') { + echo '<div class="mediamanager-tab-search" id="mediamanager__files">'; + media_tab_search($NS,$AUTH); + echo '</div>'; + } + +} + +/** + * 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 <pshns@ukr.net> + */ +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 ''; + $do = $_REQUEST['mediado']; + + $opened_tab = $_REQUEST['tab_details']; + if (!$opened_tab) $opened_tab = 'view'; + if ($_REQUEST['edit']) $opened_tab = 'edit'; + if ($do == 'restore') $opened_tab = 'view'; + + media_tabs_details($image, $opened_tab); + + if ($opened_tab == 'view') { + echo '<div class="mediamanager-tab-detail-view" id="mediamanager__details">'; + media_tab_view($image, $NS, $AUTH, $rev); + echo '</div>'; + + } elseif ($opened_tab == 'edit') { + echo '<div class="mediamanager-tab-detail-edit" id="mediamanager__details">'; + media_tab_edit($image, $NS, $AUTH); + echo '</div>'; + + } elseif ($opened_tab == 'history') { + echo '<div class="mediamanager-tab-detail-history" id="mediamanager__details">'; + media_tab_history($image,$NS,$AUTH); + echo '</div>'; + } +} + +/** * prints the namespace tree in the mediamanger popup * * Only allowed in mediamanager.php * * @author Andreas Gohr <andi@splitbrain.org> */ -function tpl_mediaTree(){ +function tpl_mediaTree($fullscreen = false){ global $NS; - ptln('<div id="media__tree">'); media_nstree($NS); ptln('</div>'); @@ -1357,6 +1439,47 @@ function tpl_getFavicon($abs=false) { return DOKU_TPL.'images/favicon.ico'; } +/** + * Prints full-screen media manager + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function tpl_media() { + // + 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 '<div class="mediamanager" id="id-mediamanager">'; + echo '<div class="mediamanager-slider" id="id-mediamanager-layout">'; + echo '<div id="id-mediamanager-layout-namespaces" class="layout" style="width: 25%;">'; + html_msgarea(); + echo '<div class="mediamanager-tabs">'; + echo '<a href="#" class="selected">'.hsc($lang['namespaces']).'</a>'; + echo '<div class="clearer"></div>'; + echo '</div>'; + echo '<div class="background-container">'; + echo hsc($lang['namespaces']); + echo '</div>'; + echo '<div class="scroll-container">'; + tpl_mediaTree(true); + echo '</div>'; + echo '</div>'; + echo '<div id="mediamanager__layout_list" class="layout" style="width: 40%;">'; + tpl_fileList(); + echo '</div>'; + echo '<div id="mediamanager__layout_detail" class="layout" style="width: 30%;">'; + tpl_fileDetails($image, $rev); + echo '</div>'; + echo '<div class="clearer"></div>'; + echo '</div>'; + echo '</div>'; +} //Setup VIM: ex: et ts=4 : diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php index 1056a05f8..59953ddc3 100644 --- a/lib/exe/ajax.php +++ b/lib/exe/ajax.php @@ -210,7 +210,31 @@ function ajax_medialist(){ global $NS; $NS = $_POST['ns']; - tpl_mediaContent(true); + if ($_POST['do'] == 'media') { + tpl_fileList(); + } else { + tpl_mediaContent(true); + } +} + +/** + * Return the content of the right column + * (image details) for the Mediamanager + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +function ajax_mediadetails(){ + global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen; + $fullscreen = true; + require_once(DOKU_INC.'lib/exe/mediamanager.php'); + + if ($_REQUEST['image']) $image = cleanID($_REQUEST['image']); + if (isset($IMG)) $image = $IMG; + if (isset($JUMPTO)) $image = $JUMPTO; + if (isset($REV) && !$JUMPTO) $rev = $REV; + + html_msgarea(); + tpl_fileDetails($image, $rev); } /** diff --git a/lib/exe/fetch.php b/lib/exe/fetch.php index 3ad4f1937..143d40f22 100644 --- a/lib/exe/fetch.php +++ b/lib/exe/fetch.php @@ -20,6 +20,10 @@ $CACHE = calc_cache($_REQUEST['cache']); $WIDTH = (int) $_REQUEST['w']; $HEIGHT = (int) $_REQUEST['h']; + $REV = (int) @$_REQUEST['rev']; + //sanitize revision + $REV = preg_replace('/[^0-9]/','',$REV); + list($EXT,$MIME,$DL) = mimetype($MEDIA,false); if($EXT === false){ $EXT = 'unknown'; @@ -28,7 +32,7 @@ } // check for permissions, preconditions and cache external files - list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE); + list($STATUS, $STATUSMESSAGE) = checkFileStatus($MEDIA, $FILE, $REV); // prepare data for plugin events $data = array('media' => $MEDIA, @@ -147,7 +151,7 @@ function sendFile($file,$mime,$dl,$cache){ * @param $file reference to the file variable * @returns array(STATUS, STATUSMESSAGE) */ -function checkFileStatus(&$media, &$file) { +function checkFileStatus(&$media, &$file, $rev='') { global $MIME, $EXT, $CACHE; //media to local file @@ -172,7 +176,7 @@ function checkFileStatus(&$media, &$file) { if(auth_quickaclcheck(getNS($media).':X') < AUTH_READ){ return array( 403, 'Forbidden' ); } - $file = mediaFN($media); + $file = mediaFN($media, $rev); } //check file existance diff --git a/lib/exe/mediamanager.php b/lib/exe/mediamanager.php index 02fde5a8d..939b5a053 100644 --- a/lib/exe/mediamanager.php +++ b/lib/exe/mediamanager.php @@ -35,7 +35,7 @@ $AUTH = auth_quickaclcheck("$NS:*"); // do not display the manager if user does not have read access - if($AUTH < AUTH_READ) { + if($AUTH < AUTH_READ && !$fullscreen) { header('HTTP/1.0 403 Forbidden'); die($lang['accessdenied']); } @@ -76,10 +76,20 @@ } // handle meta saving - if($IMG && $_REQUEST['do']['save']){ + if($IMG && @array_key_exists('save', $_REQUEST['do'])){ $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); } + if($IMG && ($_REQUEST['mediado'] == 'save' || @array_key_exists('save', $_REQUEST['mediado']))) { + $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); + } + + if ($_REQUEST['rev']) $REV = (int) $_REQUEST['rev']; + + if($_REQUEST['mediado'] == 'restore'){ + $JUMPTO = media_restore($_REQUEST['image'], $REV, $AUTH); + } + // handle deletion if($DEL) { $res = 0; @@ -88,7 +98,7 @@ } if ($res & DOKU_MEDIA_DELETED) { $msg = sprintf($lang['deletesucc'], noNS($DEL)); - if ($res & DOKU_MEDIA_EMPTY_NS) { + if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) { // current namespace was removed. redirecting to root ns passing msg along send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='. rawurlencode($msg).'&edid='.$_REQUEST['edid']); @@ -102,9 +112,11 @@ msg(sprintf($lang['deletefail'],noNS($DEL)),-1); } } - // finished - start output - header('Content-Type: text/html; charset=utf-8'); - include(template('mediamanager.php')); + + if (!$fullscreen) { + header('Content-Type: text/html; charset=utf-8'); + include(template('mediamanager.php')); + } /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ diff --git a/lib/images/icon-file.png b/lib/images/icon-file.png Binary files differnew file mode 100644 index 000000000..d350c8c31 --- /dev/null +++ b/lib/images/icon-file.png diff --git a/lib/images/icon-list.png b/lib/images/icon-list.png Binary files differnew file mode 100644 index 000000000..ecfeed92d --- /dev/null +++ b/lib/images/icon-list.png diff --git a/lib/images/icon-sort.png b/lib/images/icon-sort.png Binary files differnew file mode 100644 index 000000000..c6403dd3c --- /dev/null +++ b/lib/images/icon-sort.png diff --git a/lib/images/icon-thumb.png b/lib/images/icon-thumb.png Binary files differnew file mode 100644 index 000000000..ccc7a101d --- /dev/null +++ b/lib/images/icon-thumb.png 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 diff --git a/lib/scripts/media.js b/lib/scripts/media.js index f7e78c747..3f263f42a 100644 --- a/lib/scripts/media.js +++ b/lib/scripts/media.js @@ -60,6 +60,20 @@ var dw_mediamanager = { DOKU_BASE + 'lib/images/plus.gif'); }}); $tree.delegate('a', 'click', dw_mediamanager.list); + + 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); + + jQuery('#mediamanager__layout_detail').delegate('#mediamanager__tabs_details a', 'click', dw_mediamanager.details) + .delegate('#mediamanager__btn_update', 'submit', dw_mediamanager.list) + .delegate('#page__revisions', 'submit', dw_mediamanager.details) + .delegate('#page__revisions a', 'click', dw_mediamanager.details) + .delegate('#mediamanager__save_meta', 'submit', dw_mediamanager.details) + .delegate('#mediamanager__btn_delete', 'submit', dw_mediamanager.details) + .delegate('#mediamanager__btn_restore', 'submit', dw_mediamanager.details); + }, /** @@ -219,22 +233,128 @@ var dw_mediamanager = { * @author Pierre Spring <pierre.spring@caillou.ch> */ list: function (event) { - var $link, $content; + var $link, $content, params; + $link = jQuery(this); event.preventDefault(); jQuery('div.success, div.info, div.error, div.notify').remove(); - $link = jQuery(this); - $content = jQuery('#media__content'); - $content.html('<img src="' + DOKU_BASE + 'lib/images/loading.gif" alt="..." class="load" />'); + if (document.getElementById('media__content')) { + //popup + $content = jQuery('#media__content'); + $content.html('<img src="' + DOKU_BASE + 'lib/images/loading.gif" alt="..." class="load" />'); + + } else { + //fullscreen media manager + $content = jQuery('#mediamanager__layout_list'); + + 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('<img src="' + DOKU_BASE + 'lib/images/loading.gif" alt="..." class="load" />'); + } + + params = ''; + + if ($link[0].search) { + params = $link[0].search.substr(1)+'&call=medialist'; + } else if ($link[0].action) { + params = dw_mediamanager.form_params($link)+'&call=medialist'; + } // fetch the subtree + dw_mediamanager.update_content($content, params); + + }; + + /** + * Returns form parameters + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ + 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; + }, + + /** + * Changes view of media files list + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ + list_view: function (event) { + var $link, $content; + $link = jQuery(this); + + event.preventDefault(); + + $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'); + } + }, + + /** + * Lists the content of the right column (image details) using AJAX + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ + details: function (event) { + 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; + + $content = $('#mediamanager__layout_detail'); + jQuery('.scroll-container', $content).html('<img src="' + DOKU_BASE + 'lib/images/loading.gif" alt="..." class="load" />'); + + params = ''; + + if ($link[0].search) { + params = $link[0].search.substr(1)+'&call=mediadetails'; + } else { + params = dw_mediamanager.form_params($link)+'&call=mediadetails'; + } + + dw_mediamanager.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 = jQuery('a.files'); + params1 = $link1[0].search.substr(1)+'&call=medialist'; + $content1 = jQuery('#mediamanager__layout_list'); + jQuery('.scroll-container', $content1).html('<img src="' + DOKU_BASE + 'lib/images/loading.gif" alt="..." class="load" />'); + + dw_mediamanager.update_content($content1, params1); + } + }, + + update_content: function ($content, params) { jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', - $link[0].search.substr(1)+'&call=medialist', + params, function (data) { - $content.html(data); + content.html(data); dw_mediamanager.prepare_content($content); dw_mediamanager.updatehide(); }, diff --git a/lib/tpl/default/design.css b/lib/tpl/default/design.css index 1fdf2bfac..1dee4dc69 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 __border__; + padding-bottom: 10px; + margin-bottom: 10px; +} + +div.dokuwiki div.changestypenav label { + padding-right: 10px; +} + /* --------------- Links ------------------ */ div.dokuwiki a:link, diff --git a/lib/tpl/default/detail.php b/lib/tpl/default/detail.php index 4f42b116e..f7bb37a25 100644 --- a/lib/tpl/default/detail.php +++ b/lib/tpl/default/detail.php @@ -52,30 +52,23 @@ if (!defined('DOKU_INC')) die(); <dl class="img_tags"> <?php - $t = tpl_img_getTag('Date.EarliestTime'); - if($t) print '<dt>'.$lang['img_date'].':</dt><dd>'.dformat($t).'</dd>'; - - $t = tpl_img_getTag('File.Name'); - if($t) print '<dt>'.$lang['img_fname'].':</dt><dd>'.hsc($t).'</dd>'; - - $t = tpl_img_getTag(array('Iptc.Byline','Exif.TIFFArtist','Exif.Artist','Iptc.Credit')); - if($t) print '<dt>'.$lang['img_artist'].':</dt><dd>'.hsc($t).'</dd>'; - - $t = tpl_img_getTag(array('Iptc.CopyrightNotice','Exif.TIFFCopyright','Exif.Copyright')); - if($t) print '<dt>'.$lang['img_copyr'].':</dt><dd>'.hsc($t).'</dd>'; - - $t = tpl_img_getTag('File.Format'); - if($t) print '<dt>'.$lang['img_format'].':</dt><dd>'.hsc($t).'</dd>'; - - $t = tpl_img_getTag('File.NiceSize'); - if($t) print '<dt>'.$lang['img_fsize'].':</dt><dd>'.hsc($t).'</dd>'; - - $t = tpl_img_getTag('Simple.Camera'); - if($t) print '<dt>'.$lang['img_camera'].':</dt><dd>'.hsc($t).'</dd>'; - - $t = tpl_img_getTag(array('IPTC.Keywords','IPTC.Category','xmp.dc:subject')); - if($t) print '<dt>'.$lang['img_keywords'].':</dt><dd>'.hsc($t).'</dd>'; - + $config_files = getConfigFiles('mediameta'); + foreach ($config_files as $config_file) { + if(@file_exists($config_file)) include($config_file); + } + + 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 '<dt>'.$lang[$tag[1]].':</dt><dd>'; + if ($tag[2] == 'date') echo dformat($value); + else echo hsc($value); + echo '</dd>'; + } + } ?> </dl> <?php //Comment in for Debug// dbg(tpl_img_getTag('Simple.Raw'));?> 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(); </div> <div class="bar-right" id="bar__bottomright"> <?php tpl_button('subscribe')?> + <?php tpl_button('media')?> <?php tpl_button('admin')?> <?php tpl_button('profile')?> <?php tpl_button('login')?> diff --git a/lib/tpl/default/mediamanager.css b/lib/tpl/default/mediamanager.css new file mode 100644 index 000000000..eea62ea46 --- /dev/null +++ b/lib/tpl/default/mediamanager.css @@ -0,0 +1,247 @@ +.mediamanager { + width: 100%; + overflow-y: auto; +} + +.mediamanager .mediamanager-slider { + width: auto; +} + +.mediamanager .mediamanager-slider .layout { + float: left; + margin-left: 5px; + margin-right: 5px; +} + +.mediamanager .scroll-container { + /*height: 0px;*/ + overflow-y: auto; + overflow-x: hidden; + padding: 0; + margin: 0; + text-align: left; +} + +.background-container { + background-color: __background_alt__; + margin-bottom: 10px; + padding: 10px; + text-align: left; +} + +.mediamanager-link-thumbnails { + background: url('../../images/icon-thumb.png') 0 -4px no-repeat; + padding-left: 30px; + display: block; + float: left; + width: 0; + overflow: hidden; +} + +.mediamanager-link-list { + background: url('../../images/icon-list.png') 0 -4px no-repeat; + padding-left: 30px; + display: block; + float: left; + width: 0; + overflow: hidden; +} + +.mediamanager-block-sort { + background: url('../../images/icon-sort.png') 0 -4px no-repeat; + padding-left: 30px; + display: block; + float: right; +} + +.mediamanager-link-thumbnails:hover, +.mediamanager-link-list:hover { + width: auto; + margin-right: 10px; +} + +.mediamanager-tabs a { + font-weight: bold; + display: block; + float: left; + padding: 10px; + padding-bottom: 5px; + padding-top: 5px; + + margin-right: 2px; + + -moz-border-radius-topright: 10px; + -webkit-border-top-right-radius: 10px; + -moz-border-radius-topleft: 10px; + -webkit-border-top-left-radius: 10px; + border-top-right-radius: 10px; + border-top-left-radius: 10px; +} + +.mediamanager-tabs .selected { + background-color: __background_alt__; +} + +.mediamanager-tabs a:hover { + background-color: __background_alt__; + opacity: 0.5; +} + +.mediamanager-table td { + padding: 5px; +} + +.mediamanager-table tr:nth-child(2n+1){ + background-color: __background_neu__; +} + +.mediamanager-table { + background: expression(this.rowIndex % 2 == 0 ? "#ffffff" : "#f5f5f5"); +} + +.mediamanager-table tr:hover { + background-color: __background_alt__; +} + +form.meta textarea.edit { + height: 8em; + width: 95%; + 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; + zoom: 1; + position: relative; +} +* html .mediamanager-thumbs li { + display: inline; +} +*+html .mediamanager-thumbs li { + display: inline; + _height: 130px; +} + +.mediamanager-thumbs li .image { + width: 100%; + height: 90px; + display: block; + overflow: hidden; +} + +.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] { + display: none; + float: left; + margin: 3px; +} + +.mediamanager-thumbs li:hover input[type=checkbox], +.mediamanager-thumbs li input[type=checkbox]:checked { + display: block; +} + +.mediamanager-list li { + list-style: none; + display: block; + position: relative; + max-height: 50px; + margin: 0; + margin-bottom: 3px; +} + +.mediamanager-list li:nth-child(2n+1) { + background-color: __background_neu__; +} + +.mediamanager-list li .image { + width: 10%; + display: block; + overflow: hidden; + float: left; + height: 40px; +} + +.mediamanager-list li .image img { + width: 100%; +} + +.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] { + display: none; + float: left; + margin: 3px; +} + +.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; + color: black !important; +} +* html .mediamanager-table-50 li { + display: inline; +} + +.mediamanager-preview { + margin-bottom: 5px; +} + +.idx .selected { + color: red !important; +}
\ No newline at end of file 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 |