Index: trunk/extensions/mw-editcount/EditCountPage.php |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | |
64 | 64 | $nt = Title::newFromURL($this->target); |
65 | 65 | if (!$nt) { |
66 | | - $wgOut->addHTML(wfMsg("editcount-notuser", htmlspecialchars($this->target))); |
| 66 | + $wgOut->addWikiMsg("editcount-notuser", $this->target)); |
67 | 67 | wfProfileOut(__METHOD__); |
68 | 68 | return; |
69 | 69 | } |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | wfProfileIn(__METHOD__); |
88 | 88 | |
89 | 89 | if ($ec->getTotal() == 0) { |
90 | | - $wgOut->addHTML(wfMsg("editcount-noedits", $ec->getName())); |
| 90 | + $wgOut->addWikiMsg("editcount-noedits", $ec->getName())); |
91 | 91 | wfProfileOut(__METHOD__); |
92 | 92 | return; |
93 | 93 | } |
— | — | @@ -160,8 +160,9 @@ |
161 | 161 | |
162 | 162 | wfProfileIn(__METHOD__); |
163 | 163 | |
164 | | - $ct = Title::makeTitle(NS_SPECIAL, $this->getName()); |
| 164 | + $ct = $this->getTitle(); |
165 | 165 | $form = ""; |
| 166 | + // FIXME: use Xml::inputLabel etc |
166 | 167 | $form .= wfElement("p", null, wfMsg("editcount-des")); |
167 | 168 | $form .= wfElement("form", array("name" => "editcountform", "method" => "get", "action" => $wgScriptPath . "/index.php"), null); |
168 | 169 | $form .= wfElement("input", array("type" => "hidden", "name" => "title", "value" => "Special:EditCount"), "") . " "; |
— | — | @@ -219,6 +220,7 @@ |
220 | 221 | $this->db = wfGetDB(DB_SLAVE); |
221 | 222 | $this->user = User::newFromName($username); |
222 | 223 | if ($this->user == null) { |
| 224 | + //FIXME: HUH? |
223 | 225 | $this->user = new User; |
224 | 226 | } |
225 | 227 | $this->id = $this->user->getID(); |
— | — | @@ -235,6 +237,7 @@ |
236 | 238 | { |
237 | 239 | wfProfileIn(__METHOD__); |
238 | 240 | global $wgDBprefix; |
| 241 | + //FIXME: don't construct SQL by hand, use selectField |
239 | 242 | $cond = ($this->user->isAnon()) ? "r.rev_user_text = '" . $this->user->getName() . "'" |
240 | 243 | : "r.rev_user = " . $this->id; |
241 | 244 | $result = $this->db->query("SELECT COUNT(*) AS count |
— | — | @@ -263,6 +266,8 @@ |
264 | 267 | FROM {$wgDBprefix}revision JOIN {$wgDBprefix}page p ON rev_page = p.page_id |
265 | 268 | WHERE $cond GROUP BY ns", __METHOD__); |
266 | 269 | $nsResults = array(); |
| 270 | + |
| 271 | + // Use foreach |
267 | 272 | while (($row = $this->db->fetchRow($result)) !== false) { |
268 | 273 | $nsResults[$row["ns"]] = $row["count"]; |
269 | 274 | } |
— | — | @@ -291,6 +296,7 @@ |
292 | 297 | global $wgDBprefix; |
293 | 298 | if ($this->id == 0) { |
294 | 299 | wfProfileOut(__METHOD__); |
| 300 | + // This actually works? |
295 | 301 | return $this->db->selectField("{$wgDBprefix}revision", "COUNT(*)", array("rev_user_text" => $this->user->getName()), __METHOD__); |
296 | 302 | } |
297 | 303 | |
Index: trunk/extensions/mw-editcount/EditCount.i18n.php |
— | — | @@ -23,14 +23,13 @@ |
24 | 24 | "editcount-username" => "Username:" |
25 | 25 | ); |
26 | 26 | |
27 | | -//German |
28 | 27 | $messages['de'] = array( |
29 | 28 | "editcount" => "Anzahl der Bearbeitungen", |
30 | 29 | "editcount-des" => "Geben Sie einen Benutzernamen oder eine IP ein, um sich die Anzahl der Bearbeitungen eines Benutzers anzeigen zu lassen.", |
31 | 30 | "editcount-edits" => "Bearbeitungen", |
32 | 31 | "editcount-namespace" => "Namensraum", |
33 | 32 | "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.", |
35 | 34 | "editcount-percent" => "Prozent der Bearbeitungen insgesamt", |
36 | 35 | "editcount-percentsym" => "%", |
37 | 36 | "editcount-show" => "Anzahl anzeigen", |
— | — | @@ -39,24 +38,23 @@ |
40 | 39 | "editcount-username" => "Benutzername:" |
41 | 40 | ); |
42 | 41 | |
43 | | -//Finish |
44 | 42 | $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.", |
47 | 45 | "editcount-edits" => "muokkauksia", |
48 | 46 | "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", |
52 | 50 | "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 | +); |
57 | 56 | |
58 | | -//Polish |
59 | 57 | $messages['pl'] = array( |
60 | | - "editcount" => "Liczba edycji", |
| 58 | + "editcount" => "Liczba edycji", |
61 | 59 | "editcount-des" => "Wpisz nazwe uzytkownika lub adres IP, aby zobaczyc liczbe jego edycji.", |
62 | 60 | "editcount-edits" => "Edycji", |
63 | 61 | "editcount-namespace" => "Zakres nazw", |
— | — | @@ -70,7 +68,6 @@ |
71 | 69 | "editcount-username" => "Uzytkownik:" |
72 | 70 | ); |
73 | 71 | |
74 | | -//French |
75 | 72 | $messages['fr'] = array( |
76 | 73 | "editcount" => "Compteur d'éditions", |
77 | 74 | "editcount-des" => "Saisir un nom d'utilisateur ou une IP pour voir le nombre d'édition de l'utilisateur.", |
— | — | @@ -86,7 +83,6 @@ |
87 | 84 | "editcount-username" => "Utilisateur:" |
88 | 85 | ); |
89 | 86 | |
90 | | -//brazilian portuguese |
91 | 87 | $messages['pt-br'] = array( |
92 | 88 | "editcount" => "Contador de Edições", |
93 | 89 | "editcount-des" => "Incira um nome de usuário ou IP para ver a contagem de edições do usuário.", |
— | — | @@ -102,7 +98,6 @@ |
103 | 99 | "editcount-username" => "Nome de Usuário:" |
104 | 100 | ); |
105 | 101 | |
106 | | -//Dutch |
107 | 102 | $messages['nl'] = array( |
108 | 103 | "editcount" => "Bewerkingsteller", |
109 | 104 | "editcount-des" => "Geef een gebruikersnaam of een IP-adres om .", |
— | — | @@ -117,4 +112,3 @@ |
118 | 113 | "editcount-total" => "Totaal", |
119 | 114 | "editcount-username" => "Gebruikersnaam:" |
120 | 115 | ); |
121 | | - |
Index: trunk/extensions/mw-editcount/EditCount.php |
— | — | @@ -4,8 +4,8 @@ |
5 | 5 | * |
6 | 6 | * @package MediaWiki |
7 | 7 | * @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 |
10 | 10 | * @license GPL http://www.gnu.org/copyleft/gpl.html |
11 | 11 | */ |
12 | 12 | |
— | — | @@ -14,25 +14,25 @@ |
15 | 15 | } |
16 | 16 | |
17 | 17 | /************************************* |
18 | | - Configuartion |
| 18 | + Configuration |
19 | 19 | ***************************************/ |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * True to turn on parser function and false to not |
23 | 23 | */ |
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 | + */ |
37 | 37 | $egECEnableSpecialPage = true; |
38 | 38 | |
39 | 39 | /************************************* |
— | — | @@ -51,63 +51,62 @@ |
52 | 52 | $wgExtensionFunctions[] = "efEditCount"; |
53 | 53 | |
54 | 54 | $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. |
58 | 58 | */ |
59 | 59 | function efEditCount() { |
60 | | - global $wgAutoloadClasses, $wgSpecialPages, $wgParser,
|
61 | | - $egECParserFunction, $egECEnableSpecialPage, $egECParserFunctionNames, $wgVersion; |
62 | | - |
| 60 | + global $wgAutoloadClasses, $wgSpecialPages, $wgHooks, |
| 61 | + $egECParserFunction, $egECEnableSpecialPage; |
63 | 62 | //Autoload |
64 | 63 | $wgAutoloadClasses["EditCountPage"] = dirname(__FILE__) . "/EditCountPage.php"; |
65 | | - $wgAutoloadClasses["EditCount"] = dirname(__FILE__) . "/EditCountPage.php";
|
66 | | -
|
| 64 | + $wgAutoloadClasses["EditCount"] = dirname(__FILE__) . "/EditCountPage.php"; |
| 65 | + |
67 | 66 | if ($egECEnableSpecialPage) { |
68 | 67 | $wgSpecialPages["EditCount"] = "EditCountPage"; |
69 | 68 | $wgHooks["SkinTemplateBuildNavUrlsNav_urlsAfterPermalink"][] = "efEditCountNavUrls"; |
70 | | - $wgHooks["MonoBookTemplateToolboxEnd"][] = "efEditCountToolbox";
|
| 69 | + $wgHooks["MonoBookTemplateToolboxEnd"][] = "efEditCountToolbox"; |
71 | 70 | } |
72 | 71 | |
73 | 72 | if ($egECParserFunction) { |
74 | 73 | $wgHooks["LanguageGetMagic"][] = "efEditCountMagic"; |
75 | | - $wgHooks['ParserFirstCallInit'][] = "efEditCountRegisterParser";
|
| 74 | + $wgHooks['ParserFirstCallInit'][] = "efEditCountRegisterParser"; |
76 | 75 | } |
77 | 76 | |
78 | 77 | } |
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 |
85 | 84 | */ |
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; |
92 | 87 | |
| 88 | + if (!is_array($egECParserFunctionNames) || count($egECParserFunctionNames) == 0) { |
| 89 | + $egECParserFunctionNames = array("editcount", "ec"); |
| 90 | + } |
| 91 | + |
93 | 92 | $magicWords["editcount"] = array_merge(array(0), $egECParserFunctionNames); |
94 | 93 | 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 |
105 | 104 | */ |
106 | 105 | 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 | + } |
112 | 111 | wfLoadExtensionMessages( 'mw-editcount' ); |
113 | 112 | $title = $skinTemplate->mTitle; |
114 | 113 | if ($title->getNamespace() == NS_USER && $revisionid !== 0) { |
— | — | @@ -122,18 +121,17 @@ |
123 | 122 | * Registers the parser function with parsers |
124 | 123 | */ |
125 | 124 | function efEditCountRegisterParser(&$parser) { |
126 | | - $wgParser->setFunctionHook("editcount", "efEditCountParserFunction"); |
127 | | - |
| 125 | + $parser->setFunctionHook("editcount", "efEditCountParserFunction"); |
128 | 126 | return true; |
129 | 127 | } |
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 |
138 | 136 | */ |
139 | 137 | function efEditCountParserFunction($parser, $param1 = "", $param2 = "") { |
140 | 138 | global $wgContLang; |
— | — | @@ -152,6 +150,7 @@ |
153 | 151 | return $ec->getTotal(); |
154 | 152 | } |
155 | 153 | |
| 154 | + //FIXME: don't use is_numeric |
156 | 155 | if (!is_numeric($param2)) { |
157 | 156 | $index = Namespace::getCanonicalIndex(strtolower($param2)); |
158 | 157 | if ($index === null) { |
— | — | @@ -171,12 +170,12 @@ |
172 | 171 | wfProfileOut(__FUNCTION__); |
173 | 172 | return $ec->getByNamespace($index); |
174 | 173 | } |
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 |
181 | 180 | */ |
182 | 181 | function efEditcountToolbox(&$monobook) { |
183 | 182 | wfLoadExtensionMessages( 'mw-editcount' ); |