Skip to content

Commit

Permalink
media history
Browse files Browse the repository at this point in the history
  • Loading branch information
akate committed Jun 14, 2011
1 parent 8e69fd3 commit dad6764
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
42 changes: 29 additions & 13 deletions inc/html.php
Expand Up @@ -472,20 +472,30 @@ function html_revisions($first=0, $media_id = false){

$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))));
'href' => $href)));
$form->addElement($id);
$form->addElement(form_makeCloseTag('a'));

$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
$form->addElement(' &ndash; ');
$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'].')');
Expand All @@ -494,10 +504,14 @@ function html_revisions($first=0, $media_id = false){
}

foreach($revisions as $rev){
$date = dformat($rev);
$info = getRevisionInfo($id,$rev,true);
if (!$media_id) $exists = page_exists($id,$rev);
else $exists = @file_exists(mediaFN($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')));
Expand All @@ -518,17 +532,19 @@ function html_revisions($first=0, $media_id = false){
$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, 'tab_details' => 'view', 'rev' => $rev));
$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,
'height' => 11,
'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')));
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{
Expand Down Expand Up @@ -556,7 +572,7 @@ function html_revisions($first=0, $media_id = false){
$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']));
html_form('revisions', $form);

print '<div class="pagenav">';
Expand Down
13 changes: 10 additions & 3 deletions inc/media.php
Expand Up @@ -366,6 +366,7 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov
io_createNamespace($id, 'media');

if($move($fn_tmp, $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.)
Expand All @@ -374,9 +375,9 @@ function media_upload_finish($fn_tmp, $fn, $id, $imime, $overwrite, $move = 'mov
media_notify($id,$fn,$imime);
// add a log entry to the media changelog
if ($overwrite) {
addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_EDIT);
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{
Expand Down Expand Up @@ -704,7 +705,12 @@ function media_tab_view($image, $ns, $auth=null) {
if ($auth >= AUTH_READ && $image) {
$info = new JpegMeta(mediaFN($image));
$w = (int) $info->getField('File.Width');
$src = ml($image);

$rev = $_REQUEST['rev'];
$more = '';
if (isset($rev)) $more = "rev=$rev";
$src = ml($image, $more);

echo '<img src="'.$src.'" alt="" width="99%" style="max-width: '.$w.'px;" />';
}
echo '</div>';
Expand Down Expand Up @@ -1005,6 +1011,7 @@ function media_managerURL($params=false, $amp='&') {
unset($gets['edit']);
unset($gets['sectok']);
unset($gets['delete']);
unset($gets['rev']);

if ($params) {
foreach ($params as $k => $v) {
Expand Down

0 comments on commit dad6764

Please sign in to comment.