Index: trunk/extensions/SiteMatrix/SiteMatrix.php |
— | — | @@ -55,6 +55,9 @@ |
56 | 56 | 'prefix' => 'v', |
57 | 57 | ) |
58 | 58 | ); |
| 59 | +$wgSiteMatrixPrivateSites = null; |
| 60 | +$wgSiteMatrixFishbowlSites = null; |
| 61 | +$wgSiteMatrixClosedSites = null; |
59 | 62 | |
60 | 63 | $dir = dirname(__FILE__) . '/'; |
61 | 64 | |
Index: trunk/extensions/SiteMatrix/SiteMatrix_body.php |
— | — | @@ -10,7 +10,8 @@ |
11 | 11 | require_once( $IP.'/languages/Names.php' ); |
12 | 12 | |
13 | 13 | class SiteMatrix { |
14 | | - protected $langlist, $sites, $names, $hosts, $private, $fishbowl; |
| 14 | + protected $langlist, $sites, $names, $hosts; |
| 15 | + protected $private = null, $fishbowl = null, $closed = null; |
15 | 16 | protected $specials, $matrix, $count, $countPerSite; |
16 | 17 | |
17 | 18 | public function __construct(){ |
— | — | @@ -33,8 +34,6 @@ |
34 | 35 | $this->sites = array(); |
35 | 36 | $this->names = array(); |
36 | 37 | $this->hosts = array(); |
37 | | - $this->private = array(); |
38 | | - $this->fishbowl = array(); |
39 | 38 | |
40 | 39 | foreach( $wgSiteMatrixSites as $site => $conf ){ |
41 | 40 | $this->sites[] = $site; |
— | — | @@ -94,8 +93,6 @@ |
95 | 94 | } |
96 | 95 | |
97 | 96 | $this->count = count( $wgLocalDatabases ); |
98 | | - |
99 | | - wfRunHooks( 'SiteMatrixGetPrivateAndFishbowlWikis', array( &$this->private, &$this->fishbowl ) ); |
100 | 97 | } |
101 | 98 | |
102 | 99 | public static function sortSpecial( $a1, $a2 ){ |
— | — | @@ -115,15 +112,15 @@ |
116 | 113 | } |
117 | 114 | |
118 | 115 | public function getSpecials(){ |
119 | | - return $this->specials; |
| 116 | + return $this->specials; |
120 | 117 | } |
121 | 118 | |
122 | 119 | public function getCount(){ |
123 | | - return $this->count; |
| 120 | + return $this->count; |
124 | 121 | } |
125 | 122 | |
126 | 123 | public function getCountPerSite( $site ){ |
127 | | - return $this->countPerSite[$site]; |
| 124 | + return $this->countPerSite[$site]; |
128 | 125 | } |
129 | 126 | |
130 | 127 | public function getSiteUrl( $site ){ |
— | — | @@ -142,31 +139,59 @@ |
143 | 140 | return !empty( $this->matrix[$major][$minor] ); |
144 | 141 | } |
145 | 142 | |
146 | | - # FIXME: Function does not work any longer: |
147 | | - # 2008-01-09 04:08 Tim: migrated all locked wikis from $wgReadOnly(File) to permissions-based locking, |
148 | | - # so that stewards can edit the alternate project links, and so that various MediaWiki components don't break on page view |
| 143 | + public function isClosed( $minor, $major ) { |
| 144 | + global $wgSiteMatrixClosedSites; |
149 | 145 | |
150 | | - # From http://noc.wikimedia.org/conf/highlight.php?file=InitialiseSettings.php: |
151 | | - # 'wgReadOnlyFile' => array( |
152 | | - # # Now soft-locked via closed.dblist: |
| 146 | + $dbname = $minor . $major; |
153 | 147 | |
154 | | - public function isClosed( $minor, $major ) { |
155 | | - global $wgConf; |
| 148 | + if ( $wgSiteMatrixClosedSites === null ) { |
| 149 | + global $wgConf; |
156 | 150 | |
157 | | - $dbname = $minor . $major; |
158 | | - if( $wgConf->get( 'wgReadOnly', $dbname, $major, array( 'site' => $major, 'lang' => $minor ) ) ) |
159 | | - return true; |
160 | | - $readOnlyFile = $wgConf->get( 'wgReadOnlyFile', $dbname, $major, array( 'site' => $major, 'lang' => $minor ) ); |
161 | | - if( $readOnlyFile && file_exists( $readOnlyFile ) ) |
162 | | - return true; |
163 | | - return false; |
| 151 | + if( $wgConf->get( 'wgReadOnly', $dbname, $major, array( 'site' => $major, 'lang' => $minor ) ) ) |
| 152 | + return true; |
| 153 | + $readOnlyFile = $wgConf->get( 'wgReadOnlyFile', $dbname, $major, array( 'site' => $major, 'lang' => $minor ) ); |
| 154 | + if( $readOnlyFile && file_exists( $readOnlyFile ) ) |
| 155 | + return true; |
| 156 | + return false; |
| 157 | + } elseif ( $this->closed == null ) { |
| 158 | + $this->closed = array(); |
| 159 | + if ( is_string( $wgSiteMatrixClosedSites ) ) { |
| 160 | + $this->closed = array_map( 'trim', file( $wgSiteMatrixClosedSites ) ); |
| 161 | + } elseif ( is_array( $wgSiteMatrixClosedSites ) ) { |
| 162 | + $this->closed = $wgSiteMatrixClosedSites; |
| 163 | + } |
| 164 | + } |
| 165 | + |
| 166 | + return in_array( $dbname, $this->closed ); |
164 | 167 | } |
165 | 168 | |
166 | 169 | public function isPrivate( $dbname ) { |
| 170 | + global $wgSiteMatrixPrivateSites; |
| 171 | + |
| 172 | + if ( $this->private == null ) { |
| 173 | + $this->private = array(); |
| 174 | + if ( is_string( $wgSiteMatrixPrivateSites ) ) { |
| 175 | + $this->private = array_map( 'trim', file( $wgSiteMatrixPrivateSites ) ); |
| 176 | + } elseif ( is_array( $wgSiteMatrixPrivateSites ) ) { |
| 177 | + $this->private = $wgSiteMatrixPrivateSites; |
| 178 | + } |
| 179 | + } |
| 180 | + |
167 | 181 | return in_array( $dbname, $this->private ); |
168 | 182 | } |
169 | 183 | |
170 | 184 | public function isFishbowl( $dbname ) { |
| 185 | + global $wgSiteMatrixFishbowlSites; |
| 186 | + |
| 187 | + if ( $this->fishbowl == null ) { |
| 188 | + $this->fishbowl = array(); |
| 189 | + if ( is_string( $wgSiteMatrixFishbowlSites ) ) { |
| 190 | + $this->fishbowl = array_map( 'trim', file( $wgSiteMatrixFishbowlSites ) ); |
| 191 | + } elseif ( is_array( $wgSiteMatrixFishbowlSites ) ) { |
| 192 | + $this->fishbowl = $wgSiteMatrixFishbowlSites; |
| 193 | + } |
| 194 | + } |
| 195 | + |
171 | 196 | return in_array( $dbname, $this->fishbowl ); |
172 | 197 | } |
173 | 198 | } |
— | — | @@ -180,12 +205,12 @@ |
181 | 206 | function execute( $par ) { |
182 | 207 | global $wgOut, $wgRequest, $wgLanguageNames; |
183 | 208 | wfLoadExtensionMessages( 'SiteMatrix' ); |
184 | | - |
| 209 | + |
185 | 210 | $this->setHeaders(); |
186 | 211 | $this->outputHeader(); |
187 | 212 | |
188 | 213 | $matrix = new SiteMatrix(); |
189 | | - |
| 214 | + |
190 | 215 | if( class_exists( 'LanguageNames' ) ) { |
191 | 216 | global $wgLang; |
192 | 217 | $localLanguageNames = LanguageNames::getNames( $wgLang->getCode() ); |
— | — | @@ -290,7 +315,7 @@ |
291 | 316 | list( $lang, $site ) = $special; |
292 | 317 | $langhost = str_replace( '_', '-', $lang ); |
293 | 318 | $url = $matrix->getUrl( $lang, $site ); |
294 | | - |
| 319 | + |
295 | 320 | # Handle options |
296 | 321 | $flags = array(); |
297 | 322 | if( $matrix->isPrivate( $lang . $site ) ) |
— | — | @@ -326,7 +351,7 @@ |
327 | 352 | $matrix_out = array( |
328 | 353 | 'count' => $matrix->getCount(), |
329 | 354 | ); |
330 | | - |
| 355 | + |
331 | 356 | if( class_exists( 'LanguageNames' ) ) { |
332 | 357 | global $wgLang; |
333 | 358 | $localLanguageNames = LanguageNames::getNames( $wgLang->getCode() ); |
— | — | @@ -352,6 +377,8 @@ |
353 | 378 | 'url' => $url, |
354 | 379 | 'code' => $site, |
355 | 380 | ); |
| 381 | + if( $matrix->isClosed( $lang, $site ) ) |
| 382 | + $site_out['closed'] = ''; |
356 | 383 | $language['site'][] = $site_out; |
357 | 384 | } |
358 | 385 | } |
— | — | @@ -370,12 +397,12 @@ |
371 | 398 | $wiki = array(); |
372 | 399 | $wiki['url'] = $url; |
373 | 400 | $wiki['code'] = str_replace( '_', '-', $lang ) . ( $site != 'wiki' ? $site : '' ); |
374 | | - |
375 | | - if( $matrix->isPrivate( $lang . $site ) ) |
| 401 | + |
| 402 | + if( $matrix->isPrivate( $lang . $site ) ) |
376 | 403 | $wiki['private'] = ''; |
377 | 404 | if( $matrix->isFishbowl( $lang . $site ) ) |
378 | 405 | $wiki['fishbowl'] = ''; |
379 | | - |
| 406 | + |
380 | 407 | $specials[] = $wiki; |
381 | 408 | } |
382 | 409 | |