Index: trunk/extensions/Translate/groups/mediawiki-defines.txt |
— | — | @@ -508,6 +508,9 @@ |
509 | 509 | |
510 | 510 | Mini Preview |
511 | 511 | |
| 512 | +Most Revisors |
| 513 | +ignored = mostrevisors-users, mostrevisors-limit-few-revisors |
| 514 | + |
512 | 515 | Multi Boilerplate |
513 | 516 | ignored = multiboilerplate, multiboilerplate-label |
514 | 517 | |
Index: trunk/extensions/Translate/aliases.txt |
— | — | @@ -178,6 +178,9 @@ |
179 | 179 | Mibbit |
180 | 180 | file = Mibbit/Mibbit.alias.php |
181 | 181 | |
| 182 | +Most revisors |
| 183 | +file = MostRevisors/MostRevisors.alias.php |
| 184 | + |
182 | 185 | Multi upload |
183 | 186 | file = MultiUpload/SpecialMultipleUpload.alias.php |
184 | 187 | |
Index: trunk/extensions/MostRevisors/MostRevisors_body.php |
— | — | @@ -1,26 +1,25 @@ |
2 | 2 | <?php |
3 | 3 | class MostRevisors extends IncludableSpecialPage { |
4 | | - |
5 | 4 | private $limit = NULL; |
6 | 5 | private $namespace = NULL; |
7 | 6 | private $redirects = NULL; |
8 | 7 | |
9 | | - public function __construct() { |
10 | | - parent::__construct( 'MostRevisors' ); |
| 8 | + public function __construct() { |
| 9 | + parent::__construct( 'MostRevisors' ); |
11 | 10 | $this->mIncludable = true; |
12 | | - } |
| 11 | + } |
13 | 12 | |
14 | | - public function execute( $par ) { |
15 | | - global $wgOut, $wgRequest, $wgLang, $wgContLang, $wgUser, $wgArticle, $wgTitle; |
16 | | - wfLoadExtensionMessages( 'MostRevisors' ); |
17 | | - |
| 13 | + public function execute( $par ) { |
| 14 | + global $wgOut, $wgRequest, $wgLang, $wgContLang, $wgUser, $wgArticle, $wgTitle; |
| 15 | + wfLoadExtensionMessages( 'MostRevisors' ); |
| 16 | + |
18 | 17 | # Decipher input passed to the page |
19 | 18 | $this->decipherParams( $par ); |
20 | 19 | $this->setOptions( $wgRequest ); |
21 | | - |
22 | | - ###debug |
23 | | - #$wgOut->addWikiText( "DEBUG thisNS: $this->namespace" ); |
24 | | - |
| 20 | + |
| 21 | + # ##debug |
| 22 | + # $wgOut->addWikiText( "DEBUG thisNS: $this->namespace" ); |
| 23 | + |
25 | 24 | $dbr = wfGetDB( DB_SLAVE ); |
26 | 25 | |
27 | 26 | $conds = array(); |
— | — | @@ -31,32 +30,34 @@ |
32 | 31 | $qns = "WHERE page_namespace=" . $this->namespace; |
33 | 32 | if ( !$this->redirects ) $qns .= " AND page_is_redirect=0"; |
34 | 33 | } |
35 | | - ###debug |
36 | | - #$wgOut->addWikiText( "DEBUG qns: $qns" ); |
37 | | - $limitfewrevisors = wfMsg( 'mostrevisors-limit-few-revisors'); |
| 34 | + # ##debug |
| 35 | + # $wgOut->addWikiText( "DEBUG qns: $qns" ); |
| 36 | + $limitfewrevisors = wfMsg( 'mostrevisors-limit-few-revisors' ); |
38 | 37 | list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' ); |
39 | 38 | $sql = " |
40 | | - SELECT |
41 | | - page_title as title, page_is_redirect, page_namespace as namespace, |
42 | | - COUNT(distinct rev_user) as value |
43 | | - FROM $revision |
44 | | - JOIN $page ON page_id = rev_page |
45 | | - " . $dbr->strencode($qns) . " |
46 | | - GROUP BY page_namespace, page_title |
47 | | - HAVING COUNT(distinct rev_user) >=$limitfewrevisors |
48 | | - ORDER BY value DESC |
49 | | - LIMIT "."{$this->limit} |
50 | | - "; |
51 | | - ###debug |
52 | | - #$wgOut->addWikiText( "DEBUG sql: $sql" ); |
| 39 | + SELECT |
| 40 | + page_title as title, |
| 41 | + page_is_redirect, |
| 42 | + page_namespace as namespace, |
| 43 | + COUNT(distinct rev_user) as value |
| 44 | + FROM $revision |
| 45 | + JOIN $page ON page_id = rev_page |
| 46 | + " . $dbr->strencode( $qns ) . " |
| 47 | + GROUP BY page_namespace, page_title |
| 48 | + HAVING COUNT(distinct rev_user) >=$limitfewrevisors |
| 49 | + ORDER BY value DESC |
| 50 | + LIMIT " . "{$this->limit} |
| 51 | + "; |
| 52 | + # ##debug |
| 53 | + # $wgOut->addWikiText( "DEBUG sql: $sql" ); |
53 | 54 | $res = $dbr->query( $sql, __METHOD__ ); |
54 | 55 | $count = $dbr->numRows( $res ); |
55 | 56 | |
56 | 57 | # Don't show the navigation if we're including the page |
57 | | - if( !$this->mIncluding ) { |
| 58 | + if ( !$this->mIncluding ) { |
58 | 59 | $this->setHeaders(); |
59 | 60 | $limit = $wgLang->formatNum( $this->limit ); |
60 | | - if( $this->namespace > 0 ) { |
| 61 | + if ( $this->namespace > 0 ) { |
61 | 62 | $wgOut->addWikiMsg( 'mostrevisors-ns-header', $limit, $wgContLang->getFormattedNsText( $this->namespace ) ); |
62 | 63 | } else { |
63 | 64 | $wgOut->addWikiMsg( 'mostrevisors-header', $limit ); |
— | — | @@ -66,10 +67,10 @@ |
67 | 68 | $wgOut->addHTML( '<br />' . $this->makeRedirectToggle() . '</p>' ); |
68 | 69 | } |
69 | 70 | |
70 | | - if( $count > 0 ) { |
| 71 | + if ( $count > 0 ) { |
71 | 72 | # Make list |
72 | | - if( !$this->mIncluding ) |
73 | | - $wgOut->addWikiMsg( 'mostrevisors-showing', $wgLang->formatNum($count) ); |
| 73 | + if ( !$this->mIncluding ) |
| 74 | + $wgOut->addWikiMsg( 'mostrevisors-showing', $wgLang->formatNum( $count ) ); |
74 | 75 | $wgOut->addHTML( "<ol>" ); |
75 | 76 | foreach ( $res as $row ) { |
76 | 77 | $wgOut->addHTML( $this->makeListItem( $row ) ); |
— | — | @@ -78,25 +79,27 @@ |
79 | 80 | } else { |
80 | 81 | $wgOut->addWikiMsg( 'mostrevisors-none' ); |
81 | 82 | } |
82 | | - } |
83 | | - |
| 83 | + } |
| 84 | + |
84 | 85 | private function setOptions( &$req ) { |
85 | 86 | global $wgMostRevisorsPagesLimit; |
86 | | - if( !isset( $this->limit ) ) |
87 | | - $this->limit = $this->sanitiseLimit( $req->getInt( 'limit', $wgMostRevisorsPagesLimit ) ); |
88 | | - if( !isset( $this->namespace ) ) |
89 | | - $this->namespace = $this->extractNamespace( $req->getVal( 'namespace', 0 ) ); |
90 | | - if( !isset( $this->redirects ) ) |
91 | | - $this->redirects = (bool)$req->getInt( 'redirects', 1 ); |
| 87 | + if ( !isset( $this->limit ) ) |
| 88 | + $this->limit = $this->sanitiseLimit( $req->getInt( 'limit', $wgMostRevisorsPagesLimit ) ); |
| 89 | + if ( !isset( $this->namespace ) ) |
| 90 | + $this->namespace = $this->extractNamespace( $req->getVal( 'namespace', 0 ) ); |
| 91 | + if ( !isset( $this->redirects ) ) |
| 92 | + $this->redirects = (bool)$req->getInt( 'redirects', 1 ); |
92 | 93 | } |
| 94 | + |
93 | 95 | private function sanitiseLimit( $limit ) { |
94 | 96 | return min( (int)$limit, 5000 ); |
95 | 97 | } |
| 98 | + |
96 | 99 | private function decipherParams( $par ) { |
97 | | - if( $par ) { |
| 100 | + if ( $par ) { |
98 | 101 | $bits = explode( '/', $par ); |
99 | | - foreach( $bits as $bit ) { |
100 | | - if( is_numeric( $bit ) ) { |
| 102 | + foreach ( $bits as $bit ) { |
| 103 | + if ( is_numeric( $bit ) ) { |
101 | 104 | $this->limit = $this->sanitiseLimit( $bit ); |
102 | 105 | } else { |
103 | 106 | $this->namespace = $this->extractNamespace( $bit ); |
— | — | @@ -104,42 +107,45 @@ |
105 | 108 | } |
106 | 109 | } |
107 | 110 | } |
| 111 | + |
108 | 112 | private function extractNamespace( $namespace ) { |
109 | 113 | global $wgContLang; |
110 | | - if( is_numeric( $namespace ) ) { |
| 114 | + if ( is_numeric( $namespace ) ) { |
111 | 115 | return $namespace; |
112 | | - } elseif( $wgContLang->getNsIndex( $namespace ) !== false ) { |
| 116 | + } elseif ( $wgContLang->getNsIndex( $namespace ) !== false ) { |
113 | 117 | return $wgContLang->getNsIndex( $namespace ); |
114 | | - } elseif( $namespace == '-' ) { |
| 118 | + } elseif ( $namespace == '-' ) { |
115 | 119 | return NS_MAIN; |
116 | | - } elseif( $namespace == 'all' ) { |
| 120 | + } elseif ( $namespace == 'all' ) { |
117 | 121 | return 'all'; |
118 | 122 | } else { |
119 | 123 | return 'all'; |
120 | 124 | } |
121 | 125 | } |
| 126 | + |
122 | 127 | private function makeListItem( $row ) { |
123 | 128 | global $wgUser, $wgMostRevisorsLinkContributors; |
124 | 129 | $title = Title::makeTitleSafe( $row->namespace, $row->title ); |
125 | | - if( !is_null( $title ) ) { |
| 130 | + if ( !is_null( $title ) ) { |
126 | 131 | $skin = $wgUser->getSkin(); |
127 | 132 | $link = $row->page_is_redirect |
128 | | - ? '<span class="allpagesredirect">' . $skin->makeKnownLinkObj( $title ) . '</span>' |
129 | | - : $skin->makeKnownLinkObj( $title ); |
130 | | - $link .= " - $row->value ". wfMsg('mostrevisors-users'); |
131 | | - if ( $wgMostRevisorsLinkContributors == True ) $link .= " (".$skin->makeKnownLinkObj( Title::makeTitleSafe( -1, 'Contributors/'.$title ), wfMsg('mostrevisors-viewcontributors') ).")"; |
| 133 | + ? '<span class="allpagesredirect">' . $skin->makeKnownLinkObj( $title ) . '</span>' |
| 134 | + : $skin->makeKnownLinkObj( $title ); |
| 135 | + $link .= " - $row->value " . wfMsg( 'mostrevisors-users' ); |
| 136 | + if ( $wgMostRevisorsLinkContributors == True ) $link .= " (" . $skin->makeKnownLinkObj( Title::makeTitleSafe( - 1, 'Contributors/' . $title ), wfMsg( 'mostrevisors-viewcontributors' ) ) . ")"; |
132 | 137 | return( "<li>{$link}</li>\n" ); |
133 | 138 | } else { |
134 | 139 | return( "<!-- Invalid title " . htmlspecialchars( $row->title ) . " in namespace " . htmlspecialchars( $row->page_namespace ) . " -->\n" ); |
135 | 140 | } |
136 | 141 | } |
| 142 | + |
137 | 143 | private function makeLimitLinks() { |
138 | 144 | global $wgLang; |
139 | 145 | |
140 | 146 | $limits = array( 10, 20, 30, 50, 100, 150 ); |
141 | | - foreach( $limits as $limit ) { |
142 | | - if( $limit != $this->limit ) { |
143 | | - $links[] = $this->makeSelfLink( $wgLang->formatNum($limit), 'limit', $limit ); |
| 147 | + foreach ( $limits as $limit ) { |
| 148 | + if ( $limit != $this->limit ) { |
| 149 | + $links[] = $this->makeSelfLink( $wgLang->formatNum( $limit ), 'limit', $limit ); |
144 | 150 | } else { |
145 | 151 | $links[] = (string)$limit; |
146 | 152 | } |
— | — | @@ -151,20 +157,22 @@ |
152 | 158 | $label = wfMsgHtml( $this->redirects ? 'mostrevisors-hideredir' : 'mostrevisors-showredir' ); |
153 | 159 | return $this->makeSelfLink( $label, 'redirects', (int)!$this->redirects ); |
154 | 160 | } |
| 161 | + |
155 | 162 | private function makeSelfLink( $label, $oname = false, $oval = false ) { |
156 | 163 | global $wgUser; |
157 | 164 | $skin =& $wgUser->getSkin(); |
158 | 165 | $self = $this->getTitle(); |
159 | 166 | $attr['limit'] = $this->limit; |
160 | 167 | $attr['namespace'] = $this->namespace; |
161 | | - if( !$this->redirects ) |
162 | | - $attr['redirects'] = 0; |
163 | | - if( $oname ) |
164 | | - $attr[$oname] = $oval; |
165 | | - foreach( $attr as $aname => $aval ) |
166 | | - $attribs[] = "{$aname}={$aval}"; |
| 168 | + if ( !$this->redirects ) |
| 169 | + $attr['redirects'] = 0; |
| 170 | + if ( $oname ) |
| 171 | + $attr[$oname] = $oval; |
| 172 | + foreach ( $attr as $aname => $aval ) |
| 173 | + $attribs[] = "{$aname}={$aval}"; |
167 | 174 | return $skin->makeKnownLinkObj( $self, $label, implode( '&', $attribs ) ); |
168 | 175 | } |
| 176 | + |
169 | 177 | private function makeNamespaceForm() { |
170 | 178 | $self = $this->getTitle(); |
171 | 179 | $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) ); |
— | — | @@ -175,4 +183,4 @@ |
176 | 184 | $form .= Xml::submitButton( wfMsg( 'mostrevisors-submit' ) ) . '</form>'; |
177 | 185 | return $form; |
178 | 186 | } |
179 | | -} |
\ No newline at end of file |
| 187 | +} |
Index: trunk/extensions/MostRevisors/MostRevisors.i18n.php |
— | — | @@ -8,20 +8,22 @@ |
9 | 9 | $messages = array(); |
10 | 10 | |
11 | 11 | $messages['en'] = array( |
12 | | - 'mostrevisors-header' => "'''This page lists the {{PLURAL:$1|page|$1 pages}} with most revisors on the wiki.'''", |
| 12 | + 'mostrevisors' => 'Pages with the most revisors', |
| 13 | + 'mostrevisors-desc' => 'List [[Special:MostRevisors|pages with the most revisors]]', |
| 14 | + 'mostrevisors-header' => "'''This page lists the {{PLURAL:$1|page|$1 pages}} with most revisors on the wiki.'''", |
13 | 15 | 'mostrevisors-limitlinks' => 'Show up to $1 pages', |
14 | | - 'mostrevisors-namespace' => 'Namespace:', |
15 | | - 'mostrevisors-none' => 'No entries were found.', |
16 | | - 'mostrevisors-ns-header' => "'''This page lists the {{PLURAL:$1|page|$1 pages}} with most revisors in the $2 namespace.'''", |
17 | | - 'mostrevisors-showing' => 'Listing {{PLURAL:$1|page|$1 pages}}:', |
18 | | - 'mostrevisors-submit' => 'Go', |
19 | | - 'mostrevisors-showredir' => 'Show redirect pages', |
20 | | - 'mostrevisors-hideredir' => 'Hide redirect pages', |
21 | | - 'mostrevisors' => 'Pages with the most revisors', |
22 | | - 'mostrevisors-desc' => 'List [[Special:MostRevisors|pages with the most revisors]]', |
| 16 | + 'mostrevisors-namespace' => 'Namespace:', |
| 17 | + 'mostrevisors-none' => 'No entries were found.', |
| 18 | + 'mostrevisors-ns-header' => "'''This page lists the {{PLURAL:$1|page|$1 pages}} with most revisors in the $2 namespace.'''", |
| 19 | + 'mostrevisors-showing' => 'Listing {{PLURAL:$1|page|$1 pages}}:', |
| 20 | + 'mostrevisors-submit' => 'Go', |
| 21 | + 'mostrevisors-showredir' => 'Show redirect pages', |
| 22 | + 'mostrevisors-hideredir' => 'Hide redirect pages', |
23 | 23 | 'mostrevisors-viewcontributors' => 'View main contributors', |
24 | | - 'mostrevisors-text' => 'Show Pages with the most revisors, starting from [[MediaWiki:mostrevisors-limit-few-revisors|{{MediaWiki:mostrevisors-limit-few-revisors}} revisors]]. See also [[Special:MostRevisions]].', |
25 | | - 'mostrevisors-users' => 'editors', |
| 24 | + 'mostrevisors-text' => 'Show [[Special:MostRevisions|pages with the most revisors]], starting from [[MediaWiki:mostrevisors-limit-few-revisors|{{MediaWiki:Mostrevisors-limit-few-revisors}} revisors]].', |
| 25 | + |
| 26 | + // Settings. Do not translate these messages. |
| 27 | + 'mostrevisors-users' => 'editors', |
26 | 28 | 'mostrevisors-limit-few-revisors' => '1', |
27 | 29 | ); |
28 | 30 | |
Index: trunk/extensions/MostRevisors/MostRevisors.php |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | // If this is run directly from the web die as this is not a valid entry point. |
9 | | -if( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' ); |
| 9 | +if ( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' ); |
10 | 10 | |
11 | 11 | // Extension credits. |
12 | 12 | $wgExtensionCredits['specialpage'][] = array( |