diff --git a/blocks/html/lib.php b/blocks/html/lib.php
index 4d8fc11b228..17d98cecb28 100644
--- a/blocks/html/lib.php
+++ b/blocks/html/lib.php
@@ -18,11 +18,18 @@
/**
* Form for editing HTML block instances.
*
- * @package block_html
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package block_html
+ * @category files
+ * @param stdClass $course course object
+ * @param stdClass $birecord_or_cm block instance record
+ * @param stdClass $context context object
+ * @param string $filearea file area
+ * @param array $args extra arguments
+ * @param bool $forcedownload whether or not force download
+ * @return bool
*/
-
function block_html_pluginfile($course, $birecord_or_cm, $context, $filearea, $args, $forcedownload) {
global $SCRIPT;
@@ -79,4 +86,4 @@ function block_html_global_db_replace($search, $replace) {
}
}
$instances->close();
-}
\ No newline at end of file
+}
diff --git a/lib/filebrowser/file_browser.php b/lib/filebrowser/file_browser.php
index 298811a0d08..2b1a83d1d1d 100644
--- a/lib/filebrowser/file_browser.php
+++ b/lib/filebrowser/file_browser.php
@@ -1,5 +1,4 @@
libdir/filebrowser/file_info_context_course.php");
require_once("$CFG->libdir/filebrowser/file_info_context_module.php");
/**
- * This class provides the main entry point for other code wishing to get
- * information about files.
+ * This class provides the main entry point for other code wishing to get information about files.
*
* The whole file storage for a Moodle site can be seen as a huge virtual tree.
* The spine of the tree is the tree of contexts (system, course-categories,
@@ -56,22 +53,23 @@ require_once("$CFG->libdir/filebrowser/file_info_context_module.php");
*
* Always use this abstraction when you need to access module files from core code.
*
- * @package core
- * @subpackage filebrowser
- * @copyright 2008 Petr Skoda (http://skodak.org)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package core_files
+ * @category files
+ * @copyright 2008 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class file_browser {
/**
* Looks up file_info instance
- * @param object $context
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
- * @return file_info instance or null if not found or access not allowed
+ *
+ * @param stdClass $context context object
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
*/
public function get_file_info($context = NULL, $component = NULL, $filearea = NULL, $itemid = NULL, $filepath = NULL, $filename = NULL) {
if (!$context) {
@@ -95,12 +93,13 @@ class file_browser {
/**
* Returns info about the files at System context
- * @param object $context
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
+ *
+ * @param object $context context object
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
* @return file_info instance or null if not found or access not allowed
*/
private function get_file_info_context_system($context, $component, $filearea, $itemid, $filepath, $filename) {
@@ -111,13 +110,14 @@ class file_browser {
/**
* Returns info about the files at User context
- * @param object $context
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
- * @return file_info instance or null if not found or access not allowed
+ *
+ * @param stdClass $context context object
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
*/
private function get_file_info_context_user($context, $component, $filearea, $itemid, $filepath, $filename) {
global $DB, $USER;
@@ -142,13 +142,14 @@ class file_browser {
/**
* Returns info about the files at Course category context
- * @param object $context
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
- * @return file_info instance or null if not found or access not allowed
+ *
+ * @param stdClass $context context object
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
*/
private function get_file_info_context_coursecat($context, $component, $filearea, $itemid, $filepath, $filename) {
global $DB;
@@ -163,13 +164,14 @@ class file_browser {
/**
* Returns info about the files at Course category context
- * @param object $context
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
- * @return file_info instance or null if not found or access not allowed
+ *
+ * @param stdClass $context context object
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
*/
private function get_file_info_context_course($context, $component, $filearea, $itemid, $filepath, $filename) {
global $DB, $COURSE;
@@ -186,13 +188,14 @@ class file_browser {
/**
* Returns info about the files at Course category context
- * @param object $context
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
- * @return file_info instance or null if not found or access not allowed
+ *
+ * @param stdClass $context context object
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
*/
private function get_file_info_context_module($context, $component, $filearea, $itemid, $filepath, $filename) {
global $COURSE, $DB, $CFG;
diff --git a/lib/filebrowser/file_info.php b/lib/filebrowser/file_info.php
index 52ba8b1fc6a..44069114762 100644
--- a/lib/filebrowser/file_info.php
+++ b/lib/filebrowser/file_info.php
@@ -1,5 +1,4 @@
browser = $browser;
$this->context = $context;
@@ -50,6 +55,7 @@ abstract class file_info {
* Returns list of standard virtual file/directory identification.
* The difference from stored_file parameters is that null values
* are allowed in all fields
+ *
* @return array with keys contextid, component, filearea, itemid, filepath and filename
*/
public function get_params() {
@@ -63,30 +69,35 @@ abstract class file_info {
/**
* Returns localised visible name.
+ *
* @return string
*/
public abstract function get_visible_name();
/**
- * Is directory?
+ * Whether or not this is a directory
+ *
* @return bool
*/
public abstract function is_directory();
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public abstract function get_children();
/**
* Returns parent file_info instance
+ *
* @return file_info or null for root
*/
public abstract function get_parent();
/**
* Returns array of url encoded params.
+ *
* @return array with numeric keys
*/
public function get_params_rawencoded() {
@@ -104,8 +115,9 @@ abstract class file_info {
/**
* Returns file download url
- * @param bool $forcedownload
- * @param bool $htts force https
+ *
+ * @param bool $forcedownload whether or not force download
+ * @param bool $https whether or not force https
* @return string url
*/
public function get_url($forcedownload=false, $https=false) {
@@ -113,7 +125,8 @@ abstract class file_info {
}
/**
- * Can I read content of this file or enter directory?
+ * Whether or not I can read content of this file or enter directory
+ *
* @return bool
*/
public function is_readable() {
@@ -121,7 +134,8 @@ abstract class file_info {
}
/**
- * Can I add new files or directories?
+ * Whether or not new files or directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -143,6 +157,7 @@ abstract class file_info {
/**
* Returns file size in bytes, null for directories
+ *
* @return int bytes or null if not known
*/
public function get_filesize() {
@@ -151,6 +166,7 @@ abstract class file_info {
/**
* Returns mimetype
+ *
* @return string mimetype or null if not known
*/
public function get_mimetype() {
@@ -159,6 +175,7 @@ abstract class file_info {
/**
* Returns time created unix timestamp if known
+ *
* @return int timestamp or null
*/
public function get_timecreated() {
@@ -167,6 +184,7 @@ abstract class file_info {
/**
* Returns time modified unix timestamp if known
+ *
* @return int timestamp or null
*/
public function get_timemodified() {
@@ -183,6 +201,7 @@ abstract class file_info {
/**
* Returns the author name of the file
+ *
* @return string author name or null
*/
public function get_author() {
@@ -191,6 +210,7 @@ abstract class file_info {
/**
* Returns the source of the file
+ *
* @return string a source url or null
*/
public function get_source() {
@@ -199,6 +219,7 @@ abstract class file_info {
/**
* Returns the sort order of the file
+ *
* @return int
*/
public function get_sortorder() {
@@ -208,8 +229,9 @@ abstract class file_info {
/**
* Create new directory, may throw exception - make sure
* params are valid.
+ *
* @param string $newdirname name of new directory
- * @param int id of author, default $USER->id
+ * @param int $userid id of author, default $USER->id
* @return file_info new directory
*/
public function create_directory($newdirname, $userid = NULL) {
@@ -219,9 +241,10 @@ abstract class file_info {
/**
* Create new file from string - make sure
* params are valid.
+ *
* @param string $newfilename name of new file
* @param string $content of file
- * @param int id of author, default $USER->id
+ * @param int $userid id of author, default $USER->id
* @return file_info new file
*/
public function create_file_from_string($newfilename, $content, $userid = NULL) {
@@ -231,9 +254,10 @@ abstract class file_info {
/**
* Create new file from pathname - make sure
* params are valid.
+ *
* @param string $newfilename name of new file
* @param string $pathname location of file
- * @param int id of author, default $USER->id
+ * @param int $userid id of author, default $USER->id
* @return file_info new file
*/
public function create_file_from_pathname($newfilename, $pathname, $userid = NULL) {
@@ -243,9 +267,10 @@ abstract class file_info {
/**
* Create new file from stored file - make sure
* params are valid.
+ *
* @param string $newfilename name of new file
- * @param mixed dile id or stored_file of file
- * @param int id of author, default $USER->id
+ * @param int|stored_file $fid id or stored_file of file
+ * @param int $userid id of author, default $USER->id
* @return file_info new file
*/
public function create_file_from_storedfile($newfilename, $fid, $userid = NULL) {
@@ -254,6 +279,7 @@ abstract class file_info {
/**
* Delete file, make sure file is deletable first.
+ *
* @return bool success
*/
public function delete() {
@@ -262,12 +288,13 @@ abstract class file_info {
/**
* Copy content of this file to local storage, overriding current file if needed.
- * @param int $contextid
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
+ *
+ * @param int $contextid context ID
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
* @return boolean success
*/
public function copy_to_storage($contextid, $component, $filearea, $itemid, $filepath, $filename) {
@@ -276,6 +303,8 @@ abstract class file_info {
/**
* Copy content of this file to local storage, overriding current file if needed.
+ *
+ * @todo MDL-31068 implement move() rename() unzip() zip()
* @param string $pathname real local full file name
* @return boolean success
*/
diff --git a/lib/filebrowser/file_info_context_course.php b/lib/filebrowser/file_info_context_course.php
index 14f5283f380..32ec3a56858 100644
--- a/lib/filebrowser/file_info_context_course.php
+++ b/lib/filebrowser/file_info_context_course.php
@@ -1,5 +1,4 @@
course = $course;
@@ -46,11 +51,12 @@ class file_info_context_course extends file_info {
/**
* Return information about this specific context level
*
- * @param $component
- * @param $filearea
- * @param $itemid
- * @param $filepath
- * @param $filename
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
*/
public function get_file_info($component, $filearea, $itemid, $filepath, $filename) {
// try to emulate require_login() tests here
@@ -80,6 +86,14 @@ class file_info_context_course extends file_info {
return null;
}
+ /**
+ * Gets a stored file for the course summary filearea directory
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
+ */
protected function get_area_course_summary($itemid, $filepath, $filename) {
global $CFG;
@@ -106,7 +120,14 @@ class file_info_context_course extends file_info {
return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, get_string('areacourseintro', 'repository'), false, true, true, false);
}
-
+ /**
+ * Gets a stored file for the course section filearea directory
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
+ */
protected function get_area_course_section($itemid, $filepath, $filename) {
global $CFG, $DB;
@@ -139,7 +160,14 @@ class file_info_context_course extends file_info {
return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, $section->section, true, true, true, false);
}
-
+ /**
+ * Gets a stored file for the course legacy filearea directory
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
+ */
protected function get_area_course_legacy($itemid, $filepath, $filename) {
if (!has_capability('moodle/course:managefiles', $this->context)) {
return null;
@@ -169,6 +197,14 @@ class file_info_context_course extends file_info {
return new file_info_area_course_legacy($this->browser, $this->context, $storedfile);
}
+ /**
+ * Gets a stored file for the backup course filearea directory
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
+ */
protected function get_area_backup_course($itemid, $filepath, $filename) {
global $CFG;
@@ -202,10 +238,10 @@ class file_info_context_course extends file_info {
/**
* Gets a stored file for the automated backup filearea directory
*
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
- * @return file_info_context_course
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null
*/
protected function get_area_backup_automated($itemid, $filepath, $filename) {
global $CFG;
@@ -237,6 +273,14 @@ class file_info_context_course extends file_info {
return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, get_string('automatedbackup', 'repository'), true, $downloadable, $uploadable, false);
}
+ /**
+ * Gets a stored file for the backup section filearea directory
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null file_info instance or null if not found or access not allowed
+ */
protected function get_area_backup_section($itemid, $filepath, $filename) {
global $CFG, $DB;
@@ -273,12 +317,18 @@ class file_info_context_course extends file_info {
return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, $section->id, true, $downloadable, $uploadable, false);
}
+ /**
+ * Returns localised visible name.
+ *
+ * @return string
+ */
public function get_visible_name() {
return ($this->course->id == SITEID) ? get_string('frontpage', 'admin') : format_string($this->course->fullname, true, array('context'=>$this->context));
}
/**
- * Can I add new files or directories?
+ * Whether or not new files or directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -286,7 +336,8 @@ class file_info_context_course extends file_info {
}
/**
- * Is directory?
+ * Whether or not this is a directory
+ *
* @return bool
*/
public function is_directory() {
@@ -295,6 +346,7 @@ class file_info_context_course extends file_info {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -336,6 +388,8 @@ class file_info_context_course extends file_info {
/**
* Returns parent file_info instance
+ *
+ * @todo error checking if get_parent_contextid() returns false
* @return file_info or null for root
*/
public function get_parent() {
@@ -350,12 +404,18 @@ class file_info_context_course extends file_info {
/**
* Subclass of file_info_stored for files in the course files area.
*
- * @package core
- * @subpackage filebrowser
- * @copyright 2008 Petr Skoda (http://skodak.org)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package core_files
+ * @copyright 2008 Petr Skoda (http://skodak.org)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class file_info_area_course_legacy extends file_info_stored {
+ /**
+ * Constructor
+ *
+ * @param file_browser $browser file browser instance
+ * @param stdClass $context context object
+ * @param stored_file $storedfile stored_file instance
+ */
public function __construct($browser, $context, $storedfile) {
global $CFG;
$urlbase = $CFG->wwwroot.'/file.php';
@@ -364,8 +424,9 @@ class file_info_area_course_legacy extends file_info_stored {
/**
* Returns file download url
- * @param bool $forcedownload
- * @param bool $htts force https
+ *
+ * @param bool $forcedownload whether or not force download
+ * @param bool $https whether or not force https
* @return string url
*/
public function get_url($forcedownload=false, $https=false) {
@@ -388,6 +449,7 @@ class file_info_area_course_legacy extends file_info_stored {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -408,17 +470,26 @@ class file_info_area_course_legacy extends file_info_stored {
}
/**
- * Represents a course category context in the tree navigated by @see{file_browser}.
+ * Represents a course category context in the tree navigated by {@link file_browser}.
*
- * @package core
- * @subpackage filebrowser
+ * @package core_files
* @copyright 2008 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class file_info_area_course_section extends file_info {
+ /** @var stdClass course object */
protected $course;
+ /** @var file_info_context_course course file info object */
protected $courseinfo;
+ /**
+ * Constructor
+ *
+ * @param file_browser $browser file browser instance
+ * @param stdClass $context context object
+ * @param stdClass $course course object
+ * @param file_info_context_course $courseinfo file info instance
+ */
public function __construct($browser, $context, $course, file_info_context_course $courseinfo) {
parent::__construct($browser, $context);
$this->course = $course;
@@ -429,6 +500,7 @@ class file_info_area_course_section extends file_info {
* Returns list of standard virtual file/directory identification.
* The difference from stored_file parameters is that null values
* are allowed in all fields
+ *
* @return array with keys contextid, filearea, itemid, filepath and filename
*/
public function get_params() {
@@ -442,6 +514,7 @@ class file_info_area_course_section extends file_info {
/**
* Returns localised visible name.
+ *
* @return string
*/
public function get_visible_name() {
@@ -452,7 +525,8 @@ class file_info_area_course_section extends file_info {
}
/**
- * Can I add new files or directories?
+ * Return whether or not new files or directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -460,7 +534,7 @@ class file_info_area_course_section extends file_info {
}
/**
- * Is this empty area?
+ * Return whether or not this is a empty area
*
* @return bool
*/
@@ -470,7 +544,8 @@ class file_info_area_course_section extends file_info {
}
/**
- * Is directory?
+ * Return whether or not this is a empty area
+ *
* @return bool
*/
public function is_directory() {
@@ -479,6 +554,7 @@ class file_info_area_course_section extends file_info {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -498,7 +574,8 @@ class file_info_area_course_section extends file_info {
/**
* Returns parent file_info instance
- * @return file_info or null for root
+ *
+ * @return file_info|null file_info or null for root
*/
public function get_parent() {
return $this->courseinfo;
@@ -509,15 +586,24 @@ class file_info_area_course_section extends file_info {
/**
* Implementation of course section backup area
*
- * @package core
- * @subpackage filebrowser
+ * @package core_files
* @copyright 2008 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class file_info_area_backup_section extends file_info {
+ /** @var stdClass course object */
protected $course;
+ /** @var file_info_context_course course file info object */
protected $courseinfo;
+ /**
+ * Constructor
+ *
+ * @param file_browser $browser file browser instance
+ * @param stdClass $context context object
+ * @param stdClass $course course object
+ * @param file_info_context_course $courseinfo file info instance
+ */
public function __construct($browser, $context, $course, file_info_context_course $courseinfo) {
parent::__construct($browser, $context);
$this->course = $course;
@@ -528,6 +614,7 @@ class file_info_area_backup_section extends file_info {
* Returns list of standard virtual file/directory identification.
* The difference from stored_file parameters is that null values
* are allowed in all fields
+ *
* @return array with keys contextid, component, filearea, itemid, filepath and filename
*/
public function get_params() {
@@ -541,6 +628,7 @@ class file_info_area_backup_section extends file_info {
/**
* Returns localised visible name.
+ *
* @return string
*/
public function get_visible_name() {
@@ -548,7 +636,8 @@ class file_info_area_backup_section extends file_info {
}
/**
- * Can I add new files or directories?
+ * Return whether or not new files and directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -556,7 +645,7 @@ class file_info_area_backup_section extends file_info {
}
/**
- * Is this empty area?
+ * Whether or not this is an empty area
*
* @return bool
*/
@@ -566,7 +655,8 @@ class file_info_area_backup_section extends file_info {
}
/**
- * Is directory?
+ * Return whether or not this is a directory
+ *
* @return bool
*/
public function is_directory() {
@@ -575,6 +665,7 @@ class file_info_area_backup_section extends file_info {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -594,11 +685,10 @@ class file_info_area_backup_section extends file_info {
/**
* Returns parent file_info instance
+ *
* @return file_info or null for root
*/
public function get_parent() {
return $this->browser->get_file_info($this->context);
}
}
-
-
diff --git a/lib/filebrowser/file_info_context_coursecat.php b/lib/filebrowser/file_info_context_coursecat.php
index 044c1eee912..99b6d1fc240 100644
--- a/lib/filebrowser/file_info_context_coursecat.php
+++ b/lib/filebrowser/file_info_context_coursecat.php
@@ -1,5 +1,4 @@
category = $category;
@@ -46,11 +51,12 @@ class file_info_context_coursecat extends file_info {
/**
* Return information about this specific context level
*
- * @param $component
- * @param $filearea
- * @param $itemid
- * @param $filepath
- * @param $filename
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return fileinfo|null
*/
public function get_file_info($component, $filearea, $itemid, $filepath, $filename) {
global $DB;
@@ -80,6 +86,14 @@ class file_info_context_coursecat extends file_info {
return null;
}
+ /**
+ * Return a file from course category description area
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return fileinfo|null
+ */
protected function get_area_coursecat_description($itemid, $filepath, $filename) {
global $CFG;
@@ -110,6 +124,7 @@ class file_info_context_coursecat extends file_info {
/**
* Returns localised visible name.
+ *
* @return string
*/
public function get_visible_name() {
@@ -117,7 +132,8 @@ class file_info_context_coursecat extends file_info {
}
/**
- * Can I add new files or directories?
+ * Whether or not new files or directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -125,7 +141,8 @@ class file_info_context_coursecat extends file_info {
}
/**
- * Is directory?
+ * Whether or not this is a directory
+ *
* @return bool
*/
public function is_directory() {
@@ -134,6 +151,7 @@ class file_info_context_coursecat extends file_info {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -172,7 +190,8 @@ class file_info_context_coursecat extends file_info {
/**
* Returns parent file_info instance
- * @return file_info or null for root
+ *
+ * @return file_info|null fileinfo instance or null for root directory
*/
public function get_parent() {
$cid = get_parent_contextid($this->context);
diff --git a/lib/filebrowser/file_info_context_module.php b/lib/filebrowser/file_info_context_module.php
index a8149c677ac..0357ee34cde 100644
--- a/lib/filebrowser/file_info_context_module.php
+++ b/lib/filebrowser/file_info_context_module.php
@@ -1,5 +1,4 @@
browser, $this->context, $storedfile, $urlbase, get_string('moduleintro'), false, true, true, false);
}
+ /**
+ * Get a file from module backup area
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null
+ */
protected function get_area_backup($itemid, $filepath, $filename) {
global $CFG;
@@ -172,6 +199,7 @@ class file_info_context_module extends file_info {
/**
* Returns localised visible name.
+ *
* @return string
*/
public function get_visible_name() {
@@ -179,7 +207,8 @@ class file_info_context_module extends file_info {
}
/**
- * Can I add new files or directories?
+ * Whether or not files or directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -187,7 +216,7 @@ class file_info_context_module extends file_info {
}
/**
- * Is this empty area?
+ * Whether or not this is an emtpy area
*
* @return bool
*/
@@ -215,7 +244,8 @@ class file_info_context_module extends file_info {
}
/**
- * Is directory?
+ * Whether or not this is a directory
+ *
* @return bool
*/
public function is_directory() {
@@ -224,6 +254,7 @@ class file_info_context_module extends file_info {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -247,7 +278,8 @@ class file_info_context_module extends file_info {
/**
* Returns parent file_info instance
- * @return file_info or null for root
+ *
+ * @return file_info|null file_info or null for root
*/
public function get_parent() {
$pcid = get_parent_contextid($this->context);
diff --git a/lib/filebrowser/file_info_context_system.php b/lib/filebrowser/file_info_context_system.php
index a3908ef755b..c7583735eaa 100644
--- a/lib/filebrowser/file_info_context_system.php
+++ b/lib/filebrowser/file_info_context_system.php
@@ -1,5 +1,4 @@
user = $user;
@@ -46,11 +51,12 @@ class file_info_context_user extends file_info {
/**
* Return information about this specific context level
*
- * @param $component
- * @param $filearea
- * @param $itemid
- * @param $filepath
- * @param $filename
+ * @param string $component componet
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null
*/
public function get_file_info($component, $filearea, $itemid, $filepath, $filename) {
global $USER;
@@ -76,6 +82,15 @@ class file_info_context_user extends file_info {
return null;
}
+ /**
+ * Get a file from user private area
+ *
+ * @todo MDL-31070 this method should respect $CFG->userquota
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null
+ */
protected function get_area_user_private($itemid, $filepath, $filename) {
global $USER, $CFG;
@@ -110,6 +125,14 @@ class file_info_context_user extends file_info {
return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, get_string('areauserpersonal', 'repository'), false, true, true, false);
}
+ /**
+ * Get a file from user profile area
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null
+ */
protected function get_area_user_profile($itemid, $filepath, $filename) {
global $CFG;
@@ -144,6 +167,14 @@ class file_info_context_user extends file_info {
get_string('areauserprofile', 'repository'), false, $readaccess, $writeaccess, false);
}
+ /**
+ * Get a file from user draft area
+ *
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null
+ */
protected function get_area_user_draft($itemid, $filepath, $filename) {
global $USER, $CFG;
@@ -174,6 +205,15 @@ class file_info_context_user extends file_info {
return new file_info_stored($this->browser, $this->context, $storedfile, $urlbase, get_string('areauserdraft', 'repository'), true, true, true, true);
}
+ /**
+ * Get a file from user backup area
+ *
+ * @todo MDL-31091 maybe we need new caability for access control
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return file_info|null
+ */
protected function get_area_user_backup($itemid, $filepath, $filename) {
global $USER, $CFG;
@@ -206,6 +246,7 @@ class file_info_context_user extends file_info {
/**
* Returns localised visible name.
+ *
* @return string
*/
public function get_visible_name() {
@@ -213,7 +254,8 @@ class file_info_context_user extends file_info {
}
/**
- * Can I add new files or directories?
+ * Whether or not new files or directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -221,7 +263,8 @@ class file_info_context_user extends file_info {
}
/**
- * Is directory?
+ * Whether or not this is a directory
+ *
* @return bool
*/
public function is_directory() {
@@ -230,6 +273,7 @@ class file_info_context_user extends file_info {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -253,7 +297,8 @@ class file_info_context_user extends file_info {
/**
* Returns parent file_info instance
- * @return file_info or null for root
+ *
+ * @return file_info|null file_info instance or null for root
*/
public function get_parent() {
return $this->browser->get_file_info();
diff --git a/lib/filebrowser/file_info_stored.php b/lib/filebrowser/file_info_stored.php
index 104511948c9..787787ee6a0 100644
--- a/lib/filebrowser/file_info_stored.php
+++ b/lib/filebrowser/file_info_stored.php
@@ -1,5 +1,4 @@
wwwroot/.'pluginfile.php'
* @param string $topvisiblename the human readable name of this area
* @param int|bool $itemidused false if itemid always 0 and not included in URL
@@ -74,6 +77,7 @@ class file_info_stored extends file_info {
* Returns list of standard virtual file/directory identification.
* The difference from stored_file parameters is that null values
* are allowed in all fields
+ *
* @return array with keys contextid, component, filearea, itemid, filepath and filename
*/
public function get_params() {
@@ -87,6 +91,7 @@ class file_info_stored extends file_info {
/**
* Returns localised visible name.
+ *
* @return string
*/
public function get_visible_name() {
@@ -110,8 +115,9 @@ class file_info_stored extends file_info {
/**
* Returns file download url
- * @param bool $forcedownload
- * @param bool $htts force https
+ *
+ * @param bool $forcedownload Whether or not force download
+ * @param bool $https whether or not force https
* @return string url
*/
public function get_url($forcedownload=false, $https=false) {
@@ -140,7 +146,8 @@ class file_info_stored extends file_info {
}
/**
- * Can I read content of this file or enter directory?
+ * Whether or not I can read content of this file or enter directory
+ *
* @return bool
*/
public function is_readable() {
@@ -148,7 +155,8 @@ class file_info_stored extends file_info {
}
/**
- * Can I add new files or directories?
+ * Whether or not new files or directories can be added
+ *
* @return bool
*/
public function is_writable() {
@@ -156,7 +164,7 @@ class file_info_stored extends file_info {
}
/**
- * Is this top of empty area?
+ * Whether or not this is an empty area
*
* @return bool
*/
@@ -172,6 +180,7 @@ class file_info_stored extends file_info {
/**
* Returns file size in bytes, null for directories
+ *
* @return int bytes or null if not known
*/
public function get_filesize() {
@@ -180,6 +189,7 @@ class file_info_stored extends file_info {
/**
* Returns mimetype
+ *
* @return string mimetype or null if not known
*/
public function get_mimetype() {
@@ -188,6 +198,7 @@ class file_info_stored extends file_info {
/**
* Returns time created unix timestamp if known
+ *
* @return int timestamp or null
*/
public function get_timecreated() {
@@ -196,6 +207,7 @@ class file_info_stored extends file_info {
/**
* Returns time modified unix timestamp if known
+ *
* @return int timestamp or null
*/
public function get_timemodified() {
@@ -203,7 +215,8 @@ class file_info_stored extends file_info {
}
/**
- * Is directory?
+ * Whether or not this is a directory
+ *
* @return bool
*/
public function is_directory() {
@@ -212,6 +225,7 @@ class file_info_stored extends file_info {
/**
* Returns the license type of the file
+ *
* @return string license short name or null
*/
public function get_license() {
@@ -220,6 +234,7 @@ class file_info_stored extends file_info {
/**
* Returns the author name of the file
+ *
* @return string author name or null
*/
public function get_author() {
@@ -228,6 +243,7 @@ class file_info_stored extends file_info {
/**
* Returns the source of the file
+ *
* @return string a source url or null
*/
public function get_source() {
@@ -236,6 +252,7 @@ class file_info_stored extends file_info {
/**
* Returns the sort order of the file
+ *
* @return int
*/
public function get_sortorder() {
@@ -244,6 +261,7 @@ class file_info_stored extends file_info {
/**
* Returns list of children.
+ *
* @return array of file_info instances
*/
public function get_children() {
@@ -266,7 +284,8 @@ class file_info_stored extends file_info {
/**
* Returns parent file_info instance
- * @return file_info or null for root
+ *
+ * @return file_info|null file_info instance or null for root
*/
public function get_parent() {
if ($this->lf->get_filepath() === '/' and $this->lf->is_directory()) {
@@ -296,9 +315,10 @@ class file_info_stored extends file_info {
/**
* Create new directory, may throw exception - make sure
* params are valid.
+ *
* @param string $newdirname name of new directory
- * @param int id of author, default $USER->id
- * @return file_info new directory
+ * @param int $userid id of author, default $USER->id
+ * @return file_info|null new directory's file_info instance or null if failed
*/
public function create_directory($newdirname, $userid = NULL) {
if (!$this->is_writable() or !$this->lf->is_directory()) {
@@ -324,10 +344,11 @@ class file_info_stored extends file_info {
/**
* Create new file from string - make sure
* params are valid.
+ *
* @param string $newfilename name of new file
* @param string $content of file
- * @param int id of author, default $USER->id
- * @return file_info new file
+ * @param int $userid id of author, default $USER->id
+ * @return file_info|null new file's file_info instance or null if failed
*/
public function create_file_from_string($newfilename, $content, $userid = NULL) {
if (!$this->is_writable() or !$this->lf->is_directory()) {
@@ -370,10 +391,11 @@ class file_info_stored extends file_info {
/**
* Create new file from pathname - make sure
* params are valid.
+ *
* @param string $newfilename name of new file
* @param string $pathname location of file
- * @param int id of author, default $USER->id
- * @return file_info new file
+ * @param int $userid id of author, default $USER->id
+ * @return file_info|null new file's file_info instance or null if failed
*/
public function create_file_from_pathname($newfilename, $pathname, $userid = NULL) {
if (!$this->is_writable() or !$this->lf->is_directory()) {
@@ -416,10 +438,11 @@ class file_info_stored extends file_info {
/**
* Create new file from stored file - make sure
* params are valid.
+ *
* @param string $newfilename name of new file
- * @param mixed file id or stored_file of file
- * @param int id of author, default $USER->id
- * @return file_info new file
+ * @param int|stored_file $fid file id or stored_file of file
+ * @param int $userid id of author, default $USER->id
+ * @return file_info|null new file's file_info instance or null if failed
*/
public function create_file_from_storedfile($newfilename, $fid, $userid = NULL) {
if (!$this->is_writable() or $this->lf->get_filename() !== '.') {
@@ -461,6 +484,7 @@ class file_info_stored extends file_info {
/**
* Delete file, make sure file is deletable first.
+ *
* @return bool success
*/
public function delete() {
@@ -484,12 +508,14 @@ class file_info_stored extends file_info {
/**
* Copy content of this file to local storage, overriding current file if needed.
- * @param int $contextid
- * @param string $filearea
- * @param int $itemid
- * @param string $filepath
- * @param string $filename
- * @return boolean success
+ *
+ * @param int $contextid context ID
+ * @param string $component file component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $filepath file path
+ * @param string $filename file name
+ * @return bool success
*/
public function copy_to_storage($contextid, $component, $filearea, $itemid, $filepath, $filename) {
if (!$this->is_readable() or $this->is_directory()) {
@@ -508,8 +534,9 @@ class file_info_stored extends file_info {
/**
* Copy content of this file to local storage, overriding current file if needed.
+ *
* @param string $pathname real local full file name
- * @return boolean success
+ * @return bool success
*/
public function copy_to_pathname($pathname) {
if (!$this->is_readable() or $this->is_directory()) {
diff --git a/lib/filebrowser/virtual_root_file.php b/lib/filebrowser/virtual_root_file.php
index 6170d6727f6..f8187d20c24 100644
--- a/lib/filebrowser/virtual_root_file.php
+++ b/lib/filebrowser/virtual_root_file.php
@@ -1,5 +1,4 @@
contextid = $contextid;
@@ -53,7 +58,8 @@ class virtual_root_file {
}
/**
- * Is this a directory?
+ * Whether or not this is a directory
+ *
* @return bool
*/
public function is_directory() {
@@ -62,6 +68,7 @@ class virtual_root_file {
/**
* Delete file
+ *
* @return success
*/
public function delete() {
@@ -80,7 +87,8 @@ class virtual_root_file {
/**
* Returns file handle - read only mode, no writing allowed into pool files!
- * @return file handle
+ *
+ * @return resource file handle
*/
public function get_content_file_handle() {
return null;
@@ -88,7 +96,8 @@ class virtual_root_file {
/**
* Dumps file content to page
- * @return file handle
+ *
+ * @return resource file handle
*/
public function readfile() {
return;
@@ -96,6 +105,7 @@ class virtual_root_file {
/**
* Returns file content as string
+ *
* @return string content
*/
public function get_content() {
@@ -104,6 +114,7 @@ class virtual_root_file {
/**
* Copy content of file to given pathname
+ *
* @param string $pathname real path to new file
* @return bool success
*/
@@ -113,7 +124,8 @@ class virtual_root_file {
/**
* List contents of archive
- * @param object $file_packer
+ *
+ * @param file_packer $packer file packer instance
* @return array of file infos
*/
public function list_files(file_packer $packer) {
@@ -122,7 +134,8 @@ class virtual_root_file {
/**
* Extract file to given file path (real OS filesystem), existing files are overwrited
- * @param object $file_packer
+ *
+ * @param file_packer $packer file packer instance
* @param string $pathname target directory
* @return mixed list of processed files; false if error
*/
@@ -132,13 +145,14 @@ class virtual_root_file {
/**
* Extract file to given file path (real OS filesystem), existing files are overwrited
- * @param object $file_packer
- * @param int $contextid
- * @param string $component
- * @param string $filearea
- * @param int $itemid
- * @param string $pathbase
- * @param int $userid
+ *
+ * @param file_packer $packer file packer instance
+ * @param int $contextid context ID
+ * @param string $component component
+ * @param string $filearea file area
+ * @param int $itemid item ID
+ * @param string $pathbase path base
+ * @param int $userid user ID
* @return mixed list of processed files; false if error
*/
public function extract_to_storage(file_packer $packer, $contextid, $component, $filearea, $itemid, $pathbase, $userid = NULL) {
@@ -147,7 +161,8 @@ class virtual_root_file {
/**
* Add file/directory into archive
- * @param object $filearch
+ *
+ * @param file_archive $filearch file archive instance
* @param string $archivepath pathname in archive
* @return bool success
*/
@@ -157,84 +172,180 @@ class virtual_root_file {
/**
* Returns parent directory
- * @return object stored_file
+ *
+ * @return stored_file
*/
public function get_parent_directory() {
return null;
}
+ /**
+ * Returns context ID
+ *
+ * @return int context ID
+ */
public function get_contextid() {
return $this->contextid;
}
+ /**
+ * Returns file component
+ *
+ * @return string component
+ */
public function get_component() {
return $this->component;
}
+ /**
+ * Returns file area
+ *
+ * @return string filearea
+ */
public function get_filearea() {
return $this->filearea;
}
+ /**
+ * Returns file itemid
+ *
+ * @return int itemid
+ */
public function get_itemid() {
return $this->itemid;
}
+ /**
+ * Returns file path
+ *
+ * @return string filepath
+ */
public function get_filepath() {
return '/';
}
+ /**
+ * Returns file name
+ *
+ * @return string filename
+ */
public function get_filename() {
return '.';
}
+ /**
+ * Returns user ID
+ *
+ * @return int userid
+ */
public function get_userid() {
return null;
}
+ /**
+ * Returns file size
+ *
+ * @return int filesize
+ */
public function get_filesize() {
return 0;
}
+ /**
+ * Returns mimetype
+ *
+ * @return string mimetype
+ */
public function get_mimetype() {
return null;
}
+ /**
+ * Returns time created
+ *
+ * @return int
+ */
public function get_timecreated() {
return 0;
}
+ /**
+ * Returns time modified
+ *
+ * @return int
+ */
public function get_timemodified() {
return 0;
}
+ /**
+ * Returns status
+ *
+ * @return int
+ */
public function get_status() {
return 0;
}
+ /**
+ * Returns ID
+ *
+ * @return int
+ */
public function get_id() {
return 0;
}
+ /**
+ * Returns sha1 hash code
+ *
+ * @return string
+ */
public function get_contenthash() {
return sha1('');
}
+ /**
+ * Returns path name hash
+ *
+ * @return string
+ */
public function get_pathnamehash() {
return sha1('/'.$this->get_contextid().'/'.$this->get_component().'/'.$this->get_filearea().'/'.$this->get_itemid().$this->get_filepath().$this->get_filename());
}
+ /**
+ * Returns license
+ *
+ * @return string
+ */
public function get_license() {
return null;
}
+ /**
+ * Returns file's author
+ *
+ * @return string
+ */
public function get_author() {
return null;
}
+ /**
+ * Returns file source
+ *
+ * @return string
+ */
public function get_source() {
return null;
}
+ /**
+ * Returns file sort order
+ *
+ * @return int
+ */
public function get_sortorder() {
return null;
}
diff --git a/lib/filelib.php b/lib/filelib.php
index 1c3ddf3c8cd..43bc8ddd242 100644
--- a/lib/filelib.php
+++ b/lib/filelib.php
@@ -1,5 +1,4 @@
libdir/filestorage/file_exceptions.php");
@@ -39,7 +39,8 @@ require_once("$CFG->libdir/filebrowser/file_browser.php");
*
* @deprecated use moodle_url factory methods instead
*
- * @global object
+ * @todo MDL-31071 deprecate this function
+ * @global stdClass $CFG
* @param string $urlbase
* @param string $path /filearea/itemid/dir/dir/file.exe
* @param bool $forcedownload
@@ -84,14 +85,15 @@ function file_encode_url($urlbase, $path, $forcedownload=false, $https=false) {
* In your mform definition, you must have an 'editor' element called foobar_editor. Then you call
* your mform's set_data() supplying the object returned by this function.
*
- * @param object $data database field that holds the html text with embedded media
+ * @category files
+ * @param stdClass $data database field that holds the html text with embedded media
* @param string $field the name of the database field that holds the html text with embedded media
* @param array $options editor options (like maxifiles, maxbytes etc.)
- * @param object $context context of the editor
+ * @param stdClass $context context of the editor
* @param string $component
* @param string $filearea file area name
* @param int $itemid item id, required if item exists
- * @return object modified data object
+ * @return stdClass modified data object
*/
function file_prepare_standard_editor($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null) {
$options = (array)$options;
@@ -178,14 +180,15 @@ function file_prepare_standard_editor($data, $field, array $options, $context=nu
* function automatically adds $data properties foobar, foobarformat and
* foobartrust, where foobar has URL to embedded files encoded.
*
- * @param object $data raw data submitted by the form
+ * @category files
+ * @param stdClass $data raw data submitted by the form
* @param string $field name of the database field containing the html with embedded media files
* @param array $options editor options (trusttext, subdirs, maxfiles, maxbytes etc.)
- * @param object $context context, required for existing data
- * @param string component
+ * @param stdClass $context context, required for existing data
+ * @param string $component file component
* @param string $filearea file area name
* @param int $itemid item id, required if item exists
- * @return object modified data object
+ * @return stdClass modified data object
*/
function file_postupdate_standard_editor($data, $field, array $options, $context, $component=null, $filearea=null, $itemid=null) {
$options = (array)$options;
@@ -226,14 +229,15 @@ function file_postupdate_standard_editor($data, $field, array $options, $context
/**
* Saves text and files modified by Editor formslib element
*
- * @param object $data $database entry field
+ * @category files
+ * @param stdClass $data $database entry field
* @param string $field name of data field
* @param array $options various options
- * @param object $context context - must already exist
+ * @param stdClass $context context - must already exist
* @param string $component
* @param string $filearea file area name
* @param int $itemid must already exist, usually means data is in db
- * @return object modified data obejct
+ * @return stdClass modified data obejct
*/
function file_prepare_standard_filemanager($data, $field, array $options, $context=null, $component=null, $filearea=null, $itemid=null) {
$options = (array)$options;
@@ -257,14 +261,16 @@ function file_prepare_standard_filemanager($data, $field, array $options, $conte
/**
* Saves files modified by File manager formslib element
*
- * @param object $data $database entry field
+ * @todo MDL-31073 review this function
+ * @category files
+ * @param stdClass $data $database entry field
* @param string $field name of data field
* @param array $options various options
- * @param object $context context - must already exist
+ * @param stdClass $context context - must already exist
* @param string $component
* @param string $filearea file area name
* @param int $itemid must already exist, usually means data is in db
- * @return object modified data obejct
+ * @return stdClass modified data obejct
*/
function file_postupdate_standard_filemanager($data, $field, array $options, $context, $component, $filearea, $itemid) {
$options = (array)$options;
@@ -296,9 +302,11 @@ function file_postupdate_standard_filemanager($data, $field, array $options, $co
}
/**
+ * Generate a draft itemid
*
- * @global object
- * @global object
+ * @category files
+ * @global moodle_database $DB
+ * @global stdClass $USER
* @return int a random but available draft itemid that can be used to create a new draft
* file area.
*/
@@ -326,16 +334,17 @@ function file_get_unused_draft_itemid() {
* area will be created if one does not already exist. Normally you should
* get $draftitemid by calling file_get_submitted_draft_itemid('elementname');
*
- * @global object
- * @global object
- * @param int &$draftitemid the id of the draft area to use, or 0 to create a new one, in which case this parameter is updated.
- * @param integer $contextid This parameter and the next two identify the file area to copy files from.
+ * @category files
+ * @global stdClass $CFG
+ * @global stdClass $USER
+ * @param int $draftitemid the id of the draft area to use, or 0 to create a new one, in which case this parameter is updated.
+ * @param int $contextid This parameter and the next two identify the file area to copy files from.
* @param string $component
* @param string $filearea helps indentify the file area.
- * @param integer $itemid helps identify the file area. Can be null if there are no files yet.
+ * @param int $itemid helps identify the file area. Can be null if there are no files yet.
* @param array $options text and file options ('subdirs'=>false, 'forcehttps'=>false)
* @param string $text some html content that needs to have embedded links rewritten to point to the draft area.
- * @return string if $text was passed in, the rewritten $text is returned. Otherwise NULL.
+ * @return string|null returns string if $text was passed in, the rewritten $text is returned. Otherwise NULL.
*/
function file_prepare_draft_area(&$draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null) {
global $CFG, $USER, $CFG;
@@ -389,13 +398,14 @@ function file_prepare_draft_area(&$draftitemid, $contextid, $component, $fileare
/**
* Convert encoded URLs in $text from the @@PLUGINFILE@@/... form to an actual URL.
*
- * @global object
+ * @category files
+ * @global stdClass $CFG
* @param string $text The content that may contain ULRs in need of rewriting.
* @param string $file The script that should be used to serve these files. pluginfile.php, draftfile.php, etc.
- * @param integer $contextid This parameter and the next two identify the file area to use.
+ * @param int $contextid This parameter and the next two identify the file area to use.
* @param string $component
* @param string $filearea helps identify the file area.
- * @param integer $itemid helps identify the file area.
+ * @param int $itemid helps identify the file area.
* @param array $options text and file options ('forcehttps'=>false)
* @return string the processed text.
*/
@@ -427,9 +437,9 @@ function file_rewrite_pluginfile_urls($text, $file, $contextid, $component, $fil
/**
* Returns information about files in a draft area.
*
- * @global object
- * @global object
- * @param integer $draftitemid the draft area item id.
+ * @global stdClass $CFG
+ * @global stdClass $USER
+ * @param int $draftitemid the draft area item id.
* @return array with the following entries:
* 'filecount' => number of files in the draft area.
* (more information will be added as needed).
@@ -455,6 +465,8 @@ function file_get_draft_area_info($draftitemid) {
/**
* Get used space of files
+ * @global moodle_database $DB
+ * @global stdClass $USER
* @return int total bytes
*/
function file_get_user_used_space() {
@@ -473,6 +485,7 @@ function file_get_user_used_space() {
/**
* Convert any string to a valid filepath
+ * @todo review this function
* @param string $str
* @return string path
*/
@@ -486,9 +499,11 @@ function file_correct_filepath($str) { //TODO: what is this? (skodak)
/**
* Generate a folder tree of draft area of current USER recursively
- * @param int $itemid
+ *
+ * @todo MDL-31073 use normal return value instead, this does not fit the rest of api here (skodak)
+ * @param int $draftitemid
* @param string $filepath
- * @param mixed $data //TODO: use normal return value instead, this does not fit the rest of api here (skodak)
+ * @param mixed $data
*/
function file_get_drafarea_folders($draftitemid, $filepath, &$data) {
global $USER, $OUTPUT, $CFG;
@@ -520,7 +535,7 @@ function file_get_drafarea_folders($draftitemid, $filepath, &$data) {
* used by file manager
* @param int $draftitemid
* @param string $filepath
- * @return mixed
+ * @return stdClass
*/
function file_get_drafarea_files($draftitemid, $filepath = '/') {
global $USER, $OUTPUT, $CFG;
@@ -587,8 +602,9 @@ function file_get_drafarea_files($draftitemid, $filepath = '/') {
/**
* Returns draft area itemid for a given element.
*
+ * @category files
* @param string $elname name of formlib editor element, or a hidden form field that stores the draft area item id, etc.
- * @return integer the itemid, or 0 if there is not one yet.
+ * @return int the itemid, or 0 if there is not one yet.
*/
function file_get_submitted_draft_itemid($elname) {
// this is a nasty hack, ideally all new elements should use arrays here or there should be a new parameter
@@ -619,19 +635,19 @@ function file_get_submitted_draft_itemid($elname) {
* Saves files from a draft file area to a real one (merging the list of files).
* Can rewrite URLs in some content at the same time if desired.
*
- * @global object
- * @global object
- * @param integer $draftitemid the id of the draft area to use. Normally obtained
+ * @category files
+ * @global stdClass $USER
+ * @param int $draftitemid the id of the draft area to use. Normally obtained
* from file_get_submitted_draft_itemid('elementname') or similar.
- * @param integer $contextid This parameter and the next two identify the file area to save to.
+ * @param int $contextid This parameter and the next two identify the file area to save to.
* @param string $component
* @param string $filearea indentifies the file area.
- * @param integer $itemid helps identifies the file area.
+ * @param int $itemid helps identifies the file area.
* @param array $options area options (subdirs=>false, maxfiles=-1, maxbytes=0)
* @param string $text some html content that needs to have embedded links rewritten
* to the @@PLUGINFILE@@ form for saving in the database.
- * @param boolean $forcehttps force https urls.
- * @return string if $text was passed in, the rewritten $text is returned. Otherwise NULL.
+ * @param bool $forcehttps force https urls.
+ * @return string|null if $text was passed in, the rewritten $text is returned. Otherwise NULL.
*/
function file_save_draft_area_files($draftitemid, $contextid, $component, $filearea, $itemid, array $options=null, $text=null, $forcehttps=false) {
global $USER;
@@ -752,6 +768,8 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
* Convert the draft file area URLs in some content to @@PLUGINFILE@@ tokens
* ready to be saved in the database. Normally, this is done automatically by
* {@link file_save_draft_area_files()}.
+ *
+ * @category files
* @param string $text the content to process.
* @param int $draftitemid the draft file area the content was using.
* @param bool $forcehttps whether the content contains https URLs. Default false.
@@ -787,15 +805,16 @@ function file_rewrite_urls_to_pluginfile($text, $draftitemid, $forcehttps = fals
/**
* Set file sort order
- * @global object $DB
- * @param integer $contextid the context id
- * @param string $component
+ *
+ * @global moodle_database $DB
+ * @param int $contextid the context id
+ * @param string $component file component
* @param string $filearea file area.
- * @param integer $itemid itemid.
+ * @param int $itemid itemid.
* @param string $filepath file path.
* @param string $filename file name.
- * @param integer $sortorer the sort order of file.
- * @return boolean
+ * @param int $sortorder the sort order of file.
+ * @return bool
*/
function file_set_sortorder($contextid, $component, $filearea, $itemid, $filepath, $filename, $sortorder) {
global $DB;
@@ -811,12 +830,12 @@ function file_set_sortorder($contextid, $component, $filearea, $itemid, $filepat
/**
* reset file sort order number to 0
- * @global object $DB
- * @param integer $contextid the context id
+ * @global moodle_database $DB
+ * @param int $contextid the context id
* @param string $component
* @param string $filearea file area.
- * @param integer $itemid itemid.
- * @return boolean
+ * @param int|bool $itemid itemid.
+ * @return bool
*/
function file_reset_sortorder($contextid, $component, $filearea, $itemid=false) {
global $DB;
@@ -923,13 +942,12 @@ function format_postdata_for_curlcall($postdata) {
return $convertedpostdata;
}
-
-
-
/**
* Fetches content of file from Internet (using proxy if defined). Uses cURL extension if present.
* Due to security concerns only downloads from http(s) sources are supported.
*
+ * @todo MDL-31073 add version test for '7.10.5'
+ * @category files
* @param string $url file url starting with http(s)://
* @param array $headers http headers, null if none. If set, should be an
* associative array of header name => value pairs.
@@ -1160,6 +1178,10 @@ function download_file_content($url, $headers=null, $postdata=null, $fullrespons
/**
* internal implementation
+ * @param stdClass $received
+ * @param resource $ch
+ * @param mixed $header
+ * @return int header length
*/
function download_file_content_header_handler($received, $ch, $header) {
$received->headers[] = $header;
@@ -1168,6 +1190,9 @@ function download_file_content_header_handler($received, $ch, $header) {
/**
* internal implementation
+ * @param stdClass $received
+ * @param resource $ch
+ * @param mixed $data
*/
function download_file_content_write_handler($received, $ch, $data) {
if (!$received->fh) {
@@ -1185,6 +1210,9 @@ function download_file_content_write_handler($received, $ch, $data) {
}
/**
+ * Returns a list of information about file t ypes based on extensions
+ *
+ * @category files
* @return array List of information about file types based on extensions.
* Associative array of extension (lower-case) to associative array
* from 'element name' to data. Current element names are 'type' and 'icon'.
@@ -1372,6 +1400,7 @@ function get_mimetypes_array() {
* use a default if no information is present about that particular
* extension.
*
+ * @category files
* @param string $element Desired information (usually 'icon'
* for icon filename or 'type' for MIME type)
* @param string $filename Filename we're looking up
@@ -1413,6 +1442,7 @@ function mimeinfo($element, $filename) {
* Obtains information about a filetype based on the MIME type rather than
* the other way around.
*
+ * @category files
* @param string $element Desired information (usually 'icon')
* @param string $mimetype MIME type we're looking up
* @return string Requested piece of information from array
@@ -1434,9 +1464,10 @@ function mimeinfo_from_type($element, $mimetype) {
/**
* Get information about a filetype based on the icon file.
*
+ * @category files
* @param string $element Desired information (usually 'icon')
* @param string $icon Icon file name without extension
- * @param boolean $all return all matching entries (defaults to false - best (by ext)/last match)
+ * @param bool $all return all matching entries (defaults to false - best (by ext)/last match)
* @return string Requested piece of information from array
*/
function mimeinfo_from_icon($element, $icon, $all=false) {
@@ -1486,9 +1517,9 @@ function mimeinfo_from_icon($element, $icon, $all=false) {
* echo '';
*
*
- * @todo When an $OUTPUT->icon method is available this function should be altered
+ * @category files
+ * @todo MDL-31074 When an $OUTPUT->icon method is available this function should be altered
* to conform with that.
- *
* @param string $mimetype The mimetype to fetch an icon for
* @param int $size The size of the icon. Not yet implemented
* @return string The relative path to the icon
@@ -1517,11 +1548,11 @@ function file_mimetype_icon($mimetype, $size = NULL) {
* echo '
';
*
*
- * @todo When an $OUTPUT->icon method is available this function should be altered
+ * @todo MDL-31074 When an $OUTPUT->icon method is available this function should be altered
* to conform with that.
- * @todo Implement $size
- *
- * @param string filename The filename to get the icon for
+ * @todo MDL-31074 Implement $size
+ * @category files
+ * @param string $filename The filename to get the icon for
* @param int $size The size of the icon. Defaults to null can also be 32
* @return string
*/
@@ -1558,9 +1589,10 @@ function get_mimetype_description($mimetype, $capitalise=false) {
}
/**
- * Requested file is not found or not accessible
+ * Requested file is not found or not accessible, does not return, terminates script
*
- * @return does not return, terminates script
+ * @global stdClass $CFG
+ * @global stdClass $COURSE
*/
function send_file_not_found() {
global $CFG, $COURSE;
@@ -1572,8 +1604,7 @@ function send_file_not_found() {
* Check output buffering settings before sending file.
* Please note you should not send any other headers after calling this function.
*
- * @private to be called only from lib/filelib.php !
- * @return void
+ * To be called only from lib/filelib.php !
*/
function prepare_file_content_sending() {
// We needed to be able to send headers up until now
@@ -1606,12 +1637,11 @@ function prepare_file_content_sending() {
/**
* Handles the sending of temporary file to user, download is forced.
- * File is deleted after abort or successful sending.
+ * File is deleted after abort or successful sending, does not return, script terminated
*
* @param string $path path to file, preferably from moodledata/temp/something; or content of file itself
* @param string $filename proposed file name when saving file
- * @param bool $path is content of file
- * @return does not return, script terminated
+ * @param bool $pathisstring If the path is string
*/
function send_temp_file($path, $filename, $pathisstring=false) {
global $CFG;
@@ -1664,6 +1694,8 @@ function send_temp_file($path, $filename, $pathisstring=false) {
/**
* Internal callback function used by send_temp_file()
+ *
+ * @param string $path
*/
function send_temp_file_finished($path) {
if (file_exists($path)) {
@@ -1675,9 +1707,10 @@ function send_temp_file_finished($path) {
* Handles the sending of file data to the user's browser, including support for
* byteranges etc.
*
- * @global object
- * @global object
- * @global object
+ * @category files
+ * @global stdClass $CFG
+ * @global stdClass $COURSE
+ * @global moodle_session $SESSION
* @param string $path Path of file on disk (including real filename), or actual content of file as string
* @param string $filename Filename to send
* @param int $lifetime Number of seconds before the file should expire from caches (default 24 hours)
@@ -1689,7 +1722,7 @@ function send_temp_file_finished($path) {
* if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel,
* you must detect this case when control is returned using connection_aborted. Please not that session is closed
* and should not be reopened.
- * @return no return or void, script execution stopped unless $dontdie is true
+ * @return null script execution stopped unless $dontdie is true
*/
function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='', $dontdie=false) {
global $CFG, $COURSE, $SESSION;
@@ -1907,10 +1940,11 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
* Handles the sending of file data to the user's browser, including support for
* byteranges etc.
*
- * @global object
- * @global object
- * @global object
- * @param object $stored_file local file object
+ * @category files
+ * @global stdClass $CFG
+ * @global stdClass $COURSE
+ * @global moodle_session $SESSION
+ * @param stored_file $stored_file local file object
* @param int $lifetime Number of seconds before the file should expire from caches (default 24 hours)
* @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
* @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
@@ -1919,7 +1953,7 @@ function send_file($path, $filename, $lifetime = 'default' , $filter=0, $pathiss
* if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel,
* you must detect this case when control is returned using connection_aborted. Please not that session is closed
* and should not be reopened.
- * @return void no return or void, script execution stopped unless $dontdie is true
+ * @return null script execution stopped unless $dontdie is true
*/
function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownload=false, $filename=null, $dontdie=false) {
global $CFG, $COURSE, $SESSION;
@@ -2110,8 +2144,8 @@ function send_stored_file($stored_file, $lifetime=86400 , $filter=0, $forcedownl
* Retrieves an array of records from a CSV file and places
* them into a given table structure
*
- * @global object
- * @global object
+ * @global stdClass $CFG
+ * @global moodle_database $DB
* @param string $file The path to a CSV file
* @param string $table The table to retrieve columns from
* @return bool|array Returns an array of CSV records or false
@@ -2157,9 +2191,10 @@ function get_records_csv($file, $table) {
}
/**
+ * Create a file with CSV contents
*
- * @global object
- * @global object
+ * @global stdClass $CFG
+ * @global moodle_database $DB
* @param string $file The file to put the CSV content into
* @param array $records An array of records to write to a CSV file
* @param string $table The table to get columns from
@@ -2271,10 +2306,11 @@ function fulldelete($location) {
/**
* Send requested byterange of file.
*
- * @param object $handle A file handle
+ * @param resource $handle A file handle
* @param string $mimetype The mimetype for the output
* @param array $ranges An array of ranges to send
* @param string $filesize The size of the content if only one range is used
+ * @todo MDL-31088 check if "multipart/x-byteranges" is more compatible with current readers/browsers/servers
*/
function byteserving_send_file($handle, $mimetype, $ranges, $filesize) {
$chunksize = 1*(1024*1024); // 1MB chunks - must be less than 2MB!
@@ -2341,9 +2377,10 @@ function byteserving_send_file($handle, $mimetype, $ranges, $filesize) {
* add includes (js and css) into uploaded files
* before returning them, useful for themes and utf.js includes
*
- * @global object
+ * @global stdClass $CFG
* @param string $text text to search and replace
* @return string text with added head includes
+ * @todo MDL-21120
*/
function file_modify_html_header($text) {
// first look for