diff --git a/inc/html.php b/inc/html.php index cf0b003976454cb37d9b2ddc2233e82caac431d0..809db30bdc8d07aea0db1314c5f102852e956464 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 '<div class="pagenav">'; diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index dbd3ae9be33264a7d7b0c840504916f73ec95be8..e0e2e6cf53828c3b247e0135c315077fd0e3de96 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -241,6 +241,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'; diff --git a/inc/media.php b/inc/media.php index 56f824cb627858e5b35fd0edd160781572226cc2..1bcb6a7b241f587a9d2ece85ec53e0186702cdcd 100644 --- a/inc/media.php +++ b/inc/media.php @@ -702,7 +702,9 @@ function media_tab_view($image, $ns, $auth=null) { echo '</div>'; echo '<div class="scroll-container">'; - media_preview($image, $auth); + $rev = (int) $_REQUEST['rev']; + media_preview($image, $auth, $rev); + media_details($image, $auth, $rev); echo '</div>'; echo '</div>'; } @@ -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 '<div class="mediamanager-tab-detail-history">'; echo '<div class="background-container">'; @@ -746,8 +749,14 @@ function media_tab_history($image, $ns, $auth=null) { echo '</div>'; echo '<div class="scroll-container">'; - $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 '</div>'; echo '</div>'; } @@ -757,61 +766,132 @@ function media_tab_history($image, $ns, $auth=null) { * * @author Kate Arzamastseva <pshns@ukr.net> */ -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 '<img src="'.$src.'" alt="" width="99%" style="max-width: '.$w.'px;" /><br /><br />'; + echo '<img src="'.$src.'" alt="" width="99%" style="max-width: '.$w.'px;" /><br /><br />'; - $link = ml($image,'',true); - echo $image.' <a href="'.$link.'" target="_blank"><img src="'.DOKU_BASE.'lib/images/magnifier.png" '. - 'alt="'.$lang['mediaview'].'" title="'.$lang['mediaview'].'" class="btn" /></a>'; + $link = ml($image,$more,true); + echo $image.' <a href="'.$link.'" target="_blank"><img src="'.DOKU_BASE.'lib/images/magnifier.png" '. + 'alt="'.$lang['mediaview'].'" title="'.$lang['mediaview'].'" class="btn" /></a>'; - // delete button - if($auth >= AUTH_DELETE){ - $link = media_managerURL(array('delete' => $image,'sectok' => getSecurityToken())); - echo ' <a href="'.$link.'" class="btn_media_delete" title="'.$image.'">'. - '<img src="'.DOKU_BASE.'lib/images/trash.png" alt="'.$lang['btn_delete'].'" '. - 'title="'.$lang['btn_delete'].'" class="btn" /></a>'; - } + // delete button + if($auth >= AUTH_DELETE && !$rev){ + $link = media_managerURL(array('delete' => $image,'sectok' => getSecurityToken())); + echo ' <a href="'.$link.'" class="btn_media_delete" title="'.$image.'">'. + '<img src="'.DOKU_BASE.'lib/images/trash.png" alt="'.$lang['btn_delete'].'" '. + 'title="'.$lang['btn_delete'].'" class="btn" /></a>'; + } - echo '<br /><br />'; - - $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 '<dl class="img_tags">'; - 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 '<dt>'.$lang[$tag[1]].':</dt><dd>'; - if ($tag[2] == 'text') echo hsc($value); - if ($tag[2] == 'date') echo dformat($value); - echo '</dd>'; - } +} + +/** + * Prints mediafile tags + * + * @author Kate Arzamastseva <pshns@ukr.net> + */ +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 '<dl class="img_tags">'; + 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 '<dt>'.$lang[$tag[1]].':</dt><dd>'; + if ($tag[2] == 'text') echo hsc($value); + if ($tag[2] == 'date') echo dformat($value); + echo '</dd>'; + } + echo '</dl>'; +} + +/** + * 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 <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; } - echo '</dl>'; + }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 '<table><tr><td>'; + media_preview($image, $auth, $l_rev); + echo '</td>'; + echo '<td>'; + media_preview($image, $auth, $r_rev); + echo '</td></tr><tr><td>'; + media_details($image, $auth, $l_rev); + echo '</td>'; + echo '<td>'; + media_details($image, $auth, $r_rev); + echo '</td></tr></table>'; } /** @@ -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) {