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

PHP file_mimetype_in_typegroup函数代码示例

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

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



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

示例1: file_extension_in_typegroup

/**
 * Checks if file with name $filename has one of the extensions in groups $groups
 *
 * @see get_mimetypes_array()
 * @param string $filename name of the file to check
 * @param string|array $groups one group or array of groups to check
 * @param bool $checktype if true and extension check fails, find the mimetype and check if
 * file mimetype is in mimetypes in groups $groups
 * @return bool
 */
function file_extension_in_typegroup($filename, $groups, $checktype = false)
{
    $extension = pathinfo($filename, PATHINFO_EXTENSION);
    if (!empty($extension) && in_array('.' . strtolower($extension), file_get_typegroup('extension', $groups))) {
        return true;
    }
    return $checktype && file_mimetype_in_typegroup(mimeinfo('type', $filename), $groups);
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:18,代码来源:filelib.php


示例2: is_valid_image

 /**
  * Verifies the file is a valid web image - gif, png and jpeg only.
  *
  * It should be ok to serve this image from server without any other security workarounds.
  *
  * @return bool true if file ok
  */
 public function is_valid_image()
 {
     $mimetype = $this->get_mimetype();
     if (!file_mimetype_in_typegroup($mimetype, 'web_image')) {
         return false;
     }
     if (!($info = $this->get_imageinfo())) {
         return false;
     }
     if ($info['mimetype'] !== $mimetype) {
         return false;
     }
     // ok, GD likes this image
     return true;
 }
开发者ID:nigeli,项目名称:moodle,代码行数:22,代码来源:stored_file.php


示例3: helper_submission_attachments

 /**
  * Renders a list of files attached to the submission
  *
  * If format==html, then format a html string. If format==text, then format a text-only string.
  * Otherwise, returns html for non-images and html to display the image inline.
  *
  * @param int $submissionid submission identifier
  * @param string format the format of the returned string - html|text
  * @return string formatted text to be echoed
  */
 protected function helper_submission_attachments($submissionid, $format = 'html')
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     $fs = get_file_storage();
     $ctx = $this->page->context;
     $files = $fs->get_area_files($ctx->id, 'mod_workshop', 'submission_attachment', $submissionid);
     $outputimgs = '';
     // images to be displayed inline
     $outputfiles = '';
     // list of attachment files
     foreach ($files as $file) {
         if ($file->is_directory()) {
             continue;
         }
         $filepath = $file->get_filepath();
         $filename = $file->get_filename();
         $fileurl = moodle_url::make_pluginfile_url($ctx->id, 'mod_workshop', 'submission_attachment', $submissionid, $filepath, $filename, true);
         $embedurl = moodle_url::make_pluginfile_url($ctx->id, 'mod_workshop', 'submission_attachment', $submissionid, $filepath, $filename, false);
         $embedurl = new moodle_url($embedurl, array('preview' => 'bigthumb'));
         $type = $file->get_mimetype();
         $image = $this->output->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon'));
         $linkhtml = html_writer::link($fileurl, $image . substr($filepath, 1) . $filename);
         $linktxt = "{$filename} [{$fileurl}]";
         if ($format == 'html') {
             if (file_mimetype_in_typegroup($type, 'web_image')) {
                 $preview = html_writer::empty_tag('img', array('src' => $embedurl, 'alt' => '', 'class' => 'preview'));
                 $preview = html_writer::tag('a', $preview, array('href' => $fileurl));
                 $outputimgs .= $this->output->container($preview);
             } else {
                 $outputfiles .= html_writer::tag('li', $linkhtml, array('class' => $type));
             }
         } else {
             if ($format == 'text') {
                 $outputfiles .= $linktxt . PHP_EOL;
             }
         }
         if (!empty($CFG->enableplagiarism)) {
             require_once $CFG->libdir . '/plagiarismlib.php';
             $outputfiles .= plagiarism_get_links(array('userid' => $file->get_userid(), 'file' => $file, 'cmid' => $this->page->cm->id, 'course' => $this->page->course->id));
         }
     }
     if ($format == 'html') {
         if ($outputimgs) {
             $outputimgs = $this->output->container($outputimgs, 'images');
         }
         if ($outputfiles) {
             $outputfiles = html_writer::tag('ul', $outputfiles, array('class' => 'files'));
         }
         return $this->output->container($outputimgs . $outputfiles, 'attachments');
     } else {
         return $outputfiles;
     }
 }
开发者ID:dg711,项目名称:moodle,代码行数:64,代码来源:renderer.php


示例4: label_dndupload_handle

/**
 * Handle a file that has been uploaded
 * @param object $uploadinfo details of the file / content that has been uploaded
 * @return int instance id of the newly created mod
 */
function label_dndupload_handle($uploadinfo)
{
    global $USER;
    // Gather the required info.
    $data = new stdClass();
    $data->course = $uploadinfo->course->id;
    $data->name = $uploadinfo->displayname;
    $data->intro = '';
    $data->introformat = FORMAT_HTML;
    $data->coursemodule = $uploadinfo->coursemodule;
    // Extract the first (and only) file from the file area and add it to the label as an img tag.
    if (!empty($uploadinfo->draftitemid)) {
        $fs = get_file_storage();
        $draftcontext = context_user::instance($USER->id);
        $context = context_module::instance($uploadinfo->coursemodule);
        $files = $fs->get_area_files($draftcontext->id, 'user', 'draft', $uploadinfo->draftitemid, '', false);
        if ($file = reset($files)) {
            if (file_mimetype_in_typegroup($file->get_mimetype(), 'web_image')) {
                // It is an image - resize it, if too big, then insert the img tag.
                $config = get_config('label');
                $data->intro = label_generate_resized_image($file, $config->dndresizewidth, $config->dndresizeheight);
            } else {
                // We aren't supposed to be supporting non-image types here, but fallback to adding a link, just in case.
                $url = moodle_url::make_draftfile_url($file->get_itemid(), $file->get_filepath(), $file->get_filename());
                $data->intro = html_writer::link($url, $file->get_filename());
            }
            $data->intro = file_save_draft_area_files($uploadinfo->draftitemid, $context->id, 'mod_label', 'intro', 0, null, $data->intro);
        }
    } else {
        if (!empty($uploadinfo->content)) {
            $data->intro = $uploadinfo->content;
            if ($uploadinfo->type != 'text/html') {
                $data->introformat = FORMAT_PLAIN;
            }
        }
    }
    return label_add_instance($data, null);
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:43,代码来源:lib.php


示例5: resource_get_final_display_type

/**
 * Decide the best display format.
 * @param object $resource
 * @return int display type constant
 */
function resource_get_final_display_type($resource)
{
    global $CFG, $PAGE;
    if ($resource->display != RESOURCELIB_DISPLAY_AUTO) {
        return $resource->display;
    }
    if (empty($resource->mainfile)) {
        return RESOURCELIB_DISPLAY_DOWNLOAD;
    } else {
        $mimetype = mimeinfo('type', $resource->mainfile);
    }
    if (file_mimetype_in_typegroup($mimetype, 'archive')) {
        return RESOURCELIB_DISPLAY_DOWNLOAD;
    }
    if (file_mimetype_in_typegroup($mimetype, array('web_image', '.htm', 'web_video', 'web_audio'))) {
        return RESOURCELIB_DISPLAY_EMBED;
    }
    // let the browser deal with it somehow
    return RESOURCELIB_DISPLAY_OPEN;
}
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:25,代码来源:locallib.php


示例6: type

 /**
  * Returns what gallery type this falls into (image, audio, video).
  * @param bool $text If the function returns the internal or text representation of the item type.
  * @return int|null Returns the self::TYPE_* that most closely matches the content. Otherwise null.
  */
 public function type($text = false)
 {
     if ($this->record->externalurl != '') {
         // External URLs are either youtube videos or images.
         if ($this->get_youtube_videoid()) {
             return $text ? 'video' : self::TYPE_VIDEO;
         }
         return $text ? 'image' : self::TYPE_IMAGE;
     }
     if (!($file = $this->get_file())) {
         return null;
     }
     $videogroups = array('web_video');
     if (!empty($this->objectid)) {
         $videogroups[] = 'video';
     }
     $mimetype = $this->file->get_mimetype();
     if (file_mimetype_in_typegroup($mimetype, 'web_image')) {
         return $text ? 'image' : self::TYPE_IMAGE;
     } else {
         if (file_mimetype_in_typegroup($mimetype, 'web_audio')) {
             return $text ? 'audio' : self::TYPE_AUDIO;
         } else {
             if (file_mimetype_in_typegroup($mimetype, $videogroups)) {
                 return $text ? 'video' : self::TYPE_VIDEO;
             }
         }
     }
     $texttotype = array('audio' => self::TYPE_AUDIO, 'image' => self::TYPE_IMAGE, 'video' => self::TYPE_VIDEO);
     if ($mimetype == 'document/unknown' && !empty($this->objectid)) {
         $ref = $this->file->get_reference_details();
         if (isset($ref->type) && in_array($ref->type, array('audio', 'image', 'video'))) {
             return $text ? $ref->type : $texttotype[$ref->type];
         }
     }
     return null;
 }
开发者ID:eSrem,项目名称:moodle-mod_mediagallery,代码行数:42,代码来源:item.php


示例7: helper_submission_attachments

    /**
     * Renders a list of files attached to the submission
     *
     * If format==html, then format a html string. If format==text, then format a text-only string.
     * Otherwise, returns html for non-images and html to display the image inline.
     *
     * @param int $submissionid submission identifier
     * @param string format the format of the returned string - html|text
     * @return string formatted text to be echoed
     */
    protected function helper_submission_attachments($submissionid, $format = 'html') {
        global $CFG;
        require_once($CFG->libdir.'/filelib.php');

        $fs     = get_file_storage();
        $ctx    = $this->page->context;
        $files  = $fs->get_area_files($ctx->id, 'mod_workshop', 'submission_attachment', $submissionid);

        $outputimgs     = '';   // images to be displayed inline
        $outputfiles    = '';   // list of attachment files

        foreach ($files as $file) {
            if ($file->is_directory()) {
                continue;
            }

            $filepath   = $file->get_filepath();
            $filename   = $file->get_filename();
            $fileurl    = file_encode_url($CFG->wwwroot . '/pluginfile.php',
                                '/' . $ctx->id . '/mod_workshop/submission_attachment/' . $submissionid . $filepath . $filename, true);
            $type       = $file->get_mimetype();
            $image      = $this->output->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon'));

            $linkhtml   = html_writer::link($fileurl, $image) . substr($filepath, 1) . html_writer::link($fileurl, $filename);
            $linktxt    = "$filename [$fileurl]";

            if ($format == 'html') {
                if (file_mimetype_in_typegroup($type, 'web_image')) {
                    $preview     = html_writer::empty_tag('img', array('src' => $fileurl, 'alt' => '', 'class' => 'preview'));
                    $preview     = html_writer::tag('a', $preview, array('href' => $fileurl));
                    $outputimgs .= $this->output->container($preview);

                } else {
                    $outputfiles .= html_writer::tag('li', $linkhtml, array('class' => $type));
                }

            } else if ($format == 'text') {
                $outputfiles .= $linktxt . PHP_EOL;
            }
        }

        if ($format == 'html') {
            if ($outputimgs) {
                $outputimgs = $this->output->container($outputimgs, 'images');
            }

            if ($outputfiles) {
                $outputfiles = html_writer::tag('ul', $outputfiles, array('class' => 'files'));
            }

            return $this->output->container($outputimgs . $outputfiles, 'attachments');

        } else {
            return $outputfiles;
        }
    }
开发者ID:ncsu-delta,项目名称:moodle,代码行数:66,代码来源:renderer.php


示例8: toHtml

 function toHtml()
 {
     global $CFG, $OUTPUT;
     $htmltable = new html_table();
     $htmltable->head = array(get_string('deleteupload', 'wiki'), get_string('uploadname', 'wiki'), get_string('uploadactions', 'wiki'));
     $fs = get_file_storage();
     $files = $fs->get_area_files($this->_fileinfo['contextid'], 'mod_wiki', 'attachments', $this->_fileinfo['itemid']);
     //TODO: verify where this is coming from, all params must be validated (skodak)
     if (count($files) < 2) {
         return get_string('noattachments', 'wiki');
     }
     //get tags
     foreach (array('image', 'attach', 'link') as $tag) {
         $tags[$tag] = wiki_parser_get_token($this->_format, $tag);
     }
     foreach ($files as $file) {
         if (!$file->is_directory()) {
             $checkbox = '<input type="checkbox" name="' . $this->_attributes['name'] . '[]" value="' . $file->get_pathnamehash() . '"';
             if (in_array($file->get_pathnamehash(), $this->_value)) {
                 $checkbox .= ' checked="checked"';
             }
             $checkbox .= " />";
             //actions
             $icon = file_file_icon($file);
             $file_url = file_encode_url($CFG->wwwroot . '/pluginfile.php', "/{$this->_contextid}/mod_wiki/attachments/{$this->_fileareaitemid}/" . $file->get_filename());
             $action_icons = "";
             if (!empty($tags['attach'])) {
                 $action_icons .= "<a href=\"javascript:void(0)\" class=\"wiki-attachment-attach\" " . $this->printInsertTags($tags['attach'], $file->get_filename()) . " title=\"" . get_string('attachmentattach', 'wiki') . "\">" . $OUTPUT->pix_icon($icon, "Attach") . "</a>";
                 //TODO: localize
             }
             $action_icons .= "&nbsp;&nbsp;<a href=\"javascript:void(0)\" class=\"wiki-attachment-link\" " . $this->printInsertTags($tags['link'], $file_url) . " title=\"" . get_string('attachmentlink', 'wiki') . "\">" . $OUTPUT->pix_icon($icon, "Link") . "</a>";
             if (file_mimetype_in_typegroup($file->get_mimetype(), 'web_image')) {
                 $action_icons .= "&nbsp;&nbsp;<a href=\"javascript:void(0)\" class=\"wiki-attachment-image\" " . $this->printInsertTags($tags['image'], $file->get_filename()) . " title=\"" . get_string('attachmentimage', 'wiki') . "\">" . $OUTPUT->pix_icon($icon, "Image") . "</a>";
                 //TODO: localize
             }
             $htmltable->data[] = array($checkbox, '<a href="' . $file_url . '">' . $file->get_filename() . '</a>', $action_icons);
         }
     }
     return html_writer::table($htmltable);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:40,代码来源:wikifiletable.php


示例9: render_blog_entry_attachment

 /**
  * Renders an entry attachment
  *
  * Print link for non-images and returns images as HTML
  *
  * @param blog_entry_attachment $attachment
  * @return string List of attachments depending on the $return input
  */
 public function render_blog_entry_attachment(blog_entry_attachment $attachment)
 {
     $syscontext = context_system::instance();
     // Image attachments don't get printed as links.
     if (file_mimetype_in_typegroup($attachment->file->get_mimetype(), 'web_image')) {
         $attrs = array('src' => $attachment->url, 'alt' => '');
         $o = html_writer::empty_tag('img', $attrs);
         $class = 'attachedimages';
     } else {
         $image = $this->output->pix_icon(file_file_icon($attachment->file), $attachment->filename, 'moodle', array('class' => 'icon'));
         $o = html_writer::link($attachment->url, $image);
         $o .= format_text(html_writer::link($attachment->url, $attachment->filename), FORMAT_HTML, array('context' => $syscontext));
         $class = 'attachments';
     }
     return $this->output->container($o, $class);
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:24,代码来源:renderer.php


示例10: getMediaType

 /**
  * (non-PHPdoc)
  * @param \cm_info $rawData
  * @see \intuitel\ResourceLOFactory::getMediaType()
  * @return string
  */
 function getMediaType(\cm_info $rawData = null)
 {
     //return 'PresentationMedia';
     $context = \context_module::instance($rawData->id);
     $fs = get_file_storage();
     $files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder DESC, id ASC', false);
     $file = reset($files);
     // takes the first one that is the main file (the other ones can be uploaded and are shown when modifying but are not shown when displaying the resource -> think Moodle developers will amend this)
     unset($files);
     $mimetype = $file->get_mimetype();
     // filesize in bytes
     if (file_mimetype_in_typegroup($mimetype, array('web_image', 'image'))) {
         //this is an imagen
         $mediatype = 'PhotoPresentation';
         // could be also a DrawingPresentation.
     } else {
         if (file_mimetype_in_typegroup($mimetype, array('video', 'web_video'))) {
             $mediatype = 'VideoPresentation';
         } else {
             if (file_mimetype_in_typegroup($mimetype, array('audio', 'web_audio'))) {
                 $mediatype = 'AudioPresentation';
             } else {
                 if ($mimetype = 'text/plain') {
                     $mediatype = 'TextPresentation';
                 } else {
                     $mediatype = 'PresentationMedia';
                 }
             }
         }
     }
     return $mediatype;
 }
开发者ID:juacas,项目名称:moodle-block_intuitel,代码行数:38,代码来源:ModuleLOFactory.php


示例11: content_get_page_bgimage

/**
 * Recupera bgimage das paginas de conteudo do plugin content
 * @param stdClass $context 
 * @return string $fullpath
 */
function content_get_page_bgimage($context, $page)
{
    global $CFG;
    $fs = get_file_storage();
    $files = $fs->get_area_files($context->id, 'mod_content', 'bgpage', $page->id, 'sortorder DESC, id ASC', false);
    // TODO: this is not very efficient!!
    if (count($files) >= 1) {
        $file = reset($files);
        unset($files);
        $path = '/' . $context->id . '/mod_content/bgpage/' . $page->id . $file->get_filepath() . $file->get_filename();
        $fullurl = file_encode_url($CFG->wwwroot . '/pluginfile.php', $path, false);
        $mimetype = $file->get_mimetype();
        if (file_mimetype_in_typegroup($mimetype, 'web_image')) {
            // It's an image
            return $fullurl;
        }
        return false;
    }
    return false;
}
开发者ID:alexlova,项目名称:mod_content,代码行数:25,代码来源:locallib.php


示例12: print_attachments

 /**
  * if return=html, then return a html string.
  * if return=text, then return a text-only string.
  * otherwise, print HTML for non-images, and return image HTML
  *
  * @param bool $return Whether to return or print the generated code
  * @return void
  */
 public function print_attachments($return = false)
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/filelib.php';
     $fs = get_file_storage();
     $syscontext = get_context_instance(CONTEXT_SYSTEM);
     $files = $fs->get_area_files($syscontext->id, 'blog', 'attachment', $this->id);
     $imagereturn = "";
     $output = "";
     $strattachment = get_string("attachment", "forum");
     foreach ($files as $file) {
         if ($file->is_directory()) {
             continue;
         }
         $filename = $file->get_filename();
         $ffurl = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . SYSCONTEXTID . '/blog/attachment/' . $this->id . '/' . $filename);
         $mimetype = $file->get_mimetype();
         $image = $OUTPUT->pix_icon(file_file_icon($file), $filename, 'moodle', array('class' => 'icon'));
         if ($return == "html") {
             $output .= html_writer::link($ffurl, $image);
             $output .= html_writer::link($ffurl, $filename);
         } else {
             if ($return == "text") {
                 $output .= "{$strattachment} {$filename}:\n{$ffurl}\n";
             } else {
                 if (file_mimetype_in_typegroup($file->get_mimetype(), 'web_image')) {
                     // Image attachments don't get printed as links
                     $imagereturn .= '<br /><img src="' . $ffurl . '" alt="" />';
                 } else {
                     $imagereturn .= html_writer::link($ffurl, $image);
                     $imagereturn .= format_text(html_writer::link($ffurl, $filename), FORMAT_HTML, array('context' => $syscontext));
                 }
             }
         }
     }
     if ($return) {
         return $output;
     }
     return $imagereturn;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:48,代码来源:locallib.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP file_mode_info函数代码示例发布时间:2022-05-15
下一篇:
PHP file_mimetype_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