本文整理汇总了PHP中file_info::get_visible_name方法的典型用法代码示例。如果您正苦于以下问题:PHP file_info::get_visible_name方法的具体用法?PHP file_info::get_visible_name怎么用?PHP file_info::get_visible_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file_info
的用法示例。
在下文中一共展示了file_info::get_visible_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_node_path
/**
* Converts file_info object to element of repository return path
*
* @param file_info $fileinfo
* @return array
*/
private function get_node_path(file_info $fileinfo)
{
$encodedpath = base64_encode(json_encode($fileinfo->get_params()));
return array('path' => $encodedpath, 'name' => $fileinfo->get_visible_name());
}
示例2: __construct
/**
* Constructor of moodle_file_tree_viewer class
* @param file_info $file_info
* @param array $options
*/
public function __construct(file_info $file_info, array $options = null)
{
global $CFG;
//note: this MUST NOT use get_file_storage() !!!!!!!!!!!!!!!!!!!!!!!!!!!!
$this->options = (array) $options;
$this->context = $options['context'];
$this->tree = array();
$children = $file_info->get_children();
$current_file_params = $file_info->get_params();
$parent_info = $file_info->get_parent();
$level = $parent_info;
$this->path = array();
while ($level) {
$params = $level->get_params();
$context = context::instance_by_id($params['contextid']);
// $this->context is current context
if ($context->id != $this->context->id or empty($params['filearea'])) {
break;
}
// unset unused parameters
unset($params['component']);
unset($params['filearea']);
unset($params['filename']);
unset($params['itemid']);
$url = new moodle_url('/files/index.php', $params);
$this->path[] = html_writer::link($url, $level->get_visible_name());
$level = $level->get_parent();
}
$this->path = array_reverse($this->path);
if ($current_file_params['filepath'] != '/') {
$this->path[] = $file_info->get_visible_name();
}
foreach ($children as $child) {
$filedate = $child->get_timemodified();
$filesize = $child->get_filesize();
$mimetype = $child->get_mimetype();
$params = $child->get_params();
unset($params['component']);
unset($params['filearea']);
unset($params['filename']);
unset($params['itemid']);
$fileitem = array('params' => $params, 'filename' => $child->get_visible_name(), 'mimetype' => $child->get_mimetype(), 'filedate' => $filedate ? $filedate : '', 'filesize' => $filesize ? $filesize : '');
$url = new moodle_url('/files/index.php', $params);
if ($child->is_directory()) {
$fileitem['isdir'] = true;
$fileitem['url'] = $url->out(false);
} else {
$fileitem['url'] = $child->get_url();
}
$this->tree[] = $fileitem;
}
}