Merge branch '44711-27' of git://github.com/samhemelryk/moodle into MOODLE_27_STABLE
[moodle.git] / lib / filebrowser / virtual_root_file.php
blobf8187d20c24844eb949ca9d4adc9285b6530bd07
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Class simulating empty directories.
21 * @package core_files
22 * @copyright 2008 Petr Skoda (http://skodak.org)
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die();
28 /**
29 * Represents the root directory of an empty file area in the tree navigated by {@link file_browser}.
31 * @package core_files
32 * @copyright 2008 Petr Skoda (http://skodak.org)
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class virtual_root_file {
36 /** @var int context id */
37 protected $contextid;
38 /** @var string file component */
39 protected $component;
40 /** @var string file area */
41 protected $filearea;
42 /** @var int file itemid */
43 protected $itemid;
45 /**
46 * Constructor
48 * @param int $contextid context ID
49 * @param string $component component
50 * @param string $filearea file area
51 * @param int $itemid item ID
53 public function __construct($contextid, $component, $filearea, $itemid) {
54 $this->contextid = $contextid;
55 $this->component = $component;
56 $this->filearea = $filearea;
57 $this->itemid = $itemid;
60 /**
61 * Whether or not this is a directory
63 * @return bool
65 public function is_directory() {
66 return true;
69 /**
70 * Delete file
72 * @return success
74 public function delete() {
75 return true;
78 /**
79 * adds this file path to a curl request (POST only)
81 * @param curl $curlrequest the curl request object
82 * @param string $key what key to use in the POST request
84 public function add_to_curl_request(&$curlrequest, $key) {
85 return;
88 /**
89 * Returns file handle - read only mode, no writing allowed into pool files!
91 * @return resource file handle
93 public function get_content_file_handle() {
94 return null;
97 /**
98 * Dumps file content to page
100 * @return resource file handle
102 public function readfile() {
103 return;
107 * Returns file content as string
109 * @return string content
111 public function get_content() {
112 return '';
116 * Copy content of file to given pathname
118 * @param string $pathname real path to new file
119 * @return bool success
121 public function copy_content_to($pathname) {
122 return false;
126 * List contents of archive
128 * @param file_packer $packer file packer instance
129 * @return array of file infos
131 public function list_files(file_packer $packer) {
132 return null;
136 * Extract file to given file path (real OS filesystem), existing files are overwrited
138 * @param file_packer $packer file packer instance
139 * @param string $pathname target directory
140 * @return mixed list of processed files; false if error
142 public function extract_to_pathname(file_packer $packer, $pathname) {
143 return false;
147 * Extract file to given file path (real OS filesystem), existing files are overwrited
149 * @param file_packer $packer file packer instance
150 * @param int $contextid context ID
151 * @param string $component component
152 * @param string $filearea file area
153 * @param int $itemid item ID
154 * @param string $pathbase path base
155 * @param int $userid user ID
156 * @return mixed list of processed files; false if error
158 public function extract_to_storage(file_packer $packer, $contextid, $component, $filearea, $itemid, $pathbase, $userid = NULL) {
159 return false;
163 * Add file/directory into archive
165 * @param file_archive $filearch file archive instance
166 * @param string $archivepath pathname in archive
167 * @return bool success
169 public function archive_file(file_archive $filearch, $archivepath) {
170 return false;
174 * Returns parent directory
176 * @return stored_file
178 public function get_parent_directory() {
179 return null;
183 * Returns context ID
185 * @return int context ID
187 public function get_contextid() {
188 return $this->contextid;
192 * Returns file component
194 * @return string component
196 public function get_component() {
197 return $this->component;
201 * Returns file area
203 * @return string filearea
205 public function get_filearea() {
206 return $this->filearea;
210 * Returns file itemid
212 * @return int itemid
214 public function get_itemid() {
215 return $this->itemid;
219 * Returns file path
221 * @return string filepath
223 public function get_filepath() {
224 return '/';
228 * Returns file name
230 * @return string filename
232 public function get_filename() {
233 return '.';
237 * Returns user ID
239 * @return int userid
241 public function get_userid() {
242 return null;
246 * Returns file size
248 * @return int filesize
250 public function get_filesize() {
251 return 0;
255 * Returns mimetype
257 * @return string mimetype
259 public function get_mimetype() {
260 return null;
264 * Returns time created
266 * @return int
268 public function get_timecreated() {
269 return 0;
273 * Returns time modified
275 * @return int
277 public function get_timemodified() {
278 return 0;
282 * Returns status
284 * @return int
286 public function get_status() {
287 return 0;
291 * Returns ID
293 * @return int
295 public function get_id() {
296 return 0;
300 * Returns sha1 hash code
302 * @return string
304 public function get_contenthash() {
305 return sha1('');
309 * Returns path name hash
311 * @return string
313 public function get_pathnamehash() {
314 return sha1('/'.$this->get_contextid().'/'.$this->get_component().'/'.$this->get_filearea().'/'.$this->get_itemid().$this->get_filepath().$this->get_filename());
318 * Returns license
320 * @return string
322 public function get_license() {
323 return null;
327 * Returns file's author
329 * @return string
331 public function get_author() {
332 return null;
336 * Returns file source
338 * @return string
340 public function get_source() {
341 return null;
345 * Returns file sort order
347 * @return int
349 public function get_sortorder() {
350 return null;