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


PHP file_info类代码示例

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


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

示例1: build_tree

 /**
  * Builds a tree of files This function is then called recursively.
  *
  * @static
  * @todo take $search into account, and respect a threshold for dynamic loading
  * @param file_info $fileinfo an object returned by file_browser::get_file_info()
  * @param string $search searched string
  * @param bool $dynamicmode no recursive call is done when in dynamic mode
  * @param array $list the array containing the files under the passed $fileinfo
  * @return int the number of files found
  */
 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[] = array($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->pix_url(file_folder_icon(90))->out(false));
             //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;
             }
             //}
             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['component'], $params['filearea'], $params['itemid'], $params['filepath'], $params['filename']));
             $list[] = array('title' => $filename, 'size' => $filesize, 'date' => $filedate, 'source' => base64_encode($source), 'icon' => $OUTPUT->pix_url(file_file_icon($child, 24))->out(false), 'thumbnail' => $OUTPUT->pix_url(file_file_icon($child, 90))->out(false));
             $filecount++;
         }
     }
     return $filecount;
 }
开发者ID:isuruAb,项目名称:moodle,代码行数:64,代码来源:lib.php

示例2: __construct

 /**
  * 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;
     $this->courseinfo = $courseinfo;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:14,代码来源:file_info_context_course.php

示例3: 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());
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:11,代码来源:lib.php

示例4: __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

示例5: __construct

 /**
  * Creates an object
  *
  * @param file_info $fileinfo
  * @param repository $repository
  * @param repository_local_file $parent
  */
 private function __construct(file_info $fileinfo, repository $repository, repository_local_file $parent = null) {
     $this->repository = $repository;
     $this->fileinfo = $fileinfo;
     $this->isdir = $fileinfo->is_directory();
     if (!$this->isdir) {
         $node = array('title' => $this->fileinfo->get_visible_name());
         $this->isempty = !$repository->filter($node);
         $this->skip = false;
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:17,代码来源:lib.php

示例6: __construct

 public function __construct($browser, $course, $cm, $context, $areas, $filearea) {
     parent::__construct($browser, $context);
     $this->course   = $course;
     $this->cm       = $cm;
     $this->areas    = $areas;
     $this->filearea = $filearea;
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:7,代码来源:fileinfolib.php

示例7: __construct

 public function __construct($browser, $course, $cm, $context, $areas)
 {
     global $DB;
     parent::__construct($browser, $context);
     $this->course = $course;
     $this->cm = $cm;
     $this->areas = $areas;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:8,代码来源:file_info_module.php

示例8: __construct

 public function __construct($browser, $context, $storedfile, $urlbase, $topvisiblename, $itemidused, $readaccess, $writeaccess, $areaonly)
 {
     parent::__construct($browser, $context);
     $this->lf = $storedfile;
     $this->urlbase = $urlbase;
     $this->topvisiblename = $topvisiblename;
     $this->itemidused = $itemidused;
     $this->readaccess = $readaccess;
     $this->writeaccess = $writeaccess;
     $this->areaonly = $areaonly;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:11,代码来源:file_info_stored.php

示例9: __construct

 public function __construct($browser, $context)
 {
     global $DB, $USER;
     parent::__construct($browser, $context);
     $userid = $context->instanceid;
     if ($userid == $USER->id) {
         $this->user = $USER;
     } else {
         // if context exists user record should exist too ;-)
         $this->user = $DB->get_record('user', array('id' => $userid));
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:12,代码来源:file_info_user.php

示例10: __construct

 public function __construct($browser, $context, $course, $cm, $modname)
 {
     global $CFG;
     parent::__construct($browser, $context);
     $this->course = $course;
     $this->cm = $cm;
     $this->modname = $modname;
     include_once "{$CFG->dirroot}/mod/{$modname}/lib.php";
     //find out all supported areas
     $functionname = 'mod_' . $modname . '_get_file_areas';
     $functionname_old = $modname . '_get_file_areas';
     if (function_exists($functionname)) {
         $this->areas = $functionname($course, $cm, $context);
     } else {
         if (function_exists($functionname_old)) {
             $this->areas = $functionname_old($course, $cm, $context);
         } else {
             $this->areas = array();
         }
     }
     unset($this->areas['intro']);
     // hardcoded, ignore attempts to override it
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:23,代码来源:file_info_context_module.php

示例11: __construct

 public function __construct($browser, $context, $course)
 {
     global $DB;
     parent::__construct($browser, $context);
     $this->course = $course;
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:6,代码来源:file_info_course.php

示例12: __construct

 /**
  * Constructor (in case you did not realize it ;-)
  *
  * @param file_browser $browser
  * @param stdClass $course
  * @param stdClass $cm
  * @param stdClass $context
  * @param array $areas
  * @param string $filearea
  */
 public function __construct($browser, $course, $cm, $context, $areas, $filearea)
 {
     parent::__construct($browser, $context);
     $this->browser = $browser;
     $this->course = $course;
     $this->cm = $cm;
     $this->component = 'mod_data';
     $this->context = $context;
     $this->areas = $areas;
     $this->filearea = $filearea;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:21,代码来源:locallib.php

示例13: __construct

 /**
  * Constructor
  *
  * @param file_browser $browser file browser instance
  * @param stdClass $context context object
  * @param stdClass $category category object
  */
 public function __construct($browser, $context, $category)
 {
     parent::__construct($browser, $context);
     $this->category = $category;
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:12,代码来源:file_info_context_coursecat.php

示例14: __construct

 /**
  * Constructor
  *
  * @param file_browser $browser
  * @param stdClass $context
  * @param stdClass $user
  */
 public function __construct($browser, $context, $user)
 {
     parent::__construct($browser, $context);
     $this->user = $user;
 }
开发者ID:numbas,项目名称:moodle,代码行数:12,代码来源:file_info_context_user.php

示例15: __construct

 /**
  * Constructor
  *
  * @param file_browser $browser file_browser instance
  * @param stdClass $context context object
  */
 public function __construct($browser, $context)
 {
     parent::__construct($browser, $context);
 }
开发者ID:pzhu2004,项目名称:moodle,代码行数:10,代码来源:file_info_context_system.php


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