Extension:EditPageTrick
From MediaWiki.org
EditPageTrick Release status: beta |
|||
---|---|---|---|
Implementation | Hook | ||
Description | Add a simple random trick when editing a page. | ||
Author(s) | B. Roussel (CoRfrTalk) | ||
Last version | 1.0u | ||
MediaWiki | tested with 1.14.0 (may run with older versions) |
||
License | No license specified | ||
Download | see below | ||
|
|||
Check usage (experimental) |
Contents |
[edit] What can this extension do?
This extension adds a random trick at the head of the editing page in a really easy way.
Possible tricks are easily editable and are contained in a single page.
[edit] Usage
[edit] Tricks
In order to make the extension works, you must create a page called 'EditTricks' in the MediaWiki namespace. This page contain all the tricks that will be shown randomly. Tricks are separated by the syntaxe '----'.
Exemple:
Tricks are a really easy way to highlight new syntaxes. ---- You can upload files on the wiki using the File namespace. <pre>[[File: MyUploadedFile.pdf]]</pre> ---- Tricks are tricky.
[edit] Trick template
The tricks are rendered using a template called Trick.
You can do pretty good things using css, here is a screenshot of mine.
[edit] Install
- Create the MediaWiki:EditTricks as shown in the last paragraph
- Create the extensions/EditPageTricks.php and copy/paste the #Code
- Create the Trick template, in order to do that edit the Template:Trick page and put your template in there. A really simple template would be something like this:
{{{1}}}
- Add the following to LocalSettings.php:
require_once("$IP/extensions/EditPageTricks.php");
[edit] Code
<?php if ( !defined( 'MEDIAWIKI' ) ) die (); $wgHooks['EditPage::showEditForm:initial'][] = 'editPageTricks'; function editPageTricks($editPage) { global $wgOut; $trick = ''; $title = Title::newFromText('EditTricks', NS_MEDIAWIKI); $article = new Article($title); $tricks = explode( '----', $article->getContent() ); if( !empty($tricks) ) { $size = count($tricks); $trick = $tricks[rand(0, $size-1)]; $editPage->editFormTextTop .= $wgOut->parse( '{{Trick|'.trim($trick).'}}' ); } return true; } ?>