1 | <?php |
||
7 | class MediaFile |
||
8 | { |
||
9 | protected $id; |
||
10 | protected $path; |
||
11 | |||
12 | protected $mime; |
||
13 | protected $ext; |
||
14 | protected $downloadable; |
||
15 | |||
16 | protected $width; |
||
17 | protected $height; |
||
18 | protected $meta; |
||
19 | |||
20 | /** |
||
21 | * MediaFile constructor. |
||
22 | * @param string $id |
||
23 | * @param string|int $rev optional revision |
||
24 | */ |
||
25 | public function __construct($id, $rev = '') |
||
32 | |||
33 | /** @return string */ |
||
34 | public function getId() |
||
38 | |||
39 | /** @return string */ |
||
40 | public function getPath() |
||
44 | |||
45 | /** |
||
46 | * The ID without namespace, used for display purposes |
||
47 | * |
||
48 | * @return string |
||
49 | */ |
||
50 | public function getDisplayName() |
||
54 | |||
55 | /** @return string */ |
||
56 | public function getMime() |
||
61 | |||
62 | /** @return string */ |
||
63 | public function getExtension() |
||
67 | |||
68 | /** |
||
69 | * Similar to the extesion but does some clean up |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function getIcoClass() |
||
79 | |||
80 | /** |
||
81 | * Should this file be downloaded instead being displayed inline? |
||
82 | * |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function isDownloadable() |
||
89 | |||
90 | /** @return int */ |
||
91 | public function getFileSize() |
||
95 | |||
96 | /** @return int */ |
||
97 | public function getLastModified() |
||
101 | |||
102 | /** @return bool */ |
||
103 | public function isWritable() |
||
107 | |||
108 | /** @return bool */ |
||
109 | public function isImage() |
||
113 | |||
114 | /** |
||
115 | * initializes width and height for images when requested |
||
116 | */ |
||
117 | protected function initSizes() |
||
126 | |||
127 | /** |
||
128 | * Returns the width if this is a supported image, 0 otherwise |
||
129 | * |
||
130 | * @return int |
||
131 | */ |
||
132 | public function getWidth() |
||
137 | |||
138 | /** |
||
139 | * Returns the height if this is a supported image, 0 otherwise |
||
140 | * |
||
141 | * @return int |
||
142 | */ |
||
143 | public function getHeight() |
||
148 | |||
149 | /** |
||
150 | * Returns the permissions the current user has on the file |
||
151 | * |
||
152 | * @todo doing this for each file within a namespace is a waste, we need to cache this somehow |
||
153 | * @return int |
||
154 | */ |
||
155 | public function userPermission() |
||
159 | |||
160 | /** @return \JpegMeta */ |
||
161 | public function getMeta() |
||
166 | } |
||
167 |