• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP file_extension_in_typegroup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_file_by_reference

 /**
  * Returns information about file in this repository by reference
  * {@link repository::get_file_reference()}
  * {@link repository::get_file()}
  *
  * Returns null if file not found or is not readable
  *
  * @param stdClass $reference file reference db record
  * @return null|stdClass that has 'filepath' property
  */
 public function get_file_by_reference($reference) {
     global $USER;
     $ref = unserialize($reference->reference);
     if (!isset($ref->url)) {
         // this is an old-style reference in DB. We need to fix it
         $ref = unserialize($this->fix_old_style_reference($reference->reference));
     }
     if (!isset($ref->url)) {
         return null;
     }
     $c = new curl;
     $url = $this->get_file_download_link($ref->url);
     if (file_extension_in_typegroup($ref->path, 'web_image')) {
         $saveas = $this->prepare_file('');
         try {
             $result = $c->download_one($url, array(), array('filepath' => $saveas, 'timeout' => self::SYNCIMAGE_TIMEOUT, 'followlocation' => true));
             $info = $c->get_info();
             if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) {
                 return (object)array('filepath' => $saveas);
             }
         } catch (Exception $e) {}
     }
     $c->get($url, null, array('timeout' => self::SYNCIMAGE_TIMEOUT, 'followlocation' => true, 'nobody' => true));
     $info = $c->get_info();
     if (isset($info['http_code']) && $info['http_code'] == 200 &&
             array_key_exists('download_content_length', $info) &&
             $info['download_content_length'] >= 0) {
         return (object)array('filesize' => (int)$info['download_content_length']);
     }
     return null;
 }
开发者ID:Burick,项目名称:moodle,代码行数:41,代码来源:lib.php


示例2: sync_reference

 /**
  * Synchronize the references.
  *
  * @param stored_file $file Stored file.
  * @return boolean
  */
 public function sync_reference(stored_file $file)
 {
     if ($file->get_referencelastsync() + DAYSECS > time()) {
         // Synchronise not more often than once a day.
         return false;
     }
     $c = new curl();
     $reference = unserialize(self::convert_to_valid_reference($file->get_reference()));
     $url = $reference->downloadurl;
     if (file_extension_in_typegroup($file->get_filename(), 'web_image')) {
         $path = $this->prepare_file('');
         $result = $c->download_one($url, null, array('filepath' => $path, 'timeout' => $CFG->repositorysyncimagetimeout));
         $info = $c->get_info();
         if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) {
             $fs = get_file_storage();
             list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($path);
             $file->set_synchronized($contenthash, $filesize);
             return true;
         }
     }
     $c->get($url, null, array('timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true, 'nobody' => true));
     $info = $c->get_info();
     if (isset($info['http_code']) && $info['http_code'] == 200 && array_key_exists('download_content_length', $info) && $info['download_content_length'] >= 0) {
         $filesize = (int) $info['download_content_length'];
         $file->set_synchronized(null, $filesize);
         return true;
     }
     $file->set_missingsource();
     return true;
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:36,代码来源:lib.php


示例3: array

if (empty($CFG->courseoverviewfileslimit)) {
    return array();
}
require_once $CFG->libdir . '/filestorage/file_storage.php';
require_once $CFG->dirroot . '/course/lib.php';
$fs = get_file_storage();
$context = context_course::instance($COURSE->id);
$files = $fs->get_area_files($context->id, 'course', 'overviewfiles', false, 'filename', false);
if (count($files)) {
    $overviewfilesoptions = course_overviewfiles_options($COURSE->id);
    $acceptedtypes = $overviewfilesoptions['accepted_types'];
    if ($acceptedtypes !== '*') {
        // Filter only files with allowed extensions.
        require_once $CFG->libdir . '/filelib.php';
        foreach ($files as $key => $file) {
            if (!file_extension_in_typegroup($file->get_filename(), $acceptedtypes)) {
                unset($files[$key]);
            }
        }
    }
    if (count($files) > $CFG->courseoverviewfileslimit) {
        // Return no more than $CFG->courseoverviewfileslimit files.
        $files = array_slice($files, 0, $CFG->courseoverviewfileslimit, true);
    }
}
// Display course overview files.
$courseimage = '';
foreach ($files as $file) {
    $isimage = $file->is_valid_image();
    if ($isimage) {
        $courseimage = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
开发者ID:kennibc,项目名称:moodle-theme_pioneer,代码行数:31,代码来源:courseimage.php


示例4: sync_reference

 public function sync_reference(stored_file $file)
 {
     if ($file->get_referencelastsync() + 60 > time()) {
         // Does not cost us much to synchronise within our own filesystem, check every 1 minute.
         return false;
     }
     static $issyncing = false;
     if ($issyncing) {
         // Avoid infinite recursion when calling $file->get_filesize() and get_contenthash().
         return false;
     }
     $filepath = $this->get_rootpath() . ltrim($file->get_reference(), '/');
     if ($this->is_in_repository($file->get_reference()) && file_exists($filepath) && is_readable($filepath)) {
         $fs = get_file_storage();
         $issyncing = true;
         if (file_extension_in_typegroup($filepath, 'web_image')) {
             $contenthash = sha1_file($filepath);
             if ($file->get_contenthash() == $contenthash) {
                 // File did not change since the last synchronisation.
                 $filesize = filesize($filepath);
             } else {
                 // Copy file into moodle filepool (used to generate an image thumbnail).
                 list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($filepath);
             }
         } else {
             // Update only file size so file will NOT be copied into moodle filepool.
             $emptyfile = $contenthash = sha1('');
             $currentcontenthash = $file->get_contenthash();
             if ($currentcontenthash !== $emptyfile && $currentcontenthash === sha1_file($filepath)) {
                 // File content was synchronised and has not changed since then, leave it.
                 $contenthash = null;
             }
             $filesize = filesize($filepath);
         }
         $issyncing = false;
         $file->set_synchronized($contenthash, $filesize);
     } else {
         $file->set_missingsource();
     }
     return true;
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:41,代码来源:lib.php


示例5: get_file_by_reference

 /**
  * Returns information about file in this repository by reference
  *
  * Returns null if file not found or is not readable
  *
  * @param stdClass $reference file reference db record
  * @return stdClass|null contains one of the following:
  *   - 'filesize' if file should not be copied to moodle filepool
  *   - 'filepath' if file should be copied to moodle filepool
  */
 public function get_file_by_reference($reference) {
     $ref = $reference->reference;
     if ($ref{0} == '/') {
         $filepath = $this->root_path.substr($ref, 1, strlen($ref)-1);
     } else {
         $filepath = $this->root_path.$ref;
     }
     if (file_exists($filepath) && is_readable($filepath)) {
         if (file_extension_in_typegroup($filepath, 'web_image')) {
             // return path to image files so it will be copied into moodle filepool
             // we need the file in filepool to generate an image thumbnail
             return (object)array('filepath' => $filepath);
         } else {
             // return just the file size so file will NOT be copied into moodle filepool
             return (object)array(
                 'filesize' => filesize($filepath)
             );
         }
     } else {
         return null;
     }
 }
开发者ID:JP-Git,项目名称:moodle,代码行数:32,代码来源:lib.php


示例6: require_login

require_login();
require_capability('tool/unittest:execute', get_context_instance(CONTEXT_SYSTEM));
// get file requested
$relativepath = get_file_argument();
// basic check, start by slash
if (!$relativepath) {
    print_error('invalidargorconf');
} else {
    if ($relativepath[0] != '/') {
        print_error('pathdoesnotstartslash');
    }
}
// determine which disk file is going to be served
// and how it's going to be named
$filepath = $CFG->dataroot . '/codecoverage' . $relativepath;
$filename = basename($filepath);
// extract relative path components
$args = explode('/', ltrim($relativepath, '/'));
// only serve from some controlled subdirs
$alloweddirs = array('dbtest', 'unittest');
if (!isset($args[0]) || !in_array($args[0], $alloweddirs)) {
    print_error('invalidarguments');
}
// only serve some controlled extensions/mimetypes
if (!file_extension_in_typegroup($filepath, array('web_file', 'web_image'), true)) {
    print_error('invalidarguments');
}
// arrived here, send the file
session_get_instance()->write_close();
// unlock session during fileserving
send_file($filepath, $filename, 0, false);
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:coveragefile.php


示例7: folder_get_recent_mod_activity

/**
 * Returns all uploads since a given time in specified folder.
 *
 * @param array $activities
 * @param int $index
 * @param int $timestart
 * @param int $courseid
 * @param int $cmid
 * @param int $userid
 * @param int $groupid not used, but required for compatibilty with other modules
 */
function folder_get_recent_mod_activity(&$activities, &$index, $timestart, $courseid, $cmid, $userid = 0, $groupid = 0)
{
    global $COURSE, $DB, $OUTPUT;
    if ($COURSE->id == $courseid) {
        $course = $COURSE;
    } else {
        $course = $DB->get_record('course', array('id' => $courseid));
    }
    $modinfo = get_fast_modinfo($course);
    $cm = $modinfo->cms[$cmid];
    $context = context_module::instance($cm->id);
    if (!has_capability('mod/folder:view', $context)) {
        return;
    }
    $files = folder_get_recent_activity($context, $timestart, $userid);
    foreach ($files as $file) {
        $tmpactivity = new stdClass();
        $tmpactivity->type = 'folder';
        $tmpactivity->cmid = $cm->id;
        $tmpactivity->sectionnum = $cm->sectionnum;
        $tmpactivity->timestamp = $file->get_timemodified();
        $tmpactivity->user = core_user::get_user($file->get_userid());
        $tmpactivity->content = new stdClass();
        $tmpactivity->content->url = moodle_url::make_pluginfile_url($file->get_contextid(), 'mod_folder', 'content', $file->get_itemid(), $file->get_filepath(), $file->get_filename());
        if (file_extension_in_typegroup($file->get_filename(), 'web_image')) {
            $image = $tmpactivity->content->url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified()));
            $image = html_writer::empty_tag('img', array('src' => $image));
        } else {
            $image = $OUTPUT->pix_icon(file_file_icon($file, 24), $file->get_filename(), 'moodle');
        }
        $tmpactivity->content->image = $image;
        $tmpactivity->content->filename = $file->get_filename();
        $activities[$index++] = $tmpactivity;
    }
}
开发者ID:dg711,项目名称:moodle,代码行数:46,代码来源:lib.php


示例8: supports

 /**
  * Returns human-readable string of supported file/link types for the "Manage media players" page
  * @param array $usedextensions extensions that should NOT be highlighted
  * @return string
  */
 public function supports($usedextensions = [])
 {
     $out = [];
     if ($extensions = $this->get_supported_extensions()) {
         $video = $audio = $other = [];
         foreach ($extensions as $key => $extension) {
             $displayextension = $extension;
             if (!in_array($extension, $usedextensions)) {
                 $displayextension = '<strong>' . $extension . '</strong>';
             }
             if (file_extension_in_typegroup('file.' . $extension, 'audio')) {
                 $audio[] = $displayextension;
             } else {
                 if (file_extension_in_typegroup('file.' . $extension, 'video')) {
                     $video[] = $displayextension;
                 } else {
                     $other[] = $displayextension;
                 }
             }
         }
         if ($video) {
             $out[] = get_string('videoextensions', 'core_media', join(', ', $video));
         }
         if ($audio) {
             $out[] = get_string('audioextensions', 'core_media', join(', ', $audio));
         }
         if ($other) {
             $out[] = get_string('extensions', 'core_media', join(', ', $other));
         }
     }
     return join('<br>', $out);
 }
开发者ID:lucaboesch,项目名称:moodle,代码行数:37,代码来源:player.php


示例9: sync_reference

 public function sync_reference(stored_file $file)
 {
     global $CFG;
     if ($file->get_referencelastsync() + DAYSECS > time()) {
         // Synchronise not more often than once a day.
         return false;
     }
     $ref = unserialize($file->get_reference());
     if (!isset($ref->url)) {
         // this is an old-style reference in DB. We need to fix it
         $ref = unserialize($this->fix_old_style_reference($file->get_reference()));
     }
     if (!isset($ref->url)) {
         return false;
     }
     $c = new curl();
     $url = $this->get_file_download_link($ref->url);
     if (file_extension_in_typegroup($ref->path, 'web_image')) {
         $saveas = $this->prepare_file('');
         try {
             $result = $c->download_one($url, array(), array('filepath' => $saveas, 'timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true));
             $info = $c->get_info();
             if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) {
                 $fs = get_file_storage();
                 list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($saveas);
                 $file->set_synchronized($contenthash, $filesize);
                 return true;
             }
         } catch (Exception $e) {
         }
     }
     $c->get($url, null, array('timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true, 'nobody' => true));
     $info = $c->get_info();
     if (isset($info['http_code']) && $info['http_code'] == 200 && array_key_exists('download_content_length', $info) && $info['download_content_length'] >= 0) {
         $filesize = (int) $info['download_content_length'];
         $file->set_synchronized(null, $filesize);
         return true;
     }
     $file->set_missingsource();
     return true;
 }
开发者ID:krysnuvadga,项目名称:moodle,代码行数:41,代码来源:lib.php


示例10: sync_reference

 /**
  * Performs synchronisation of an external file if the previous one has expired.
  *
  * This function must be implemented for external repositories supporting
  * FILE_REFERENCE, it is called for existing aliases when their filesize,
  * contenthash or timemodified are requested. It is not called for internal
  * repositories (see {@link repository::has_moodle_files()}), references to
  * internal files are updated immediately when source is modified.
  *
  * Referenced files may optionally keep their content in Moodle filepool (for
  * thumbnail generation or to be able to serve cached copy). In this
  * case both contenthash and filesize need to be synchronized. Otherwise repositories
  * should use contenthash of empty file and correct filesize in bytes.
  *
  * Note that this function may be run for EACH file that needs to be synchronised at the
  * moment. If anything is being downloaded or requested from external sources there
  * should be a small timeout. The synchronisation is performed to update the size of
  * the file and/or to update image and re-generated image preview. There is nothing
  * fatal if syncronisation fails but it is fatal if syncronisation takes too long
  * and hangs the script generating a page.
  *
  * Note: If you wish to call $file->get_filesize(), $file->get_contenthash() or
  * $file->get_timemodified() make sure that recursion does not happen.
  *
  * Called from {@link stored_file::sync_external_file()}
  *
  * @inheritDocs
  */
 public function sync_reference(stored_file $file)
 {
     global $CFG;
     if ($file->get_referencelastsync() + DAYSECS > time()) {
         // Only synchronise once per day.
         return false;
     }
     $reference = $this->unpack_reference($file->get_reference());
     if (!isset($reference->url)) {
         // The URL to sync with is missing.
         return false;
     }
     $c = new curl();
     $url = $this->get_file_download_link($reference->url);
     if (file_extension_in_typegroup($reference->path, 'web_image')) {
         $saveas = $this->prepare_file('');
         try {
             $result = $c->download_one($url, [], ['filepath' => $saveas, 'timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true]);
             $info = $c->get_info();
             if ($result === true && isset($info['http_code']) && $info['http_code'] == 200) {
                 $fs = get_file_storage();
                 list($contenthash, $filesize, ) = $fs->add_file_to_pool($saveas);
                 $file->set_synchronized($contenthash, $filesize);
                 return true;
             }
         } catch (Exception $e) {
             // IF the download_one fails, we will attempt to download
             // again with get() anyway.
         }
     }
     $c->get($url, null, array('timeout' => $CFG->repositorysyncimagetimeout, 'followlocation' => true, 'nobody' => true));
     $info = $c->get_info();
     if (isset($info['http_code']) && $info['http_code'] == 200 && array_key_exists('download_content_length', $info) && $info['download_content_length'] >= 0) {
         $filesize = (int) $info['download_content_length'];
         $file->set_synchronized(null, $filesize);
         return true;
     }
     $file->set_missingsource();
     return true;
 }
开发者ID:dg711,项目名称:moodle,代码行数:68,代码来源:lib.php


示例11: foreach

 foreach ($files->list as $file) {
     if ($file->type != 'folder') {
         $drafturl = $file->url;
         // a file
         echo '<li>';
         echo $OUTPUT->pix_icon(file_file_icon($file), '', 'moodle', array('class' => 'iconsmall'));
         echo html_writer::link($drafturl, $file->filename);
         $home_url->param('filename', $file->filename);
         $home_url->param('draftpath', $file->filepath);
         $home_url->param('action', 'deletedraft');
         echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('delete') . '</a>]';
         $home_url->param('action', 'movefile');
         echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('move') . '</a>]';
         $home_url->param('action', 'renameform');
         echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('rename') . '</a>]';
         if (file_extension_in_typegroup($file->filename, 'archive', true)) {
             $home_url->param('action', 'unzip');
             $home_url->param('draftpath', $file->filepath);
             echo ' [<a href="' . $home_url->out() . '" class="fm-operation">' . get_string('unzip') . '</a>]';
         }
         echo '</li>';
     } else {
         // a folder
         echo '<li>';
         echo '<img src="' . $OUTPUT->pix_url(file_folder_icon()) . '" class="iconsmall" />';
         $home_url->param('action', 'browse');
         $home_url->param('draftpath', $file->filepath);
         $filepathchunks = explode('/', trim($file->filepath, '/'));
         $foldername = trim(array_pop($filepathchunks), '/');
         echo html_writer::link($home_url, $foldername);
         $home_url->param('draftpath', $file->filepath);
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:31,代码来源:draftfiles_manager.php


示例12: file_get_drafarea_files

/**
 * Listing all files (including folders) in current path (draft area)
 * used by file manager
 * @param int $draftitemid
 * @param string $filepath
 * @return stdClass
 */
function file_get_drafarea_files($draftitemid, $filepath = '/')
{
    global $USER, $OUTPUT, $CFG;
    $context = context_user::instance($USER->id);
    $fs = get_file_storage();
    $data = new stdClass();
    $data->path = array();
    $data->path[] = array('name' => get_string('files'), 'path' => '/');
    // will be used to build breadcrumb
    $trail = '/';
    if ($filepath !== '/') {
        $filepath = file_correct_filepath($filepath);
        $parts = explode('/', $filepath);
        foreach ($parts as $part) {
            if ($part != '' && $part != null) {
                $trail .= $part . '/';
                $data->path[] = array('name' => $part, 'path' => $trail);
            }
        }
    }
    $list = array();
    $maxlength = 12;
    if ($files = $fs->get_directory_files($context->id, 'user', 'draft', $draftitemid, $filepath, false)) {
        foreach ($files as $file) {
            $item = new stdClass();
            $item->filename = $file->get_filename();
            $item->filepath = $file->get_filepath();
            $item->fullname = trim($item->filename, '/');
            $filesize = $file->get_filesize();
            $item->size = $filesize ? $filesize : null;
            $item->filesize = $filesize ? display_size($filesize) : '';
            $item->sortorder = $file->get_sortorder();
            $item->author = $file->get_author();
            $item->license = $file->get_license();
            $item->datemodified = $file->get_timemodified();
            $item->datecreated = $file->get_timecreated();
            $item->isref = $file->is_external_file();
            if ($item->isref && $file->get_status() == 666) {
                $item->originalmissing = true;
            }
            // find the file this draft file was created from and count all references in local
            // system pointing to that file
            $source = @unserialize($file->get_source());
            if (isset($source->original)) {
                $item->refcount = $fs->search_references_count($source->original);
            }
            if ($file->is_directory()) {
                $item->filesize = 0;
                $item->icon = $OUTPUT->pix_url(file_folder_icon(24))->out(false);
                $item->type = 'folder';
                $foldername = explode('/', trim($item->filepath, '/'));
                $item->fullname = trim(array_pop($foldername), '/');
                $item->thumbnail = $OUTPUT->pix_url(file_folder_icon(90))->out(false);
            } else {
                // do NOT use file browser here!
                $item->mimetype = get_mimetype_description($file);
                if (file_extension_in_typegroup($file->get_filename(), 'archive')) {
                    $item->type = 'zip';
                } else {
                    $item->type = 'file';
                }
                $itemurl = moodle_url::make_draftfile_url($draftitemid, $item->filepath, $item->filename);
                $item->url = $itemurl->out();
                $item->icon = $OUTPUT->pix_url(file_file_icon($file, 24))->out(false);
                $item->thumbnail = $OUTPUT->pix_url(file_file_icon($file, 90))->out(false);
                if ($imageinfo = $file->get_imageinfo()) {
                    $item->realthumbnail = $itemurl->out(false, array('preview' => 'thumb', 'oid' => $file->get_timemodified()));
                    $item->realicon = $itemurl->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified()));
                    $item->image_width = $imageinfo['width'];
                    $item->image_height = $imageinfo['height'];
                }
            }
            $list[] = $item;
        }
    }
    $data->itemid = $draftitemid;
    $data->list = $list;
    return $data;
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:86,代码来源:filelib.php


示例13: get_course_overviewfiles

 /**
  * Returns all course overview files
  *
  * @return array array of stored_file objects
  */
 public function get_course_overviewfiles()
 {
     global $CFG;
     if (empty($CFG->courseoverviewfileslimit)) {
         return array();
     }
     require_once $CFG->libdir . '/filestorage/file_storage.php';
     require_once $CFG->dirroot . '/course/lib.php';
     $fs = get_file_storage();
     $context = context_course::instance($this->id);
     $files = $fs->get_area_files($context->id, 'course', 'overviewfiles', false, 'filename', false);
     if (count($files)) {
         $overviewfilesoptions = course_overviewfiles_options($this->id);
         $acceptedtypes = $overviewfilesoptions['accepted_types'];
         if ($acceptedtypes !== '*') {
             // Filter only files with allowed extensions.
             require_once $CFG->libdir . '/filelib.php';
             foreach ($files as $key => $file) {
                 if (!file_extension_in_typegroup($file->get_filename(), $acceptedtypes)) {
                     unset($files[$key]);
                 }
             }
         }
         if (count($files) > $CFG->courseoverviewfileslimit) {
             // Return no more than $CFG->courseoverviewfileslimit files.
             $files = array_slice($files, 0, $CFG->courseoverviewfileslimit, true);
         }
     }
     return $files;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:35,代码来源:coursecatlib.php


示例14: htmllize_tree

    /**
     * Internal function - creates htmls structure suitable for YUI tree.
     */
    protected function htmllize_tree($tree, $dir) {
        global $CFG;

        if (empty($dir['subdirs']) and empty($dir['files'])) {
            return '';
        }
        $result = '<ul>';
        foreach ($dir['subdirs'] as $subdir) {
            $image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle');
            $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
                    html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename'));
            $filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon'));
            $result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir));
        }
        foreach ($dir['files'] as $file) {
            $filename = $file->get_filename();
            $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(),
                    $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $filename, false);
            if (file_extension_in_typegroup($filename, 'web_image')) {
                $image = $url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified()));
                $image = html_writer::empty_tag('img', array('src' => $image));
            } else {
                $image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle');
            }
            $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')).
                    html_writer::tag('span', $filename, array('class' => 'fp-filename'));
            $filename = html_writer::tag('span',
                    html_writer::link($url->out(false, array('forcedownload' => 1)), $filename),
                    array('class' => 'fp-filename-icon'));
            $result .= html_writer::tag('li', $filename);
        }
        $result .= '</ul>';

        return $result;
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:38,代码来源:renderer.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_field函数代码示例发布时间:2022-05-15
下一篇:
PHP file_extension_icon函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap