added licensing information and changelog
[editimage_extension] / EditImage.php
1 <?php   
2 /* Copyright (c) 2008 Benjamin Mako Hill <mako@atdot.cc>
3    This file is part of the EditImage Mediawiki Extension.  
4
5    EditImage is free software: you can redistribute it and/or modify it
6    under the terms of the GNU General Public License as published by the
7    Free Software Foundation, either version 3 of the License, or (at
8    your option) any later version.  
9    
10    Foobar is distributed in the hope that it will be useful, but WITHOUT
11    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13    for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.  */
17
18 # Alert the user that this is not a valid entry point to MediaWiki if
19 # they try to access the special pages file directly.
20 if (!defined('MEDIAWIKI')) {
21         echo <<<EOT
22 To install my extension, put the following line in LocalSettings.php:
23 require_once( "\$IP/extensions/EditImage/EditImage.php" );
24 EOT;
25         exit( 1 );
26 }
27
28 $dir = dirname(__FILE__) . '/';
29 $wgAutoloadClasses['EditImage'] = $dir . 'EditImage_body.php';
30 $wgExtensionMessagesFiles['EditImage'] = $dir . 'EditImage.i18n.php';
31 $wgSpecialPages['EditImage'] = 'EditImage'; 
32 # $wgHooks['LanguageGetSpecialPageAliases'][] = 'EditImageLocalizedPageName';
33 $wgHooks['SkinTemplateContentActions'][] = 'wfAddactionContentHook';
34 #$wgHooks['UnknownAction'][] = 'wfAddactActionHook';
35
36 function myExtensionLocalizedPageName(&$specialPageArray, $code) {
37   # The localized title of the special page is among the messages of the extension:
38   wfLoadExtensionMessages('EditImage');
39   $text = wfMsg('editimage');
40
41   # Convert from title in text form to DBKey and put it into the alias array:
42   $title = Title::newFromText($text);
43   $specialPageArray['EditImage'][] = $title->getDBKey();
44
45   return true;
46 }
47
48 $wgExtensionCredits['specialpage'][] = array(
49     'name' => 'EditImage',
50     'version' => '0.1',
51     'author' => 'Benjamin Mako Hill', 
52     'url' => 'http://www.mediawiki.org/wiki/User:Benjamin_Mako_Hill', 
53     'description' => 'This extension provides a way for Mediawiki users to edit images from the web.'
54 );
55
56 function wfAddActionContentHook( &$content_actions ) {
57     global $wgRequest, $wgRequest, $wgTitle;
58     
59     $action = $wgRequest->getText( 'action' ); 
60     if ( $wgTitle->getNamespace() == NS_IMAGE ) {
61
62         $editimage_page = SpecialPage::getTitleFor( 'EditImage');;
63
64         $content_actions['editimage'] = array(
65             'class' => $action == 'editimage' ? 'selected' : false,
66             'text' => "Crop Image", // the wfMsg was not working...
67             'href' => $editimage_page->getLocalURL("image={$wgTitle->getPrefixedURL()}")
68             );
69     }
70
71     return true;
72 }
73
74
75 ?>

Benjamin Mako Hill || Want to submit a patch?