Index: trunk/extensions/SiteMatrix/SiteMatrix_body.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | $wgConf->loadFullData(); |
23 | 23 | |
24 | 24 | if( file_exists( $wgSiteMatrixFile ) ){ |
25 | | - $this->langlist = array_map( 'trim', file( $wgSiteMatrixFile ) ); |
| 25 | + $this->langlist = $this->extractFile( $wgSiteMatrixFile ); |
26 | 26 | $hideEmpty = false; |
27 | 27 | } else { |
28 | 28 | $this->langlist = array_keys( Language::getLanguageNames( false ) ); |
— | — | @@ -145,6 +145,8 @@ |
146 | 146 | $dbname = $minor . $major; |
147 | 147 | |
148 | 148 | if ( $wgSiteMatrixClosedSites === null ) { |
| 149 | + // Fallback to old behavior checking read-only settings; |
| 150 | + // not very reliable. |
149 | 151 | global $wgConf; |
150 | 152 | |
151 | 153 | if( $wgConf->get( 'wgReadOnly', $dbname, $major, array( 'site' => $major, 'lang' => $minor ) ) ) |
— | — | @@ -153,15 +155,11 @@ |
154 | 156 | if( $readOnlyFile && file_exists( $readOnlyFile ) ) |
155 | 157 | return true; |
156 | 158 | 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 | 159 | } |
165 | 160 | |
| 161 | + if( $this->closed == null ) { |
| 162 | + $this->closed = $this->extractDbList( $wgSiteMatrixClosedSites ); |
| 163 | + } |
166 | 164 | return in_array( $dbname, $this->closed ); |
167 | 165 | } |
168 | 166 | |
— | — | @@ -169,12 +167,7 @@ |
170 | 168 | global $wgSiteMatrixPrivateSites; |
171 | 169 | |
172 | 170 | 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 | | - } |
| 171 | + $this->private = $this->extractDbList( $wgSiteMatrixPrivateSites ); |
179 | 172 | } |
180 | 173 | |
181 | 174 | return in_array( $dbname, $this->private ); |
— | — | @@ -184,16 +177,38 @@ |
185 | 178 | global $wgSiteMatrixFishbowlSites; |
186 | 179 | |
187 | 180 | 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 | | - } |
| 181 | + $this->fishbowl = $this->extractDbList( $wgSiteMatrixFishbowlSites ); |
194 | 182 | } |
195 | 183 | |
196 | 184 | return in_array( $dbname, $this->fishbowl ); |
197 | 185 | } |
| 186 | + |
| 187 | + /** |
| 188 | + * Pull a list of dbnames from a given text file, or pass through an array. |
| 189 | + * Used for the DB list configuration settings. |
| 190 | + * |
| 191 | + * @param mixed $listOrFilename array of strings, or string with a filename |
| 192 | + * @return array |
| 193 | + */ |
| 194 | + private function extractDbList( $listOrFilename ) { |
| 195 | + if ( is_string( $listOrFilename ) ) { |
| 196 | + return $this->extractFile( $listOrFilename ); |
| 197 | + } elseif ( is_array( $listOrFilename ) ) { |
| 198 | + return $listOrFilename; |
| 199 | + } else { |
| 200 | + return array(); |
| 201 | + } |
| 202 | + } |
| 203 | + |
| 204 | + /** |
| 205 | + * Pull a list of dbnames from a given text file. |
| 206 | + * |
| 207 | + * @param string $filename |
| 208 | + * @return array |
| 209 | + */ |
| 210 | + private function extractFile( $filename ) { |
| 211 | + return array_map( 'trim', file( $filename ) ); |
| 212 | + } |
198 | 213 | } |
199 | 214 | |
200 | 215 | class SiteMatrixPage extends SpecialPage { |