Index: trunk/extensions/content_action.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * An extension that demonstrated how to use the SkinTemplateContentActions |
| 5 | + * hook to add a new content action |
| 6 | + * |
| 7 | + * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
| 8 | + */ |
| 9 | + |
| 10 | +$wgExtensionFunctions[] = 'wfAddaction'; |
| 11 | +$wgExtensionCredits['other'][] = array( |
| 12 | + 'name' => 'Content action hook', |
| 13 | + 'author' => 'Ævar Arnfjörð Bjarmason', |
| 14 | +); |
| 15 | + |
| 16 | + |
| 17 | +function wfAddaction() { |
| 18 | + global $wgHooks, $wgMessageCache; |
| 19 | + $wgMessageCache->addMessage( 'myact', 'My action' ); |
| 20 | + $wgHooks['SkinTemplateContentActions'][] = 'wfAddactionHook'; |
| 21 | +} |
| 22 | + |
| 23 | +function wfAddActionHook( &$content_actions ) { |
| 24 | + global $wgRequest, $wgRequest, $wgTitle; |
| 25 | + |
| 26 | + $action = $wgRequest->getText( 'action' ); |
| 27 | + |
| 28 | + if ($wgTitle->getNamespace() != NS_SPECIAL) { |
| 29 | + $content_actions['myact'] = array( |
| 30 | + 'class' => $action == 'myact' ? 'selected' : false, |
| 31 | + 'text' => wfMsg( 'myact' ), |
| 32 | + 'href' => $wgTitle->getLocalUrl( 'action=myact' ) |
| 33 | + ); |
| 34 | + } |
| 35 | +} |
Property changes on: trunk/extensions/content_action.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |
Added: svn:keywords |
2 | 37 | + Author Date Id Revision |