r76579 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76578‎ | r76579 | r76580 >
Date:16:33, 12 November 2010
Author:dantman
Status:deferred
Tags:
Comment:
Move CreateRedirect.setup.php to standard naming.
Modified paths:
  • /trunk/extensions/CreateRedirect/CreateRedirect.php (added) (history)
  • /trunk/extensions/CreateRedirect/CreateRedirect.setup.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/CreateRedirect/CreateRedirect.setup.php
@@ -1,101 +0,0 @@
2 -<?php
3 -
4 -/*
5 - * MediaWiki Extension
6 - * CreateRedirect
7 - * By Marco Zafra ("Digi")
8 - * Started: September 18, 2007
9 - *
10 - * Adds a special page that eases creation of redirects via a simple form. Also adds a menu item to the sidebar as a shortcut.
11 - *
12 - * This program, CreateRedirect, is Copyright (C) 2007 Marco Zafra. CreateRedirect is released under the GNU Lesser General Public License version 3.
13 - *
14 - * This file is part of CreateRedirect.
15 - *
16 - * CreateRedirect is free software: you can redistribute it and/or modify
17 - * it under the terms of the GNU Lesser General Public License as published by
18 - * the Free Software Foundation, either version 3 of the License, or
19 - * (at your option) any later version.
20 - *
21 - * CreateRedirect is distributed in the hope that it will be useful,
22 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 - * GNU Lesser General Public License for more details.
25 - *
26 - * You should have received a copy of the GNU Lesser General Public License
27 - * along with CreateRedirect. If not, see <http://www.gnu.org/licenses/>.
28 - */
29 -
30 -/* Setup file:
31 - * Performs setup routines to hook the extension up to MediaWiki.
32 - */
33 -
34 -# Alert the user that this is not a valid entry point to MediaWiki if they try to access the file directly.
35 -if (!defined('MEDIAWIKI')) {
36 - echo <<<EOT
37 -To install the CreateRedirect extension, put the following line in LocalSettings.php:
38 -require_once( "$IP/extensions/CreateRedirect/CreateRedirect.setup.php" );
39 -EOT;
40 - exit( 1 );
41 -}
42 -
43 -# Add this extension to Special:Credits.
44 -$wgExtensionCredits['specialpage'][] = array(
45 - 'name' => 'CreateRedirect',
46 - 'author' => 'Digiku',
47 - 'version' => 1.0,
48 - 'description' => 'Adds [[Special:CreateRedirect]] to easily create redirects.'
49 -);
50 -
51 -# Set up the actual extension functionality.
52 -$wgAutoloadClasses['CreateRedirect'] = dirname(__FILE__) . '/CreateRedirect.body.php'; # Tell MediaWiki to load the extension body.
53 -$wgSpecialPages['Createredirect'] = 'CreateRedirect'; # Let MediaWiki know about your new special page.
54 -$wgHooks['LoadAllMessages'][] = 'CreateRedirect::loadMessages'; # Load the internationalization messages for your special page.
55 -$wgHooks['LanguageGetSpecialPageAliases'][] = 'createRedirect_LanguageGetSpecialPageAliases'; # Add any aliases for the special page.
56 -
57 -function createRedirect_LanguageGetSpecialPageAliases(&$specialPageArray, $code) {
58 - # The localized title of the special page is among the messages of the extension:
59 - CreateRedirect::loadMessages();
60 - $text = wfMsg('createredirect');
61 -
62 - # Convert from title in text form to DBKey and put it into the alias array:
63 - $title = Title::newFromText($text);
64 - $specialPageArray['CreateRedirect'][] = $title->getDBKey();
65 -
66 - return true;
67 -}
68 -
69 -# Other hooks.
70 -$wgHooks['MonoBookTemplateToolboxEnd'][] = 'createRedirect_addToolboxLink'; # Add a shortcut link to the sidebar menu in Monobook; specifically the toolbox.
71 -
72 -/*
73 - * createRedirect_AddToolboxLink(): Adds to the "toolbox" menu in the Monobook skin a shortcut link pointing to Special:Createredirect. If applicable, also adds a reference to the current title as a GET param.
74 - * Params: None
75 - * Returns: true
76 - */
77 -function createRedirect_AddToolboxLink() {
78 - global $wgRequest, $wgOut, $wgScript;
79 -
80 - // 1. Determine whether to actually add the link at all. There are certain cases, e.g. in the edit dialog, in a special page, where it's inappropriate for the link to appear.
81 - // First, see if "action" exists. If there's an "action" parameter in the URL, we assume that to mean "action=edit" or any other thing. In which case, we don't display the link.
82 - if($wgRequest->getText("action")) { return true; }
83 -
84 - // 2. Check the title. Is it a "Special:" page? Don't display the link.
85 - $title = $wgRequest->getText("title"); // We use this for more than one thing.
86 - if(strpos($title, "Special:") === 0) { return true; }
87 -
88 - // TODO: Determine better ways to detect cases to not display the link. --Digi 11/4/07
89 -
90 - // 3. Are we still here? Good; we can display the link! If $title exists, we pass that as a GET var; the special page can automatically fill in a field using that var.
91 - if($title) {
92 - $crTitle = "&crTitle=$title";
93 - } else {
94 - $crTitle = "";
95 - }
96 -
97 - // 4. Add the link!
98 - $finalItem = "<li><a href=\"" . $wgScript . "?title=Special:Createredirect$crTitle\">Create redirect</a></li>";
99 - echo $finalItem;
100 -
101 - return true;
102 -}
Index: trunk/extensions/CreateRedirect/CreateRedirect.php
@@ -0,0 +1,101 @@
 2+<?php
 3+
 4+/*
 5+ * MediaWiki Extension
 6+ * CreateRedirect
 7+ * By Marco Zafra ("Digi")
 8+ * Started: September 18, 2007
 9+ *
 10+ * Adds a special page that eases creation of redirects via a simple form. Also adds a menu item to the sidebar as a shortcut.
 11+ *
 12+ * This program, CreateRedirect, is Copyright (C) 2007 Marco Zafra. CreateRedirect is released under the GNU Lesser General Public License version 3.
 13+ *
 14+ * This file is part of CreateRedirect.
 15+ *
 16+ * CreateRedirect is free software: you can redistribute it and/or modify
 17+ * it under the terms of the GNU Lesser General Public License as published by
 18+ * the Free Software Foundation, either version 3 of the License, or
 19+ * (at your option) any later version.
 20+ *
 21+ * CreateRedirect is distributed in the hope that it will be useful,
 22+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 23+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 24+ * GNU Lesser General Public License for more details.
 25+ *
 26+ * You should have received a copy of the GNU Lesser General Public License
 27+ * along with CreateRedirect. If not, see <http://www.gnu.org/licenses/>.
 28+ */
 29+
 30+/* Setup file:
 31+ * Performs setup routines to hook the extension up to MediaWiki.
 32+ */
 33+
 34+# Alert the user that this is not a valid entry point to MediaWiki if they try to access the file directly.
 35+if (!defined('MEDIAWIKI')) {
 36+ echo <<<EOT
 37+To install the CreateRedirect extension, put the following line in LocalSettings.php:
 38+require_once( "\$IP/extensions/CreateRedirect/CreateRedirect.php" );
 39+EOT;
 40+ exit( 1 );
 41+}
 42+
 43+# Add this extension to Special:Credits.
 44+$wgExtensionCredits['specialpage'][] = array(
 45+ 'name' => 'CreateRedirect',
 46+ 'author' => 'Digiku',
 47+ 'version' => 1.0,
 48+ 'description' => 'Adds [[Special:CreateRedirect]] to easily create redirects.'
 49+);
 50+
 51+# Set up the actual extension functionality.
 52+$wgAutoloadClasses['CreateRedirect'] = dirname(__FILE__) . '/CreateRedirect.body.php'; # Tell MediaWiki to load the extension body.
 53+$wgSpecialPages['Createredirect'] = 'CreateRedirect'; # Let MediaWiki know about your new special page.
 54+$wgHooks['LoadAllMessages'][] = 'CreateRedirect::loadMessages'; # Load the internationalization messages for your special page.
 55+$wgHooks['LanguageGetSpecialPageAliases'][] = 'createRedirect_LanguageGetSpecialPageAliases'; # Add any aliases for the special page.
 56+
 57+function createRedirect_LanguageGetSpecialPageAliases(&$specialPageArray, $code) {
 58+ # The localized title of the special page is among the messages of the extension:
 59+ CreateRedirect::loadMessages();
 60+ $text = wfMsg('createredirect');
 61+
 62+ # Convert from title in text form to DBKey and put it into the alias array:
 63+ $title = Title::newFromText($text);
 64+ $specialPageArray['CreateRedirect'][] = $title->getDBKey();
 65+
 66+ return true;
 67+}
 68+
 69+# Other hooks.
 70+$wgHooks['MonoBookTemplateToolboxEnd'][] = 'createRedirect_addToolboxLink'; # Add a shortcut link to the sidebar menu in Monobook; specifically the toolbox.
 71+
 72+/*
 73+ * createRedirect_AddToolboxLink(): Adds to the "toolbox" menu in the Monobook skin a shortcut link pointing to Special:Createredirect. If applicable, also adds a reference to the current title as a GET param.
 74+ * Params: None
 75+ * Returns: true
 76+ */
 77+function createRedirect_AddToolboxLink() {
 78+ global $wgRequest, $wgOut, $wgScript;
 79+
 80+ // 1. Determine whether to actually add the link at all. There are certain cases, e.g. in the edit dialog, in a special page, where it's inappropriate for the link to appear.
 81+ // First, see if "action" exists. If there's an "action" parameter in the URL, we assume that to mean "action=edit" or any other thing. In which case, we don't display the link.
 82+ if($wgRequest->getText("action")) { return true; }
 83+
 84+ // 2. Check the title. Is it a "Special:" page? Don't display the link.
 85+ $title = $wgRequest->getText("title"); // We use this for more than one thing.
 86+ if(strpos($title, "Special:") === 0) { return true; }
 87+
 88+ // TODO: Determine better ways to detect cases to not display the link. --Digi 11/4/07
 89+
 90+ // 3. Are we still here? Good; we can display the link! If $title exists, we pass that as a GET var; the special page can automatically fill in a field using that var.
 91+ if($title) {
 92+ $crTitle = "&crTitle=$title";
 93+ } else {
 94+ $crTitle = "";
 95+ }
 96+
 97+ // 4. Add the link!
 98+ $finalItem = "<li><a href=\"" . $wgScript . "?title=Special:Createredirect$crTitle\">Create redirect</a></li>";
 99+ echo $finalItem;
 100+
 101+ return true;
 102+}
Property changes on: trunk/extensions/CreateRedirect/CreateRedirect.php
___________________________________________________________________
Added: svn:eol-style
1103 + native

Status & tagging log