dirroot. '/theme/edumy/ccn/user_handler/ccn_user_handler.php'); require_once($CFG->dirroot. '/theme/edumy/ccn/course_handler/ccn_course_handler.php'); require_once($CFG->dirroot. '/theme/edumy/ccn/general_handler/ccn_video_handler.php'); require_once($CFG->dirroot. '/theme/edumy/ccn/block_handler/ccn_block_handler.php'); class block_cocoon_course_intro extends block_base { public function init() { $this->title = get_string('cocoon_course_intro', 'block_cocoon_course_intro'); } public function specialization() { global $CFG; include($CFG->dirroot . '/theme/edumy/ccn/block_handler/specialization.php'); } public function get_content() { global $CFG, $DB, $COURSE, $PAGE; $courseid = $COURSE->id; $context = context_course::instance($courseid); require_once($CFG->libdir . '/behat/lib.php'); require_once($CFG->libdir . '/filelib.php'); // initialize fetch if(!empty($this->config->user)){ $ccnUserHandler = new ccnUserHandler(); $ccnUser = $ccnUserHandler->ccnGetUserDetails($this->config->user); } if(!empty($this->config->video_url)) { $ccnVideoHandler = new ccnVideoHandler(); $ccnVideo = $ccnVideoHandler->ccnVideoEmbedHandler($this->config->video_url); } $ccnCourseHandler = new ccnCourseHandler(); $ccnCourse = $ccnCourseHandler->ccnGetCourseDetails($COURSE->id); if ($this->content !== null) { return $this->content; } $this->content = new stdClass; // initialize overrides if(!empty($this->config->teacher)){$this->content->teacher = $this->config->teacher;} if(!empty($this->config->accent)){$this->content->accent = $this->config->accent;} if(!empty($this->config->video)){$this->content->video = $this->config->video;} if(!empty($this->config->video_url)){$this->content->video_url = $this->config->video_url;} else {$this->content->video_url = '';} if(!empty($this->config->style)){$this->content->style = $this->config->style;} if(!empty($this->config->show_teacher)){$this->content->show_teacher = $this->config->show_teacher;} $fs = get_file_storage(); $files = $fs->get_area_files($this->context->id, 'block_cocoon_course_intro', 'content'); foreach ($files as $file) { $filename = $file->get_filename(); if ($filename <> '.') { $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $filename); $this->content->image = '' . $filename . ''; } } // map data if(!empty($this->config->teacher)){ $renderName = '
  • '. $this->content->teacher .'
  • '; } elseif(!empty($this->config->user)){ $renderName = '
  • '. $ccnUser->fullname .'
  • '; } else { $renderName = ''; } if(!empty($this->config->accent)){ $renderAccent = '
  • '. format_text($this->content->accent, FORMAT_HTML, array('filter' => true)) .'
  • '; } else { $renderAccent = ''; } if(!empty($this->content->image)){ $renderImage = '
  • '. $this->content->image .'
  • '; }elseif(!empty($this->config->user)){ $renderImage = '
  • '; } else { $renderImage = ''; } $cocoon_share_fb = 'https://www.facebook.com/sharer/sharer.php?u='. $this->page->url; $white = ''; if($PAGE->theme->settings->course_single_style != 0){ $white = 'color-white'; } $this->content->text = '

    '. format_text($COURSE->fullname, FORMAT_HTML, array('filter' => true)) .'

      '; $this->content->text .= $renderAccent; $this->content->text .= $ccnCourse->ccnRender->starRating; $this->content->text .='
    '; if($PAGE->theme->settings->coursecat_enrolments != 1 || $PAGE->theme->settings->coursecat_announcements != 1){ $this->content->text .=''; } $this->content->text .='
    '; if(!empty($this->content->video_url)) { $this->content->text .='
    '; } $this->content->text .='
    '; return $this->content; } public function instance_allow_multiple() { return true; } function applicable_formats() { $ccnBlockHandler = new ccnBlockHandler(); return $ccnBlockHandler->ccnGetBlockApplicability(array('course-view')); } public function html_attributes() { global $CFG; $attributes = parent::html_attributes(); include($CFG->dirroot . '/theme/edumy/ccn/block_handler/attributes.php'); return $attributes; } }