Code Erweiterung

lib\tpl\arctic\main.php

Nun störte mich noch der Backlink auf dem aktuellen Namen oben links. Weg damit ("do=backlink" wird ersatzlos gestrichen).

  <div class="stylehead">
    <div class="header">
      <div class="pagename">
        [[<?php tpl_link(wl($ID,''),tpl_pagetitle($ID,true))?>]]
      </div>
      <div class="logo">
        <?php tpl_link(wl(),$conf['title'],'name="dokuwiki__top" accesskey="h" title="[ALT+H]"')?>
      </div>
    </div>


Nachdem nun alles soweit OK war, hat mich i.M. nur noch gestört, das der Gast meiner Seite, der nur lesen darf, immer noch die Links "Seite anzeigen" und "Ältere Versionen" angezeigt bekam.

Doch wie bekomme ich die weg….?

Also nochmal ran an den Code.

lib\tpl\arctic\main.php

Angezeigt (oder auch nicht) werden die Buttons oder Actionlinks in "tpl_button" (bzw "tpl_actionlink") in "inc/template.php". Da ich den DokuWiki source nicht verändern möchte, erstelle ich mir halt eigene Funktionen und rufe meine Funktion "tpl_Logon_button" bzw "tpl_Logon_actionlink" statt der originalen "tpl_button" bzw "tpl_actionlink" auf.

D.h. aus

          switch(tpl_getConf('wiki_actionlinks')) {
            case('buttons'):
              tpl_button('edit');
              tpl_button('history');     
              break;
            case('links'):
              tpl_actionlink('edit');
              tpl_actionlink('history');
              break;
              } 

wurde

          switch(tpl_getConf('wiki_actionlinks')) {
            case('buttons'):
              tpl_Logon_button('edit');
              tpl_Logon_button('history');     
              break;
            case('links'):
              tpl_Logon_actionlink('edit');
              tpl_Logon_actionlink('history');
              break;
          } 

Achtung, das gibts zweimal im code !!

lib\tpl\arctic\tpl_functions.php

Nun braucht es noch die neuen Funktionen. Also:

Für die Buttons:

function tpl_Logon_button($type){
// under some circumstances, the link should not be visible
switch($type){
  case 'edit':
    if ($_SERVER['REMOTE_USER']){
      tpl_button($type);
    }else{
       if(tpl_getConf('logoffShowEdit') == 1){
         tpl_button($type);
       }
    }
    return true;
  case 'history':
    if ($_SERVER['REMOTE_USER']){
      tpl_button($type);
    }else{
       if(tpl_getConf('logoffShowHistory') == 1){
         tpl_button($type);
       }
    }
    return true;
  default:
    tpl_button($type);
    return true;
}

}

Für die Actionlinks:

function tpl_Logon_actionlink($type,$pre='',$suf=''){
// under some circumstances, the link should not be visible
switch($type){
  case 'edit':
    if ($_SERVER['REMOTE_USER']){
      tpl_actionlink($type, $pre, $suf);
    }else{
       if(tpl_getConf('logoffShowEdit') == 1){
         tpl_actionlink($type, $pre, $suf);
       }
    }
    return true;
  case 'history':
    if ($_SERVER['REMOTE_USER']){
      tpl_actionlink($type, $pre, $suf);
    }else{
       if(tpl_getConf('logoffShowHistory') == 1){
         tpl_actionlink($type, $pre, $suf);
       }
    }
    return true;
  default:
    tpl_actionlink($type, $pre, $suf);
    return true;
}

}

Im Prinzip also nur eine Art Wrapper um die original Funktionen.

Konfiguration Erweiterung

Damit meine Code-Änderungen auch konfiguriert werden können, müssen die neuen Flags natürlich noch definiert werden.

lib\tpl\arctic\conf\metadata.php

Dies erweitert die "arctic" Konfiguration um die beiden neuen Flags.

$meta['logoffShowEdit']           = array('onoff');
$meta['logoffShowHistory']        = array('onoff');

lib\tpl\arctic\conf\default.php

Dies setzt die Standardwerte in der "arctic" Konfiguration für die beiden neuen Flags.

$conf['logoffShowEdit']             = 0;                            // show EDIT button/link for not logged in users
$conf['logoffShowHistory']          = 0;                            // show HISTORY button/link for not logged in users

lib\tpl\arctic\conf\lang\de\settings.php

Nun müssen natürlich noch die sprachspezifischen Labels erfasst werden. Hier für Deutsch (de), aber muss/sollte natürlich für alle Sprachdateien hinzugefügt werden.

$lang['logoffShowEdit']                 = 'Zeige [Edit] button/link für nicht angemeldete Benutzer';
$lang['logoffShowHistory']              = 'Zeige [History] button/link für nicht angemeldete Benutzer';

Das sieht dann etwa so aus:

projekt/dokuwiki/arcticcode.txt · Zuletzt geändert: 2008/01/15 16:51 von pramach