diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index bd4eccfb5c64a7cc08e87761f44059b8517b1842..47b427fa347d6214ff52bfb848089fe758b37c28 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -37,6 +37,7 @@ $conf['camelcase'] = 0; //Use CamelCase for linking? (I don't $conf['deaccent'] = 1; //convert accented chars to unaccented ones in pagenames? $conf['useheading'] = 0; //use the first heading in a page as its name $conf['refcheck'] = 1; //check references before deleting media files +$conf['refshow'] = 0; //show where media files are still used $conf['refcount'] = 5; //search only no of references to satisfy the refcheck /* Antispam Features */ diff --git a/inc/html.php b/inc/html.php index 785172b84b4d527d9dc9e731c576d77cb6c6f750..3c724865dc20092dbe75a459b41de70bf622d6ff 100644 --- a/inc/html.php +++ b/inc/html.php @@ -171,7 +171,35 @@ function html_topbtn(){ } /** - * Displays a button (using it's own form) + * Just the back to media window button in its own form + * + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> + */ +function html_backtomedia_button($params,$akey=''){ + global $conf; + global $lang; + + $ret = '<form class="button" method="get" action="'.DOKU_BASE.'lib/exe/media.php">'; + + reset($params); + while (list($key, $val) = each($params)) { + $ret .= '<input type="hidden" name="'.$key.'" '; + $ret .= 'value="'.htmlspecialchars($val).'" />'; + } + + $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_backtomedia']).'" class="button" '; + if($akey){ + $ret .= 'title="ALT+'.strtoupper($akey).'" '; + $ret .= 'accesskey="'.$akey.'" '; + } + $ret .= '/>'; + $ret .= '</form>'; + + return $ret; +} + +/** + * Displays a button (using its own form) * * @author Andreas Gohr <andi@splitbrain.org> */ diff --git a/inc/lang/de/lang.php b/inc/lang/de/lang.php index 7e3e46469d0c0dddd9be0951cd61c27e12eb4eab..ae7932806851327e2f21c165793e0233b2dfc186 100644 --- a/inc/lang/de/lang.php +++ b/inc/lang/de/lang.php @@ -32,6 +32,7 @@ $lang['btn_admin'] = 'Admin'; $lang['btn_update'] = 'Updaten'; $lang['btn_delete'] = 'Löschen'; $lang['btn_back'] = 'Zurück'; +$lang['btn_backtomedia'] = 'Zurück zur Dateiauswahl'; $lang['loggedinas'] = 'Angemeldet als'; $lang['user'] = 'Benutzername'; @@ -77,6 +78,10 @@ $lang['mediainuse'] = 'Die Datei "%s" wurde nicht gelöscht - sie wird noch ver $lang['namespaces'] = 'Namensräume'; $lang['mediafiles'] = 'Vorhandene Dateien in'; +$lang['reference'] = 'Verwendung von'; +$lang['ref_inuse'] = 'Diese Datei kann nicht gelöscht werden, da sie noch von folgenden Seiten benutzt wird:'; +$lang['ref_hidden'] = 'Einige Verweise sind auf Seiten für die Sie keine Leseberechtigung haben.'; + $lang['hits'] = 'Treffer'; $lang['quickhits'] = 'Passende Seitennamen'; $lang['toc'] = 'Inhaltsverzeichnis'; diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 235eeff80a1db452a43a49f5974abec40c696e32..93f43d08962cdffb70f3ffd7118c76699c2e2ae3 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -31,6 +31,7 @@ $lang['btn_admin'] = 'Admin'; $lang['btn_update'] = 'Update'; $lang['btn_delete'] = 'Delete'; $lang['btn_back'] = 'Back'; +$lang['btn_backtomedia'] = 'Back to Mediafile Selection'; $lang['loggedinas'] = 'Logged in as'; $lang['user'] = 'Username'; @@ -75,6 +76,10 @@ $lang['mediainuse'] = 'The file "%s" hasn\'t been deleted - it is still in use. $lang['namespaces'] = 'Namespaces'; $lang['mediafiles'] = 'Available files in'; +$lang['reference'] = 'References for'; +$lang['ref_inuse'] = 'The file can\'t be deleted, because it\'s still used by the following pages:'; +$lang['ref_hidden'] = 'Some references are on pages you don\'t have permission to read'; + $lang['hits'] = 'Hits'; $lang['quickhits'] = 'Matching pagenames'; $lang['toc'] = 'Table of Contents'; diff --git a/inc/search.php b/inc/search.php index 0caae3d7c602e20fab7e2cb44cce130b67db6d02..e61d044913a376fb5e6a43d517b21ddb58b08d1e 100644 --- a/inc/search.php +++ b/inc/search.php @@ -355,7 +355,7 @@ function search_reference(&$data,$base,$file,$type,$lvl,$opts){ //'false' will skip subdirectories to speed search up. if(count($data) >= $conf['refcount']) return false; - $reg = '{{ *'.$opts['query'].' *(\|.*)?}}'; + $reg = '\{\{ *\:?'.$opts['query'].' *(\|.*)?\}\}'; search_regex($data,$base,$file,$reg,array($opts['query'])); return true; } diff --git a/inc/template.php b/inc/template.php index bc2bc561b2fd4fba0578dc2d08c9830dca94cc76..b37d335a8a90d08543b53d8a0f062351356157f2 100644 --- a/inc/template.php +++ b/inc/template.php @@ -247,17 +247,20 @@ function tpl_getparent($ID){ * edit - edit/create/show button * history - old revisions * recent - recent changes - * login - login/logout button - if ACL enabled - * index - The index - * admin - admin page - if enough rights - * top - a back to top button - * back - a back to parent button - if available + * login - login/logout button - if ACL enabled + * index - The index + * admin - admin page - if enough rights + * top - a back to top button + * back - a back to parent button - if available + * backtomedia - returns to the mediafile upload dialog + * after references have been displayed * * @author Andreas Gohr <andi@splitbrain.org> * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> */ function tpl_button($type){ global $ID; + global $NS; global $INFO; global $conf; @@ -294,6 +297,9 @@ function tpl_button($type){ case 'admin': if($INFO['perm'] == AUTH_ADMIN) print html_btn(admin,$ID,'',array('do' => 'admin')); + break; + case 'backtomedia': + print html_backtomedia_button(array('ns' => $NS),'b'); break; default: print '[unknown button type]'; @@ -589,7 +595,6 @@ function tpl_mediafilelist(){ $del = ''; } - if($item['isimg']){ $w = $item['info'][0]; $h = $item['info'][1]; @@ -614,6 +619,36 @@ function tpl_mediafilelist(){ ptln('</ul>',2); } +/** + * show references to a media file + * References uses the same visual as search results and share + * their CSS tags except pagenames won't be links. + * + * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> + */ +function tpl_showreferences(&$data){ + global $lang; + + $hidden=0; //count of hits without read permission + + if(count($data)){ + usort($data,'sort_search_fulltext'); + foreach($data as $row){ + if(auth_quickaclcheck($row['id']) >= AUTH_READ){ + print '<div class="search_result">'; + print '<span class="mediaref_ref">'.$row['id'].'</span>'; + print ': <span class="search_cnt">'.$row['count'].' '.$lang['hits'].'</span><br />'; + print '<div class="search_snippet">'.$row['snippet'].'</div>'; + print '</div>'; + }else + $hidden++; + } + if ($hidden){ + print '<div class="mediaref_hidden">'.$lang['ref_hidden'].'</div>'; + } + } +} + /** * Print the media upload form if permissions are correct * diff --git a/lib/exe/media.php b/lib/exe/media.php index f0d0795adee53fe9885e23ff656846f8ee813c29..27975a493286de79faae59b05479ed940b4131f5 100644 --- a/lib/exe/media.php +++ b/lib/exe/media.php @@ -41,9 +41,8 @@ } if(!count($mediareferences)){ media_delete($DEL); - }else{ - $text = str_replace('%s',noNS($DEL),$lang['mediainuse']); - msg($text,0); + }elseif(!$conf['refshow']){ + msg(str_replace('%s',noNS($DEL),$lang['mediainuse']),0); } } @@ -54,8 +53,12 @@ //start output and load template header('Content-Type: text/html; charset=utf-8'); - include(DOKU_INC.'lib/tpl/'.$conf['template'].'/media.php'); - + if($conf['refshow'] && count($mediareferences)){ + include(DOKU_INC.'lib/tpl/'.$conf['template'].'/mediaref.php'); + }else{ + include(DOKU_INC.'lib/tpl/'.$conf['template'].'/media.php'); + } + //restore old umask umask($conf['oldumask']); @@ -75,8 +78,7 @@ function media_delete($delid){ return true; } //something went wrong - $text = str_replace('%s',$file,$lang['deletefail']); - msg($text,-1); + msg(str_replace('%s',$file,$lang['deletefail']),-1); return false; } diff --git a/lib/tpl/default/layout.css b/lib/tpl/default/layout.css index fea7c58ab468363e5442d14c388ee42f5da25ce1..45fed3d49690dee74b7ac018285258b34e55d038 100644 --- a/lib/tpl/default/layout.css +++ b/lib/tpl/default/layout.css @@ -107,3 +107,27 @@ div.uploadform { padding: 0.5em; width:65%; } + +div.mediaref_head { + margin-left:0.5em; +} + +div.mediaref .search_result { + padding-left:1em; +} + +.mediaref_ref { + color:#009900; +} + +div.mediaref_hidden { + margin-top:1em; + text-align:center; + font-size:1.2em; + color:#BB0000; +} + +div.mediaref_footer { + margin-top:1em; + text-align:center; +}