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();
         if (trim(strip_tags($this->resource->alltext))) {
             echo format_text($this->resource->alltext, FORMAT_MOODLE, $formatoptions, $this->course->id);
         }
         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;
         $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
         $inpopup = optional_param('inpopup', '', PARAM_BOOL);
         if ($resource->popup) {
             if ($inpopup) {
                 /// Popup only
                 add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
                 print_header();
                 print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id), "center", "", "", "20");
                 print_footer($course);
             } else {
                 /// Make a page and a pop-up window
                 $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));
                 echo "\n<script type=\"text/javascript\">";
                 echo "\n//<![CDATA[\n";
                 echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
                 echo "\n//]]>\n";
                 echo '</script>';
                 if (trim(strip_tags($resource->summary))) {
                     print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
                 }
                 $link = "<a href=\"{$CFG->wwwroot}/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">" . format_string($resource->name, true) . "</a>";
                 echo '<div class="popupnotice">';
                 print_string('popupresource', 'resource');
                 echo '<br />';
                 print_string('popupresourcelink', 'resource', $link);
                 echo '</div>';
                 print_footer($course);
             }
         } else {
             /// not a popup at all
             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));
             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);
         }
     }
 }
 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;
             $player_url = $CFG->wwwroot . '/mod/kaltura/kswfdoc.php?context=' . $this->course->id . '&entry_id=' . $resource->alltext;
             $formatoptions = new object();
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
             if ($resource->alltext) {
                 echo '<input style="margin-top:20px;" type="button" value="View video presentation" onclick="kalturaInitModalBox(\'' . $player_url . '\', {width:780, height:400});">';
             }
             //            echo embed_kaltura($resource->alltext,get_width($entry),get_height($entry),$entry->entry_type);
         }
         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;
         }
         $formatoptions = new object();
         $formatoptions->noclean = true;
         print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
         if (trim(strip_tags($this->resource->alltext))) {
             $player_url = $CFG->wwwroot . '/mod/kaltura/kswfdoc.php?context=' . $this->course->id . '&entry_id=' . $resource->alltext;
             if ($resource->alltext) {
                 echo '<input type="button" style="margin-top:20px;"  value="View video presentation" onclick="kalturaInitModalBox(\'' . $player_url . '\', {width:780, height:400});">';
             }
             //          echo embed_kaltura($resource->alltext,get_width($entry),get_height($entry),$entry->entry_type);
         }
         /*       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);
     }
 }
 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);
     }
 }