Personal tools
shadowfax.org.uk logo
Views

MediaWiki

From Shadowfax

Jump to: navigation, search

Skinning MediaWiki

Like cats there are many ways! MediaWiki may be simplicity itself to contribute to and modify as a punter, however as designer or administrator things get a little more difficult. Skins for MediaWiki are controlled by a number of files, specifically the skin's PHP file and CSS (eg MonoBook.php and main.css). However, as a trap to the unwary there are also a number of CSS files which contain specific browser fixes. In my view desperately bad practice and massively confusing as it means that when you make a css change in main.css it can sometimes not work (or even half work) due to a patch to the same named element in a browser specific CSS file. When basing a skin on Monobook it is worth commenting out all the browser specific fix files to ensure that they are not stitching you up!

I've been asked how I disabled the view source tab for anonymous users - and I must confess it took me a while to remember. However, the key to it lies with the template skin file (eg MonoBook.php). In this there is a block of code that loops through the content_actions array. I simply enclosed this inside a test to see if the user was logged in.

<?php if($this->data['loggedin']==1) {
        echo "<ul>";
        foreach($this->data['content_actions'] as $key => $tab) {
          echo '
         <li id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
          if( $tab['class'] ) {
            echo ' class="'.htmlspecialchars($tab['class']).'"';
          }
          echo '><a href="'.htmlspecialchars($tab['href']).'"';
          # We don't want to give the watch tab an accesskey if the
          # page is being edited, because that conflicts with the
          # accesskey on the watch checkbox.  We also don't want to
          # give the edit tab an accesskey, because that's fairly su-
          # perfluous and conflicts with an accesskey (Ctrl-E) often
          # used for editing in Safari.
           if( in_array( $action, array( 'edit', 'submit' ) )
           && in_array( $key, array( 'edit', 'watch', 'unwatch' ))) {
             echo $skin->tooltip( "ca-$key" );
           } else {
             echo $skin->tooltipAndAccesskey( "ca-$key" );
           }
           echo '>'.htmlspecialchars($tab['text']).'</a></li>';
        }
        echo "</ul>";
       }
 ?>

It is also advisable to disable edit access by adding the following line to LocalSettings.php

$wgGroupPermissions['*']['edit']             = false;

External Links

Some hints and tips regarding the usage of MediaWiki

Configuration

Developer Resources

Community

Misc



Leave your comment

Menu