#170 Elements now respect filters

This commit is contained in:
Mark Nelson 2018-06-06 20:38:08 +08:00
parent 9352c969ad
commit 808ac9bc3d
5 changed files with 23 additions and 7 deletions

View file

@ -57,7 +57,8 @@ class element extends \mod_customcert\element {
public function render_html() {
global $COURSE;
return \mod_customcert\element_helper::render_html_content($this, $COURSE->fullname);
$categoryname = format_string($COURSE->fullname, true, ['context' => \context_course::instance($COURSE->id)]);
return \mod_customcert\element_helper::render_html_content($this, $categoryname);
}
/**
@ -74,9 +75,10 @@ class element extends \mod_customcert\element {
// Check that there is a course category available.
if (!empty($course->category)) {
return $DB->get_field('course_categories', 'name', array('id' => $course->category), MUST_EXIST);
$categoryname = $DB->get_field('course_categories', 'name', array('id' => $course->category), MUST_EXIST);
return format_string($categoryname, true, ['context' => \context_course::instance($courseid)]);
} else { // Must be in a site template.
return $SITE->fullname;
return format_string($SITE->fullname, true, ['context' => \context_system::instance()]);
}
}
}

View file

@ -46,7 +46,8 @@ class element extends \mod_customcert\element {
$courseid = \mod_customcert\element_helper::get_courseid($this->get_id());
$course = get_course($courseid);
\mod_customcert\element_helper::render_content($pdf, $this, $course->fullname);
$coursename = format_string($course->fullname, true, ['context' => \context_course::instance($courseid)]);
\mod_customcert\element_helper::render_content($pdf, $this, $coursename);
}
/**
@ -60,6 +61,7 @@ class element extends \mod_customcert\element {
public function render_html() {
global $COURSE;
return \mod_customcert\element_helper::render_html_content($this, $COURSE->fullname);
$coursename = format_string($COURSE->fullname, true, ['context' => \context_course::instance($COURSE->id)]);
return \mod_customcert\element_helper::render_html_content($this, $coursename);
}
}

View file

@ -82,7 +82,9 @@ class element extends \mod_customcert\element {
$module = $DB->get_record('modules', array('id' => $cm->module), '*', MUST_EXIST);
// Get the name of the item.
$courseid = \mod_customcert\element_helper::get_courseid($this->get_data());
$itemname = $DB->get_field($module->name, 'name', array('id' => $cm->instance), MUST_EXIST);
$itemname = format_string($itemname, true, ['context' => \context_course::instance($courseid)]);
\mod_customcert\element_helper::render_content($pdf, $this, $itemname);
}
@ -106,7 +108,9 @@ class element extends \mod_customcert\element {
$module = $DB->get_record('modules', array('id' => $cm->module), '*', MUST_EXIST);
// Get the name of the item.
$courseid = \mod_customcert\element_helper::get_courseid($this->get_data());
$itemname = $DB->get_field($module->name, 'name', array('id' => $cm->instance), MUST_EXIST);
$itemname = format_string($itemname, true, ['context' => \context_course::instance($courseid)]);
return \mod_customcert\element_helper::render_html_content($this, $itemname);
}

View file

@ -67,7 +67,9 @@ class element extends \mod_customcert\element {
* @param \stdClass $user the user we are rendering this for
*/
public function render($pdf, $preview, $user) {
\mod_customcert\element_helper::render_content($pdf, $this, $this->get_data());
$courseid = \mod_customcert\element_helper::get_courseid($this->get_id());
$text = format_text($this->get_data(), FORMAT_MOODLE, ['context' => \context_course::instance($courseid)]);
\mod_customcert\element_helper::render_content($pdf, $this, $text);
}
/**
@ -79,7 +81,9 @@ class element extends \mod_customcert\element {
* @return string the html
*/
public function render_html() {
return \mod_customcert\element_helper::render_html_content($this, $this->get_data());
$courseid = \mod_customcert\element_helper::get_courseid($this->get_id());
$text = format_text($this->get_data(), FORMAT_MOODLE, ['context' => \context_course::instance($courseid)]);
return \mod_customcert\element_helper::render_html_content($this, $text);
}
/**

View file

@ -119,6 +119,8 @@ class element extends \mod_customcert\element {
$value = $user->$field;
}
$courseid = \mod_customcert\element_helper::get_courseid($this->get_id());
$value = format_string($value, true, ['context' => \context_course::instance($courseid)]);
\mod_customcert\element_helper::render_content($pdf, $this, $value);
}
@ -155,6 +157,8 @@ class element extends \mod_customcert\element {
$value = $USER->$field;
}
$courseid = \mod_customcert\element_helper::get_courseid($this->get_id());
$value = format_string($value, true, ['context' => \context_course::instance($courseid)]);
return \mod_customcert\element_helper::render_html_content($this, $value);
}