1a5c08a2da48d4c83d6ef44447e93a853186b294
[lhc/web/wiklou.git] / includes / filerepo / Image.php
1 <?php
2
3 /**
4 * Backwards compatibility class
5 * @deprecated
6 */
7 class Image extends LocalFile {
8 function __construct( $title ) {
9 wfDeprecated( __METHOD__ );
10 $repo = RepoGroup::singleton()->getLocalRepo();
11 parent::__construct( $title, $repo );
12 }
13
14 /**
15 * Wrapper for wfFindFile(), for backwards-compatibility only
16 * Do not use in core code.
17 * @deprecated
18 */
19 static function newFromTitle( $title, $time = false ) {
20 wfDeprecated( __METHOD__ );
21 $img = wfFindFile( $title, $time );
22 if ( !$img ) {
23 $img = wfLocalFile( $title );
24 }
25 return $img;
26 }
27
28 /**
29 * Wrapper for wfFindFile(), for backwards-compatibility only.
30 * Do not use in core code.
31 *
32 * @param string $name name of the image, used to create a title object using Title::makeTitleSafe
33 * @return image object or null if invalid title
34 * @deprecated
35 */
36 static function newFromName( $name ) {
37 wfDeprecated( __METHOD__ );
38 $title = Title::makeTitleSafe( NS_IMAGE, $name );
39 if ( is_object( $title ) ) {
40 $img = wfFindFile( $title );
41 if ( !$img ) {
42 $img = wfLocalFile( $title );
43 }
44 return $img;
45 } else {
46 return NULL;
47 }
48 }
49
50 /**
51 * Return the URL of an image, provided its name.
52 *
53 * Backwards-compatibility for extensions.
54 * Note that fromSharedDirectory will only use the shared path for files
55 * that actually exist there now, and will return local paths otherwise.
56 *
57 * @param string $name Name of the image, without the leading "Image:"
58 * @param boolean $fromSharedDirectory Should this be in $wgSharedUploadPath?
59 * @return string URL of $name image
60 * @deprecated
61 */
62 static function imageUrl( $name, $fromSharedDirectory = false ) {
63 wfDeprecated( __METHOD__ );
64 $image = null;
65 if( $fromSharedDirectory ) {
66 $image = wfFindFile( $name );
67 }
68 if( !$image ) {
69 $image = wfLocalFile( $name );
70 }
71 return $image->getUrl();
72 }
73 }