Index: trunk/extensions/Configure/Configure.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | 'url' => 'http://www.mediawiki.org/wiki/Extension:Configure', |
19 | 19 | 'description' => 'Allow authorised users to configure the wiki by a web-based interface', |
20 | 20 | 'descriptionmsg' => 'configure-desc', |
21 | | - 'version' => '0.9.5', |
| 21 | + 'version' => '0.9.6', |
22 | 22 | ); |
23 | 23 | |
24 | 24 | ## Configuration part |
— | — | @@ -179,6 +179,10 @@ |
180 | 180 | $wgAutoloadClasses['ExtPreviewConfigurationDiff'] = $dir . 'Configure.diff.php'; |
181 | 181 | $wgAutoloadClasses['HistoryConfigurationDiff'] = $dir . 'Configure.diff.php'; |
182 | 182 | |
| 183 | +## Pager stuff |
| 184 | +$wgAutoloadClasses['ConfigurationPagerDb'] = $dir . 'Configure.pager-db.php'; |
| 185 | +$wgAutoloadClasses['ConfigurationPagerFiles'] = $dir . 'Configure.pager-files.php'; |
| 186 | + |
183 | 187 | ## API module |
184 | 188 | $wgAutoloadClasses['ApiConfigure'] = $dir . 'Configure.api.php'; |
185 | 189 | $wgAPIModules['configure'] = 'ApiConfigure'; |
Index: trunk/extensions/Configure/Configure.page.php |
— | — | @@ -318,27 +318,39 @@ |
319 | 319 | */ |
320 | 320 | protected function buildOldVersionSelect(){ |
321 | 321 | global $wgConf, $wgLang, $wgUser; |
| 322 | + |
| 323 | + $showAllLink = false; |
| 324 | + $count = 0; |
| 325 | + $links = array(); |
| 326 | + |
322 | 327 | $versions = $wgConf->listArchiveVersions(); |
| 328 | + $skin = $wgUser->getSkin(); |
| 329 | + $title = $this->getTitle(); |
| 330 | + foreach( $versions as $ts ){ |
| 331 | + if( $count > 10 ) { |
| 332 | + $showAllLink = true; |
| 333 | + break; |
| 334 | + } elseif( in_array( $this->mWiki, $wgConf->getWikisInVersion( $ts ) ) ){ |
| 335 | + $count++; |
| 336 | + $links[] = $skin->makeKnownLinkObj( $title, $wgLang->timeAndDate( $ts ), "version=$ts" ); |
| 337 | + } else { |
| 338 | + $showAllLink = true; |
| 339 | + } |
| 340 | + } |
| 341 | + |
323 | 342 | $text = '<fieldset><legend>' . wfMsgHtml( 'configure-old' ) . '</legend>'; |
324 | | - if( empty( $versions ) ){ |
| 343 | + if( !count( $links ) ){ |
325 | 344 | $text .= wfMsgExt( 'configure-no-old', array( 'parse' ) ); |
326 | 345 | } else { |
327 | 346 | $text .= wfMsgExt( 'configure-old-versions', array( 'parse' ) ); |
328 | | - $text .= "<ul>\n"; |
329 | | - $skin = $wgUser->getSkin(); |
330 | | - $title = $this->getTitle(); |
331 | | - if( count( $versions ) > 10 ){ |
332 | | - $versions = array_slice( $versions, 0, 10 ); |
333 | | - $link = SpecialPage::getTitleFor( 'ViewConfig' ); |
334 | | - $moreLink = $skin->makeKnownLinkObj( $link, wfMsgHtml( 'configure-view-all-versions' ) ); |
335 | | - } else { |
336 | | - $moreLink = ''; |
337 | | - } |
338 | | - foreach( $versions as $ts ){ |
339 | | - $text .= '<li>' . $skin->makeKnownLinkObj( $title, $wgLang->timeAndDate( $ts ), "version=$ts" ) . "</li>\n"; |
340 | | - } |
341 | | - $text .= '</ul>' . $moreLink; |
| 347 | + $text .= "<ul>\n<li>"; |
| 348 | + $text .= implode( "</li>\n<li>", $links ); |
| 349 | + $text .= "</li>\n</ul>\n"; |
342 | 350 | } |
| 351 | + if( $showAllLink ){ |
| 352 | + $link = SpecialPage::getTitleFor( 'ViewConfig' ); |
| 353 | + $text .= $skin->makeKnownLinkObj( $link, wfMsgHtml( 'configure-view-all-versions' ) ); |
| 354 | + } |
343 | 355 | $text .= '</fieldset>'; |
344 | 356 | return $text; |
345 | 357 | } |
Index: trunk/extensions/Configure/Configure.handler.php |
— | — | @@ -36,6 +36,13 @@ |
37 | 37 | public function getWikisInVersion( $ts ); |
38 | 38 | |
39 | 39 | /** |
| 40 | + * Returns a pager for this handler |
| 41 | + * |
| 42 | + * @return Pager |
| 43 | + */ |
| 44 | + public function getPager(); |
| 45 | + |
| 46 | + /** |
40 | 47 | * Save a new configuration |
41 | 48 | * @param $settings array of settings |
42 | 49 | * @param $wiki String: wiki name or false to use the current one |
Index: trunk/extensions/Configure/Configure.pager-files.php |
— | — | @@ -0,0 +1,55 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class used to list versions at Special:ViewConfig when using a files handler |
| 6 | + * |
| 7 | + * @ingroup Extensions |
| 8 | + * @author Alexandre Emsenhuber |
| 9 | + */ |
| 10 | +class ConfigurationPagerFiles implements Pager { |
| 11 | + protected $mHandler, $mCallback; |
| 12 | + |
| 13 | + function __construct( ConfigureHandler $handler ) { |
| 14 | + $this->mHandler = $handler; |
| 15 | + } |
| 16 | + |
| 17 | + function getBody() { |
| 18 | + $versions = $this->mHandler->listArchiveVersions(); |
| 19 | + if( empty( $versions ) ){ |
| 20 | + return wfMsgExt( 'configure-no-old', array( 'parse' ) ); |
| 21 | + } |
| 22 | + |
| 23 | + $text = "<ul>\n"; |
| 24 | + $count = 0; |
| 25 | + foreach( $versions as $version ){ |
| 26 | + $count++; |
| 27 | + $wikis = array_keys( $this->mHandler->getOldSettings( $version ) ); |
| 28 | + $info = array( |
| 29 | + 'timestamp' => $version, |
| 30 | + 'wikis' => $wikis, |
| 31 | + 'count' => $count, |
| 32 | + ); |
| 33 | + $text .= $this->formatRow( $info ); |
| 34 | + } |
| 35 | + $text .= "</ul>\n"; |
| 36 | + return $text; |
| 37 | + } |
| 38 | + |
| 39 | + function getNumRows() { |
| 40 | + return count( $this->mHandler->listArchiveVersions() ); |
| 41 | + } |
| 42 | + |
| 43 | + function getNavigationBar() { |
| 44 | + return ''; |
| 45 | + } |
| 46 | + |
| 47 | + function setFormatCallback( $callback ) { |
| 48 | + $this->mCallback = $callback; |
| 49 | + } |
| 50 | + |
| 51 | + function formatRow( $info ) { |
| 52 | + if( !is_callable( $this->mCallback ) ) |
| 53 | + throw new MWException( 'ConfigurationPagerFiles::$mCallback not callable' ); |
| 54 | + return call_user_func( $this->mCallback, $info ); |
| 55 | + } |
| 56 | +} |
Property changes on: trunk/extensions/Configure/Configure.pager-files.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 57 | + native |
Index: trunk/extensions/Configure/Configure.handler-db.php |
— | — | @@ -127,6 +127,15 @@ |
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
| 131 | + * Returns a pager for this handler |
| 132 | + * |
| 133 | + * @return Pager |
| 134 | + */ |
| 135 | + public function getPager(){ |
| 136 | + return new ConfigurationPagerDb( $this ); |
| 137 | + } |
| 138 | + |
| 139 | + /** |
131 | 140 | * Save a new configuration |
132 | 141 | * @param $settings array of settings |
133 | 142 | * @param $wiki String: wiki name or true for all |
Index: trunk/extensions/Configure/Configure.obj.php |
— | — | @@ -151,6 +151,15 @@ |
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
| 155 | + * Returns a pager for this handler |
| 156 | + * |
| 157 | + * @return Pager |
| 158 | + */ |
| 159 | + public function getPager(){ |
| 160 | + return $this->mHandler->getPager(); |
| 161 | + } |
| 162 | + |
| 163 | + /** |
155 | 164 | * Get the defalut values for all settings |
156 | 165 | * Very, very hacky... |
157 | 166 | * |
Index: trunk/extensions/Configure/Configure.handler-files.php |
— | — | @@ -83,6 +83,15 @@ |
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
| 87 | + * Returns a pager for this handler |
| 88 | + * |
| 89 | + * @return Pager |
| 90 | + */ |
| 91 | + public function getPager(){ |
| 92 | + return new ConfigurationPagerFiles( $this ); |
| 93 | + } |
| 94 | + |
| 95 | + /** |
87 | 96 | * Save a new configuration |
88 | 97 | * @param $settings array of settings |
89 | 98 | * @param $wiki String: wiki name or true for all |
Index: trunk/extensions/Configure/CHANGELOG |
— | — | @@ -1,7 +1,12 @@ |
2 | 2 | This file lists changes on this extension. |
3 | 3 | Localisation updates are done on betawiki and aren't listed here. |
4 | 4 | |
5 | | -0.9.5 - 10 November 2008 |
| 5 | +0.9.6 - 13 November 2008 |
| 6 | + * Version list on Special:ViewConfig now uses a pager. |
| 7 | + * Listed version at the top Special:Configure and Special:Extension are only |
| 8 | + shown when they contain the configuration for the wiki being modified. |
| 9 | + |
| 10 | +0.9.5 - 12 November 2008 |
6 | 11 | Added $wgNamespacesToBeSearchedProject. |
7 | 12 | |
8 | 13 | 0.9.4 - 9 November 2008 |
Index: trunk/extensions/Configure/SpecialViewConfig.php |
— | — | @@ -118,100 +118,121 @@ |
119 | 119 | if( !$this->isWebConfig ) |
120 | 120 | return ''; |
121 | 121 | |
122 | | - $versions = $wgConf->listArchiveVersions(); |
123 | | - if( empty( $versions ) ){ |
124 | | - return wfMsgExt( 'configure-no-old', array( 'parse' ) ); |
125 | | - } |
| 122 | + $self = $this->getTitle(); |
| 123 | + $pager = $wgConf->getPager(); |
| 124 | + $pager->setFormatCallback( array( $this, 'formatVersionRow' ) ); |
| 125 | + $showDiff = $pager->getNumRows() > 1; |
126 | 126 | |
127 | | - $title = $this->getTitle(); |
128 | | - $skin = $wgUser->getSkin(); |
129 | | - $showDiff = count( $versions ) > 1; |
| 127 | + $formatConf = array( |
| 128 | + 'showDiff' => $showDiff, |
| 129 | + 'allowedConfig' => $wgUser->isAllowed( 'configure' ), |
| 130 | + 'allowedExtensions' => $wgUser->isAllowed( 'extensions' ), |
| 131 | + 'allowedAll' => $this->isUserAllowedInterwiki(), |
| 132 | + 'allowedConfigAll' => $wgUser->isAllowed( 'configure-interwiki' ), |
| 133 | + 'allowedExtensionsAll' => $wgUser->isAllowed( 'extensions-interwiki' ), |
| 134 | + 'self' => $self, |
| 135 | + 'skin' => $wgUser->getSkin(), |
| 136 | + 'editMsg' => wfMsg( 'edit' ) . ': ', |
| 137 | + ); |
130 | 138 | |
131 | | - $allowedConfig = $wgUser->isAllowed( 'configure' ); |
132 | | - $allowedExtensions = $wgUser->isAllowed( 'extensions' ); |
| 139 | + if( $formatConf['allowedConfig'] ) |
| 140 | + $formatConf['configTitle'] = SpecialPage::getTitleFor( 'Configure' ); |
133 | 141 | |
134 | | - $allowedAll = $this->isUserAllowedInterwiki(); |
135 | | - $allowedConfigAll = $wgUser->isAllowed( 'configure-interwiki' ); |
136 | | - $allowedExtensionsAll = $wgUser->isAllowed( 'extensions-interwiki' ); |
| 142 | + if( $formatConf['allowedExtensions'] ) |
| 143 | + $formatConf['extTitle'] = SpecialPage::getTitleFor( 'Extensions' ); |
137 | 144 | |
138 | | - if( $allowedConfig ) |
139 | | - $configTitle = SpecialPage::getTitleFor( 'Configure' ); |
| 145 | + $this->formatConf = $formatConf; |
140 | 146 | |
141 | | - if( $allowedExtensions ) |
142 | | - $extTitle = SpecialPage::getTitleFor( 'Extensions' ); |
143 | | - |
144 | 147 | $text = wfMsgExt( 'configure-old-versions', array( 'parse' ) ); |
145 | | - if( $showDiff ) |
| 148 | + $text .= $pager->getNavigationBar(); |
| 149 | + if( $showDiff ) { |
146 | 150 | $text .= Xml::openElement( 'form', array( 'action' => $wgScript ) ) . "\n" . |
147 | | - Xml::hidden( 'title', $title->getPrefixedDBKey() ) . "\n" . |
148 | | - $this->getButton() . "\n"; |
149 | | - $text .= "<ul>\n"; |
150 | | - |
151 | | - $editMsg = wfMsg( 'edit' ) . ': '; |
152 | | - $c = 0; |
153 | | - foreach( $versions as $ts ){ |
154 | | - $c++; |
155 | | - $time = $wgLang->timeAndDate( $ts ); |
156 | | - if( $allowedAll || $allowedConfigAll || $allowedExtensionsAll ){ |
157 | | - $wikis = $wgConf->getWikisInVersion( $ts ); |
| 151 | + Xml::hidden( 'title', $self->getPrefixedDBKey() ) . "\n" . |
| 152 | + $this->getButton() . "<br/>\n"; |
| 153 | + } |
| 154 | + $text .= $pager->getBody(); |
| 155 | + if( $showDiff ) { |
| 156 | + $text .= $this->getButton() . "</form>"; |
| 157 | + } |
| 158 | + $text .= $pager->getNavigationBar(); |
| 159 | + return $text; |
| 160 | + } |
| 161 | + |
| 162 | + public function formatVersionRow( $arr ){ |
| 163 | + global $wgLang; |
| 164 | + |
| 165 | + $ts = $arr['timestamp']; |
| 166 | + $wikis = $arr['wikis']; |
| 167 | + $c = $arr['count']; |
| 168 | + $hasSelf = in_array( $this->mWiki, $wikis ); |
| 169 | + |
| 170 | + extract( $this->formatConf ); |
| 171 | + $time = $wgLang->timeAndDate( $ts ); |
| 172 | + |
| 173 | + $actions = array(); |
| 174 | + if( $hasSelf ) |
| 175 | + $view = $skin->makeKnownLinkObj( $self, wfMsgHtml( 'configure-view' ), "version=$ts" ); |
| 176 | + else |
| 177 | + $view = wfMsgHtml( 'configure-view' ); |
| 178 | + |
| 179 | + if( $allowedAll ){ |
| 180 | + $viewWikis = array(); |
| 181 | + foreach( $wikis as $wiki ){ |
| 182 | + $viewWikis[] = $skin->makeKnownLinkObj( $self, htmlspecialchars( $wiki ), "version={$ts}&wiki={$wiki}" ); |
158 | 183 | } |
159 | | - $actions = array(); |
160 | | - $view = $skin->makeKnownLinkObj( $title, wfMsg( 'configure-view' ), "version=$ts" ); |
161 | | - if( $allowedAll ){ |
| 184 | + $view .= ' (' . implode( ', ', $viewWikis ) . ')'; |
| 185 | + } |
| 186 | + $actions[] = $view; |
| 187 | + $editDone = false; |
| 188 | + if( $allowedConfig ){ |
| 189 | + if( $hasSelf ) |
| 190 | + $editCore = $editMsg . $skin->makeKnownLinkObj( $configTitle, wfMsgHtml( 'configure-edit-core' ), "version=$ts" ); |
| 191 | + else |
| 192 | + $editCore = $editMsg . wfMsgHtml( 'configure-edit-core' ); |
| 193 | + |
| 194 | + if( $allowedConfigAll ){ |
162 | 195 | $viewWikis = array(); |
163 | 196 | foreach( $wikis as $wiki ){ |
164 | | - $viewWikis[] = $skin->makeKnownLinkObj( $title, $wiki, "version={$ts}&wiki={$wiki}" ); |
| 197 | + $viewWikis[] = $skin->makeKnownLinkObj( $configTitle, htmlspecialchars( $wiki ), "version={$ts}&wiki={$wiki}" ); |
165 | 198 | } |
166 | | - $view .= ' (' . implode( ', ', $viewWikis ) . ')'; |
| 199 | + $editCore .= ' (' . implode( ', ', $viewWikis ) . ')'; |
167 | 200 | } |
168 | | - $actions[] = $view; |
169 | | - $editDone = false; |
170 | | - if( $allowedConfig ){ |
171 | | - $editCore = $editMsg . $skin->makeKnownLinkObj( $configTitle, wfMsg( 'configure-edit-core' ), "version=$ts" ); |
172 | | - if( $allowedConfigAll ){ |
173 | | - $viewWikis = array(); |
174 | | - foreach( $wikis as $wiki ){ |
175 | | - $viewWikis[] = $skin->makeKnownLinkObj( $configTitle, $wiki, "version={$ts}&wiki={$wiki}" ); |
176 | | - } |
177 | | - $editCore .= ' (' . implode( ', ', $viewWikis ) . ')'; |
| 201 | + $actions[] = $editCore; |
| 202 | + } |
| 203 | + if( $allowedExtensions ){ |
| 204 | + $editExt = ''; |
| 205 | + if( !$allowedConfig ) |
| 206 | + $editExt .= $editMsg; |
| 207 | + if( $hasSelf ) |
| 208 | + $editExt .= $skin->makeKnownLinkObj( $extTitle, wfMsgHtml( 'configure-edit-ext' ), "version=$ts" ); |
| 209 | + else |
| 210 | + $editExt .= wfMsgHtml( 'configure-edit-ext' ); |
| 211 | + |
| 212 | + if( $allowedExtensionsAll ){ |
| 213 | + $viewWikis = array(); |
| 214 | + foreach( $wikis as $wiki ){ |
| 215 | + $viewWikis[] = $skin->makeKnownLinkObj( $extTitle, htmlspecialchars( $wiki ), "version={$ts}&wiki={$wiki}" ); |
178 | 216 | } |
179 | | - $actions[] = $editCore; |
| 217 | + $editExt .= ' (' . implode( ', ', $viewWikis ) . ')'; |
180 | 218 | } |
181 | | - if( $allowedExtensions ){ |
182 | | - $editExt = ''; |
183 | | - if( !$allowedConfig ) |
184 | | - $editExt .= $editMsg; |
185 | | - $editExt .= $skin->makeKnownLinkObj( $extTitle, wfMsg( 'configure-edit-ext' ), "version=$ts" ); |
186 | | - if( $allowedExtensionsAll ){ |
187 | | - $viewWikis = array(); |
188 | | - foreach( $wikis as $wiki ){ |
189 | | - $viewWikis[] = $skin->makeKnownLinkObj( $extTitle, $wiki, "version={$ts}&wiki={$wiki}" ); |
190 | | - } |
191 | | - $editExt .= ' (' . implode( ', ', $viewWikis ) . ')'; |
192 | | - } |
193 | | - $actions[] = $editExt; |
194 | | - } |
195 | | - if( $showDiff ){ |
196 | | - $diffCheck = $c == 2 ? array( 'checked' => 'checked' ) : array(); |
197 | | - $versionCheck = $c == 1 ? array( 'checked' => 'checked' ) : array(); |
198 | | - $buttons = |
199 | | - Xml::element( 'input', array_merge( |
200 | | - array( 'type' => 'radio', 'name' => 'diff', 'value' => $ts ), |
201 | | - $diffCheck ) ) . |
202 | | - Xml::element( 'input', array_merge( |
203 | | - array( 'type' => 'radio', 'name' => 'version', 'value' => $ts ), |
204 | | - $versionCheck ) ); |
205 | | - |
206 | | - } else { |
207 | | - $buttons = ''; |
208 | | - } |
209 | | - $action = implode( ', ', $actions ); |
210 | | - $text .= "<li>{$buttons}{$time}: {$action}</li>\n"; |
| 219 | + $actions[] = $editExt; |
211 | 220 | } |
212 | | - $text .= "</ul>"; |
213 | | - if( $showDiff ) |
214 | | - $text .= $this->getButton() . "</form>"; |
215 | | - return $text; |
| 221 | + if( $showDiff ){ |
| 222 | + $diffCheck = $c == 2 ? array( 'checked' => 'checked' ) : array(); |
| 223 | + $versionCheck = $c == 1 ? array( 'checked' => 'checked' ) : array(); |
| 224 | + $buttons = |
| 225 | + Xml::element( 'input', array_merge( |
| 226 | + array( 'type' => 'radio', 'name' => 'diff', 'value' => $ts ), |
| 227 | + $diffCheck ) ) . |
| 228 | + Xml::element( 'input', array_merge( |
| 229 | + array( 'type' => 'radio', 'name' => 'version', 'value' => $ts ), |
| 230 | + $versionCheck ) ); |
| 231 | + |
| 232 | + } else { |
| 233 | + $buttons = ''; |
| 234 | + } |
| 235 | + $action = implode( ', ', $actions ); |
| 236 | + return "<li>{$buttons}{$time}: {$action}</li>\n"; |
216 | 237 | } |
217 | 238 | |
218 | 239 | /** |
Index: trunk/extensions/Configure/Configure.pager-db.php |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Class used to list versions at Special:ViewConfig when using a database |
| 6 | + * handler |
| 7 | + * |
| 8 | + * @ingroup Extensions |
| 9 | + * @author Alexandre Emsenhuber |
| 10 | + */ |
| 11 | +class ConfigurationPagerDb extends ReverseChronologicalPager { |
| 12 | + protected $mHandler, $mCallback, $mCounter; |
| 13 | + |
| 14 | + function __construct( ConfigureHandlerDb $handler ) { |
| 15 | + parent::__construct(); |
| 16 | + $this->mHandler = $handler; |
| 17 | + $this->mDb = $handler->getSlaveDB(); |
| 18 | + } |
| 19 | + |
| 20 | + function getQueryInfo() { |
| 21 | + $queryInfo = array( |
| 22 | + 'tables' => array( 'config_version' ), |
| 23 | + 'fields' => array( '*' ), |
| 24 | + 'conds' => array(), |
| 25 | + 'options' => array() |
| 26 | + ); |
| 27 | + return $queryInfo; |
| 28 | + } |
| 29 | + |
| 30 | + function getIndexField() { |
| 31 | + return 'cv_timestamp'; |
| 32 | + } |
| 33 | + |
| 34 | + function setFormatCallback( $callback ) { |
| 35 | + $this->mCallback = $callback; |
| 36 | + } |
| 37 | + |
| 38 | + function formatRow( $row ) { |
| 39 | + if( !is_callable( $this->mCallback ) ) |
| 40 | + throw new MWException( 'ConfigurationPagerDb::$mCallback not callable' ); |
| 41 | + $this->mCounter++; |
| 42 | + $info = array( |
| 43 | + 'timestamp' => $row->cv_timestamp, |
| 44 | + 'wikis' => array( $row->cv_wiki ), |
| 45 | + 'count' => $this->mCounter, |
| 46 | + ); |
| 47 | + return call_user_func( $this->mCallback, $info ); |
| 48 | + } |
| 49 | + |
| 50 | + function getStartBody() { |
| 51 | + $this->mCounter = 0; |
| 52 | + return "<ul>\n"; |
| 53 | + } |
| 54 | + |
| 55 | + function getEndBody() { |
| 56 | + return "</ul>\n"; |
| 57 | + } |
| 58 | +} |
Property changes on: trunk/extensions/Configure/Configure.pager-db.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 59 | + native |