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