From ba6d101f3cf520f6214414d5dd5c2d6bd1a3b62f Mon Sep 17 00:00:00 2001 From: Matheus Garcia Date: Thu, 15 Aug 2019 17:21:58 -0300 Subject: [PATCH] =?UTF-8?q?Adapta=C3=A7=C3=A3o=20para=20exibir=20sum=C3=A1?= =?UTF-8?q?rio=20ao=20lado=20da=20caixa=20do=20curso?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/output/core/course_renderer.php | 40 +++++++++++++++++++++---- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/classes/output/core/course_renderer.php b/classes/output/core/course_renderer.php index 120ecc3..3ede56d 100644 --- a/classes/output/core/course_renderer.php +++ b/classes/output/core/course_renderer.php @@ -51,6 +51,33 @@ require_once($CFG->dirroot . '/course/renderer.php'); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class course_renderer extends \core_course_renderer { + + // Renderiza caixa de informações de curso + // @param $displayCourseInfo indica se deve exibir informações do curso à direita (true) + // ou em botão "Mais Informações" (false) + public function course_info_box(stdClass $course, $displayCourseInfo = false) { + $content = '
'; + + $content .= '
'; + $chelper = new coursecat_helper(); + $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED); + + $content .= $this->coursecat_coursebox($chelper, $course, '', $displayCourseInfo); + $content .= '
'; + + if($displayCourseInfo) { + if ($course instanceof stdClass) { + $course = new core_course_list_element($course); + } + $content .= '
'; + $content .= $chelper->get_course_formatted_summary($course, array('noclean' => true, 'para' => false)); + $content .= '
'; + } + + $content .= '
'; + return $content; + } + /** * Renders the list of courses for frontpage and /course * @@ -151,7 +178,8 @@ class course_renderer extends \core_course_renderer { * depend on the course position in list - first/last/even/odd) * @return string */ - protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '') { + + protected function coursecat_coursebox(coursecat_helper $chelper, $course, $additionalclasses = '', $displayCourseInfo = false) { global $CFG; if (!isset($this->strings->summary)) { $this->strings->summary = get_string('summary'); @@ -176,10 +204,12 @@ class course_renderer extends \core_course_renderer { 'data-courseid' => $course->id, 'data-type' => self::COURSECAT_TYPE_COURSE, )); - $content .= $this->coursecat_coursebox_content($chelper, $course); + $content .= $this->coursecat_coursebox_content($chelper, $course, $displayCourseInfo); $content .= html_writer::end_tag('div'); + // End coursebox. $content .= html_writer::end_tag('div'); + // End col-md-4. return $content; } @@ -192,7 +222,7 @@ class course_renderer extends \core_course_renderer { * @param stdClass|core_course_list_element $course * @return string */ - protected function coursecat_coursebox_content(coursecat_helper $chelper, $course) { + protected function coursecat_coursebox_content(coursecat_helper $chelper, $course, $displayCourseInfo = false) { if ($course instanceof stdClass) { $course = new core_course_list_element($course); } @@ -242,7 +272,7 @@ class course_renderer extends \core_course_renderer { $content .= 'Inscrever'; $content .= html_writer::end_tag('div'); } - //if ($course->has_summary() && false) { + if (!$displayCourseInfo) { $content .= html_writer::start_tag('div', array('class' => 'btn btn-mais-info m-2', 'id' => "course-popover-{$course->id}", 'role' => 'button', 'data-region' => 'popover-region-toggle', 'data-toggle' => 'popover', 'data-placement' => 'right', @@ -250,7 +280,7 @@ class course_renderer extends \core_course_renderer { array('noclean' => true, 'para' => false)), 'data-html' => 'true', 'tabindex' => '0', 'data-trigger' => 'focus')); $content .= 'Mais informações'; $content .= html_writer::end_tag('div'); - //} + } $content .= html_writer::end_tag('div'); // End summary. return $content;