2006-09-26 01:44:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Created on Sep 25, 2006
|
|
|
|
|
*
|
|
|
|
|
* API for MediaWiki 1.8+
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (!defined('MEDIAWIKI')) {
|
|
|
|
|
// Eclipse helper - will be ignored in production
|
2006-10-01 02:02:13 +00:00
|
|
|
require_once ('ApiQueryBase.php');
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ApiQueryInfo extends ApiQueryBase {
|
|
|
|
|
|
2006-10-03 05:41:55 +00:00
|
|
|
public function __construct($query, $moduleName) {
|
|
|
|
|
parent :: __construct($query, $moduleName);
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
2006-10-01 20:17:16 +00:00
|
|
|
public function requestExtraData() {
|
|
|
|
|
$pageSet = $this->getPageSet();
|
|
|
|
|
$pageSet->requestField('page_is_redirect');
|
|
|
|
|
$pageSet->requestField('page_touched');
|
|
|
|
|
$pageSet->requestField('page_latest');
|
|
|
|
|
}
|
|
|
|
|
|
2006-09-27 05:13:48 +00:00
|
|
|
public function execute() {
|
2006-09-26 06:37:26 +00:00
|
|
|
|
2006-10-01 20:17:16 +00:00
|
|
|
$pageSet = $this->getPageSet();
|
|
|
|
|
$titles = $pageSet->getGoodTitles();
|
|
|
|
|
$result = & $this->getResult();
|
2006-09-26 01:44:13 +00:00
|
|
|
|
2006-10-01 20:17:16 +00:00
|
|
|
$pageIsRedir = $pageSet->getCustomField('page_is_redirect');
|
|
|
|
|
$pageTouched = $pageSet->getCustomField('page_touched');
|
|
|
|
|
$pageLatest = $pageSet->getCustomField('page_latest');
|
|
|
|
|
|
|
|
|
|
foreach ($titles as $pageid => $title) {
|
2006-10-20 07:10:18 +00:00
|
|
|
$pageInfo = array (
|
2006-10-21 08:44:07 +00:00
|
|
|
'touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]),
|
2006-10-21 08:26:32 +00:00
|
|
|
'lastrevid' => intval($pageLatest[$pageid])
|
2006-10-20 07:10:18 +00:00
|
|
|
);
|
2006-10-01 20:17:16 +00:00
|
|
|
|
|
|
|
|
if ($pageIsRedir[$pageid])
|
|
|
|
|
$pageInfo['redirect'] = '';
|
2006-09-26 01:44:13 +00:00
|
|
|
|
2006-10-01 20:17:16 +00:00
|
|
|
$result->addValue(array (
|
|
|
|
|
'query',
|
|
|
|
|
'pages'
|
|
|
|
|
), $pageid, $pageInfo);
|
|
|
|
|
}
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-27 05:13:48 +00:00
|
|
|
protected function getDescription() {
|
2006-10-01 20:17:16 +00:00
|
|
|
return 'Get basic page information such as namespace, title, last touched date, ...';
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-27 05:13:48 +00:00
|
|
|
protected function getExamples() {
|
2006-09-26 01:44:13 +00:00
|
|
|
return array (
|
2006-10-01 20:17:16 +00:00
|
|
|
'api.php?action=query&prop=info&titles=Main%20Page'
|
2006-09-26 01:44:13 +00:00
|
|
|
);
|
|
|
|
|
}
|
2006-10-01 21:20:55 +00:00
|
|
|
|
|
|
|
|
public function getVersion() {
|
|
|
|
|
return __CLASS__ . ': $Id$';
|
|
|
|
|
}
|
2006-09-26 01:44:13 +00:00
|
|
|
}
|
2006-10-21 08:26:32 +00:00
|
|
|
?>
|