r8016 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r8015‎ | r8016 | r8017 >
Date:11:09, 1 April 2005
Author:avar
Status:old
Tags:
Comment:
* New feature, the ability to 'invert' namespaces in Special:Allmessages, given
a namespace the 'Invert' namespace can be selected to perform WHERE
page_namespace != $namespace instead of WHERE page_namespace = ..

** Added code in includes/SpecialAllpages.php to make this possible

** Removed messages: allpagesformtext1 and allpagesformtext2 (obsoleted by the
new allpagesformtext messsage)
** Renamed message allpagesnamespace to allinnamespace
** Added messages allnonarticles, allnotinnamespace, contributionsformtext

** includes/SpecialContributions.php no longer uses allpagesformtext2 but the
new contributionsformtext
Modified paths:
  • /trunk/phase3/includes/SpecialAllpages.php (modified) (history)
  • /trunk/phase3/includes/SpecialContributions.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/LanguageEs.php (modified) (history)
  • /trunk/phase3/languages/LanguageFi.php (modified) (history)
  • /trunk/phase3/languages/LanguageFr.php (modified) (history)
  • /trunk/phase3/languages/LanguageIs.php (modified) (history)
  • /trunk/phase3/languages/LanguageNds.php (modified) (history)
  • /trunk/phase3/languages/LanguageNn.php (modified) (history)
  • /trunk/phase3/languages/LanguageRu.php (modified) (history)
  • /trunk/phase3/languages/LanguageZh_cn.php (modified) (history)
  • /trunk/phase3/languages/LanguageZh_tw.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialAllpages.php
@@ -11,23 +11,38 @@
1212 */
1313 function wfSpecialAllpages( $par=NULL ) {
1414 global $indexMaxperpage, $toplevelMaxperpage, $wgRequest, $wgOut, $wgContLang;
 15+ # Config
1516 $indexMaxperpage = 480;
1617 $toplevelMaxperpage = 50;
 18+ # GET values
1719 $from = $wgRequest->getVal( 'from' );
1820 $namespace = $wgRequest->getInt( 'namespace' );
 21+ $invert = $wgRequest->getInt( 'invert' );
 22+
1923 $names = $wgContLang->getNamespaces();
 24+
2025 if( !isset( $names[$namespace] ) ) {
2126 $namespace = 0;
2227 }
23 - $wgOut->setPagetitle ( $namespace > 0 ? wfMsg ( 'allpagesnamespace', $names[$namespace] )
24 - : wfMsg ( 'allarticles' ) );
2528
 29+ if ($invert) {
 30+ $wgOut->setPagetitle( $namespace > 0 ?
 31+ wfMsg( 'allnotinnamespace', $names[$namespace] ) :
 32+ wfMsg( 'allnonarticles' )
 33+ );
 34+ } else {
 35+ $wgOut->setPagetitle( $namespace > 0 ?
 36+ wfMsg( 'allinnamespace', $names[$namespace] ) :
 37+ wfMsg( 'allarticles' )
 38+ );
 39+ }
 40+
2641 if ( $par ) {
27 - indexShowChunk( $par, $namespace );
 42+ indexShowChunk( $namespace, $par, $invert );
2843 } elseif ( $from ) {
29 - indexShowChunk( $from, $namespace );
 44+ indexShowChunk( $namespace, $from, $invert );
3045 } else {
31 - indexShowToplevel ( $namespace );
 46+ indexShowToplevel ( $namespace, $invert );
3247 }
3348 }
3449
@@ -36,9 +51,8 @@
3752 * @param integer $namespace A namespace constant (default NS_MAIN).
3853 * @param string $from Article name we are starting listing at.
3954 */
40 -function namespaceForm ( $namespace = NS_MAIN, $from = '' ) {
 55+function namespaceForm ( $namespace = NS_MAIN, $from = '', $invert = 0) {
4156 global $wgContLang, $wgScript;
42 -
4357 $t = Title::makeTitle( NS_SPECIAL, "Allpages" );
4458
4559 $namespaceselect = '<select name="namespace">';
@@ -55,11 +69,12 @@
5670 $frombox = '<input type="text" size="20" name="from" value="'
5771 . htmlspecialchars ( $from ) . '"/>';
5872 $submitbutton = '<input type="submit" value="' . wfMsg( 'allpagessubmit' ) . '" />';
 73+
 74+ $invertbox = "<input type='checkbox' name='invert' value='1'" . ( $invert == 1 ? ' checked="checked"' : '' ) . ' />';
5975
6076 $out = "<div class='namespaceselector'><form method='get' action='{$wgScript}'>";
6177 $out .= '<input type="hidden" name="title" value="'.$t->getPrefixedText().'" />';
62 - $out .= wfMsg ( 'allpagesformtext1', $frombox ) . '<br />';
63 - $out .= wfMsg ( 'allpagesformtext2', $namespaceselect, $submitbutton );
 78+ $out .= wfMsg ( 'allpagesformtext', $frombox, $namespaceselect, $submitbutton, $invertbox );
6479 $out .= '</form></div>';
6580 return $out;
6681 }
@@ -68,7 +83,7 @@
6984 * @todo Document
7085 * @param integer $namespace (default NS_MAIN)
7186 */
72 -function indexShowToplevel ( $namespace = NS_MAIN ) {
 87+function indexShowToplevel ( $namespace = NS_MAIN, $invert = 0 ) {
7388 global $wgOut, $indexMaxperpage, $toplevelMaxperpage, $wgContLang, $wgRequest, $wgUser;
7489 $sk = $wgUser->getSkin();
7590 $fname = "indexShowToplevel";
@@ -79,7 +94,8 @@
8095
8196 $dbr =& wfGetDB( DB_SLAVE );
8297 $page = $dbr->tableName( 'page' );
83 - $fromwhere = "FROM $page WHERE page_namespace=$namespace";
 98+ $invsql = ($invert) ? '!' : '';
 99+ $fromwhere = "FROM $page WHERE page_namespace$invsql=$namespace";
84100 $order_arr = array ( 'ORDER BY' => 'page_title' );
85101 $order_str = 'ORDER BY page_title';
86102 $out = "";
@@ -87,11 +103,11 @@
88104
89105 $count = $dbr->selectField( 'page', 'COUNT(*)', $where, $fname );
90106 $sections = ceil( $count / $indexMaxperpage );
91 -
 107+
92108 if ( $sections < 3 ) {
93109 # If there are only two or less sections, don't even display them.
94110 # Instead, display the first section directly.
95 - indexShowChunk( '', $namespace );
 111+ indexShowChunk( $namespace, '', $invert );
96112 return;
97113 }
98114
@@ -110,7 +126,7 @@
111127 $lines = array();
112128
113129 # If we are going to show n rows, we need n+1 queries to find the relevant titles.
114 - for ( $i = $offset; $i <= $stopat; $i++ ) {
 130+ for ( $i = $offset; $i <= $stopat; ++$i ) {
115131 if ( $i == $sections ) # if we're displaying the last section, we need to
116132 $from = $count-1; # find the last page_title in the DB
117133 else if ( $i > $offset )
@@ -136,9 +152,9 @@
137153 $out .= indexShowline ( $inpoint, $outpoint, $namespace );
138154 }
139155 $out .= '</table>';
 156+
 157+ $nsForm = namespaceForm ( $namespace, '', $invert );
140158
141 - $nsForm = namespaceForm ( $namespace );
142 -
143159 # Is there more?
144160 $morelinks = '';
145161 if ( $offset > 0 ) {
@@ -193,7 +209,7 @@
194210 return '<tr><td align="right">'.$out.'</td></tr>';
195211 }
196212
197 -function indexShowChunk( $from, $namespace = NS_MAIN ) {
 213+function indexShowChunk( $namespace = NS_MAIN, $from, $invert ) {
198214 global $wgOut, $wgUser, $indexMaxperpage, $wgContLang;
199215 $sk = $wgUser->getSkin();
200216 $maxPlusOne = $indexMaxperpage + 1;
@@ -206,7 +222,8 @@
207223 $fromTitle = Title::newFromURL( $from );
208224 $fromKey = is_null( $fromTitle ) ? '' : $fromTitle->getDBkey();
209225
210 - $sql = "SELECT page_title FROM $page WHERE page_namespace=$namespacee" .
 226+ $invsql = ($invert) ? '!' : '';
 227+ $sql = "SELECT page_title FROM $page WHERE page_namespace$invsql=$namespacee" .
211228 " AND page_title >= ". $dbr->addQuotes( $fromKey ) .
212229 " ORDER BY page_title LIMIT " . $maxPlusOne;
213230 $res = $dbr->query( $sql, 'indexShowChunk' );
@@ -235,8 +252,8 @@
236253 $out .= '</tr>';
237254 }
238255 $out .= '</table>';
239 -
240 - $nsForm = namespaceForm ( $namespace, $from );
 256+
 257+ $nsForm = namespaceForm ( $namespace, $from, $invert );
241258 $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">';
242259 $out2 .= '<tr valign="top"><td align="left">' . $nsForm;
243260 $out2 .= '</td><td align="right" style="font-size: smaller; margin-bottom: 1em;">' .
@@ -244,10 +261,11 @@
245262 wfMsg ( 'allpages' ) );
246263 if ( ($n == $indexMaxperpage) && ($s = $dbr->fetchObject( $res )) ) {
247264 $namespaceparam = $namespace ? "&namespace=$namespace" : "";
 265+ $invertparam = $invert ? "&invert=$invert" : '';
248266 $out2 .= " | " . $sk->makeKnownLink(
249267 $wgContLang->specialPage( "Allpages" ),
250268 wfMsg ( 'nextpage', $s->page_title ),
251 - "from=" . wfUrlEncode ( $s->page_title ) . $namespaceparam );
 269+ "from=" . wfUrlEncode ( $s->page_title ) . $namespaceparam . $invertparam );
252270 }
253271 $out2 .= "</td></tr></table><hr />";
254272
Index: trunk/phase3/includes/SpecialContributions.php
@@ -244,7 +244,7 @@
245245 $out .= '<input type="hidden" name="title" value="'.$wgContLang->specialpage( 'Contributions' ).'" />';
246246 $out .= '<input type="hidden" name="target" value="'.htmlspecialchars( $target ).'" />';
247247 $out .= '<input type="hidden" name="hideminor" value="'.$hideminor.'" />';
248 - $out .= wfMsg ( 'allpagesformtext2', $namespaceselect, $submitbutton );
 248+ $out .= wfMsg ( 'contributionsformtext', $namespaceselect, $submitbutton );
249249 $out .= '</form></div>';
250250 return $out;
251251 }
Index: trunk/phase3/languages/LanguageZh_tw.php
@@ -943,9 +943,7 @@
944944 'allmessages' => "系統界面", //"All system messages",
945945 'allmessagesnotsupportedDB' => "系統界面功能處於關閉狀態 (wgUseDatabaseMessages)。", //"Special:AllMessages not supported because wgUseDatabaseMessages is off.",
946946 'allmessagestext' => "這裡列出所有可定製的系統界面。", //"This is a list of all system messages available in the MediaWiki: namespace.",
947 -'allpagesformtext1' => "列出從 $1 起的條目", //"Display pages starting at: $1",
948 -'allpagesformtext2' => "選定名字空間: $1 $2", //"Choose namespace: $1 $2",
949 -'allpagesnamespace' => "所有 $1 名字空間的條目", //"All pages ($1 namespace)",
 947+'allinnamespace' => "所有 $1 名字空間的條目", //"All pages ($1 namespace)",
950948 'allpagesnext' => "下一頁", //"Next",
951949 'allpagesprev' => "上一頁", //"Previous",
952950 'allpagessubmit' => "提交", //"Go",
Index: trunk/phase3/languages/LanguageEs.php
@@ -1043,12 +1043,10 @@
10441044 # Special:Allpages
10451045 'nextpage' => 'Next page ($1)',
10461046 'articlenamespace' => '(artículos)',
1047 -'allpagesformtext1' => 'Mostrar páginas que comiencen por: $1',
1048 -'allpagesformtext2' => 'Elige espacio de nombres: $1 $2',
10491047 'allarticles' => 'Todos los artículos',
10501048 'allpagesprev' => 'Anterior',
10511049 'allpagesnext' => 'Siguiente',
1052 -'allpagesnamespace' => 'Todas las páginas (espacio $1)',
 1050+'allinnamespace' => 'Todas las páginas (espacio $1)',
10531051 'allpagessubmit' => 'Mostrar',
10541052
10551053 # Patrolling
Index: trunk/phase3/languages/LanguageIs.php
@@ -156,7 +156,6 @@
157157 'allmessages' => 'Kerfismeldingar',
158158 'allmessagestext' => 'Listi yfir meldingar í kerfismeldingarýminu.',
159159 'allpages' => 'Allar síður',
160 -'allpagesformtext2' => 'Nafnrými: $1 $2',
161160 'alphaindexline' => '$1 til $2',
162161 'alreadyloggedin' => '<font color=red><b>Notandinn $1 er þegar innskráður!</b></font><br />',
163162 'ancientpages' => 'Elstu síður',
Index: trunk/phase3/languages/LanguageFi.php
@@ -709,7 +709,7 @@
710710 'allarticles' => 'Kaikki artikkelit',
711711 'allpagesprev' => 'Edellinen',
712712 'allpagesnext' => 'Seuraaa',
713 -'allpagesnamespace' => 'Kaikki sivut (nimiavaruudessa $1 )',
 713+'allinnamespace' => 'Kaikki sivut (nimiavaruudessa $1 )',
714714 'allpagessubmit' => 'Mene',
715715
716716 # Email this user
Index: trunk/phase3/languages/LanguageFr.php
@@ -818,9 +818,7 @@
819819
820820 # All pages
821821 #
822 -'allpagesformtext1' => "Afficher les pages à partir de : $1",
823 -'allpagesformtext2' => "Choisir un <i>namespace</i> : $1 $2",
824 -'allpagesnamespace' => "Toutes les pages (espace $1)",
 822+'allinnamespace' => "Toutes les pages (espace $1)",
825823 'allpagesnext' => "Suivant",
826824 'allpagesprev' => "Précédent",
827825 'allpagessubmit' => "Valider",
Index: trunk/phase3/languages/LanguageNn.php
@@ -899,12 +899,10 @@
900900 # Special:Allpages
901901 'nextpage' => 'Neste side ($1)',
902902 'articlenamespace' => '(innhaldssider)',
903 -'allpagesformtext1' => 'Vis sider frå: $1',
904 -'allpagesformtext2' => 'Velj namnerom: $1 $2',
905903 'allarticles' => 'Alle innhaldssider',
906904 'allpagesprev' => 'Førre',
907905 'allpagesnext' => 'Neste',
908 -'allpagesnamespace' => 'Alle sider ($1 namnerom)',
 906+'allinnamespace' => 'Alle sider ($1 namnerom)',
909907 'allpagessubmit' => 'Utfør',
910908
911909 # Email this user
Index: trunk/phase3/languages/Language.php
@@ -1163,15 +1163,30 @@
11641164 # Special:Allpages
11651165 'nextpage' => 'Next page ($1)',
11661166 'articlenamespace' => '(articles)',
1167 -'allpagesformtext1' => 'Display pages starting at: $1',
1168 -'allpagesformtext2' => 'Choose namespace: $1 $2',
1169 -'allarticles' => 'All articles',
1170 -'allpagesprev' => 'Previous',
1171 -'allpagesnext' => 'Next',
1172 -'allpagesnamespace' => 'All pages ($1 namespace)',
1173 -'allpagessubmit' => 'Go',
 1167+'allpagesformtext' => '
 1168+<table border="0">
 1169+ <tr>
 1170+ <td align="right">Display pages starting at:</td>
 1171+ <td align="left">$1</td>
 1172+ </tr>
 1173+ <tr>
 1174+ <td align="right">Namespace:</td>
 1175+ <td align="left">$2 $3</td>
 1176+ </tr>
 1177+ <tr>
 1178+ <td align="right">$4</td>
 1179+ <td align="left">Invert</td>
 1180+ </tr>
 1181+</table>',
 1182+'allarticles' => 'All articles',
 1183+'allnonarticles' => 'All non-articles',
 1184+'allinnamespace' => 'All pages ($1 namespace)',
 1185+'allnotinnamespace' => 'All pages (not in $1 namespace)',
 1186+'allpagesprev' => 'Previous',
 1187+'allpagesnext' => 'Next',
 1188+'allpagessubmit' => 'Go',
11741189
1175 -# Email this user
 1190+# E this user
11761191 #
11771192 'mailnologin' => 'No send address',
11781193 'mailnologintext' => "You must be <a href=\"{{localurl:Special:Userlogin\">logged in</a>
@@ -1354,6 +1369,13 @@
13551370 'contributions' => 'User contributions',
13561371 'mycontris' => 'My contributions',
13571372 'contribsub' => "For $1",
 1373+'contributionsformtext' => '
 1374+<table border="0">
 1375+ <tr>
 1376+ <td align="right">Namespace:</td>
 1377+ <td align="left">$1 $2</td>
 1378+ </tr>
 1379+</table>',
13581380 'nocontribs' => 'No changes were found matching these criteria.',
13591381 'ucnote' => "Below are this user's last <b>$1</b> changes in the last <b>$2</b> days.",
13601382 'uclinks' => "View the last $1 changes; view the last $2 days.",
@@ -1958,7 +1980,7 @@
19591981 global $wgUser, $wgLocalTZoffset;
19601982
19611983 if (!$tz) {
1962 - $tz = $wgUser->getOption( 'timecorrection' );
 1984+ $tz = $wgUser->getOption( 'timecorrection' );
19631985 }
19641986
19651987 if ( $tz === '' ) {
@@ -2026,7 +2048,7 @@
20272049 }
20282050 return $this->formatNum( $t );
20292051 }
2030 -
 2052+
20312053 function timeanddate( $ts, $adj = false, $format = MW_DATE_USER_FORMAT, $timecorrection = false, $dateandtime = false) {
20322054 global $wgUser;
20332055 $ts=wfTimestamp(TS_MW,$ts);
Index: trunk/phase3/languages/LanguageRu.php
@@ -1010,12 +1010,10 @@
10111011 # Special:Allpages
10121012 'nextpage' => 'Следующая страница ($1)',
10131013 'articlenamespace' => '(статьи)',
1014 -'allpagesformtext1' => 'Показать страницы начиная с: $1',
1015 -'allpagesformtext2' => 'Выберите пространство имён: $1 $2',
10161014 'allarticles' => 'Все статьи',
10171015 'allpagesprev' => 'Предыдущие',
10181016 'allpagesnext' => 'Следующие',
1019 -'allpagesnamespace' => 'Все страницы ($1 пространство имён)',
 1017+'allinnamespace' => 'Все страницы ($1 пространство имён)',
10201018 'allpagessubmit' => 'Выполнить',
10211019
10221020 # Email this user
Index: trunk/phase3/languages/LanguageZh_cn.php
@@ -957,9 +957,7 @@
958958 'allmessages' => "系统界面", //"All system messages",
959959 'allmessagesnotsupportedDB' => "系统界面功能处于关闭状态 (wgUseDatabaseMessages)。", //"Special:AllMessages not supported because wgUseDatabaseMessages is off.",
960960 'allmessagestext' => "这里列出所有可定制的系统界面。", //"This is a list of all system messages available in the MediaWiki: namespace.",
961 -'allpagesformtext1' => "列出从 $1 起的条目", //"Display pages starting at: $1",
962 -'allpagesformtext2' => "选定名字空间: $1 $2", //"Choose namespace: $1 $2",
963 -'allpagesnamespace' => "所有 $1 名字空间的条目", //"All pages ($1 namespace)",
 961+'allinnamespace' => "所有 $1 名字空间的条目", //"All pages ($1 namespace)",
964962 'allpagesnext' => "下一页", //"Next",
965963 'allpagesprev' => "上一页", //"Previous",
966964 'allpagessubmit' => "提交", //"Go",
Index: trunk/phase3/languages/LanguageNds.php
@@ -868,12 +868,10 @@
869869 # Special:Allpages
870870 'nextpage' => 'tokamen Siet ($1)',
871871 'articlenamespace' => '(Artikels)',
872 -'allpagesformtext1' => 'Wies Sieten, anfungen bi: $1',
873 -'allpagesformtext2' => 'Wähl Naamruum: $1 $2',
874872 'allarticles' => 'Alle Artikels',
875873 'allpagesprev' => 'vörig',
876874 'allpagesnext' => 'tokamen',
877 -'allpagesnamespace' => 'Alle Sieten ($1 Naamruum)',
 875+'allinnamespace' => 'Alle Sieten ($1 Naamruum)',
878876 'allpagessubmit' => 'Los',
879877
880878 # Oppasslist

Status & tagging log