removed debug code
[editimage_extension] / EditImage.php
1 <?php   
2
3 # Alert the user that this is not a valid entry point to MediaWiki if
4 # they try to access the special pages file directly.
5 if (!defined('MEDIAWIKI')) {
6         echo <<<EOT
7 To install my extension, put the following line in LocalSettings.php:
8 require_once( "\$IP/extensions/EditImage/EditImage.php" );
9 EOT;
10         exit( 1 );
11 }
12
13 $dir = dirname(__FILE__) . '/';
14 $wgAutoloadClasses['EditImage'] = $dir . 'EditImage_body.php';
15 $wgExtensionMessagesFiles['EditImage'] = $dir . 'EditImage.i18n.php';
16 $wgSpecialPages['EditImage'] = 'EditImage'; 
17 # $wgHooks['LanguageGetSpecialPageAliases'][] = 'EditImageLocalizedPageName';
18 $wgHooks['SkinTemplateContentActions'][] = 'wfAddactionContentHook';
19 #$wgHooks['UnknownAction'][] = 'wfAddactActionHook';
20
21 function myExtensionLocalizedPageName(&$specialPageArray, $code) {
22   # The localized title of the special page is among the messages of the extension:
23   wfLoadExtensionMessages('EditImage');
24   $text = wfMsg('editimage');
25
26   # Convert from title in text form to DBKey and put it into the alias array:
27   $title = Title::newFromText($text);
28   $specialPageArray['EditImage'][] = $title->getDBKey();
29
30   return true;
31 }
32
33 $wgExtensionCredits['specialpage'][] = array(
34     'name' => 'EditImage',
35     'version' => '0.1',
36     'author' => 'Benjamin Mako Hill', 
37     'url' => 'http://www.mediawiki.org/wiki/User:Benjamin_Mako_Hill', 
38     'description' => 'This extension provides a way for Mediawiki users to edit images from the web.'
39 );
40
41
42
43 function wfAddActionContentHook( &$content_actions ) {
44     global $wgRequest, $wgRequest, $wgTitle;
45     
46     $action = $wgRequest->getText( 'action' ); 
47     if ( $wgTitle->getNamespace() == NS_IMAGE ) {
48
49         $editimage_page = SpecialPage::getTitleFor( 'EditImage');;
50
51         $content_actions['editimage'] = array(
52             'class' => $action == 'editimage' ? 'selected' : false,
53             'text' => "Crop Image", // the wfMsg was not working...
54             'href' => $editimage_page->getLocalURL("image={$wgTitle->getPrefixedURL()}")
55             );
56     }
57
58     return true;
59 }
60
61
62 ?>

Benjamin Mako Hill || Want to submit a patch?