* Stop emitting named entities, so we can use <!DOCTYPE html> while still being
well-formed XML
* texvc now supports \bcancel and \xcancel in addition to \cancel and \cancelto
+* Added scriptExtension setting to $wgForeignFileRepos
+* ForeignApiRepo uses scriptDirUrl if apiBase not set
=== Bug fixes in 1.17 ===
* (bug 17560) Half-broken deletion moved image files to deletion archive
* for local repositories:
* - descBaseUrl URL of image description pages, e.g. http://en.wikipedia.org/wiki/Image:
* - scriptDirUrl URL of the MediaWiki installation, equivalent to $wgScriptPath, e.g.
- * http://en.wikipedia.org/w
+ * http://en.wikipedia.org/w
+ * - scriptExtension Script extension of the MediaWiki installation, equivalent to
+ * $wgScriptExtension, e.g. .php5 defaults to .php
*
* - articleUrl Equivalent to $wgArticlePath, e.g. http://en.wikipedia.org/wiki/$1
* - fetchDescription Fetch the text of the remote file description page. Equivalent to
const OVERWRITE_SAME = 4;
var $thumbScriptUrl, $transformVia404;
- var $descBaseUrl, $scriptDirUrl, $articleUrl, $fetchDescription, $initialCapital;
+ var $descBaseUrl, $scriptDirUrl, $scriptExtension, $articleUrl;
+ var $fetchDescription, $initialCapital;
var $pathDisclosureProtection = 'paranoid';
var $descriptionCacheExpiry, $hashLevels, $url, $thumbUrl;
$this->initialCapital = MWNamespace::isCapitalized( NS_FILE );
foreach ( array( 'descBaseUrl', 'scriptDirUrl', 'articleUrl', 'fetchDescription',
'thumbScriptUrl', 'initialCapital', 'pathDisclosureProtection',
- 'descriptionCacheExpiry', 'hashLevels', 'url', 'thumbUrl' ) as $var )
+ 'descriptionCacheExpiry', 'hashLevels', 'url', 'thumbUrl', 'scriptExtension' )
+ as $var )
{
if ( isset( $info[$var] ) ) {
$this->$var = $info[$var];
function getName() {
return $this->name;
}
+
+ /**
+ * Make an url to this repo
+ *
+ * @param $query mixed Query string to append
+ * @param $entry string Entry point; defaults to index
+ * @return string
+ */
+ function makeUrl( $query = '', $entry = 'index' ) {
+ $ext = isset( $this->scriptExtension ) ? $this->scriptExtension : '.php';
+ return wfAppendQuery( "{$this->scriptDirUrl}/{$entry}{$ext}?", $query );
+ }
/**
* Get the URL of an image description page. May return false if it is
# We use "Image:" as the canonical namespace for
# compatibility across all MediaWiki versions,
# and just sort of hope index.php is right. ;)
- return $this->scriptDirUrl .
- "/index.php?title=Image:$encName";
+ return $this->makeUrl( "title=Image:$encName" );
}
return false;
}
$query .= '&uselang=' . $lang;
}
if ( isset( $this->scriptDirUrl ) ) {
- return $this->scriptDirUrl . '/index.php?title=' .
+ return $this->makeUrl(
+ 'title=' .
wfUrlencode( 'Image:' . $name ) .
- "&$query";
+ "&$query" );
} else {
$descUrl = $this->getDescriptionUrl( $name );
if ( $descUrl ) {
static function newFromTitle( $title, $repo ) {
$data = $repo->fetchImageQuery( array(
'titles' => 'File:' . $title->getText(),
- 'iiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime',
+ 'iiprop' => self::getProps(),
'prop' => 'imageinfo' ) );
$info = $repo->getImageInfo( $data );
}
}
+ /**
+ * Get the property string for iiprop and aiprop
+ */
+ static function getProps() {
+ return 'timestamp|user|comment|url|size|sha1|metadata|mime';
+ }
+
// Dummy functions...
public function exists() {
return $this->mExists;
}
public function getSize() {
- return intval( @$this->mInfo['size'] );
+ return isset( $this->mInfo['size'] ) ? intval( $this->mInfo['size'] ) : null;
}
public function getUrl() {
- return strval( @$this->mInfo['url'] );
+ return isset( $this->mInfo['url'] ) ? strval( $this->mInfo['url'] ) : null;
}
public function getUser( $method='text' ) {
- return strval( @$this->mInfo['user'] );
+ return isset( $this->mInfo['user'] ) ? strval( $this->mInfo['user'] ) : null;
}
public function getDescription() {
- return strval( @$this->mInfo['comment'] );
+ return isset( $this->mInfo['comment'] ) ? strval( $this->mInfo['comment'] ) : null;
}
function getSha1() {
- return wfBaseConvert( strval( @$this->mInfo['sha1'] ), 16, 36, 31 );
+ return isset( $this->mInfo['sha1'] ) ?
+ wfBaseConvert( strval( $this->mInfo['sha1'] ), 16, 36, 31 ) :
+ null;
}
function getTimestamp() {
- return wfTimestamp( TS_MW, strval( @$this->mInfo['timestamp'] ) );
+ return wfTimestamp( TS_MW,
+ isset( $this->mInfo['timestamp'] ) ?
+ strval( $this->mInfo['timestamp'] ) :
+ null
+ );
}
function getMimeType() {
function __construct( $info ) {
parent::__construct( $info );
- $this->mApiBase = $info['apibase']; // http://commons.wikimedia.org/w/api.php
+
+ // http://commons.wikimedia.org/w/api.php
+ $this->mApiBase = isset( $info['apibase'] ) ? $info['apibase'] : null;
+
if( isset( $info['apiThumbCacheExpiry'] ) ) {
$this->apiThumbCacheExpiry = $info['apiThumbCacheExpiry'];
}
function fetchImageQuery( $query ) {
global $wgMemc;
- $url = $this->mApiBase .
- '?' .
- wfArrayToCgi(
- array_merge( $query,
- array(
- 'format' => 'json',
- 'action' => 'query',
- 'redirects' => 'true' ) ) );
+ $query = array_merge( $query,
+ array(
+ 'format' => 'json',
+ 'action' => 'query',
+ 'redirects' => 'true'
+ ) );
+ if ( $this->mApiBase ) {
+ $url = wfAppendQuery( $this->mApiBase, $query );
+ } else {
+ $url = $this->makeUrl( $query, 'api' );
+ }
if( !isset( $this->mQueryCache[$url] ) ) {
$key = $this->getLocalCacheKey( 'ForeignAPIRepo', 'Metadata', md5( $url ) );
function findBySha1( $hash ) {
$results = $this->fetchImageQuery( array(
'aisha1base36' => $hash,
- 'aiprop' => 'timestamp|user|comment|url|size|sha1|metadata|mime',
+ 'aiprop' => ForeignAPIFile::getProps(),
'list' => 'allimages', ) );
$ret = array();
if ( isset( $results['query']['allimages'] ) ) {