<?php
-
/**
- * Created on May 12, 2007
*
- * API for MediaWiki 1.8+
+ *
+ * Created on May 12, 2007
*
* Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
*
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
*/
if ( !defined( 'MEDIAWIKI' ) ) {
const LINKS = 'links';
const TEMPLATES = 'templates';
- private $table, $prefix, $description;
+ private $table, $prefix, $description, $helpUrl;
public function __construct( $query, $moduleName ) {
switch ( $moduleName ) {
$this->prefix = 'pl';
$this->description = 'link';
$this->titlesParam = 'titles';
+ $this->helpUrl = 'http://www.mediawiki.org/wiki/API:Properties#links_.2F_pl';
break;
case self::TEMPLATES:
$this->table = 'templatelinks';
$this->prefix = 'tl';
$this->description = 'template';
$this->titlesParam = 'templates';
+ $this->helpUrl = 'http://www.mediawiki.org/wiki/API:Properties#templates_.2F_tl';
break;
default:
ApiBase::dieDebug( __METHOD__, 'Unknown module name' );
$this->run();
}
+ public function getCacheMode( $params ) {
+ return 'public';
+ }
+
public function executeGenerator( $resultPageSet ) {
$this->run( $resultPageSet );
}
+ /**
+ * @param $resultPageSet ApiPageSet
+ * @return
+ */
private function run( $resultPageSet = null ) {
if ( $this->getPageSet()->getGoodTitleCount() == 0 ) {
return; // nothing to do
$this->addTables( $this->table );
$this->addWhereFld( $this->prefix . '_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
$this->addWhereFld( $this->prefix . '_namespace', $params['namespace'] );
-
+
if ( !is_null( $params[$this->titlesParam] ) ) {
$lb = new LinkBatch;
foreach ( $params[$this->titlesParam] as $t ) {
);
if ( $this->getModuleName() == self::LINKS ) {
$arr[$this->titlesParam] = 'Only list links to these titles. Useful for checking whether a certain page links to a certain title.';
- } else if ( $this->getModuleName() == self::TEMPLATES ) {
+ } elseif ( $this->getModuleName() == self::TEMPLATES ) {
$arr[$this->titlesParam] = 'Only list these templates. Useful for checking whether a certain page uses a certain template.';
}
return $arr;
return "Returns all {$this->description}s from the given page(s)";
}
- protected function getExamples() {
+ public function getExamples() {
return array(
"Get {$this->description}s from the [[Main Page]]:",
" api.php?action=query&prop={$this->getModuleName()}&titles=Main%20Page",
);
}
+ public function getHelpUrls() {
+ return $this->helpUrl;
+ }
+
public function getVersion() {
return __CLASS__ . ': $Id$';
}
-}
\ No newline at end of file
+}