summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKate Arzamastseva <pshns@ukr.net>2011-08-03 15:19:52 +0300
committerKate Arzamastseva <pshns@ukr.net>2011-08-03 15:19:52 +0300
commit92cac9a97ee63d9c3c9bb8b0da1e3eb0604ba04f (patch)
tree95598bccc9a68bb5e4e458fbf7d579e4e70274f9
parente5d185e17e613b7a9737fc76310f1e78008f71ec (diff)
downloadrpg-92cac9a97ee63d9c3c9bb8b0da1e3eb0604ba04f.tar.gz
rpg-92cac9a97ee63d9c3c9bb8b0da1e3eb0604ba04f.tar.bz2
issue #38 diff links only if diff available; deleted files
-rw-r--r--inc/html.php30
-rw-r--r--inc/media.php31
-rw-r--r--inc/template.php5
-rw-r--r--lib/exe/ajax.php2
4 files changed, 41 insertions, 27 deletions
diff --git a/inc/html.php b/inc/html.php
index 2b4e2835e..c58fd64ad 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -695,20 +695,28 @@ function html_recent($first=0, $show_changes='both'){
$form->addElement(form_makeCloseTag('span'));
if ($recent['media']) {
- $href = media_managerURL(array('tab_details' => 'history',
- 'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
+ $diff = (count(getRevisions($recent['id'], 0, 1, 8192, true)) && @file_exists(mediaFN($recent['id'])));
+ if ($diff) {
+ $href = media_managerURL(array('tab_details' => 'history',
+ 'mediado' => 'diff', 'image' => $recent['id'], 'ns' => getNS($recent['id'])), '&');
+ }
} else {
$href = wl($recent['id'],"do=diff", false, '&');
}
- $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
- $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'));
+
+ if ($recent['media'] && !$diff) {
+ $form->addElement('<img src="'.DOKU_BASE.'lib/images/blank.gif" width="15" height="11" alt="" />');
+ } else {
+ $form->addElement(form_makeOpenTag('a', array('class' => 'diff_link', 'href' => $href)));
+ $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'));
+ }
if ($recent['media']) {
$href = media_managerURL(array('tab_details' => 'history',
diff --git a/inc/media.php b/inc/media.php
index 8c23dc115..c009785fd 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -313,7 +313,7 @@ function media_save($file, $id, $ow, $auth, $move) {
}
}
- global $lang;
+ global $lang, $conf;
// get filename
$id = cleanID($id,false,true);
@@ -603,7 +603,7 @@ function media_tabs_details($image, $selected=false){
media_tab(media_managerURL(array('tab_details' => 'view')), 'view', $lang['media_viewtab'], $selected);
list($ext, $mime) = mimetype($image);
- if ($mime == 'image/jpeg') {
+ if ($mime == 'image/jpeg' && @file_exists(mediaFN($image))) {
media_tab(media_managerURL(array('tab_details' => 'edit')), 'edit', $lang['media_edittab'], $selected);
}
if ($conf['mediarevisions']) {
@@ -867,12 +867,15 @@ function media_preview_buttons($image, $auth, $rev=false) {
}
$link = ml($image,$more,true,'&');
- // view original file button
- $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank'));
- $form->addElement(form_makeButton('submit','',$lang['mediaview']));
- $form->printForm();
+ if (@file_exists(mediaFN($image, $rev))) {
+
+ // view original file button
+ $form = new Doku_Form(array('action'=>$link, 'target'=>'_blank'));
+ $form->addElement(form_makeButton('submit','',$lang['mediaview']));
+ $form->printForm();
+ }
- if($auth >= AUTH_DELETE && !$rev){
+ if($auth >= AUTH_DELETE && !$rev && @file_exists(mediaFN($image))){
// delete button
$form = new Doku_Form(array('id' => 'mediamanager__btn_delete',
@@ -892,7 +895,7 @@ function media_preview_buttons($image, $auth, $rev=false) {
$form->printForm();
}
- if($auth >= AUTH_DELETE && $rev && $conf['mediarevisions']){
+ if($auth >= AUTH_DELETE && $rev && $conf['mediarevisions'] && @file_exists(mediaFN($image, $rev))){
// restore button
$form = new Doku_Form(array('id' => 'mediamanager__btn_restore',
@@ -916,7 +919,7 @@ function media_preview_buttons($image, $auth, $rev=false) {
* @return array
*/
function media_image_preview_size($image, $rev, $meta, $size = 500) {
- if (!preg_match("/\.(jpe?g|gif|png)$/", $image)) return false;
+ if (!preg_match("/\.(jpe?g|gif|png)$/", $image) || !file_exists(mediaFN($image, $rev))) return false;
$info = getimagesize(mediaFN($image, $rev));
$w = (int) $info[0];
@@ -1206,7 +1209,8 @@ function media_image_diff($image, $l_rev, $r_rev, $meta, $type) {
function media_restore($image, $rev, $auth){
global $conf;
if ($auth < AUTH_DELETE || !$conf['mediarevisions']) return false;
- if (!$image || !file_exists(mediaFN($image))) return false;
+ $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')));
+ if (!$image || (!file_exists(mediaFN($image)) && !$removed)) return false;
if (!$rev || !file_exists(mediaFN($image, $rev))) return false;
list($iext,$imime,$dl) = mimetype($image);
$res = media_upload_finish(mediaFN($image, $rev),
@@ -1526,16 +1530,17 @@ function media_managerURL($params=false, $amp='&amp;', $abs=false) {
* @author Kate Arzamastseva <pshns@ukr.net>
*/
function media_uploadform($ns, $auth, $fullscreen = false){
- global $lang;
+ global $lang, $conf;
if($auth < AUTH_UPLOAD) {
echo '<div class="nothing">'.$lang['media_perm_upload'].'</div>'.NL;
return;
}
+ $auth_ow = (($conf['mediarevisions']) ? AUTH_UPLOAD : AUTH_DELETE);
$update = false;
$id = '';
- if ($auth >= AUTH_DELETE && $fullscreen && $_REQUEST['mediado'] == 'update') {
+ if ($auth >= $auth_ow && $fullscreen && $_REQUEST['mediado'] == 'update') {
$update = true;
$id = cleanID($_REQUEST['image']);
}
@@ -1562,7 +1567,7 @@ function media_uploadform($ns, $auth, $fullscreen = false){
$form->addElement(form_makeButton('submit', '', $lang['btn_upload']));
$form->addElement(form_makeCloseTag('p'));
- if($auth >= AUTH_DELETE){
+ if($auth >= $auth_ow){
$form->addElement(form_makeOpenTag('p'));
$attrs = array();
if ($update) $attrs['checked'] = 'checked';
diff --git a/inc/template.php b/inc/template.php
index e6673c3f3..04e3e79cc 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -1174,7 +1174,8 @@ function tpl_fileList(){
function tpl_fileDetails($image, $rev){
global $AUTH, $NS, $conf;
- if (!$image || !file_exists(mediaFN($image))) return '';
+ $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions']);
+ if (!$image || (!file_exists(mediaFN($image)) && !$removed)) return '';
if ($rev && !file_exists(mediaFN($image, $rev))) $rev = false;
if (isset($NS) && getNS($image) != $NS) return '';
$do = $_REQUEST['mediado'];
@@ -1201,7 +1202,7 @@ function tpl_fileDetails($image, $rev){
media_tab_view($image, $NS, $AUTH, $rev);
echo '</div>';
- } elseif ($opened_tab == 'edit') {
+ } elseif ($opened_tab == 'edit' && !$removed) {
echo '<div id="mediamanager__details">';
media_tab_edit($image, $NS, $AUTH);
echo '</div>';
diff --git a/lib/exe/ajax.php b/lib/exe/ajax.php
index 300fb8acb..20fc99de4 100644
--- a/lib/exe/ajax.php
+++ b/lib/exe/ajax.php
@@ -222,7 +222,7 @@ function ajax_medialist(){
* @author Kate Arzamastseva <pshns@ukr.net>
*/
function ajax_mediadetails(){
- global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen;
+ global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf;
$fullscreen = true;
require_once(DOKU_INC.'lib/exe/mediamanager.php');