Index: trunk/extensions/examples/Content_action.php |
— | — | @@ -1,55 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * An extension that demonstrates how to use the SkinTemplateContentActions |
5 | | - * hook to add a new content action |
6 | | - * |
7 | | - * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
8 | | - * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason |
9 | | - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
10 | | - */ |
11 | | - |
12 | | -$wgExtensionFunctions[] = 'wfAddaction'; |
13 | | -$wgExtensionCredits['other'][] = array( |
14 | | - 'path' => __FILE__, |
15 | | - 'name' => 'Content action hook', |
16 | | - 'author' => 'Ævar Arnfjörð Bjarmason', |
17 | | - 'description' => 'Adds a new tab to each page', |
18 | | -); |
19 | | - |
20 | | - |
21 | | -function wfAddaction() { |
22 | | - global $wgHooks, $wgMessageCache; |
23 | | - // This is not the proper way to do i18n |
24 | | - // See FourFileTemplate how to do i18n |
25 | | - $wgMessageCache->addMessage( 'myact', 'My action' ); |
26 | | - $wgHooks['SkinTemplateContentActions'][] = 'wfAddactionContentHook'; |
27 | | - $wgHooks['UnknownAction'][] = 'wfAddactActionHook'; |
28 | | -} |
29 | | - |
30 | | -function wfAddActionContentHook( &$content_actions ) { |
31 | | - global $wgRequest, $wgRequest, $wgTitle; |
32 | | - |
33 | | - $action = $wgRequest->getText( 'action' ); |
34 | | - |
35 | | - if ( $wgTitle->getNamespace() != NS_SPECIAL ) { |
36 | | - $content_actions['myact'] = array( |
37 | | - 'class' => $action === 'myact' ? 'selected' : false, |
38 | | - 'text' => wfMsg( 'myact' ), |
39 | | - 'href' => $wgTitle->getLocalUrl( 'action=myact' ) |
40 | | - ); |
41 | | - } |
42 | | - |
43 | | - return true; |
44 | | -} |
45 | | - |
46 | | -function wfAddactActionHook( $action, &$article ) { |
47 | | - global $wgOut; |
48 | | - |
49 | | - $title = $article->getTitle(); |
50 | | - |
51 | | - if ( $action === 'myact' ) { |
52 | | - $wgOut->addWikiText( 'The page name is ' . $title->getText() . ' and you are ' . $article->getUserText() ); |
53 | | - } |
54 | | - |
55 | | - return false; |
56 | | -} |
Index: trunk/extensions/examples/ContentAction/ContentAction.i18n.php |
— | — | @@ -0,0 +1,12 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Messages for Content action extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + */ |
| 8 | + |
| 9 | +$messages = array(); |
| 10 | + |
| 11 | +$messages['en'] = array( |
| 12 | + 'myact' => 'My action', |
| 13 | +); |
Property changes on: trunk/extensions/examples/ContentAction/ContentAction.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 14 | + native |
Index: trunk/extensions/examples/ContentAction/ContentAction.php |
— | — | @@ -0,0 +1,50 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * An extension that demonstrates how to use the SkinTemplateContentActions |
| 5 | + * hook to add a new content action |
| 6 | + * |
| 7 | + * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com> |
| 8 | + * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason |
| 9 | + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later |
| 10 | + */ |
| 11 | + |
| 12 | +$wgExtensionCredits['other'][] = array( |
| 13 | + 'path' => __FILE__, |
| 14 | + 'name' => 'Content action hook', |
| 15 | + 'author' => 'Ævar Arnfjörð Bjarmason', |
| 16 | + 'description' => 'Adds a new tab to each page', |
| 17 | +); |
| 18 | + |
| 19 | +$wgHooks['UnknownAction'][] = 'wfAddactActionHook'; |
| 20 | +$wgHooks['SkinTemplateContentActions'][] = 'wfAddactionContentHook'; |
| 21 | + |
| 22 | +$wgExtensionMessagesFiles['ContentAction'] = dirname( __FILE__ ) . '/ContentAction.i18n.php'; |
| 23 | + |
| 24 | +function wfAddActionContentHook( &$content_actions ) { |
| 25 | + global $wgRequest, $wgRequest, $wgTitle; |
| 26 | + |
| 27 | + $action = $wgRequest->getText( 'action' ); |
| 28 | + |
| 29 | + if ( $wgTitle->getNamespace() != NS_SPECIAL ) { |
| 30 | + $content_actions['myact'] = array( |
| 31 | + 'class' => $action === 'myact' ? 'selected' : false, |
| 32 | + 'text' => wfMsg( 'myact' ), |
| 33 | + 'href' => $wgTitle->getLocalUrl( 'action=myact' ) |
| 34 | + ); |
| 35 | + } |
| 36 | + |
| 37 | + return true; |
| 38 | +} |
| 39 | + |
| 40 | +function wfAddactActionHook( $action, &$article ) { |
| 41 | + global $wgOut; |
| 42 | + |
| 43 | + $title = $article->getTitle(); |
| 44 | + |
| 45 | + if ( $action === 'myact' ) { |
| 46 | + $wgOut->addWikiText( 'The page name is ' . $title->getText() . ' and you are ' . $article->getUserText() ); |
| 47 | + return false; |
| 48 | + } |
| 49 | + |
| 50 | + return true; |
| 51 | +} |
Property changes on: trunk/extensions/examples/ContentAction/ContentAction.php |
___________________________________________________________________ |
Added: svn:keywords |
1 | 52 | + Author Date Id Revision |
Added: svn:eol-style |
2 | 53 | + native |