2 /* Copyright (c) 2008 Benjamin Mako Hill <mako@atdot.cc>
3 This file is part of the EditImage Mediawiki Extension.
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.
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
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/>. */
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')) {
22 To install my extension, put the following line in LocalSettings.php:
23 require_once( "\$IP/extensions/EditImage/EditImage.php" );
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';
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');
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();
48 $wgExtensionCredits['specialpage'][] = array(
49 'name' => 'EditImage',
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.'
56 function wfAddActionContentHook( &$content_actions ) {
57 global $wgRequest, $wgRequest, $wgTitle;
59 $action = $wgRequest->getText( 'action' );
60 if ( $wgTitle->getNamespace() == NS_IMAGE ) {
62 $editimage_page = SpecialPage::getTitleFor( 'EditImage');;
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()}")