[Home]WikiPatches/GetAdminBar

UseModWiki | WikiPatches | RecentChanges | Preferences

Produces an administration bar similar to the GetGotobar. I know nothing about perl so I did everything by imitation. Use at your own risk. It works great for me.


This patch has been added to the 1.0 version of UseModWiki. Thanks to ElMoro and the others below who helped with the code. --CliffordAdams

ergo, NextRelease

Instructions for the clueless:

1. Include the following subroutines just before the comment #END_OF_BROWSE_CODE (see /Where, heading 3)

 sub GetLockLink {
   my ($id, $name) = @_;
   if ($FreeLinks) {
     $id = &FreeToNormal($id);
     $name =~ s/_/ /g;
   }
   return &ScriptLink("action=pagelock&set=1&id=$id", $name);
 }

 sub GetUnLockLink {
   my ($id, $name) = @_;
   if ($FreeLinks) {
     $id = &FreeToNormal($id);
     $name =~ s/_/ /g;
   }
   return &ScriptLink("action=pagelock&set=0&id=$id", $name);
 }

 sub GetAdminBar {
   my ($id) = @_;
   my ($main, $result);
   my ($fname);
   $result .= 'Administration: ';
        if (-f &GetLockedPageFile($id))   { 
          $result .= &GetUnLockLink($id,T('Unlock page'));
        }
        else  {
            $result .= &GetLockLink($id,T('Lock page'));
        }
        $result .=" ";
        $result .= &ScriptLink("action=editbanned",T("Edit Banned List"));
        $result .=" "; $result .= &ScriptLink("action=maintain",T("Run Maintenance"));
        $result .=" "; $result .= &ScriptLink("action=editlinks",T("Edit/Rename pages")); 

        $fname = "$DataDir/noedit";
        if (-f $fname) {
          $result .=" "; $result .= &ScriptLink("action=editlock&set=0",T("Unlock site")); 
        } else {
          $result .=" "; $result .= &ScriptLink("action=editlock&set=1",T("Lock site"));
        }
  return $result;
 }
2. The previous code will not actually do anything to your output. To see an admin link bar you may want to include the four lines below between ####begin and ###end almost at the end of sub GetFooterText between
 $result .= '<TR><TD>' . &GetSearchForm()  ; 
and before
 if ($DataDir =~ m|/tmp/|) { 

(This will put your adminbar at the bottom of the page below the search form. Note you don't have to include them exactly there)

 ##### begin 
 if (&UserIsAdmin()) {
        $result .= '<BR>';
   $result .= &GetAdminBar($id);
 }
 ##### End

Questions and Comments

not bad at all, & congrats on fixing it the same day -RiVer

A Because you don't necessarily want the admin functions together with the goto links. I personally place it at the bottom of the page so that my page looks as close as possible to the page the users see. Also the Gotobar would be too long. --ElMoro

I have no objections to the config var but I'll let the project administrator implement this as I am not sure he is willing to include the patch. --ElMoro


Hi - I just added a couple of PRE tags around the code for the truely hopeless (eg: Me) who copy and paste from the rendered page and wonder why it's complaining about question-marks.... =)

Cheers! -[Trav]


To have bars within the admin bar use:

sub GetAdminBar {
    my ($id) = @_;
    my ($main, $result);
    my ($fname);
    $result .= 'Administration: ';
    if (-f &GetLockedPageFile($id))   {
        $result .= &GetUnLockLink($id,T('Unlock page'));
    }
    else {
        $result .= &GetLockLink($id,T('Lock page'));
    }
$result .= " | " . &ScriptLink("action=editbanned",T("Edit Banned List"));
$result .= " | " . &ScriptLink("action=maintain",T("Run Maintenance"));
$result .= " | " . &ScriptLink("action=editlinks",T("Edit/Rename pages"));
    $fname = "$DataDir/noedit";
    if (-f $fname) {
$result .= " | " . &ScriptLink("action=editlock&set=0",T("Unlock site"));
    } else {
$result .=" | " . &ScriptLink("action=editlock&set=1",T("Lock site"));
    }
    return $result;
}

-- Ralf Baerwaldt


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 2, 2009 11:26 am by JuanmaMP (diff)
Search: