/** * 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); } }
/** * * @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'])); }
/** * 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); }
/** * * @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); }