r68621 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68620‎ | r68621 | r68622 >
Date:06:59, 27 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Encoding fixes and random clean up and notes
Modified paths:
  • /trunk/extensions/mw-editcount/EditCount.i18n.php (modified) (history)
  • /trunk/extensions/mw-editcount/EditCount.php (modified) (history)
  • /trunk/extensions/mw-editcount/EditCountPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/mw-editcount/EditCountPage.php
@@ -62,7 +62,7 @@
6363
6464 $nt = Title::newFromURL($this->target);
6565 if (!$nt) {
66 - $wgOut->addHTML(wfMsg("editcount-notuser", htmlspecialchars($this->target)));
 66+ $wgOut->addWikiMsg("editcount-notuser", $this->target));
6767 wfProfileOut(__METHOD__);
6868 return;
6969 }
@@ -86,7 +86,7 @@
8787 wfProfileIn(__METHOD__);
8888
8989 if ($ec->getTotal() == 0) {
90 - $wgOut->addHTML(wfMsg("editcount-noedits", $ec->getName()));
 90+ $wgOut->addWikiMsg("editcount-noedits", $ec->getName()));
9191 wfProfileOut(__METHOD__);
9292 return;
9393 }
@@ -160,8 +160,9 @@
161161
162162 wfProfileIn(__METHOD__);
163163
164 - $ct = Title::makeTitle(NS_SPECIAL, $this->getName());
 164+ $ct = $this->getTitle();
165165 $form = "";
 166+ // FIXME: use Xml::inputLabel etc
166167 $form .= wfElement("p", null, wfMsg("editcount-des"));
167168 $form .= wfElement("form", array("name" => "editcountform", "method" => "get", "action" => $wgScriptPath . "/index.php"), null);
168169 $form .= wfElement("input", array("type" => "hidden", "name" => "title", "value" => "Special:EditCount"), "") . " ";
@@ -219,6 +220,7 @@
220221 $this->db = wfGetDB(DB_SLAVE);
221222 $this->user = User::newFromName($username);
222223 if ($this->user == null) {
 224+ //FIXME: HUH?
223225 $this->user = new User;
224226 }
225227 $this->id = $this->user->getID();
@@ -235,6 +237,7 @@
236238 {
237239 wfProfileIn(__METHOD__);
238240 global $wgDBprefix;
 241+ //FIXME: don't construct SQL by hand, use selectField
239242 $cond = ($this->user->isAnon()) ? "r.rev_user_text = '" . $this->user->getName() . "'"
240243 : "r.rev_user = " . $this->id;
241244 $result = $this->db->query("SELECT COUNT(*) AS count
@@ -263,6 +266,8 @@
264267 FROM {$wgDBprefix}revision JOIN {$wgDBprefix}page p ON rev_page = p.page_id
265268 WHERE $cond GROUP BY ns", __METHOD__);
266269 $nsResults = array();
 270+
 271+ // Use foreach
267272 while (($row = $this->db->fetchRow($result)) !== false) {
268273 $nsResults[$row["ns"]] = $row["count"];
269274 }
@@ -291,6 +296,7 @@
292297 global $wgDBprefix;
293298 if ($this->id == 0) {
294299 wfProfileOut(__METHOD__);
 300+ // This actually works?
295301 return $this->db->selectField("{$wgDBprefix}revision", "COUNT(*)", array("rev_user_text" => $this->user->getName()), __METHOD__);
296302 }
297303
Index: trunk/extensions/mw-editcount/EditCount.i18n.php
@@ -23,14 +23,13 @@
2424 "editcount-username" => "Username:"
2525 );
2626
27 -//German
2827 $messages['de'] = array(
2928 "editcount" => "Anzahl der Bearbeitungen",
3029 "editcount-des" => "Geben Sie einen Benutzernamen oder eine IP ein, um sich die Anzahl der Bearbeitungen eines Benutzers anzeigen zu lassen.",
3130 "editcount-edits" => "Bearbeitungen",
3231 "editcount-namespace" => "Namensraum",
3332 "editcount-noedits" => "Es wurden keine Bearbeitungen von $1 gefunden.",
34 - "editcount-notuser" => "$1 ist kein g�ltiger Benutzer.",
 33+ "editcount-notuser" => "$1 ist kein gültiger Benutzer.",
3534 "editcount-percent" => "Prozent der Bearbeitungen insgesamt",
3635 "editcount-percentsym" => "%",
3736 "editcount-show" => "Anzahl anzeigen",
@@ -39,24 +38,23 @@
4039 "editcount-username" => "Benutzername:"
4140 );
4241
43 -//Finish
4442 $messages['fi'] = array(
45 - "editcount" => "K�ytt�jien muokkausm��r�t",
46 - "editcount-des" => "Voit tarkastella k�ytt�j�n tekemien tai IP-osoitteesta tehtyjen muokkausten lukum��r�� sy�tt�m�ll� tunnuksen tai IP:n alla olevaan kentt��n.",
 43+ "editcount" => "Käyttäjien muokkausmäärät",
 44+ "editcount-des" => "Voit tarkastella käyttäjän tekemien tai IP-osoitteesta tehtyjen muokkausten lukumäärää syättämällä tunnuksen tai IP:n alla olevaan kenttään.",
4745 "editcount-edits" => "muokkauksia",
4846 "editcount-namespace" => "nimiavaruus",
49 - "editcount-noedits" => "$1 ei ole tehnyt yht��n muokkausta.",
50 - "editcount-notuser" => "K�ytt�j�tunnusta $1 ei ole olemassa.",
51 - "editcount-percent" => "osuus k�ytt�j�n muokkauksista",
 47+ "editcount-noedits" => "$1 ei ole tehnyt yhtään muokkausta.",
 48+ "editcount-notuser" => "Käyttäjätunnusta $1 ei ole olemassa.",
 49+ "editcount-percent" => "osuus käyttäjän muokkauksista",
5250 "editcount-percentsym" => " %",
53 - "editcount-show" => "N�yt�",
54 - "editcount-toolbox" => "K�ytt�j�n muokkausten m��r�",
55 - "editcount-total" => "yhteens�",
56 - "editcount-username" => "K�ytt�j�:" );
 51+ "editcount-show" => "Näytä",
 52+ "editcount-toolbox" => "Käyttäjän muokkausten määrä",
 53+ "editcount-total" => "yhteensä",
 54+ "editcount-username" => "Käyttäjä:"
 55+);
5756
58 -//Polish
5957 $messages['pl'] = array(
60 - "editcount" => "Liczba edycji",
 58+ "editcount" => "Liczba edycji",
6159 "editcount-des" => "Wpisz nazwe uzytkownika lub adres IP, aby zobaczyc liczbe jego edycji.",
6260 "editcount-edits" => "Edycji",
6361 "editcount-namespace" => "Zakres nazw",
@@ -70,7 +68,6 @@
7169 "editcount-username" => "Uzytkownik:"
7270 );
7371
74 -//French
7572 $messages['fr'] = array(
7673 "editcount" => "Compteur d'éditions",
7774 "editcount-des" => "Saisir un nom d'utilisateur ou une IP pour voir le nombre d'édition de l'utilisateur.",
@@ -86,7 +83,6 @@
8784 "editcount-username" => "Utilisateur:"
8885 );
8986
90 -//brazilian portuguese
9187 $messages['pt-br'] = array(
9288 "editcount" => "Contador de Edições",
9389 "editcount-des" => "Incira um nome de usuário ou IP para ver a contagem de edições do usuário.",
@@ -102,7 +98,6 @@
10399 "editcount-username" => "Nome de Usuário:"
104100 );
105101
106 -//Dutch
107102 $messages['nl'] = array(
108103 "editcount" => "Bewerkingsteller",
109104 "editcount-des" => "Geef een gebruikersnaam of een IP-adres om .",
@@ -117,4 +112,3 @@
118113 "editcount-total" => "Totaal",
119114 "editcount-username" => "Gebruikersnaam:"
120115 );
121 -
Index: trunk/extensions/mw-editcount/EditCount.php
@@ -4,8 +4,8 @@
55 *
66 * @package MediaWiki
77 * @subpackage EditCount
8 - * @author Fahad Sadah
9 - * @copyright 2009 Fahad Sadah and Benjamin Peterson
 8+ * @author Fahad Sadah
 9+ * @copyright 2009 Fahad Sadah and Benjamin Peterson
1010 * @license GPL http://www.gnu.org/copyleft/gpl.html
1111 */
1212
@@ -14,25 +14,25 @@
1515 }
1616
1717 /*************************************
18 - Configuartion
 18+ Configuration
1919 ***************************************/
2020
2121 /**
2222 * True to turn on parser function and false to not
2323 */
24 -$egECParserFunction = true;
25 -
26 -/**
27 - * An array of the names of the parser functions
28 - *
29 - * This array of parser function names must be single words (can have - and _). They are not case sensitive. These will have "#" appended to the front of them in wikimarkup.
30 - * @var array
31 - */
32 -$egECParserFunctionNames = array("editcount", "ec");
33 -
34 -/**
35 - * True to enable the Special:EditCount page
36 - */
 24+$egECParserFunction = true;
 25+
 26+/**
 27+ * An array of the names of the parser functions
 28+ *
 29+ * This array of parser function names must be single words (can have - and _). They are not case sensitive. These will have "#" appended to the front of them in wikimarkup.
 30+ * @var array
 31+ */
 32+$egECParserFunctionNames = array("editcount", "ec");
 33+
 34+/**
 35+ * True to enable the Special:EditCount page
 36+ */
3737 $egECEnableSpecialPage = true;
3838
3939 /*************************************
@@ -51,63 +51,62 @@
5252 $wgExtensionFunctions[] = "efEditCount";
5353
5454 $wgExtensionMessagesFiles['mw-editcount'] = dirname(__FILE__) . '/EditCount.i18n.php';
55 -
56 -/**
57 - * The extension function that's called to set up EditCount.
 55+
 56+/**
 57+ * The extension function that's called to set up EditCount.
5858 */
5959 function efEditCount() {
60 - global $wgAutoloadClasses, $wgSpecialPages, $wgParser,
61 - $egECParserFunction, $egECEnableSpecialPage, $egECParserFunctionNames, $wgVersion;
62 -
 60+ global $wgAutoloadClasses, $wgSpecialPages, $wgHooks,
 61+ $egECParserFunction, $egECEnableSpecialPage;
6362 //Autoload
6463 $wgAutoloadClasses["EditCountPage"] = dirname(__FILE__) . "/EditCountPage.php";
65 - $wgAutoloadClasses["EditCount"] = dirname(__FILE__) . "/EditCountPage.php";
66 -
 64+ $wgAutoloadClasses["EditCount"] = dirname(__FILE__) . "/EditCountPage.php";
 65+
6766 if ($egECEnableSpecialPage) {
6867 $wgSpecialPages["EditCount"] = "EditCountPage";
6968 $wgHooks["SkinTemplateBuildNavUrlsNav_urlsAfterPermalink"][] = "efEditCountNavUrls";
70 - $wgHooks["MonoBookTemplateToolboxEnd"][] = "efEditCountToolbox";
 69+ $wgHooks["MonoBookTemplateToolboxEnd"][] = "efEditCountToolbox";
7170 }
7271
7372 if ($egECParserFunction) {
7473 $wgHooks["LanguageGetMagic"][] = "efEditCountMagic";
75 - $wgHooks['ParserFirstCallInit'][] = "efEditCountRegisterParser";
 74+ $wgHooks['ParserFirstCallInit'][] = "efEditCountRegisterParser";
7675 }
7776
7877 }
79 -
80 -/**
81 - * Sets up the parser function magic words in Mediawiki 1.7 and greater.
82 - *
83 - * @param array $magicWords the array of magic word we'll add to
84 - * @return bool always true
 78+
 79+/**
 80+ * Sets up the parser function magic words in Mediawiki 1.7 and greater.
 81+ *
 82+ * @param array $magicWords the array of magic word we'll add to
 83+ * @return bool always true
8584 */
86 -function efEditCountMagic(&$magicWords) {
87 - global $egECParserFunctionNames;
88 -
89 - if (!is_array($egECParserFunctionNames) || count($egECParserFunctionNames) == 0) {
90 - $egECParserFunctionNames = array("editcount", "ec");
91 - }
 85+function efEditCountMagic(&$magicWords) {
 86+ global $egECParserFunctionNames;
9287
 88+ if (!is_array($egECParserFunctionNames) || count($egECParserFunctionNames) == 0) {
 89+ $egECParserFunctionNames = array("editcount", "ec");
 90+ }
 91+
9392 $magicWords["editcount"] = array_merge(array(0), $egECParserFunctionNames);
9493 return true;
95 -}
96 -
97 -/**
98 - * Adds the path of the EditCount special page to toolboxes on user pages
99 - *
100 - * @param SkinTemplate $skinTemplate
101 - * @param array $navUrls the navagation urls
102 - * @param int $oldid the oldid of the article
103 - * @param int $revisionid the revision id
104 - * @return bool always true
 94+}
 95+
 96+/**
 97+ * Adds the path of the EditCount special page to toolboxes on user pages
 98+ *
 99+ * @param SkinTemplate $skinTemplate
 100+ * @param array $navUrls the navagation urls
 101+ * @param int $oldid the oldid of the article
 102+ * @param int $revisionid the revision id
 103+ * @return bool always true
105104 */
106105 function efEditCountNavUrls(&$skinTemplate, &$navUrls, $oldid, $revisionid) {
107 - global $wgAutoloadClasses, $egECEnableSpecialPage;
108 -
109 - if (!$egECEnableSpecialPage) {
110 - return;
111 - }
 106+ global $egECEnableSpecialPage;
 107+
 108+ if (!$egECEnableSpecialPage) {
 109+ return;
 110+ }
112111 wfLoadExtensionMessages( 'mw-editcount' );
113112 $title = $skinTemplate->mTitle;
114113 if ($title->getNamespace() == NS_USER && $revisionid !== 0) {
@@ -122,18 +121,17 @@
123122 * Registers the parser function with parsers
124123 */
125124 function efEditCountRegisterParser(&$parser) {
126 - $wgParser->setFunctionHook("editcount", "efEditCountParserFunction");
127 -
 125+ $parser->setFunctionHook("editcount", "efEditCountParserFunction");
128126 return true;
129127 }
130 -
131 -/**
132 - * Preforms the parser function action (getting the edit count of a user)
133 - *
134 - * @param Parser $parser the parser instance
135 - * @param string $param1 the name of the user in question (hopefully)
136 - * @param string $param2 (optional) namespace
137 - * @return mixed
 128+
 129+/**
 130+ * Preforms the parser function action (getting the edit count of a user)
 131+ *
 132+ * @param Parser $parser the parser instance
 133+ * @param string $param1 the name of the user in question (hopefully)
 134+ * @param string $param2 (optional) namespace
 135+ * @return mixed
138136 */
139137 function efEditCountParserFunction($parser, $param1 = "", $param2 = "") {
140138 global $wgContLang;
@@ -152,6 +150,7 @@
153151 return $ec->getTotal();
154152 }
155153
 154+ //FIXME: don't use is_numeric
156155 if (!is_numeric($param2)) {
157156 $index = Namespace::getCanonicalIndex(strtolower($param2));
158157 if ($index === null) {
@@ -171,12 +170,12 @@
172171 wfProfileOut(__FUNCTION__);
173172 return $ec->getByNamespace($index);
174173 }
175 -
176 -/**
177 - * Actually adds the HTML
178 - *
179 - * @param SkinMonoBook $monobook the template we're in
180 - * @return bool always true
 174+
 175+/**
 176+ * Actually adds the HTML
 177+ *
 178+ * @param SkinMonoBook $monobook the template we're in
 179+ * @return bool always true
181180 */
182181 function efEditcountToolbox(&$monobook) {
183182 wfLoadExtensionMessages( 'mw-editcount' );

Status & tagging log