mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-74350 usertours: Prevent adding unnecessary breaktags to the content
This commit is contained in:
parent
ad6dc71c56
commit
d506386d32
@ -214,7 +214,7 @@ class editstep extends \moodleform {
|
||||
if ($data->contenttype == static::CONTENTTYPE_LANGSTRING) {
|
||||
$data->content = [
|
||||
'text' => $data->contentlangstring,
|
||||
'format' => FORMAT_HTML,
|
||||
'format' => FORMAT_MOODLE,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -866,10 +866,10 @@ class manager {
|
||||
// the format filename => version. The version value needs to
|
||||
// be increased if the tour has been updated.
|
||||
$shippedtours = [
|
||||
'40_tour_navigation_dashboard.json' => 2,
|
||||
'40_tour_navigation_mycourse.json' => 2,
|
||||
'40_tour_navigation_course_teacher.json' => 1,
|
||||
'40_tour_navigation_course_student.json' => 1,
|
||||
'40_tour_navigation_dashboard.json' => 4,
|
||||
'40_tour_navigation_mycourse.json' => 4,
|
||||
'40_tour_navigation_course_teacher.json' => 3,
|
||||
'40_tour_navigation_course_student.json' => 3,
|
||||
];
|
||||
|
||||
// These are tours that we used to ship but don't ship any longer.
|
||||
|
@ -88,8 +88,6 @@ class step implements \renderable {
|
||||
'element' => $step->get_target()->convert_to_css(),
|
||||
];
|
||||
|
||||
$result->content = str_replace("\n", "<br>\n", $result->content);
|
||||
|
||||
foreach ($step->get_config_keys() as $key) {
|
||||
$result->$key = $step->get_config($key);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ class step {
|
||||
$this->title = $record->title;
|
||||
$this->content = $record->content;
|
||||
}
|
||||
$this->contentformat = isset($record->contentformat) ? $record->contentformat : 1;
|
||||
$this->contentformat = isset($record->contentformat) ? $record->contentformat : FORMAT_MOODLE;
|
||||
$this->targettype = $record->targettype;
|
||||
$this->targetvalue = $record->targetvalue;
|
||||
$this->sortorder = $record->sortorder;
|
||||
|
@ -26,7 +26,7 @@
|
||||
<FIELD NAME="tourid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
|
||||
<FIELD NAME="title" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Title of the step"/>
|
||||
<FIELD NAME="content" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Content of the user tour - allow for multilang tags"/>
|
||||
<FIELD NAME="contentformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="1" SEQUENCE="false"/>
|
||||
<FIELD NAME="contentformat" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
<FIELD NAME="targettype" TYPE="int" LENGTH="2" NOTNULL="true" SEQUENCE="false" COMMENT="Type of the target (e.g. block, CSS selector, etc.)"/>
|
||||
<FIELD NAME="targetvalue" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="The value for the specified target type."/>
|
||||
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
|
||||
|
@ -100,26 +100,33 @@ function xmldb_tool_usertours_upgrade($oldversion) {
|
||||
upgrade_plugin_savepoint(true, 2021100700, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
if ($oldversion < 2021101300) {
|
||||
if ($oldversion < 2022040601) {
|
||||
// Define field contentformat to be added to tool_usertours_steps.
|
||||
$table = new xmldb_table('tool_usertours_steps');
|
||||
$field = new xmldb_field('contentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '1', 'content');
|
||||
$field = new xmldb_field('contentformat', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, FORMAT_MOODLE, 'content');
|
||||
|
||||
// Conditionally launch add field contentformat.
|
||||
if (!$dbman->field_exists($table, $field)) {
|
||||
$dbman->add_field($table, $field);
|
||||
} else {
|
||||
// Field was added by previous upgrade step with the default value is FORMAT_HTML.
|
||||
// Need to drop the field and re-create with the new structure to make sure all the existing tours use FORMAT_MOODLE.
|
||||
// FORMAT_MOODLE will force the external_format_text method to use nl2br to convert the new line to line break tag.
|
||||
$dbman->drop_field($table, $field);
|
||||
// Add the field again.
|
||||
$dbman->add_field($table, $field);
|
||||
}
|
||||
|
||||
// Usertours savepoint reached.
|
||||
upgrade_plugin_savepoint(true, 2021101300, 'tool', 'usertours');
|
||||
upgrade_plugin_savepoint(true, 2022040601, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
if ($oldversion < 2021101303) {
|
||||
if ($oldversion < 2022040602) {
|
||||
// Update shipped tours.
|
||||
// Normally, we just bump the version numbers because we need to call update_shipped_tours only once.
|
||||
manager::update_shipped_tours();
|
||||
|
||||
upgrade_plugin_savepoint(true, 2021101303, 'tool', 'usertours');
|
||||
upgrade_plugin_savepoint(true, 2022040602, 'tool', 'usertours');
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -24,6 +24,6 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->version = 2021101303; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2022040602; // The current module version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2021052500; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_usertours'; // Full name of the plugin (used for diagnostics).
|
||||
|
Loading…
x
Reference in New Issue
Block a user