本文整理汇总了PHP中repository::get_file方法的典型用法代码示例。如果您正苦于以下问题:PHP repository::get_file方法的具体用法?PHP repository::get_file怎么用?PHP repository::get_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repository
的用法示例。
在下文中一共展示了repository::get_file方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_file
/**
* Download a file, this function can be overridden by subclass. {@link curl}
*
* @param string $url the url of file
* @param string $filename save location
* @return array with elements:
* path: internal location of the file
* url: URL to the source (from parameters)
*/
public function get_file($url, $filename = '')
{
global $CFG, $USER;
//if its mobile then we need to treat it as an upload
if (\filter_poodll\poodlltools::isMobile($CFG->filter_poodll_html5rec)) {
//get the filename as used by our recorder
$recordedname = basename($url);
//get a temporary download path
$path = $this->prepare_file($filename);
//fetch the file we submitted earlier
$fs = get_file_storage();
$context = context_user::instance($USER->id);
$f = $fs->get_file($context->id, "user", "draft", "0", "/", $recordedname);
//write the file out to the temporary location
$fhandle = fopen($path, 'w');
$data = $f->get_content();
$result = fwrite($fhandle, $data);
// Close file handler.
fclose($fhandle);
//bail if we errored out
if ($result === false) {
unlink($path);
return null;
} else {
//clear up the original file which we no longer need
self::delete_tempfile_from_draft("0", "/", $recordedname);
}
//return to Moodle what it needs to know
return array('path' => $path, 'url' => $url);
}
//if not mobile, determine the player options
switch ($this->options['recording_format']) {
case self::POODLLSNAPSHOT:
case self::MP3AUDIO:
case self::POODLLWHITEBOARD:
//get the filename as used by our recorder
$recordedname = basename($url);
//get a temporary download path
$path = $this->prepare_file($filename);
//fetch the file we submitted earlier
$fs = get_file_storage();
$context = context_user::instance($USER->id);
$f = $fs->get_file($context->id, "user", "draft", "0", "/", $recordedname);
//write the file out to the temporary location
$fhandle = fopen($path, 'w');
$data = $f->get_content();
$result = fwrite($fhandle, $data);
// Close file handler.
fclose($fhandle);
//bail if we errored out
if ($result === false) {
unlink($path);
return null;
} else {
//clear up the original file which we no longer need
self::delete_tempfile_from_draft("0", "/", $recordedname);
}
//return to Moodle what it needs to know
return array('path' => $path, 'url' => $url);
break;
default:
return parent::get_file($url, $filename);
}
}
示例2: get_file
/**
*
* @global object $CFG
* @param string $photoid
* @param string $file
* @return string
*/
public function get_file($photoid, $file = '') {
global $CFG;
$info = $this->flickr->photos_getInfo($photoid);
if ($info['owner']['realname']) {
$author = $info['owner']['realname'];
} else {
$author = $info['owner']['username'];
}
$copyright = get_string('author', 'repository') . ': ' . $author;
// If we can read the original secret, it means that we have access to the original picture.
if (isset($info['originalsecret'])) {
$source = $this->flickr->buildPhotoURL($info, 'original');
} else {
$source = $this->build_photo_url($photoid);
}
$result = parent::get_file($source, $file);
$path = $result['path'];
if (!empty($this->usewatermarks)) {
$img = new moodle_image($path);
$img->watermark($copyright, array(10,10), array('ttf'=>true, 'fontsize'=>12))->saveas($path);
}
return array('path'=>$path, 'author'=>$info['owner']['realname'], 'license'=>$this->license4moodle($info['license']));
}
示例3: get_file
/**
* Download a file from alfresco
*
* @param string $uuid a unique id of directory in alfresco
* @param string $path path to a directory
* @return array
*/
public function get_file($uuid, $file = '')
{
$node = $this->user_session->getNode($this->store, $uuid);
$url = $this->get_url($node);
return parent::get_file($url, $file);
}
示例4: get_file
/**
*
* @param string $photoid
* @param string $file
* @return string
*/
public function get_file($photoid, $file = '')
{
$url = $this->build_photo_url($photoid);
return parent::get_file($url, $file);
}