Index: trunk/extensions/AjaxQueryPages/AjaxQueryPages.php |
— | — | @@ -14,6 +14,9 @@ |
15 | 15 | |
16 | 16 | $wgExtensionMessagesFiles['AjaxQueryPages'] = $dir . 'AjaxQueryPages.i18n.php'; |
17 | 17 | |
| 18 | +$wgHooks['AjaxAddScript'][] = 'wfAjaxQueryPagesAddJS'; |
| 19 | +$wgAjaxExportList[] = 'wfAjaxQueryPages'; |
| 20 | + |
18 | 21 | // Load hooks |
19 | 22 | require_once( $dir . 'Hooks.php' ); |
20 | 23 | |
Index: trunk/extensions/AjaxQueryPages/Response.php |
— | — | @@ -2,33 +2,26 @@ |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) |
4 | 4 | die( 1 ); |
5 | 5 | |
6 | | -// Ajax actions registration |
7 | | -$wgAjaxExportList[] = "wfAjaxQueryPages"; |
8 | | - |
9 | 6 | /** |
10 | 7 | * Ajax responder entry point |
11 | 8 | */ |
12 | 9 | function wfAjaxQueryPages( $specialpagename, $offset, $limit, $dir = false ) { |
| 10 | + global $wgRequest, $wgOut; |
| 11 | + |
13 | 12 | // Make sure we requested an existing special page |
14 | 13 | if ( !$spObj = SpecialPage::getPageByAlias( $specialpagename ) ) { |
15 | 14 | return null; |
16 | 15 | } |
17 | 16 | |
18 | 17 | // Alter the GET request. |
19 | | - $_GET['offset'] = $offset; |
20 | | - $_GET['limit'] = (int) $limit; |
| 18 | + $wgRequest->setVal( 'offset', $offset ); |
| 19 | + $wgRequest->setVal( 'limit', $limit ); |
21 | 20 | |
22 | 21 | if ( $dir == 'prev' || $dir == 'next' ) { |
23 | | - $_GET['dir'] = $dir ; |
24 | | - } else { |
25 | | - unset( $_GET['dir'] ); |
| 22 | + $wgRequest->setVal( 'dir', $dir ); |
26 | 23 | } |
27 | | - // HACK : rebuild the webrequest object so it knows about offset & limit |
28 | | - global $wgRequest ; |
29 | | - $wgRequest->__construct(); |
30 | 24 | |
31 | 25 | $spObj->execute( null ); |
32 | 26 | |
33 | | - global $wgOut; |
34 | 27 | return $wgOut->getHTML(); |
35 | 28 | } |
Index: trunk/extensions/AjaxQueryPages/Hooks.php |
— | — | @@ -2,26 +2,15 @@ |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) |
4 | 4 | die( 1 ); |
5 | 5 | |
6 | | -// Hooks registration: |
7 | | -global $wgHooks; |
8 | | -$wgHooks['AjaxAddScript'][] = 'wfAjaxQueryPagesAddJS'; |
9 | | - |
10 | 6 | // Insert our javascript only for QueryPages |
11 | 7 | function wfAjaxQueryPagesAddJS( $out ) { |
12 | | - global $wgTitle; |
13 | | - if ( $wgTitle->getNamespace() != NS_SPECIAL ) { |
14 | | - return true; |
15 | | - } |
16 | | - global $wgQueryPages; |
17 | | - if ( !$spObj = SpecialPage::getPageByAlias( $wgTitle->getDBkey() ) |
18 | | -// or !(isset($wgQueryPages) ) |
| 8 | + global $wgExtensionAssetsPath; |
| 9 | + |
| 10 | + if ( $out->getTitle()->getNamespace() == NS_SPECIAL && |
| 11 | + SpecialPage::getPageByAlias( $out->getTitle()->getDBkey() ) |
19 | 12 | ) { |
20 | | - return true; |
| 13 | + $out->addScriptFile( "$wgExtensionAssetsPath/AjaxQueryPages/AjaxQueryPages.js" ); |
21 | 14 | } |
22 | 15 | |
23 | | - global $wgJsMimeType, $wgScriptPath ; |
24 | | - $out->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/AjaxQueryPages/AjaxQueryPages.js\"></script>\n" ); |
25 | 16 | return true; |
26 | 17 | } |
27 | | - |
28 | | - |