function display()
 {
     global $CFG;
     $formatoptions = new object();
     $formatoptions->noclean = true;
     /// Are we displaying the course blocks?
     if ($this->resource->options == 'showblocks') {
         parent::display_course_blocks_start();
         $entry = get_record('kaltura_entries', 'context', "R_" . "{$this->resource}->id");
         if (trim(strip_tags($this->resource->alltext))) {
             echo $entry->title;
             $context = get_context_instance(CONTEXT_COURSE, $this->course->id);
             $formatoptions = new object();
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
             if (has_capability('moodle/course:manageactivities', $context)) {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), $entry->entry_type, $entry->design, true);
             } else {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), KalturaEntryType::MEDIA_CLIP, $entry->design, true);
             }
         }
         parent::display_course_blocks_end();
     } else {
         /// Set up generic stuff first, including checking for access
         parent::display();
         /// Set up some shorthand variables
         $cm = $this->cm;
         $course = $this->course;
         $resource = $this->resource;
         $entry = get_record('kaltura_entries', 'context', "R_" . "{$resource->id}");
         $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
         $inpopup = optional_param('inpopup', '', PARAM_BOOL);
         add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
         $navigation = build_navigation($this->navlinks, $cm);
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         if (trim(strip_tags($this->resource->alltext))) {
             echo $entry->title;
             $context = get_context_instance(CONTEXT_COURSE, $this->course->id);
             $formatoptions = new object();
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
             if (has_capability('moodle/course:manageactivities', $context)) {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), $entry->entry_type, $entry->design, true);
             } else {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), KalturaEntryType::MEDIA_CLIP, $entry->design, true);
             }
         }
         /*       print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id),
                         "center", "", "", "20");
         */
         $strlastmodified = get_string("lastmodified");
         echo "<div class=\"modified\">{$strlastmodified}: " . userdate($resource->timemodified) . "</div>";
         print_footer($course);
     }
 }
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
$meta = '<link rel="stylesheet" type="text/css" href="' . $CFG->wwwroot . '/mod/kaltura/styles.php" />' . "\n";
//$meta = '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/mod/kaltura/css/kaltura.css" />'."\n";
print_header('Kaltura Preview', '', '', '', $meta);
$id = '';
if (isset($_GET['entry_id'])) {
    $id = $_GET['entry_id'];
}
if (empty($id)) {
    die('missing id');
}
if (isset($_GET['design'])) {
    $design = $_GET['design'];
} else {
    $design = 'light';
}
$entry = new kaltura_entry();
if (isset($_GET['width']) && isset($_GET['dimensions'])) {
    $entry->dimensions = $_GET['dimensions'];
    $entry->custom_width = $_GET['width'];
    $entry->size = KalturaPlayerSize::CUSTOM;
} else {
    $entry->dimensions = KalturaPlayerSize::LARGE;
    $entry->custom_width = 400;
    $entry->size = KalturaPlayerSize::CUSTOM;
}
echo embed_kaltura($id, get_width($entry), get_height($entry), KalturaEntryType::MEDIA_CLIP, $design);
echo '<div style="width:400px; margin-top:15px; text-align:center;"><input type="button"  value="' . get_string("close", "kaltura") . '" onclick="window.parent.kalturaCloseModalBox();" />';
print_footer();