forked from Brickimedia/Answers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomePageList.php
54 lines (45 loc) · 1.73 KB
/
HomePageList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* HomePageList - API wrappers for answers' home page lists (recent questions
* sidebar, main page lists etc.)
*
* @file
* @ingroup Extensions
* @version 1.0
* @author Przemek Piotrowski (Nef) <[email protected]>
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This is not a valid entry point to MediaWiki.' );
}
// Extension credits that will show up on Special:Version
$wgExtensionCredits['other'][] = array(
'name' => 'HomePageList',
'version' => '1.0',
'author' => 'Przemek Piotrowski',
'description' => "API wrappers for answers' home page lists (recent questions sidebar, main page lists etc.)",
'url' => 'https://www.mediawiki.org/wiki/Extension:Answers',
);
// Autoload our main class and set up the API module used by this extension
$dir = dirname( __FILE__ ) . '/';
$wgAutoloadClasses['HomePageList'] = $dir . 'HomePageList.class.php';
$wgAutoloadClasses['ApiQueryCategoriesOnAnswers'] = $dir . 'api/ApiQueryCategoriesOnAnswers.php';
$wgAPIListModules['categoriesonanswers'] = 'ApiQueryCategoriesOnAnswers';
// Register the two new parser hooks
$wgHooks['ParserFirstCallInit'][] = 'HomePageList::registerParserHooks';
$wgAjaxExportList[] = 'HomePageListAjax';
function HomePageListAjax() {
global $wgRequest;
$method = $wgRequest->getVal( 'method', false );
if ( method_exists( 'HomePageList', $method ) ) {
$data = HomePageList::$method( /* is_ajax */ true );
if ( is_array( $data ) ) {
$json = json_encode( $data );
$response = new AjaxResponse( $json );
$response->setContentType( 'application/json; charset=utf-8' );
} else {
$response = new AjaxResponse( $data );
$response->setContentType( 'text/html; charset=utf-8' );
}
return $response;
}
}