コード例 #1
0
 public function frontpage_available_courses()
 {
     /* available courses */
     global $CFG, $OUTPUT, $PAGE;
     require_once $CFG->libdir . '/coursecatlib.php';
     $chelper = new coursecat_helper();
     $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
     $chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
     $courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
     $totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options());
     $rcourseids = array_keys($courses);
     $acourseids = array_chunk($rcourseids, 5);
     $newcourse = get_string('availablecourses');
     $header = '<div id="frontpage-course-list">
     <h2>' . $newcourse . '</h2>
     <div class="courses frontpage-course-list-all">';
     $footer = '
     </div>
     </div>';
     $content = '';
     if (count($rcourseids) > 0) {
         foreach ($acourseids as $courseids) {
             $content .= '<div class="row-fluid">';
             $rowcontent = '';
             foreach ($courseids as $courseid) {
                 $course = get_course($courseid);
                 $no = get_config('theme_pioneer', 'patternselect');
                 $nimgp = empty($no) || $no == "default" ? 'no-image' : 'cs0' . $no . '/no-image';
                 $summary = theme_pioneer_strip_html_tags($course->summary);
                 $summary = theme_pioneer_course_trim_char($summary, 20);
                 $trimtitle = theme_pioneer_course_trim_char($course->fullname, 25);
                 $noimgurl = $OUTPUT->pix_url($nimgp, 'theme');
                 $courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
                 if ($course instanceof stdClass) {
                     require_once $CFG->libdir . '/coursecatlib.php';
                     $course = new course_in_list($course);
                 }
                 $imgurl = '';
                 $context = context_course::instance($course->id);
                 foreach ($course->get_course_overviewfiles() as $file) {
                     $isimage = $file->is_valid_image();
                     $imgurl = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
                     if (!$isimage) {
                         $imgurl = $noimgurl;
                     }
                 }
                 if (empty($imgurl)) {
                     $imgurl = $PAGE->theme->setting_file_url('headerbackgroundimage', 'headerbackgroundimage', true);
                     if (!$imgurl) {
                         $imgurl = $noimgurl;
                     }
                 }
                 $rowcontent .= '
                     <div style="background-image: url(' . $imgurl . ');background-repeat: no-repeat;background-size:cover; background-position:center;" class="fp-avail-courses">
                     <div class="fp-coursebox">
                     <div class="fp-courseinfo">
                     <p><a href="' . $courseurl . '" id="button" data-toggle="tooltip" data-placement="top" title="' . $course->fullname . '" >' . $trimtitle . '</a></p>
                     </div>
                     </div>
                     </div>
                     ';
             }
             $content .= $rowcontent;
             $content .= '</div>';
         }
     }
     $coursehtml = $header . $content . $footer;
     echo $coursehtml;
     if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
         // Print link to create a new course, for the 1st available category.
         echo $this->add_new_course_button();
     }
 }
コード例 #2
0
ファイル: renderer.php プロジェクト: rushi963/moodle
 /**
  * Returns HTML to print list of available courses for the frontpage
  *
  * @return string
  */
 public function frontpage_available_courses()
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $chelper = new coursecat_helper();
     $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
     $chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
     $courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
     $totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options());
     if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
         // Print link to create a new course, for the 1st available category.
         return $this->add_new_course_button();
     }
     return $this->coursecat_courses($chelper, $courses, $totalcount);
 }
コード例 #3
0
ファイル: renderer.php プロジェクト: Jtgadbois/Pedadida
 /**
  * Returns HTML to print list of available courses for the frontpage
  *
  * @return string
  */
 public function frontpage_available_courses()
 {
     global $CFG;
     require_once $CFG->libdir . '/coursecatlib.php';
     $chelper = new coursecat_helper();
     $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
     $chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
     $courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
     $totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options());
     if (!$totalcount && has_capability('moodle/course:create', context_system::instance())) {
         // Print link to create a new course, for the 1st available category.
         $output = $this->container_start('buttons');
         $url = new moodle_url('/course/edit.php', array('category' => $CFG->defaultrequestcategory, 'returnto' => 'topcat'));
         $output .= $this->single_button($url, get_string('addnewcourse'), 'get');
         $output .= $this->container_end('buttons');
         return $output;
     }
     return $this->coursecat_courses($chelper, $courses, $totalcount);
 }
コード例 #4
0
ファイル: renderers.php プロジェクト: josespinozaf/bcu
 public function frontpage_my_courses()
 {
     global $USER, $CFG, $DB;
     $output = '';
     if (!isloggedin() or isguestuser()) {
         return '';
     }
     $courses = block_course_overview_get_sorted_courses();
     list($sortedcourses, $sitecourses, $totalcourses) = block_course_overview_get_sorted_courses();
     if (!empty($sortedcourses) || !empty($rcourses) || !empty($rhosts)) {
         $chelper = new coursecat_helper();
         if (count($courses) > $CFG->frontpagecourselimit) {
             // There are more enrolled courses than we can display, display link to 'My courses'.
             $totalcount = count($sortedcourses);
             $courses = array_slice($sortedcourses, 0, $CFG->frontpagecourselimit, true);
             $chelper->set_courses_display_options(array('viewmoreurl' => new moodle_url('/my/'), 'viewmoretext' => new lang_string('mycourses')));
         } else {
             // All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.
             $chelper->set_courses_display_options(array('viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
             $totalcount = $DB->count_records('course') - 1;
         }
         $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_attributes(array('class' => 'frontpage-course-list-enrolled'));
         $output .= $this->coursecat_courses($chelper, $sortedcourses, $totalcount);
         if (!empty($rcourses)) {
             $output .= html_writer::start_tag('div', array('class' => 'courses'));
             foreach ($rcourses as $course) {
                 $output .= $this->frontpage_remote_course($course);
             }
             $output .= html_writer::end_tag('div');
         } else {
             if (!empty($rhosts)) {
                 $output .= html_writer::start_tag('div', array('class' => 'courses'));
                 foreach ($rhosts as $host) {
                     $output .= $this->frontpage_remote_host($host);
                 }
                 $output .= html_writer::end_tag('div');
             }
         }
     }
     return $output;
 }
コード例 #5
0
 public function frontpage_available_courses()
 {
     /* available courses */
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/coursecatlib.php';
     $chelper = new coursecat_helper();
     $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->set_courses_display_options(array('recursive' => true, 'limit' => $CFG->frontpagecourselimit, 'viewmoreurl' => new moodle_url('/course/index.php'), 'viewmoretext' => new lang_string('fulllistofcourses')));
     $chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
     $courses = coursecat::get(0)->get_courses($chelper->get_courses_display_options());
     $totalcount = coursecat::get(0)->get_courses_count($chelper->get_courses_display_options());
     $rcourseids = array_keys($courses);
     $acourseids = array_chunk($rcourseids, 4);
     $newcourse = get_string('availablecourses');
     $header = '<div id="frontpage-course-list">
     <h2>' . $newcourse . '</h2>
     <div class="courses frontpage-course-list-all">';
     $footer = '
     </div>
     </div>';
     $content = '';
     if (count($rcourseids) > 0) {
         foreach ($acourseids as $courseids) {
             $content .= '<div class="row-fluid">';
             $rowcontent = '';
             foreach ($courseids as $courseid) {
                 $course = get_course($courseid);
                 $no = get_config('theme_eguru', 'patternselect');
                 $nimgp = empty($no) || $no == "default" ? 'cs00/no-image' : 'cs0' . $no . '/no-image';
                 $noimgurl = $OUTPUT->pix_url($nimgp, 'theme');
                 $courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
                 if ($course instanceof stdClass) {
                     require_once $CFG->libdir . '/coursecatlib.php';
                     $course = new course_in_list($course);
                 }
                 $imgurl = '';
                 $context = context_course::instance($course->id);
                 foreach ($course->get_course_overviewfiles() as $file) {
                     $isimage = $file->is_valid_image();
                     $imgurl = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
                     if (!$isimage) {
                         $imgurl = $noimgurl;
                     }
                 }
                 if (empty($imgurl)) {
                     $imgurl = $noimgurl;
                 }
                 $rowcontent .= '<div class="span3">
                     <div class="fp-coursebox">
                     <div class="fp-coursethumb">
                     <a href="' . $courseurl . '">
                     <img src="' . $imgurl . '" width="243" height="165" alt="' . $course->fullname . '">
                     </a>
                     </div>
                     <div class="fp-courseinfo">
                     <h5><a href="' . $courseurl . '">' . $course->fullname . '</a></h5>
                     </div>
                     </div>
                     </div>';
             }
             $content .= $rowcontent;
             $content .= '</div>';
         }
     }
     $coursehtml = $header . $content . $footer;
     echo $coursehtml;
     if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
         // Print link to create a new course, for the 1st available category.
         echo $this->add_new_course_button();
     }
 }
コード例 #6
0
 /**
  * Renders the list of courses
  *
  * This is internal function, please use {@link core_course_renderer::courses_list()} or another public
  * method from outside of the class
  *
  * If list of courses is specified in $courses; the argument $chelper is only used
  * to retrieve display options and attributes, only methods get_show_courses(),
  * get_courses_display_option() and get_and_erase_attributes() are called.
  *
  * @param coursecat_helper $chelper various display options
  * @param array $courses the list of courses to display
  * @param int|null $totalcount total number of courses (affects display mode if it is AUTO or pagination if applicable),
  *     defaulted to count($courses)
  * @return string
  */
 protected function coursecat_courses(coursecat_helper $chelper, $courses, $totalcount = null)
 {
     global $CFG;
     if ($totalcount === null) {
         $totalcount = count($courses);
     }
     if (!$totalcount) {
         // Courses count is cached during courses retrieval.
         return '';
     }
     if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_AUTO) {
         // In 'auto' course display mode we analyse if number of courses is more or less than $CFG->courseswithsummarieslimit
         if ($totalcount <= $CFG->courseswithsummarieslimit) {
             $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED);
         } else {
             $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_COLLAPSED);
         }
     }
     // prepare content of paging bar if it is needed
     $paginationurl = $chelper->get_courses_display_option('paginationurl');
     $paginationallowall = $chelper->get_courses_display_option('paginationallowall');
     if ($totalcount > count($courses)) {
         // there are more results that can fit on one page
         if ($paginationurl) {
             // the option paginationurl was specified, display pagingbar
             $perpage = $chelper->get_courses_display_option('limit', $CFG->coursesperpage);
             $page = $chelper->get_courses_display_option('offset') / $perpage;
             $pagingbar = $this->paging_bar($totalcount, $page, $perpage, $paginationurl->out(false, array('perpage' => $perpage)));
             if ($paginationallowall) {
                 $pagingbar .= html_writer::tag('div', html_writer::link($paginationurl->out(false, array('perpage' => 'all')), get_string('showall', '', $totalcount)), array('class' => 'paging paging-showall'));
             }
         } else {
             if ($viewmoreurl = $chelper->get_courses_display_option('viewmoreurl')) {
                 // the option for 'View more' link was specified, display more link
                 $viewmoretext = $chelper->get_courses_display_option('viewmoretext', new lang_string('viewmore'));
                 $morelink = html_writer::tag('div', html_writer::link($viewmoreurl, $viewmoretext), array('class' => 'paging paging-morelink'));
             }
         }
     } else {
         if ($totalcount > $CFG->coursesperpage && $paginationurl && $paginationallowall) {
             // there are more than one page of results and we are in 'view all' mode, suggest to go back to paginated view mode
             $pagingbar = html_writer::tag('div', html_writer::link($paginationurl->out(false, array('perpage' => $CFG->coursesperpage)), get_string('showperpage', '', $CFG->coursesperpage)), array('class' => 'paging paging-showperpage'));
         }
     }
     // display list of courses
     $attributes = $chelper->get_and_erase_attributes('courses');
     $content = html_writer::start_tag('div', $attributes);
     if (!empty($pagingbar)) {
         $content .= $pagingbar;
     }
     $coursecount = 0;
     foreach ($courses as $course) {
         $coursecount++;
         $classes = $coursecount % 2 ? 'odd' : 'even';
         if ($coursecount == 1) {
             $classes .= ' first';
         }
         if ($coursecount >= count($courses)) {
             $classes .= ' last';
         }
         $content .= $this->coursecat_coursebox($chelper, $course, $classes);
     }
     if (!empty($pagingbar)) {
         $content .= $pagingbar;
     }
     if (!empty($morelink)) {
         $content .= $morelink;
     }
     $content .= html_writer::end_tag('div');
     // .courses
     return $content;
 }