Exemplo n.º 1
0
 public static function render_instance(BlockInstance $instance, $editing = false)
 {
     global $CFG;
     $configdata = $instance->get('configdata');
     $result = '';
     $width = !empty($configdata['width']) ? hsc($configdata['width']) : self::$default_width;
     $height = !empty($configdata['height']) ? hsc($configdata['height']) : self::$default_height;
     if (isset($configdata['videoid'])) {
         $block = $instance->get('id');
         $configuring = $block == param_integer('blockconfig', 0);
         $result = GcrFileLib::getVideoEmbedHtml($configdata['videoid'], $width, $height);
     }
     return $result;
 }
Exemplo n.º 2
0
/**
 * Display embedded url file.
 * @param object $url
 * @param object $cm
 * @param object $course
 * @param stored_file $file main file
 * @return does not return
 */
function mediaelementjs_display_embed($url, $cm, $course)
{
    global $CFG, $PAGE, $OUTPUT;
    $mimetype = resourcelib_guess_url_mimetype($url->externalurl);
    $cloud_storage_mimetype = mediaelementjs_guess_cloud_storage_mimetype($url->externalurl);
    if ($cloud_storage_mimetype) {
        $mimetype = $cloud_storage_mimetype;
    }
    $fullurl = mediaelementjs_get_full_url($url, $cm, $course);
    $title = $url->name;
    $link = html_writer::tag('a', $fullurl, array('href' => str_replace('&', '&', $fullurl)));
    $clicktoopen = get_string('clicktoopen', 'mediaelementjs', $link);
    $extension = resourcelib_get_extension($url->externalurl);
    if (in_array($mimetype, array('image/gif', 'image/jpeg', 'image/png'))) {
        // It's an image
        $code = resourcelib_embed_image($fullurl, $title);
    } else {
        if ($mimetype == 'audio/mp3' || $mimetype == 'audio/x-pn-realaudio-plugin') {
            // MP3 audio file
            $code = GcrFileLib::getAudioEmbedHtml($fullurl, $mimetype);
        } else {
            if ($mimetype == 'application/x-shockwave-flash') {
                // Flash file
                $code = resourcelib_embed_flash($fullurl, $title, $clicktoopen);
            } else {
                if ($mimetype == 'video/x-ms' || $mimetype == 'video/mpeg' || $mimetype == 'video/quicktime' || $mimetype == 'video/webm' || $mimetype == 'video/ogv' || $mimetype == 'video/ogg' || $mimetype == 'video/mp4') {
                    $code = GcrFileLib::getVideoEmbedHtml($fullurl, '100%', '100%', $mimetype);
                } else {
                    // anything else - just try object tag enlarged as much as possible
                    $code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
                }
            }
        }
    }
    mediaelementjs_print_header($url, $cm, $course);
    mediaelementjs_print_heading($url, $cm, $course);
    echo $code;
    mediaelementjs_print_intro($url, $cm, $course);
    echo $OUTPUT->footer();
    die;
}
 public function getObjectUrl($obj)
 {
     $metadata = $this->api->get_object_metadata($this->bucket, $obj);
     $mimetype = GcrFileLib::mimeinfo($obj);
     if ($metadata['ContentType'] != $mimetype) {
         $this->setContentType($obj, $mimetype);
     }
     if (empty($metadata['cache-control'])) {
         $this->setCacheControl($obj);
     }
     $response = $this->api->get_object_url($this->bucket, $obj, '5 minutes');
     return str_replace('http://', 'https://', $response);
 }
 public function executeGetUserStorageFileList(sfWebRequest $request)
 {
     global $CFG;
     $CFG->current_app->requireLogin();
     $return_array = array();
     $user_storage = new GcrUserStorageAccessS3();
     $file_list = $user_storage->getFileList(false);
     foreach ($file_list as $filename) {
         $file_array = array('filename' => $filename, 'mimetype' => GcrFileLib::mimeinfo($filename));
         $return_array[$user_storage->getStaticUrl($filename)] = $file_array;
     }
     $this->getResponse()->setHttpHeader('Content-type', 'application/json');
     return $this->renderText(json_encode($return_array));
 }