Part 1 of 2, moving ResourceLoader*Module classes to their own files - this commit...
[mediawiki.git] / includes / filerepo / Image.php
blob59a07ef9a8591fa8658484f836beba9d8cdb3a16
1 <?php
2 /**
3 * Backward compatibility code for MW < 1.11
5 * @file
6 */
8 /**
9 * Backwards compatibility class
11 * @deprecated. Will be removed in 1.18!
12 * @ingroup FileRepo
14 class Image extends LocalFile {
15 function __construct( $title ) {
16 wfDeprecated( __METHOD__ );
17 $repo = RepoGroup::singleton()->getLocalRepo();
18 parent::__construct( $title, $repo );
21 /**
22 * Wrapper for wfFindFile(), for backwards-compatibility only
23 * Do not use in core code.
24 * @deprecated
26 static function newFromTitle( $title, $repo, $time = null ) {
27 wfDeprecated( __METHOD__ );
28 $img = wfFindFile( $title, array( 'time' => $time ) );
29 if ( !$img ) {
30 $img = wfLocalFile( $title );
32 return $img;
35 /**
36 * Wrapper for wfFindFile(), for backwards-compatibility only.
37 * Do not use in core code.
39 * @param $name String: name of the image, used to create a title object using Title::makeTitleSafe
40 * @return image object or null if invalid title
41 * @deprecated
43 static function newFromName( $name ) {
44 wfDeprecated( __METHOD__ );
45 $title = Title::makeTitleSafe( NS_FILE, $name );
46 if ( is_object( $title ) ) {
47 $img = wfFindFile( $title );
48 if ( !$img ) {
49 $img = wfLocalFile( $title );
51 return $img;
52 } else {
53 return null;
57 /**
58 * Return the URL of an image, provided its name.
60 * Backwards-compatibility for extensions.
61 * Note that fromSharedDirectory will only use the shared path for files
62 * that actually exist there now, and will return local paths otherwise.
64 * @param $name String: name of the image, without the leading "Image:"
65 * @param $fromSharedDirectory Boolean: Should this be in $wgSharedUploadPath?
66 * @return string URL of $name image
67 * @deprecated
69 static function imageUrl( $name, $fromSharedDirectory = false ) {
70 wfDeprecated( __METHOD__ );
71 $image = null;
72 if( $fromSharedDirectory ) {
73 $image = wfFindFile( $name );
75 if( !$image ) {
76 $image = wfLocalFile( $name );
78 return $image->getUrl();