本文整理汇总了PHP中repository::encode_path方法的典型用法代码示例。如果您正苦于以下问题:PHP repository::encode_path方法的具体用法?PHP repository::encode_path怎么用?PHP repository::encode_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repository
的用法示例。
在下文中一共展示了repository::encode_path方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_tree
/**
* Builds a tree of files This function is
* then called recursively.
*
* @param $fileinfo an object returned by file_browser::get_file_info()
* @param $search searched string
* @param $dynamicmode bool no recursive call is done when in dynamic mode
* @param $list - the array containing the files under the passed $fileinfo
* @returns int the number of files found
*
* todo: take $search into account, and respect a threshold for dynamic loading
*/
public static function build_tree($fileinfo, $search, $dynamicmode, &$list)
{
global $CFG, $OUTPUT;
$filecount = 0;
$children = $fileinfo->get_children();
foreach ($children as $child) {
$filename = $child->get_visible_name();
$filesize = $child->get_filesize();
$filesize = $filesize ? display_size($filesize) : '';
$filedate = $child->get_timemodified();
$filedate = $filedate ? userdate($filedate) : '';
$filetype = $child->get_mimetype();
if ($child->is_directory()) {
$path = array();
$level = $child->get_parent();
while ($level) {
$params = $level->get_params();
$path[] = repository::encode_path($params['filearea'], $params['filepath'], $level->get_visible_name());
$level = $level->get_parent();
}
$tmp = array('title' => $child->get_visible_name(), 'size' => 0, 'date' => $filedate, 'path' => array_reverse($path), 'thumbnail' => $OUTPUT->old_icon_url('f/folder-32'));
//if ($dynamicmode && $child->is_writable()) {
// $tmp['children'] = array();
//} else {
// if folder name matches search, we send back all files contained.
$_search = $search;
if ($search && stristr($tmp['title'], $search) !== false) {
$_search = false;
}
$tmp['children'] = array();
$_filecount = repository::build_tree($child, $_search, $dynamicmode, $tmp['children']);
if ($search && $_filecount) {
$tmp['expanded'] = 1;
}
//}
//Uncomment this following line if you wanna display all directory ()even empty
if (!$search || $_filecount || stristr($tmp['title'], $search) !== false) {
$filecount += $_filecount;
$list[] = $tmp;
}
} else {
// not a directory
// skip the file, if we're in search mode and it's not a match
if ($search && stristr($filename, $search) === false) {
continue;
}
$params = $child->get_params();
$source = serialize(array($params['contextid'], $params['filearea'], $params['itemid'], $params['filepath'], $params['filename']));
$list[] = array('title' => $filename, 'size' => $filesize, 'date' => $filedate, 'source' => base64_encode($source), 'thumbnail' => $OUTPUT->old_icon_url(file_extension_icon($filename, 32)));
$filecount++;
}
}
return $filecount;
}