Add a new isVectorized() to files and media handlers. Only SVG returns true.
[lhc/web/wiklou.git] / includes / filerepo / Image.php
1 <?php
2 /**
3 * Backward compatibility code for MW < 1.11
4 *
5 * @file
6 */
7
8 /**
9 * Backwards compatibility class
10 *
11 * @deprecated. Will be removed in 1.18!
12 * @ingroup FileRepo
13 */
14 class Image extends LocalFile {
15 function __construct( $title ) {
16 wfDeprecated( __METHOD__ );
17 $repo = RepoGroup::singleton()->getLocalRepo();
18 parent::__construct( $title, $repo );
19 }
20
21 /**
22 * Wrapper for wfFindFile(), for backwards-compatibility only
23 * Do not use in core code.
24 * @deprecated
25 */
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 );
31 }
32 return $img;
33 }
34
35 /**
36 * Wrapper for wfFindFile(), for backwards-compatibility only.
37 * Do not use in core code.
38 *
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
42 */
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 );
50 }
51 return $img;
52 } else {
53 return null;
54 }
55 }
56
57 /**
58 * Return the URL of an image, provided its name.
59 *
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.
63 *
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
68 */
69 static function imageUrl( $name, $fromSharedDirectory = false ) {
70 wfDeprecated( __METHOD__ );
71 $image = null;
72 if( $fromSharedDirectory ) {
73 $image = wfFindFile( $name );
74 }
75 if( !$image ) {
76 $image = wfLocalFile( $name );
77 }
78 return $image->getUrl();
79 }
80 }