How can i use moodle api methods, such sa get_file_browser()
and get_system_context()?
I got the error (PHP Fatal error: Call to undefined function
get_file_browser() in
/usr/share/moodle/browsfiles.php)
The following is the example from moodle file api:
<?php
$browser = get_file_browser();
$context = get_system_context();
$filearea = null;
$itemid = null;
$filename = null;
if ($fileinfo = $browser->get_file_info($context, $component, $filearea,
$itemid, '/', $filename)) {
// build a Breadcrumb trail
$level = $fileinfo->get_parent();
while($level) {
$path[] = array('name'=>$level->get_visible_name());
$level = $level->get_parent();
}
$path = array_reverse($path);
$children = $fileinfo->get_children();
foreach($children as $child) {
if($child->is_directory()) {
echo $child->get_visible_name();
// display contextid, itemid, component, filepath and filename
var_dump($child->get_params());
}
}
}
?>
Please help to solve the issue, much thanks!