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 '