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


PHP get_file_browser函数代码示例

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


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

示例1: 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 '';
        }
        $browser = get_file_browser();
        $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) {
            $fileinfo = $browser->get_file_info($tree->context, $file->get_component(),
                    $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename());
            $url = $fileinfo->get_url(true);
            $filename = $file->get_filename();
            if ($imageinfo = $fileinfo->get_imageinfo()) {
                $fileurl = new moodle_url($fileinfo->get_url());
                $image = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $fileinfo->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, $filename), array('class' => 'fp-filename-icon'));
            $result .= html_writer::tag('li', $filename);
        }
        $result .= '</ul>';

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

示例2: test_upload

 public function test_upload()
 {
     global $USER;
     $this->resetAfterTest();
     $this->setAdminUser();
     $context = context_user::instance($USER->id);
     $contextid = $context->id;
     $component = "user";
     $filearea = "private";
     $itemid = 0;
     $filepath = "/";
     $filename = "Simple.txt";
     $filecontent = base64_encode("Let us create a nice simple file");
     $browser = get_file_browser();
     // Make sure no file exists.
     $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
     $this->assertEmpty($file);
     // Call the api to create a file.
     core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent);
     // Make sure the file was created.
     $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
     $this->assertNotEmpty($file);
     // Make sure no file exists.
     $itemid = 2;
     $filename = "Simple2.txt";
     $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename);
     $this->assertEmpty($file);
     // Call the api to create a file.
     $fileinfo = core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent);
     // Make sure itemid is always set to 0.
     $this->assertEquals(0, $fileinfo['itemid']);
     // Make sure the same file cannot be created again.
     $this->setExpectedException("moodle_exception");
     core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent);
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:35,代码来源:externallib_test.php

示例3: retrieveFile

 /**
  * Retrieve a file for a user of the Moodle client calling this function
  * The file is encoded in base64
  * @global <type> $DB
  * @global <type> $USER
  * @global <type> $MNET_REMOTE_CLIENT
  * @param <type> $username
  * @param <type> $source
  * @return <type>
  */
 public function retrieveFile($username, $source)
 {
     global $DB, $USER, $MNET_REMOTE_CLIENT;
     ///check the the user is known
     ///he has to be previously connected to the server site in order to be in the database
     //TODO: this seems weird - is it executed from cron or what? Please review
     $USER = $DB->get_record('user', array('username' => $username, 'mnethostid' => $MNET_REMOTE_CLIENT->id));
     if (empty($USER)) {
         exit(mnet_server_fault(9016, get_string('usernotfound', 'repository_remotemoodle', $username)));
     }
     $file = unserialize(base64_decode($source));
     $contextid = $file[0];
     $filearea = $file[1];
     $itemid = $file[2];
     $filepath = $file[3];
     $filename = $file[4];
     ///check that the user has read permission on this file
     $browser = get_file_browser();
     $fileinfo = $browser->get_file_info(get_context_instance_by_id($contextid), $filearea, $itemid, $filepath, $filename);
     if (empty($fileinfo)) {
         exit(mnet_server_fault(9016, get_string('usercannotaccess', 'repository_remotemoodle', $file)));
     }
     ///retrieve the file with file API functions and return it encoded in base64
     $fs = get_file_storage();
     $sf = $fs->get_file($contextid, $filearea, $itemid, $filepath, $filename);
     $contents = base64_encode($sf->get_content());
     return array($contents, $sf->get_filename());
 }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:38,代码来源:repository.class.php

示例4: get_listing

 /**
  * Get file listing
  *
  * @param string $encodedpath
  * @return mixed
  */
 public function get_listing($encodedpath = '', $page = '')
 {
     global $CFG, $USER, $OUTPUT;
     $ret = array();
     $ret['dynload'] = true;
     $ret['nosearch'] = true;
     $ret['nologin'] = true;
     $list = array();
     if (!empty($encodedpath)) {
         $params = unserialize(base64_decode($encodedpath));
         if (is_array($params)) {
             $component = is_null($params['component']) ? NULL : clean_param($params['component'], PARAM_COMPONENT);
             $filearea = is_null($params['filearea']) ? NULL : clean_param($params['filearea'], PARAM_AREA);
             $itemid = is_null($params['itemid']) ? NULL : clean_param($params['itemid'], PARAM_INT);
             $filepath = is_null($params['filepath']) ? NULL : clean_param($params['filepath'], PARAM_PATH);
             $filename = is_null($params['filename']) ? NULL : clean_param($params['filename'], PARAM_FILE);
             $context = get_context_instance_by_id(clean_param($params['contextid'], PARAM_INT));
         }
     } else {
         $itemid = null;
         $filename = null;
         $filearea = null;
         $filepath = null;
         $component = null;
         if (!empty($this->context)) {
             list($context, $course, $cm) = get_context_info_array($this->context->id);
             if (is_object($course)) {
                 $context = get_context_instance(CONTEXT_COURSE, $course->id);
             } else {
                 $context = get_system_context();
             }
         } else {
             $context = get_system_context();
         }
     }
     $browser = get_file_browser();
     $list = array();
     if ($fileinfo = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename)) {
         // build file tree
         $element = repository_local_file::retrieve_file_info($fileinfo, $this);
         $nonemptychildren = $element->get_non_empty_children();
         foreach ($nonemptychildren as $child) {
             $list[] = (array) $child->get_node();
         }
     } else {
         // if file doesn't exist, build path nodes root of current context
         $fileinfo = $browser->get_file_info($context, null, null, null, null, null);
     }
     // build path navigation
     $ret['path'] = array();
     $element = repository_local_file::retrieve_file_info($fileinfo, $this);
     for ($level = $element; $level; $level = $level->get_parent()) {
         if ($level == $element || !$level->can_skip()) {
             array_unshift($ret['path'], $level->get_node_path());
         }
     }
     $ret['list'] = array_filter($list, array($this, 'filter'));
     return $ret;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:65,代码来源:lib.php

示例5: get_listing

 /**
  * Get file listing
  *
  * @param string $encodedpath
  * @return mixed
  */
 public function get_listing($encodedpath = '')
 {
     global $CFG, $USER, $OUTPUT;
     $ret = array();
     $ret['dynload'] = true;
     $ret['nosearch'] = true;
     $ret['nologin'] = true;
     $list = array();
     if (!empty($encodedpath)) {
         $params = unserialize(base64_decode($encodedpath));
         if (is_array($params)) {
             $filepath = clean_param($params['filepath'], PARAM_PATH);
             $filename = clean_param($params['filename'], PARAM_FILE);
         }
     } else {
         $itemid = 0;
         $filepath = '/';
         $filename = null;
     }
     $filearea = 'private';
     $component = 'user';
     $itemid = 0;
     $context = get_context_instance(CONTEXT_USER, $USER->id);
     try {
         $browser = get_file_browser();
         if ($fileinfo = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename)) {
             $pathnodes = array();
             $level = $fileinfo;
             $params = $fileinfo->get_params();
             while ($level && $params['component'] == 'user' && $params['filearea'] == 'private') {
                 $encodedpath = base64_encode(serialize($level->get_params()));
                 $pathnodes[] = array('name' => $level->get_visible_name(), 'path' => $encodedpath);
                 $level = $level->get_parent();
                 $params = $level->get_params();
             }
             $ret['path'] = array_reverse($pathnodes);
             // build file tree
             $children = $fileinfo->get_children();
             foreach ($children as $child) {
                 if ($child->is_directory()) {
                     $encodedpath = base64_encode(serialize($child->get_params()));
                     $node = array('title' => $child->get_visible_name(), 'size' => 0, 'date' => '', 'path' => $encodedpath, 'children' => array(), 'thumbnail' => $OUTPUT->pix_url('f/folder-32')->out(false));
                     $list[] = $node;
                 } else {
                     $encodedpath = base64_encode(serialize($child->get_params()));
                     $node = array('title' => $child->get_visible_name(), 'size' => 0, 'date' => '', 'source' => $encodedpath, 'thumbnail' => $OUTPUT->pix_url(file_extension_icon($child->get_visible_name(), 32))->out(false));
                     $list[] = $node;
                 }
             }
         }
     } catch (Exception $e) {
         throw new repository_exception('emptyfilelist', 'repository_user');
     }
     $ret['list'] = $list;
     $ret['list'] = array_filter($list, array($this, 'filter'));
     return $ret;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:63,代码来源:lib.php

示例6: get_file

 /**
  * Return draft files information
  *
  * @global object $USER
  * @param string $fid file id
  * @param string $title
  * @param string $itemid
  * @return string the location of the file
  */
 public function get_file($fid, $title = '', $itemid = '')
 {
     global $USER;
     $ret = array();
     $browser = get_file_browser();
     $user_context = get_context_instance(CONTEXT_USER, $USER->id);
     $ret['itemid'] = $itemid;
     $ret['title'] = $title;
     $ret['contextid'] = $user_context->id;
     return $ret;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:20,代码来源:repository.class.php

示例7: print_student_answer

 function print_student_answer($userid, $return = false)
 {
     global $CFG, $USER, $OUTPUT;
     $fs = get_file_storage();
     $browser = get_file_browser();
     $output = '';
     if ($files = $fs->get_area_files($this->context->id, 'assignment_submission', $userid, "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 . '/assignment_submission/' . $userid . '/' . $filename);
             $output .= '<a href="' . $path . '" ><img class="icon" src="' . $OUTPUT->old_icon_url(file_mimetype_icon($mimetype)) . '" alt="' . $mimetype . '" />' . s($filename) . '</a><br />';
         }
     }
     $output = '<div class="files">' . $output . '</div>';
     return $output;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:18,代码来源:assignment.class.php

示例8: 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:EmmanuelYupit,项目名称:educursos,代码行数:22,代码来源:assignment.class.php

示例9: upload

 /**
  * Uploading a file to moodle
  *
  * @param int    $contextid    context id
  * @param string $component    component
  * @param string $filearea     file area
  * @param int    $itemid       item id
  * @param string $filepath     file path
  * @param string $filename     file name
  * @param string $filecontent  file content
  * @param string $contextlevel Context level (block, course, coursecat, system, user or module)
  * @param int    $instanceid   Instance id of the item associated with the context level
  * @return array
  * @since Moodle 2.2
  */
 public static function upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent, $contextlevel, $instanceid)
 {
     global $USER, $CFG;
     $fileinfo = self::validate_parameters(self::upload_parameters(), array('contextid' => $contextid, 'component' => $component, 'filearea' => $filearea, 'itemid' => $itemid, 'filepath' => $filepath, 'filename' => $filename, 'filecontent' => $filecontent, 'contextlevel' => $contextlevel, 'instanceid' => $instanceid));
     if (!isset($fileinfo['filecontent'])) {
         throw new moodle_exception('nofile');
     }
     // Saving file.
     $dir = make_temp_directory('wsupload');
     if (empty($fileinfo['filename'])) {
         $filename = uniqid('wsupload', true) . '_' . time() . '.tmp';
     } else {
         $filename = $fileinfo['filename'];
     }
     if (file_exists($dir . $filename)) {
         $savedfilepath = $dir . uniqid('m') . $filename;
     } else {
         $savedfilepath = $dir . $filename;
     }
     file_put_contents($savedfilepath, base64_decode($fileinfo['filecontent']));
     @chmod($savedfilepath, $CFG->filepermissions);
     unset($fileinfo['filecontent']);
     if (!empty($fileinfo['filepath'])) {
         $filepath = $fileinfo['filepath'];
     } else {
         $filepath = '/';
     }
     // Only allow uploads to draft area
     if (!($fileinfo['component'] == 'user' and $fileinfo['filearea'] == 'draft')) {
         throw new coding_exception('File can be uploaded to user draft area only');
     } else {
         $component = 'user';
         $filearea = $fileinfo['filearea'];
     }
     $itemid = 0;
     if (isset($fileinfo['itemid'])) {
         $itemid = $fileinfo['itemid'];
     }
     if ($filearea == 'draft' && $itemid <= 0) {
         // Generate a draft area for the files.
         $itemid = file_get_unused_draft_itemid();
     } else {
         if ($filearea == 'private') {
             // TODO MDL-31116 in user private area, itemid is always 0.
             $itemid = 0;
         }
     }
     // We need to preserve backword compatibility. Context id is no more a required.
     if (empty($fileinfo['contextid'])) {
         unset($fileinfo['contextid']);
     }
     // Get and validate context.
     $context = self::get_context_from_params($fileinfo);
     self::validate_context($context);
     if ($fileinfo['component'] == 'user' and $fileinfo['filearea'] == 'private') {
         throw new moodle_exception('privatefilesupload');
     }
     $browser = get_file_browser();
     // Check existing file.
     if ($file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename)) {
         throw new moodle_exception('fileexist');
     }
     // Move file to filepool.
     if ($dir = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, '.')) {
         $info = $dir->create_file_from_pathname($filename, $savedfilepath);
         $params = $info->get_params();
         unlink($savedfilepath);
         return array('contextid' => $params['contextid'], 'component' => $params['component'], 'filearea' => $params['filearea'], 'itemid' => $params['itemid'], 'filepath' => $params['filepath'], 'filename' => $params['filename'], 'url' => $info->get_url());
     } else {
         throw new moodle_exception('nofile');
     }
 }
开发者ID:evltuma,项目名称:moodle,代码行数:87,代码来源:externallib.php

示例10: get_listing

    /**
     * Get file listing
     *
     * @param string $encodedpath
     * @return mixed
     */
    public function get_listing($encodedpath = '') {
        global $CFG, $USER, $OUTPUT;
        $ret = array();
        $ret['dynload'] = true;
        $ret['nosearch'] = true;
        $ret['nologin'] = true;
        $list = array();

        if (!empty($encodedpath)) {
            $params = unserialize(base64_decode($encodedpath));
            if (is_array($params)) {
                $component = is_null($params['component']) ? NULL : clean_param($params['component'], PARAM_COMPONENT);
                $filearea  = is_null($params['filearea']) ? NULL : clean_param($params['filearea'], PARAM_AREA);
                $itemid    = is_null($params['itemid']) ? NULL : clean_param($params['itemid'], PARAM_INT);
                $filepath  = is_null($params['filepath']) ? NULL : clean_param($params['filepath'], PARAM_PATH);;
                $filename  = is_null($params['filename']) ? NULL : clean_param($params['filename'], PARAM_FILE);
                $context = get_context_instance_by_id(clean_param($params['contextid'], PARAM_INT));
            }
        } else {
            $itemid   = null;
            $filename = null;
            $filearea = null;
            $filepath = null;
            $component = null;
            if (!empty($this->context)) {
                list($context, $course, $cm) = get_context_info_array($this->context->id);
                $courseid = is_object($course) ? $course->id : SITEID;
                $context = get_context_instance(CONTEXT_COURSE, $courseid);
            } else {
                $context = get_system_context();
            }
        }

        $browser = get_file_browser();

        if ($fileinfo = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename)) {
            // build path navigation
            $pathnodes = array();
            $encodedpath = base64_encode(serialize($fileinfo->get_params()));
            $pathnodes[] = array('name'=>$fileinfo->get_visible_name(), 'path'=>$encodedpath);
            $level = $fileinfo->get_parent();
            while ($level) {
                $encodedpath = base64_encode(serialize($level->get_params()));
                $pathnodes[] = array('name'=>$level->get_visible_name(), 'path'=>$encodedpath);
                $level = $level->get_parent();
            }
            if (!empty($pathnodes) && is_array($pathnodes)) {
                $pathnodes = array_reverse($pathnodes);
                $ret['path'] = $pathnodes;
            }
            // build file tree
            $children = $fileinfo->get_children();
            foreach ($children as $child) {
                if ($child->is_directory()) {
                    if ($child->is_empty_area()) {
                        continue;
                    }
                    $params = $child->get_params();
                    $encodedpath = base64_encode(serialize($params));
                    // hide user_private area from local plugin, user should
                    // use private file plugin to access private files
                    //if ($params['filearea'] == 'user_private') {
                        //continue;
                    //}
                    $node = array(
                        'title' => $child->get_visible_name(),
                        'size' => 0,
                        'date' => '',
                        'path' => $encodedpath,
                        'children'=>array(),
                        'thumbnail' => $OUTPUT->pix_url('f/folder-32')->out(false)
                    );
                    $list[] = $node;
                } else {
                    $encodedpath = base64_encode(serialize($child->get_params()));
                    $node = array(
                        'title' => $child->get_visible_name(),
                        'size' => 0,
                        'date' => '',
                        'source'=> $encodedpath,
                        'thumbnail' => $OUTPUT->pix_url(file_extension_icon($child->get_visible_name(), 32))->out(false)
                    );
                    $list[] = $node;
                }
            }
        } else {
            // if file doesn't exist, build path nodes root of current context
            $pathnodes = array();
            $fileinfo = $browser->get_file_info($context, null, null, null, null, null);
            $encodedpath = base64_encode(serialize($fileinfo->get_params()));
            $pathnodes[] = array('name'=>$fileinfo->get_visible_name(), 'path'=>$encodedpath);
            $level = $fileinfo->get_parent();
            while ($level) {
                $encodedpath = base64_encode(serialize($level->get_params()));
//.........这里部分代码省略.........
开发者ID:ravivare,项目名称:moodle-1,代码行数:101,代码来源:lib.php

示例11: instance_remotedownload

function instance_remotedownload($contextid, $filename, $component, $filearea, $itemid, $requestid, $filepath = '/')
{
    global $CFG, $USER;
    //set up return object
    //set up return object
    $return = fetchReturnArray(true);
    //set up auto transcoding (mp3 or mp4) or not
    //The jsp to call is different.
    $jsp = "download.jsp";
    $convertlocally = false;
    $downloadfilename = $filename;
    $ext = substr($filename, -4);
    $filenamebase = substr($filename, 0, -4);
    switch ($ext) {
        case ".mp4":
            if ($CFG->filter_poodll_ffmpeg) {
                $convertlocally = true;
                $downloadfilename = $filenamebase . ".flv";
            } else {
                $jsp = "convert.jsp";
            }
            break;
        case ".mp3":
            if ($CFG->filter_poodll_ffmpeg) {
                $convertlocally = true;
                $downloadfilename = $filenamebase . ".flv";
            } else {
                $jsp = "convert.jsp";
            }
            break;
        case ".png":
            $jsp = "snapshot.jsp";
            break;
        default:
            $jsp = "download.jsp";
            break;
    }
    //setup our file manipulators
    $fs = get_file_storage();
    $browser = get_file_browser();
    //create the file record for our new file
    $file_record = new stdClass();
    $file_record->userid = $USER->id;
    $file_record->contextid = $contextid;
    $file_record->component = $component;
    $file_record->filearea = $filearea;
    $file_record->itemid = $itemid;
    $file_record->filepath = $filepath;
    $file_record->filename = $filename;
    $file_record->license = $CFG->sitedefaultlicense;
    $file_record->author = 'Moodle User';
    $file_record->source = '';
    $file_record->timecreated = time();
    $file_record->timemodified = time();
    //one condition of using this function is that only one file can be here,
    //attachment limits
    /*
    if($filearea=='draft'){
        $fs->delete_area_files($contextid,$component,$filearea,$itemid);
    }
    */
    //if file already exists, delete it
    //we could use fileinfo, but it don&'t work
    if ($fs->file_exists($contextid, $component, $filearea, $itemid, $filepath, $filename)) {
        //delete here ---
    }
    //setup download information
    $red5_fileurl = "http://" . $CFG->filter_poodll_servername . ":" . $CFG->filter_poodll_serverhttpport . "/poodll/" . $jsp . "?poodllserverid=" . $CFG->filter_poodll_serverid . "&filename=" . $downloadfilename . "&caller=" . urlencode($CFG->wwwroot);
    //download options
    $options = array();
    $options['headers'] = null;
    $options['postdata'] = null;
    $options['fullresponse'] = false;
    $options['timeout'] = 300;
    $options['connecttimeout'] = 20;
    $options['skipcertverify'] = false;
    $options['calctimeout'] = false;
    //clear the output buffer, otherwise strange characters can get in to our file
    //seems to have no effect though ...
    while (ob_get_level()) {
        ob_end_clean();
    }
    //branch logic depending on whether (converting locally) or (not conv||convert on server)
    if ($convertlocally) {
        //determine the temp directory
        if (isset($CFG->tempdir)) {
            $tempdir = $CFG->tempdir . "/";
        } else {
            //moodle 2.1 users have no $CFG->tempdir
            $tempdir = $CFG->dataroot . "/temp/";
        }
        //actually make the file on disk so FFMPEG can get it
        $mediastring = file_get_contents($red5_fileurl);
        $ret = file_put_contents($tempdir . $downloadfilename, $mediastring);
        //if successfully saved to disk, convert
        if ($ret) {
            $do_bg_encoding = $CFG->filter_poodll_bgtranscode_audio && $ext == ".mp3" || $CFG->filter_poodll_bgtranscode_video && $ext == ".mp4";
            if ($do_bg_encoding && $CFG->version >= 2014051200) {
                $stored_file = convert_with_ffmpeg_bg($file_record, $tempdir, $downloadfilename, $filenamebase, $ext);
            } else {
//.........这里部分代码省略.........
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:101,代码来源:poodllfilelib.php

示例12: pathIsWritable

function pathIsWritable($moduleid, $courseid, $itemid, $filearea, $filepath = DIRECTORY_SEPARATOR, $filename = "")
{
    global $DB;
    //get a handle on the module context
    $thiscontext = get_context_instance(CONTEXT_MODULE, $moduleid);
    //fetch info and ids about the module calling this data
    $course = $DB->get_record('course', array('id' => $courseid));
    $modinfo = get_fast_modinfo($course);
    $cm = $modinfo->get_cm($moduleid);
    $component = "mod_" . $cm->modname;
    //FIlter could submit submission/draft/content/intro as options here
    if ($filearea == "") {
        $filearea = "content";
    }
    //get our file object
    $filepath = DIRECTORY_SEPARATOR;
    $filename = "";
    $browser = get_file_browser();
    $fileinfo = $browser->get_file_info($thiscontext, $component, $filearea, $itemid, $filepath, $filename);
    //return writeable or not
    if ($fileinfo && $fileinfo->is_writable()) {
        return true;
    } else {
        return false;
    }
}
开发者ID:laiello,项目名称:poodll.poodll2,代码行数:26,代码来源:poodllfilelib.php

示例13: copy_to_area

 /**
  * Copy a file to file area
  *
  * @global object $USER
  * @global object $DB
  * @param string $encoded The metainfo of file, it is base64 encoded php serialized data
  * @param string $draftitemid itemid
  * @param string $new_filename The intended name of file
  * @param string $new_filepath the new path in draft area
  * @return array The information of file
  */
 public function copy_to_area($encoded, $draftitemid, $new_filepath, $new_filename)
 {
     global $USER, $DB;
     $info = array();
     $browser = get_file_browser();
     $fs = get_file_storage();
     $user_context = get_context_instance(CONTEXT_USER, $USER->id);
     // the final file
     $params = unserialize(base64_decode($encoded));
     $contextid = clean_param($params['contextid'], PARAM_INT);
     $fileitemid = clean_param($params['itemid'], PARAM_INT);
     $filename = clean_param($params['filename'], PARAM_FILE);
     $filepath = clean_param($params['filepath'], PARAM_PATH);
     $filearea = clean_param($params['filearea'], PARAM_ALPHAEXT);
     $component = clean_param($params['component'], PARAM_ALPHAEXT);
     $context = get_context_instance_by_id($contextid);
     if ($existingfile = $fs->get_file($user_context->id, 'user', 'draft', $draftitemid, $new_filepath, $new_filename)) {
         throw new moodle_exception('fileexists');
     }
     $file_info = $browser->get_file_info($context, $component, $filearea, $fileitemid, $filepath, $filename);
     $file_info->copy_to_storage($user_context->id, 'user', 'draft', $draftitemid, $new_filepath, $new_filename);
     $info['itemid'] = $draftitemid;
     $info['title'] = $new_filename;
     $info['contextid'] = $user_context->id;
     $info['filesize'] = $file_info->get_filesize();
     return $info;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:38,代码来源:lib.php

示例14: get_listing

 /**
  * Get file listing
  *
  * @param string $encodedpath
  * @return mixed
  */
 public function get_listing($encodedpath = '', $page = '')
 {
     global $CFG, $USER, $OUTPUT;
     $ret = array();
     $ret['dynload'] = true;
     $ret['nosearch'] = true;
     $ret['nologin'] = true;
     $manageurl = new moodle_url('/user/files.php');
     $ret['manage'] = $manageurl->out();
     $list = array();
     if (!empty($encodedpath)) {
         $params = json_decode(base64_decode($encodedpath), true);
         if (is_array($params)) {
             $filepath = clean_param($params['filepath'], PARAM_PATH);
             $filename = clean_param($params['filename'], PARAM_FILE);
         }
     } else {
         $itemid = 0;
         $filepath = '/';
         $filename = null;
     }
     $filearea = 'private';
     $component = 'user';
     $itemid = 0;
     $context = context_user::instance($USER->id);
     try {
         $browser = get_file_browser();
         if ($fileinfo = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename)) {
             $pathnodes = array();
             $level = $fileinfo;
             $params = $fileinfo->get_params();
             while ($level && $params['component'] == 'user' && $params['filearea'] == 'private') {
                 $encodedpath = base64_encode(json_encode($level->get_params()));
                 $pathnodes[] = array('name' => $level->get_visible_name(), 'path' => $encodedpath);
                 $level = $level->get_parent();
                 $params = $level->get_params();
             }
             $ret['path'] = array_reverse($pathnodes);
             // build file tree
             $children = $fileinfo->get_children();
             foreach ($children as $child) {
                 if ($child->is_directory()) {
                     $encodedpath = base64_encode(json_encode($child->get_params()));
                     $node = array('title' => $child->get_visible_name(), 'datemodified' => $child->get_timemodified(), 'datecreated' => $child->get_timecreated(), 'path' => $encodedpath, 'children' => array(), 'thumbnail' => $OUTPUT->pix_url(file_folder_icon(90))->out(false));
                     $list[] = $node;
                 } else {
                     $encodedpath = base64_encode(json_encode($child->get_params()));
                     $node = array('title' => $child->get_visible_name(), 'size' => $child->get_filesize(), 'datemodified' => $child->get_timemodified(), 'datecreated' => $child->get_timecreated(), 'author' => $child->get_author(), 'license' => $child->get_license(), 'isref' => $child->is_external_file(), 'source' => $encodedpath, 'icon' => $OUTPUT->pix_url(file_file_icon($child, 24))->out(false), 'thumbnail' => $OUTPUT->pix_url(file_file_icon($child, 90))->out(false));
                     if ($child->get_status() == 666) {
                         $node['originalmissing'] = true;
                     }
                     if ($imageinfo = $child->get_imageinfo()) {
                         $fileurl = new moodle_url($child->get_url());
                         $node['realthumbnail'] = $fileurl->out(false, array('preview' => 'thumb', 'oid' => $child->get_timemodified()));
                         $node['realicon'] = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $child->get_timemodified()));
                         $node['image_width'] = $imageinfo['width'];
                         $node['image_height'] = $imageinfo['height'];
                     }
                     $list[] = $node;
                 }
             }
         }
     } catch (Exception $e) {
         throw new repository_exception('emptyfilelist', 'repository_user');
     }
     $ret['list'] = $list;
     $ret['list'] = array_filter($list, array($this, 'filter'));
     return $ret;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:75,代码来源:lib.php

示例15: user_complete

 /**
  * Print complete information about the user's interaction with the assignment
  *
  * @param $user object
  */
 function user_complete($user)
 {
     global $OUTPUT;
     if ($submission = $this->get_submission($user->id)) {
         $fs = get_file_storage();
         $browser = get_file_browser();
         if ($files = $fs->get_area_files($this->context->id, 'assignment_submission', $user->id, "timemodified", false)) {
             $countfiles = count($files) . " " . get_string("uploadedfiles", "assignment");
             foreach ($files as $file) {
                 $countfiles .= "; " . $file->get_filename();
             }
         }
         echo $OUTPUT->box_start();
         echo get_string("lastmodified") . ": ";
         echo userdate($submission->timemodified);
         echo $this->display_lateness($submission->timemodified);
         $this->print_user_files($user->id);
         echo '<br />';
         if (empty($submission->timemarked)) {
             print_string("notgradedyet", "assignment");
         } else {
             $this->view_feedback($submission);
         }
         echo $OUTPUT->box_end();
     } else {
         print_string("notsubmittedyet", "assignment");
     }
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:33,代码来源:lib.php


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