当前位置: 首页>>代码示例>>PHP>>正文


PHP file_info::get_parent方法代码示例

本文整理汇总了PHP中file_info::get_parent方法的典型用法代码示例。如果您正苦于以下问题:PHP file_info::get_parent方法的具体用法?PHP file_info::get_parent怎么用?PHP file_info::get_parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file_info的用法示例。


在下文中一共展示了file_info::get_parent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: can_skip

 /**
  * Whether this folder may be skipped in folder hierarchy
  *
  * 1. Skip the name of a single filearea in a module
  * 2. Skip course categories for non-admins who do not have navshowmycoursecategories setting
  *
  * @param file_info $fileinfo
  * @param string|array $extensions, for example '*' or array('.gif','.jpg')
  * @param file_info|int $parent specify parent here if we know it to avoid creating extra objects
  * @return bool
  */
 private function can_skip(file_info $fileinfo, $extensions, $parent = -1)
 {
     global $CFG;
     if (!$fileinfo->is_directory()) {
         // do not skip files
         return false;
     }
     if ($fileinfo instanceof file_info_context_coursecat) {
         // This is a course category. For non-admins we do not display categories
         return empty($CFG->navshowmycoursecategories) && !has_capability('moodle/course:update', context_system::instance());
     } else {
         if ($fileinfo instanceof file_info_context_course || $fileinfo instanceof file_info_context_user || $fileinfo instanceof file_info_area_course_legacy || $fileinfo instanceof file_info_context_module || $fileinfo instanceof file_info_context_system) {
             // these instances can never be filearea inside an activity, they will never be skipped
             return false;
         } else {
             $params = $fileinfo->get_params();
             if (strlen($params['filearea']) && ($params['filepath'] === '/' || empty($params['filepath'])) && ($params['filename'] === '.' || empty($params['filename'])) && context::instance_by_id($params['contextid'])->contextlevel == CONTEXT_MODULE) {
                 if ($parent === -1) {
                     $parent = $fileinfo->get_parent();
                 }
                 // This is a filearea inside an activity, it can be skipped if it has no non-empty siblings
                 if ($parent && $parent instanceof file_info_context_module) {
                     if ($parent->count_non_empty_children($extensions, 2) <= 1) {
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:42,代码来源:lib.php

示例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;
     }
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:57,代码来源:renderer.php


注:本文中的file_info::get_parent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。