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


PHP get_mimetype_description函数代码示例

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


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

示例1: print_student_answer

    function print_student_answer($userid, $return=false){
        global $CFG, $USER, $OUTPUT;

        $fs = get_file_storage();
        $browser = get_file_browser();

        $output = '';

        if ($submission = $this->get_submission($userid)) {
            if ($files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false)) {
                foreach ($files as $file) {
                    $filename = $file->get_filename();
                    $found = true;
                    $mimetype = $file->get_mimetype();
                    $path = file_encode_url($CFG->wwwroot.'/pluginfile.php', '/'.$this->context->id.'/mod_assignment/submission/'.$submission->id.'/'.$filename);
                    $output .= '<a href="'.$path.'" >'.$OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')).s($filename).'</a><br />';
                    $output .= plagiarism_get_links(array('userid'=>$userid, 'file'=>$file, 'cmid'=>$this->cm->id, 'course'=>$this->course, 'assignment'=>$this->assignment));
                    $output .='<br/>';
                }
            }
        }

        $output = '<div class="files">'.$output.'</div>';
        return $output;
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:25,代码来源:assignment.class.php

示例2: files_read_only

 /**
  * Displays any attached files when the question is in read-only mode.
  * @param question_attempt $qa the question attempt to display.
  * @param question_display_options $options controls what should and should
  *      not be displayed. Used to get the context.
  */
 public function files_read_only(question_attempt $qa, question_display_options $options)
 {
     $files = $qa->get_last_qt_files('attachments', $options->context->id);
     $output = array();
     foreach ($files as $file) {
         $output[] = html_writer::tag('p', html_writer::link($qa->get_response_file_url($file), $this->output->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')) . ' ' . s($file->get_filename())));
     }
     return implode($output);
 }
开发者ID:rama1712,项目名称:moodle,代码行数:15,代码来源:renderer.php

示例3: render_files_tree_viewer

    public function render_files_tree_viewer(files_tree_viewer $tree) {
        $html = $this->output->heading_with_help(get_string('coursefiles'), 'courselegacyfiles', 'moodle');

        $html .= $this->output->container_start('coursefilesbreadcrumb');
        foreach($tree->path as $path) {
            $html .= $path;
            $html .= ' / ';
        }
        $html .= $this->output->container_end();

        $html .= $this->output->box_start();
        $table = new html_table();
        $table->head = array(get_string('name'), get_string('lastmodified'), get_string('size', 'repository'), get_string('type', 'repository'));
        $table->align = array('left', 'left', 'left', 'left');
        $table->width = '100%';
        $table->data = array();

        foreach ($tree->tree as $file) {
            $filedate = $filesize = $filetype = '';
            if ($file['filedate']) {
                $filedate = userdate($file['filedate'], get_string('strftimedatetimeshort', 'langconfig'));
            }
            if (empty($file['isdir'])) {
                if ($file['filesize']) {
                    $filesize = display_size($file['filesize']);
                }
                $fileicon = file_file_icon($file, 24);
                $filetype = get_mimetype_description($file);
            } else {
                $fileicon = file_folder_icon(24);
            }
            $table->data[] = array(
                html_writer::link($file['url'], $this->output->pix_icon($fileicon, get_string('icon')) . ' ' . $file['filename']),
                $filedate,
                $filesize,
                $filetype
                );
        }

        $html .= html_writer::table($table);
        $html .= $this->output->single_button(new moodle_url('/files/coursefilesedit.php', array('contextid'=>$tree->context->id)), get_string('coursefilesedit'), 'get');
        $html .= $this->output->box_end();
        return $html;
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:44,代码来源:renderer.php

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

示例5: mail

    public function mail($message, $reply = false, $offset = 0) {
        global $CFG, $USER;

        $totalusers = 0;
        $output = '';

        if (!$reply) {
            $output .= html_writer::empty_tag('input', array(
                    'type' => 'hidden',
                    'name' => 'm',
                    'value' => $message->id(),
            ));

            $output .= html_writer::empty_tag('input', array(
                    'type' => 'hidden',
                    'name' => 'offset',
                    'value' => $offset,
            ));
        }

        $output .= $this->output->container_start('mail_header');
        $output .= $this->output->container_start('left');
        $output .= $this->output->user_picture($message->sender());
        $output .= $this->output->container_end();
        $output .= $this->output->container_start('mail_info');
        $output .= html_writer::link(new moodle_url('/user/view.php',
                                            array(
                                                'id' => $message->sender()->id,
                                                'course' => $message->course()->id
                                            )),
                                    fullname($message->sender()),
                                    array('class' => 'user_from'));
        $output .= $this->date($message, true);
        if (!$reply) {
            $output .= $this->output->container_start('mail_recipients');
            foreach (array('to', 'cc', 'bcc') as $role) {
                $recipients = $message->recipients($role);
                if (!empty($recipients)) {
                    if ($role == 'bcc' and $message->sender()->id !== $USER->id) {
                        continue;
                    }
                    $output .= html_writer::start_tag('div');
                    $output .= html_writer::tag('span', get_string($role, 'local_mail'), array('class' => 'mail_role'));
                    $numusers = count($recipients);
                    $totalusers += $numusers;
                    $cont = 1;
                    foreach ($recipients as $user) {
                        $output .= html_writer::link(new moodle_url('/user/view.php',
                                            array(
                                                'id' => $user->id,
                                                'course' => $message->course()->id
                                            )),
                                            fullname($user));
                        if ($cont < $numusers) {
                            $output .= ', ';
                        }
                        $cont += 1;
                    }
                    $output .= ' ';
                    $output .= html_writer::end_tag('div');
                }
            }
            $output .= $this->output->container_end();
        } else {
            $output .= html_writer::tag('div', '', array('class' => 'mail_recipients'));
        }
        $output .= $this->output->container_end();
        $output .= $this->output->container_end();

        $output .= $this->output->container_start('mail_body');
        $output .= $this->output->container_start('mail_content');
        $output .= local_mail_format_content($message);
        $attachments = local_mail_attachments($message);
        if ($attachments) {
            $output .= $this->output->container_start('mail_attachments');
            if (count($attachments) > 1) {
                $text = get_string('attachnumber', 'local_mail', count($attachments));
                $output .= html_writer::tag('span', $text, array('class' => 'mail_attachment_text'));
                $downloadurl = new moodle_url($this->page->url, array('downloadall' => '1'));
                $iconimage = $this->output->pix_icon('a/download_all', get_string('downloadall', 'local_mail'), 'moodle', array('class' => 'icon'));
                $output .= html_writer::start_div('mail_attachment_downloadall');
                $output .= html_writer::link($downloadurl, $iconimage);
                $output .= html_writer::link($downloadurl, get_string('downloadall', 'local_mail'), array('class' => 'mail_downloadall_text'));
                $output .= html_writer::end_div();
            }
            foreach ($attachments as $attach) {
                $filename = $attach->get_filename();
                $filepath = $attach->get_filepath();
                $mimetype = $attach->get_mimetype();
                $iconimage = $this->output->pix_icon(file_file_icon($attach), get_mimetype_description($attach), 'moodle', array('class' => 'icon'));
                $path = '/'.$attach->get_contextid().'/local_mail/message/'.$attach->get_itemid().$filepath.$filename;
                $fullurl = moodle_url::make_file_url('/pluginfile.php', $path, true);
                $output .= html_writer::start_tag('div', array('class' => 'mail_attachment'));
                $output .= html_writer::link($fullurl, $iconimage);
                $output .= html_writer::link($fullurl, s($filename));
                $output .= html_writer::tag('span', display_size($attach->get_filesize()), array('class' => 'mail_attachment_size'));
                $output .= html_writer::end_tag('div');
            }
            $output .= $this->output->container_end();
        }
//.........这里部分代码省略.........
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:101,代码来源:renderer.php

示例6: resource_get_optional_details

/**
 * Gets optional details for a resource, depending on resource settings.
 *
 * Result may include the file size and type if those settings are chosen,
 * or blank if none.
 *
 * @param object $resource Resource table row
 * @param object $cm Course-module table row
 * @return string Size and type or empty string if show options are not enabled
 */
function resource_get_optional_details($resource, $cm) {
    global $DB;

    $details = '';

    $options = empty($resource->displayoptions) ? array() : unserialize($resource->displayoptions);
    if (!empty($options['showsize']) || !empty($options['showtype']) || !empty($options['showdate'])) {
        $context = context_module::instance($cm->id);
        $size = '';
        $type = '';
        $date = '';
        $langstring = '';
        $infodisplayed = 0;
        $fs = get_file_storage();
        $files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder DESC, id ASC', false);
        if (!empty($options['showsize']) && count($files)) {
            $sizebytes = 0;
            foreach ($files as $file) {
                // this will also synchronize the file size for external files if needed
                $sizebytes += $file->get_filesize();
            }
            if ($sizebytes) {
                $size = display_size($sizebytes);
            }
            $langstring .= 'size';
            $infodisplayed += 1;
        }
        if (!empty($options['showtype']) && count($files)) {
            // For a typical file resource, the sortorder is 1 for the main file
            // and 0 for all other files. This sort approach is used just in case
            // there are situations where the file has a different sort order
            $mainfile = reset($files);
            $type = get_mimetype_description($mainfile);
            // Only show type if it is not unknown
            if ($type === get_mimetype_description('document/unknown')) {
                $type = '';
            }
            $langstring .= 'type';
            $infodisplayed += 1;
        }
        if (!empty($options['showdate'])) {
            $mainfile = reset($files);
            $uploaddate = $mainfile->get_timecreated();
            $modifieddate = $mainfile->get_timemodified();

            if ($modifieddate > $uploaddate) {
                $date = get_string('modifieddate', 'mod_resource', userdate($modifieddate));
            } else {
                $date = get_string('uploadeddate', 'mod_resource', userdate($uploaddate));
            }
            $langstring .= 'date';
            $infodisplayed += 1;
        }

        if ($infodisplayed > 1) {
            $details = get_string("resourcedetails_{$langstring}", 'resource',
                    (object)array('size' => $size, 'type' => $type, 'date' => $date));
        } else {
            // Only one of size, type and date is set, so just append.
            $details = $size . $type . $date;
        }
    }

    return $details;
}
开发者ID:nnnguyen,项目名称:moodletest,代码行数:75,代码来源:locallib.php

示例7: resource_get_file_details

/**
 * Gets details of the file to cache in course cache to be displayed using {@link resource_get_optional_details()}
 *
 * @param object $resource Resource table row (only property 'displayoptions' is used here)
 * @param object $cm Course-module table row
 * @return string Size and type or empty string if show options are not enabled
 */
function resource_get_file_details($resource, $cm)
{
    $options = empty($resource->displayoptions) ? array() : @unserialize($resource->displayoptions);
    $filedetails = array();
    if (!empty($options['showsize']) || !empty($options['showtype']) || !empty($options['showdate'])) {
        $context = context_module::instance($cm->id);
        $fs = get_file_storage();
        $files = $fs->get_area_files($context->id, 'mod_resource', 'content', 0, 'sortorder DESC, id ASC', false);
        // For a typical file resource, the sortorder is 1 for the main file
        // and 0 for all other files. This sort approach is used just in case
        // there are situations where the file has a different sort order.
        $mainfile = $files ? reset($files) : null;
        if (!empty($options['showsize'])) {
            $filedetails['size'] = 0;
            foreach ($files as $file) {
                // This will also synchronize the file size for external files if needed.
                $filedetails['size'] += $file->get_filesize();
                if ($file->get_repository_id()) {
                    // If file is a reference the 'size' attribute can not be cached.
                    $filedetails['isref'] = true;
                }
            }
        }
        if (!empty($options['showtype'])) {
            if ($mainfile) {
                $filedetails['type'] = get_mimetype_description($mainfile);
                // Only show type if it is not unknown.
                if ($filedetails['type'] === get_mimetype_description('document/unknown')) {
                    $filedetails['type'] = '';
                }
            } else {
                $filedetails['type'] = '';
            }
        }
        if (!empty($options['showdate'])) {
            if ($mainfile) {
                // Modified date may be up to several minutes later than uploaded date just because
                // teacher did not submit the form promptly. Give teacher up to 5 minutes to do it.
                if ($mainfile->get_timemodified() > $mainfile->get_timecreated() + 5 * MINSECS) {
                    $filedetails['modifieddate'] = $mainfile->get_timemodified();
                } else {
                    $filedetails['uploadeddate'] = $mainfile->get_timecreated();
                }
                if ($mainfile->get_repository_id()) {
                    // If main file is a reference the 'date' attribute can not be cached.
                    $filedetails['isref'] = true;
                }
            } else {
                $filedetails['uploadeddate'] = '';
            }
        }
    }
    return $filedetails;
}
开发者ID:evltuma,项目名称:moodle,代码行数:61,代码来源:locallib.php

示例8: 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

示例9: ss_print_section


//.........这里部分代码省略.........
                echo "</div>";
                if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(".format_string($groupings[$mod->groupingid]->name).')</span>';
                }

            } else { // Normal activity
                $instancename = format_string($modinfo->cms[$modnumber]->name, true,  $course->id);
              #  echo format_string($modinfo->cms[$modnumber]->intro, true,  $course->id);
              #  echo format_string($modinfo->cms[$modnumber]->name, true,  $course->id);
              #  print_r($modinfo->cms[$modnumber]);

                $customicon = $modinfo->cms[$modnumber]->icon;
                if (!empty($customicon)) {
                    if (substr($customicon, 0, 4) === 'mod/') {
                        list($modname, $iconname) = explode('/', substr($customicon, 4), 2);
                        $icon = $OUTPUT->pix_url($iconname, $modname);
                    } else {
                        $icon = $OUTPUT->pix_url($customicon);
                    }
                } else {
                    $icon = $OUTPUT->pix_url('icon', $mod->modname);
                }

                //Accessibility: for files get description via icon, this is very ugly hack!
                $altname = '';
                $altname = $mod->modfullname;
                if (!empty($customicon)) {
                    $archetype = plugin_supports('mod', $mod->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
                    if ($archetype == MOD_ARCHETYPE_RESOURCE) {
                        $mimetype = mimeinfo_from_icon('type', $customicon);
                        $altname = get_mimetype_description($mimetype);
                    }
                }
                // Avoid unnecessary duplication.
                if (false !== stripos($instancename, $altname)) {
                    $altname = '';
                }
                // File type after name, for alphabetic lists (screen reader).
                if ($altname) {
                    $altname = get_accesshide(' '.$altname);
                }

                // We may be displaying this just in order to show information
                // about visibility, without the actual link
                if ($mod->uservisible) {
                    // Display normal module link
                    if (!$accessiblebutdim) {
                        $linkcss = '';
                        $accesstext  ='';
                    } else {
                        $linkcss = ' class="dimmed" ';
                        $accesstext = '<span class="accesshide">'.
                            get_string('hiddenfromstudents').': </span>';
                    }

                    echo '<a '.$linkcss.' '.$extra.
                         ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.
                         '<img src="'.$icon.'" class="activityicon" alt="'.get_string('modulename',$mod->modname).'" /> '.
                         $accesstext.'<span class="instancename">'.$instancename.$altname.'</span></a>';

                    if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                        if (!isset($groupings)) {
                            $groupings = groups_get_all_groupings($course->id);
开发者ID:noisyjerm,项目名称:moodle-course_format_slides,代码行数:67,代码来源:lib.php

示例10: print_topicstree_section


//.........这里部分代码省略.........
            if (!empty($mod->closelevel)) {
                for ($n = 0; $n < $mod->closelevel; $n++) {
                    echo '</ul></li>' . "\n";
                }
            }
            if (!empty($mod->islast)) {
                $lastcss = 'last ';
            }
            echo '<li class="activity treeactivity ' . $lastcss . $mod->modname . '" id="module-' . $modnumber . '">';
            // Unique ID
            /// Add spacer for activities without collapse/expand button
            if (empty($mod->openlevel)) {
                echo $spacer;
            }
            $extra = '';
            if (!empty($modinfo->cms[$modnumber]->extra)) {
                $extra = $modinfo->cms[$modnumber]->extra;
            }
            if ($mod->modname == "label") {
                if (!$mod->visible) {
                    echo "<span class=\"dimmed_text\">";
                }
                echo format_text($extra, FORMAT_HTML, $labelformatoptions);
                if (!$mod->visible) {
                    echo "</span>";
                }
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            } else {
                // Normal activity
                $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id);
                if (!empty($modinfo->cms[$modnumber]->icon)) {
                    $icon = "{$CFG->pixpath}/" . $modinfo->cms[$modnumber]->icon;
                } else {
                    $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif";
                }
                //Accessibility: for files get description via icon.
                $altname = '';
                if ('resource' == $mod->modname) {
                    if (!empty($modinfo->cms[$modnumber]->icon)) {
                        $possaltname = $modinfo->cms[$modnumber]->icon;
                        $mimetype = mimeinfo_from_icon('type', $possaltname);
                        $altname = get_mimetype_description($mimetype);
                    } else {
                        $altname = $mod->modfullname;
                    }
                } else {
                    $altname = $mod->modfullname;
                }
                // Avoid unnecessary duplication.
                if (false !== stripos($instancename, $altname)) {
                    $altname = '';
                }
                // File type after name, for alphabetic lists (screen reader).
                if ($altname) {
                    $altname = get_accesshide(' ' . $altname);
                }
                $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
                echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>';
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            }
            if ($usetracking && $mod->modname == 'forum') {
                if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) {
                    echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">';
                    if ($unread == 1) {
                        echo $strunreadpostsone;
                    } else {
                        print_string('unreadpostsnumber', 'forum', $unread);
                    }
                    echo '</a></span>';
                }
            }
            /// Open new level if necessary, else print end of li
            if (isset($mod->openlevel)) {
                echo '<ul class="treelevel-' . ($mod->openlevel + 1) . '">' . "\n";
            } else {
                echo "</li>\n";
            }
        }
        /// End modules iterator
        /// Close remaining levels if necessary
        if (!empty($mod->indent)) {
            for ($n = 0; $n < $mod->indent; $n++) {
                echo '</ul></li>' . "\n";
            }
        }
    }
    if (!empty($section->sequence)) {
        echo "</ul><!--class='section'-->\n\n";
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:101,代码来源:format.php

示例11: print_user_files

 /**
  * Produces a list of links to the files uploaded by a user
  *
  * @param $userid int optional id of the user. If 0 then $USER->id is used.
  * @param $return boolean optional defaults to false. If true the list is returned rather than printed
  * @return string optional
  */
 function print_user_files($userid = 0, $return = false)
 {
     global $CFG, $USER, $OUTPUT;
     if (!$userid) {
         if (!isloggedin()) {
             return '';
         }
         $userid = $USER->id;
     }
     $output = '';
     $submission = $this->get_submission($userid);
     if (!$submission) {
         return $output;
     }
     $fs = get_file_storage();
     $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, "timemodified", false);
     if (!empty($files)) {
         require_once $CFG->dirroot . '/mod/assignment/locallib.php';
         if ($CFG->enableportfolios) {
             require_once $CFG->libdir . '/portfoliolib.php';
             $button = new portfolio_add_button();
         }
         foreach ($files as $file) {
             $filename = $file->get_filename();
             $mimetype = $file->get_mimetype();
             $path = file_encode_url($CFG->wwwroot . '/pluginfile.php', '/' . $this->context->id . '/mod_assignment/submission/' . $submission->id . '/' . $filename);
             $output .= '<a href="' . $path . '" >' . $OUTPUT->pix_icon(file_file_icon($file), get_mimetype_description($file), 'moodle', array('class' => 'icon')) . s($filename) . '</a>';
             if ($CFG->enableportfolios && $this->portfolio_exportable() && has_capability('mod/assignment:exportownsubmission', $this->context)) {
                 $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id, 'submissionid' => $submission->id, 'fileid' => $file->get_id()), '/mod/assignment/locallib.php');
                 $button->set_format_by_file($file);
                 $output .= $button->to_html(PORTFOLIO_ADD_ICON_LINK);
             }
             if ($CFG->enableplagiarism) {
                 require_once $CFG->libdir . '/plagiarismlib.php';
                 $output .= plagiarism_get_links(array('userid' => $userid, 'file' => $file, 'cmid' => $this->cm->id, 'course' => $this->course, 'assignment' => $this->assignment));
                 $output .= '<br />';
             }
         }
         if ($CFG->enableportfolios && count($files) > 1 && $this->portfolio_exportable() && has_capability('mod/assignment:exportownsubmission', $this->context)) {
             $button->set_callback_options('assignment_portfolio_caller', array('id' => $this->cm->id, 'submissionid' => $submission->id), '/mod/assignment/locallib.php');
             $output .= '<br />' . $button->to_html(PORTFOLIO_ADD_TEXT_LINK);
         }
     }
     $output = '<div class="files">' . $output . '</div>';
     if ($return) {
         return $output;
     }
     echo $output;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:56,代码来源:lib.php

示例12: bigbluebuttonbn_get_presentation_array

function bigbluebuttonbn_get_presentation_array($context, $presentation, $id = null)
{
    $presentation_name = null;
    $presentation_url = null;
    $presentation_icon = null;
    $presentation_mimetype_description = null;
    if (!empty($presentation)) {
        $fs = get_file_storage();
        $files = $fs->get_area_files($context->id, 'mod_bigbluebuttonbn', 'presentation', 0, 'itemid, filepath, filename', false);
        if (count($files) < 1) {
            //resource_print_filenotfound($resource, $cm, $course);
            //die;
            //exit;
        } else {
            $file = reset($files);
            unset($files);
            $presentation_name = $file->get_filename();
            $presentation_icon = file_file_icon($file, 24);
            $presentation_mimetype_description = get_mimetype_description($file);
            if (!is_null($id)) {
                //Create the nonce component for granting a temporary public access
                $cache = cache::make_from_params(cache_store::MODE_APPLICATION, 'mod_bigbluebuttonbn', 'presentation_cache');
                $presentation_nonce_key = sha1($id);
                $presentation_nonce_value = bigbluebuttonbn_generate_nonce();
                $cache->set($presentation_nonce_key, array("value" => $presentation_nonce_value, "counter" => 0));
                //The item id was adapted for granting public access to the presentation once in order to allow BigBlueButton to gather the file
                $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $presentation_nonce_value, $file->get_filepath(), $file->get_filename());
            } else {
                $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename());
            }
            $presentation_url = $url->out(false);
        }
    }
    $presentation_array = array("url" => $presentation_url, "name" => $presentation_name, "icon" => $presentation_icon, "mimetype_description" => $presentation_mimetype_description);
    return $presentation_array;
}
开发者ID:blindsidenetworks,项目名称:moodle-mod_bigbluebuttonbn,代码行数:36,代码来源:locallib.php

示例13: process_upload


//.........这里部分代码省略.........
     if ($record->filepath !== '/') {
         $record->filepath = file_correct_filepath($record->filepath);
     }
     if (!isset($_FILES[$elname])) {
         throw new moodle_exception('nofile');
     }
     if (!empty($_FILES[$elname]['error'])) {
         switch ($_FILES[$elname]['error']) {
             case UPLOAD_ERR_INI_SIZE:
                 throw new moodle_exception('upload_error_ini_size', 'repository_upload');
                 break;
             case UPLOAD_ERR_FORM_SIZE:
                 throw new moodle_exception('upload_error_form_size', 'repository_upload');
                 break;
             case UPLOAD_ERR_PARTIAL:
                 throw new moodle_exception('upload_error_partial', 'repository_upload');
                 break;
             case UPLOAD_ERR_NO_FILE:
                 throw new moodle_exception('upload_error_no_file', 'repository_upload');
                 break;
             case UPLOAD_ERR_NO_TMP_DIR:
                 throw new moodle_exception('upload_error_no_tmp_dir', 'repository_upload');
                 break;
             case UPLOAD_ERR_CANT_WRITE:
                 throw new moodle_exception('upload_error_cant_write', 'repository_upload');
                 break;
             case UPLOAD_ERR_EXTENSION:
                 throw new moodle_exception('upload_error_extension', 'repository_upload');
                 break;
             default:
                 throw new moodle_exception('nofile');
         }
     }
     // scan the files, throws exception and deletes if virus found
     // this is tricky because clamdscan daemon might not be able to access the files
     $permissions = fileperms($_FILES[$elname]['tmp_name']);
     @chmod($_FILES[$elname]['tmp_name'], $CFG->filepermissions);
     self::antivir_scan_file($_FILES[$elname]['tmp_name'], $_FILES[$elname]['name'], true);
     @chmod($_FILES[$elname]['tmp_name'], $permissions);
     if (empty($saveas_filename)) {
         $record->filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
     } else {
         $ext = '';
         $match = array();
         $filename = clean_param($_FILES[$elname]['name'], PARAM_FILE);
         if (preg_match('/\\.([a-z0-9]+)$/i', $filename, $match)) {
             if (isset($match[1])) {
                 $ext = $match[1];
             }
         }
         $ext = !empty($ext) ? $ext : '';
         if (preg_match('#\\.(' . $ext . ')$#i', $saveas_filename)) {
             // saveas filename contains file extension already
             $record->filename = $saveas_filename;
         } else {
             $record->filename = $saveas_filename . '.' . $ext;
         }
     }
     // Check the file has some non-null contents - usually an indication that a user has
     // tried to upload a folder by mistake
     if (!$this->check_valid_contents($_FILES[$elname]['tmp_name'])) {
         throw new moodle_exception('upload_error_invalid_file', 'repository_upload', '', $record->filename);
     }
     if ($this->mimetypes != '*') {
         // check filetype
         $filemimetype = mimeinfo('type', $_FILES[$elname]['name']);
         if (!in_array($filemimetype, $this->mimetypes)) {
             throw new moodle_exception('invalidfiletype', 'repository', '', get_mimetype_description(array('filename' => $_FILES[$elname]['name'])));
         }
     }
     if (empty($record->itemid)) {
         $record->itemid = 0;
     }
     if ($maxbytes !== -1 && filesize($_FILES[$elname]['tmp_name']) > $maxbytes) {
         throw new file_exception('maxbytes');
     }
     $record->contextid = $context->id;
     $record->userid = $USER->id;
     $record->source = '';
     if (repository::draftfile_exists($record->itemid, $record->filepath, $record->filename)) {
         $existingfilename = $record->filename;
         $unused_filename = repository::get_unused_filename($record->itemid, $record->filepath, $record->filename);
         $record->filename = $unused_filename;
         $stored_file = $fs->create_file_from_pathname($record, $_FILES[$elname]['tmp_name']);
         $event = array();
         $event['event'] = 'fileexists';
         $event['newfile'] = new stdClass();
         $event['newfile']->filepath = $record->filepath;
         $event['newfile']->filename = $unused_filename;
         $event['newfile']->url = moodle_url::make_draftfile_url($record->itemid, $record->filepath, $unused_filename)->out(false);
         $event['existingfile'] = new stdClass();
         $event['existingfile']->filepath = $record->filepath;
         $event['existingfile']->filename = $existingfilename;
         $event['existingfile']->url = moodle_url::make_draftfile_url($record->itemid, $record->filepath, $existingfilename)->out(false);
         return $event;
     } else {
         $stored_file = $fs->create_file_from_pathname($record, $_FILES[$elname]['tmp_name']);
         return array('url' => moodle_url::make_draftfile_url($record->itemid, $record->filepath, $record->filename)->out(false), 'id' => $record->itemid, 'file' => $record->filename);
     }
 }
开发者ID:nmicha,项目名称:moodle,代码行数:101,代码来源:lib.php

示例14: prepare_listing

    /**
     * Prepares list of files before passing it to AJAX, makes sure data is in the correct
     * format and stores formatted values.
     *
     * @param array|stdClass $listing result of get_listing() or search() or file_get_drafarea_files()
     * @return array
     */
    public static function prepare_listing($listing) {
        global $OUTPUT;

        $defaultfoldericon = $OUTPUT->pix_url(file_folder_icon(24))->out(false);
        // prepare $listing['path'] or $listing->path
        if (is_array($listing) && isset($listing['path']) && is_array($listing['path'])) {
            $path = &$listing['path'];
        } else if (is_object($listing) && isset($listing->path) && is_array($listing->path)) {
            $path = &$listing->path;
        }
        if (isset($path)) {
            $len = count($path);
            for ($i=0; $i<$len; $i++) {
                if (is_array($path[$i]) && !isset($path[$i]['icon'])) {
                    $path[$i]['icon'] = $defaultfoldericon;
                } else if (is_object($path[$i]) && !isset($path[$i]->icon)) {
                    $path[$i]->icon = $defaultfoldericon;
                }
            }
        }

        // prepare $listing['list'] or $listing->list
        if (is_array($listing) && isset($listing['list']) && is_array($listing['list'])) {
            $listing['list'] = array_values($listing['list']); // convert to array
            $files = &$listing['list'];
        } else if (is_object($listing) && isset($listing->list) && is_array($listing->list)) {
            $listing->list = array_values($listing->list); // convert to array
            $files = &$listing->list;
        } else {
            return $listing;
        }
        $len = count($files);
        for ($i=0; $i<$len; $i++) {
            if (is_object($files[$i])) {
                $file = (array)$files[$i];
                $converttoobject = true;
            } else {
                $file = & $files[$i];
                $converttoobject = false;
            }
            if (isset($file['size'])) {
                $file['size'] = (int)$file['size'];
                $file['size_f'] = display_size($file['size']);
            }
            if (isset($file['license']) &&
                    get_string_manager()->string_exists($file['license'], 'license')) {
                $file['license_f'] = get_string($file['license'], 'license');
            }
            if (isset($file['image_width']) && isset($file['image_height'])) {
                $a = array('width' => $file['image_width'], 'height' => $file['image_height']);
                $file['dimensions'] = get_string('imagesize', 'repository', (object)$a);
            }
            foreach (array('date', 'datemodified', 'datecreated') as $key) {
                if (!isset($file[$key]) && isset($file['date'])) {
                    $file[$key] = $file['date'];
                }
                if (isset($file[$key])) {
                    // must be UNIX timestamp
                    $file[$key] = (int)$file[$key];
                    if (!$file[$key]) {
                        unset($file[$key]);
                    } else {
                        $file[$key.'_f'] = userdate($file[$key], get_string('strftimedatetime', 'langconfig'));
                        $file[$key.'_f_s'] = userdate($file[$key], get_string('strftimedatetimeshort', 'langconfig'));
                    }
                }
            }
            $isfolder = (array_key_exists('children', $file) || (isset($file['type']) && $file['type'] == 'folder'));
            $filename = null;
            if (isset($file['title'])) {
                $filename = $file['title'];
            }
            else if (isset($file['fullname'])) {
                $filename = $file['fullname'];
            }
            if (!isset($file['mimetype']) && !$isfolder && $filename) {
                $file['mimetype'] = get_mimetype_description(array('filename' => $filename));
            }
            if (!isset($file['icon'])) {
                if ($isfolder) {
                    $file['icon'] = $defaultfoldericon;
                } else if ($filename) {
                    $file['icon'] = $OUTPUT->pix_url(file_extension_icon($filename, 24))->out(false);
                }
            }
            if ($converttoobject) {
                $files[$i] = (object)$file;
            }
        }
        return $listing;
    }
开发者ID:nicusX,项目名称:moodle,代码行数:98,代码来源:lib.php

示例15: render_post


//.........这里部分代码省略.........
     // Get content of actual message in HTML
     if ($html) {
         $message = $post->get_formatted_message();
         if (!$expanded && !$deletedhide) {
             // When not expanded and no subject, we include a summary of the
             // message
             $stripped = strip_tags(preg_replace('~<script.*?</script>~s', '', $message));
             $messagetosummarise = $subject !== null ? '<h3>' . $subject . '</h3>&nbsp;' . $stripped : $stripped;
             $summary = self::nice_shorten_text($messagetosummarise, 50);
             $out .= $lf . '<div class="forumng-summary"><div class="forumng-text">' . $summary . '</div> ' . $expandlink . '</div>';
         }
     }
     // Start of post main section
     if ($expanded && !$deletedhide) {
         if ($html) {
             $out .= '<div class="forumng-postmain">';
         }
         // Attachments
         $attachments = $post->get_attachment_names();
         if (count($attachments)) {
             if ($html) {
                 $out .= $lf;
                 if (count($attachments) == 1) {
                     $attachmentlabel = get_string('attachment', 'forumng');
                 } else {
                     $attachmentlabel = get_string('attachments', 'forumng');
                 }
                 $out .= '<span class="accesshide">' . $attachmentlabel . '</span><ul class="forumng-attachments">';
             }
             foreach ($attachments as $attachment) {
                 if ($html) {
                     require_once $CFG->libdir . '/filelib.php';
                     $iconsrc = $this->pix_url('/f/' . mimeinfo('icon', $attachment));
                     $alt = get_mimetype_description(mimeinfo('type', $attachment));
                     $out .= '<li><a href="' . $post->get_attachment_url($attachment) . '">' . '<img src="' . $iconsrc . '" alt="' . $alt . '" /> <span>' . htmlspecialchars($attachment) . '</span></a> </li>';
                 } else {
                     // Right-align the entry to 70 characters
                     $padding = 70 - strlen($attachment);
                     if ($padding > 0) {
                         $out .= str_repeat(' ', $padding);
                     }
                     // Add filename
                     $out .= $attachment . $lf;
                 }
             }
             if ($html) {
                 $out .= '</ul>' . $lf;
             } else {
                 $out .= $lf;
                 // Extra line break after attachments
             }
         }
         // Display actual content
         if ($html) {
             if ($options[mod_forumng_post::OPTION_PRINTABLE_VERSION]) {
                 $message = preg_replace('~<a[^>]*\\shref\\s*=\\s*[\'"](http:.*?)[\'"][^>]*>' . '(?!(http:|www\\.)).*?</a>~', "\$0 [\$1]", $message);
             }
             $out .= $lf . '<div class="forumng-message">' . $message . '</div>';
         } else {
             $out .= $post->get_email_message();
             $out .= "\n\n";
         }
         if ($html) {
             $out .= $lf . '<div class="clear forumng-postfooter">';
         }
         // Ratings.
开发者ID:nadavkav,项目名称:moodle-mod_forumng,代码行数:67,代码来源:renderer.php


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