*
* Created on July 7, 2007
*
- * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@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
* @file
*/
-if ( !defined( 'MEDIAWIKI' ) ) {
- // Eclipse helper - will be ignored in production
- require_once( 'ApiQueryBase.php' );
-}
-
/**
* @ingroup API
*/
$query = $params['query'];
$protocol = self::getProtocolPrefix( $params['protocol'] );
- $db = $this->getDB();
$this->addTables( array( 'page', 'externallinks' ) ); // must be in this order for 'USE INDEX'
$this->addOption( 'USE INDEX', 'el_index' );
$this->addWhere( 'page_id=el_from' );
$this->addWhereFld( 'page_namespace', $params['namespace'] );
}
- $whereQuery = $this->prepareUrlQuerySearchString( $db, $query, $protocol );
+ $whereQuery = $this->prepareUrlQuerySearchString( $query, $protocol );
if ( $whereQuery !== null ) {
$this->addWhere( $whereQuery );
ApiQueryBase::addTitleInfo( $vals, $title );
}
if ( $fld_url ) {
+ // We *could* run this through wfExpandUrl() but I think it's better to output the link verbatim, even if it's protocol-relative --Roan
$vals['url'] = $row->el_to;
}
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
global $wgUrlProtocols;
$protocols = array( '' );
foreach ( $wgUrlProtocols as $p ) {
- $protocols[] = substr( $p, 0, strpos( $p, ':' ) );
+ if ( $p !== '//' ) {
+ $protocols[] = substr( $p, 0, strpos( $p, ':' ) );
+ }
}
- return $protocols;
+ return $protocols;
}
public static function getProtocolPrefix( $protocol ) {
return $desc;
}
+ public function getResultProperties() {
+ return array(
+ 'ids' => array(
+ 'pageid' => 'integer'
+ ),
+ 'title' => array(
+ 'ns' => 'namespace',
+ 'title' => 'string'
+ ),
+ 'url' => array(
+ 'url' => 'string'
+ )
+ );
+ }
+
public function getDescription() {
return 'Enumerate pages that contain a given URL';
}
) );
}
- protected function getExamples() {
+ public function getExamples() {
return array(
'api.php?action=query&list=exturlusage&euquery=www.mediawiki.org'
);
}
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Exturlusage';
+ }
+
public function getVersion() {
return __CLASS__ . ': $Id$';
}