From 370e83bb0dfd0c70de268c93bf07ad5ee0897192 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 15 Aug 2008 01:29:47 +0200 Subject: Update auf 1.13.0 --- includes/filerepo/Image.php | 74 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 includes/filerepo/Image.php (limited to 'includes/filerepo/Image.php') diff --git a/includes/filerepo/Image.php b/includes/filerepo/Image.php new file mode 100644 index 00000000..665dd4bf --- /dev/null +++ b/includes/filerepo/Image.php @@ -0,0 +1,74 @@ +getLocalRepo(); + parent::__construct( $title, $repo ); + } + + /** + * Wrapper for wfFindFile(), for backwards-compatibility only + * Do not use in core code. + * @deprecated + */ + static function newFromTitle( $title, $time = false ) { + wfDeprecated( __METHOD__ ); + $img = wfFindFile( $title, $time ); + if ( !$img ) { + $img = wfLocalFile( $title ); + } + return $img; + } + + /** + * Wrapper for wfFindFile(), for backwards-compatibility only. + * Do not use in core code. + * + * @param string $name name of the image, used to create a title object using Title::makeTitleSafe + * @return image object or null if invalid title + * @deprecated + */ + static function newFromName( $name ) { + wfDeprecated( __METHOD__ ); + $title = Title::makeTitleSafe( NS_IMAGE, $name ); + if ( is_object( $title ) ) { + $img = wfFindFile( $title ); + if ( !$img ) { + $img = wfLocalFile( $title ); + } + return $img; + } else { + return NULL; + } + } + + /** + * Return the URL of an image, provided its name. + * + * Backwards-compatibility for extensions. + * Note that fromSharedDirectory will only use the shared path for files + * that actually exist there now, and will return local paths otherwise. + * + * @param string $name Name of the image, without the leading "Image:" + * @param boolean $fromSharedDirectory Should this be in $wgSharedUploadPath? + * @return string URL of $name image + * @deprecated + */ + static function imageUrl( $name, $fromSharedDirectory = false ) { + wfDeprecated( __METHOD__ ); + $image = null; + if( $fromSharedDirectory ) { + $image = wfFindFile( $name ); + } + if( !$image ) { + $image = wfLocalFile( $name ); + } + return $image->getUrl(); + } +} -- cgit v1.2.3-54-g00ecf