3 * An extension that demonstrates how to use the SkinTemplateContentActions
4 * hook to add a new content action
6 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
8 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
11 $wgExtensionFunctions[] = 'wfAddaction';
12 $wgExtensionCredits['other'][] = array(
13 'name' => 'Content action hook',
14 'author' => 'Ævar Arnfjörð Bjarmason',
15 'desciprion' => 'Adds a new tab to each page',
19 function wfAddaction() {
20 global $wgHooks, $wgMessageCache;
21 $wgMessageCache->addMessage( 'myact', 'My action' );
22 $wgHooks['SkinTemplateContentActions'][] = 'wfAddactionContentHook';
23 $wgHooks['UnknownAction'][] = 'wfAddactActionHook';
26 function wfAddActionContentHook( &$content_actions ) {
27 global $wgRequest, $wgRequest, $wgTitle;
29 $action = $wgRequest->getText( 'action' );
31 if ( $wgTitle->getNamespace() != NS_SPECIAL
) {
32 $content_actions['myact'] = array(
33 'class' => $action == 'myact' ?
'selected' : false,
34 'text' => wfMsg( 'myact' ),
35 'href' => $wgTitle->getLocalUrl( 'action=myact' )
42 function wfAddactActionHook( $action, &$wgArticle ) {
45 $title = $wgArticle->getTitle();
47 if ( $action == 'myact' )
48 $wgOut->addHTML( 'The page name is ' . $title->getText() . ' and you are ' . $wgArticle->getUserText() );