From: skodak Date: Mon, 20 Apr 2009 19:42:38 +0000 (+0000) Subject: MDL-18910 normalised module intro and introformat X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8b6c22a657ff442862bc4e4a16c5524a14c2b979;p=moodle.git MDL-18910 normalised module intro and introformat --- diff --git a/mod/resource/backuplib.php b/mod/resource/backuplib.php index 73ad6b4360..fdd9d373b2 100644 --- a/mod/resource/backuplib.php +++ b/mod/resource/backuplib.php @@ -51,7 +51,7 @@ fwrite ($bf,full_tag("NAME",4,false,$resource->name)); fwrite ($bf,full_tag("TYPE",4,false,$resource->type)); fwrite ($bf,full_tag("REFERENCE",4,false,$resource->reference)); - fwrite ($bf,full_tag("SUMMARY",4,false,$resource->summary)); + fwrite ($bf,full_tag("SUMMARY",4,false,$resource->intro)); fwrite ($bf,full_tag("ALLTEXT",4,false,$resource->alltext)); fwrite ($bf,full_tag("POPUP",4,false,$resource->popup)); fwrite ($bf,full_tag("OPTIONS",4,false,$resource->options)); diff --git a/mod/resource/db/install.xml b/mod/resource/db/install.xml index 865f9ce323..546fcd03fe 100644 --- a/mod/resource/db/install.xml +++ b/mod/resource/db/install.xml @@ -1,5 +1,5 @@ - @@ -10,19 +10,20 @@ - - - + + + + - + - + \ No newline at end of file diff --git a/mod/resource/db/upgrade.php b/mod/resource/db/upgrade.php index 8a00a2c7c1..fe60af2128 100644 --- a/mod/resource/db/upgrade.php +++ b/mod/resource/db/upgrade.php @@ -28,6 +28,35 @@ function xmldb_resource_upgrade($oldversion) { //===== 1.9.0 upgrade line ======// + if ($result && $oldversion < 2009042000) { + + /// Rename field summary on table resource to intro + $table = new xmldb_table('resource'); + $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'reference'); + + /// Launch rename field summary + $dbman->rename_field($table, $field, 'intro'); + + /// resource savepoint reached + upgrade_mod_savepoint($result, 2009042000, 'resource'); + } + + if ($result && $oldversion < 2009042001) { + + /// Define field introformat to be added to resource + $table = new xmldb_table('resource'); + $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'intro'); + + /// Launch add field introformat + $dbman->add_field($table, $field); + + /// set format to current + $DB->set_field('resource', 'introformat', FORMAT_MOODLE, array()); + + /// resource savepoint reached + upgrade_mod_savepoint($result, 2009042001, 'resource'); + } + return $result; } diff --git a/mod/resource/index.php b/mod/resource/index.php index 36810f67dc..15d85d9e4e 100644 --- a/mod/resource/index.php +++ b/mod/resource/index.php @@ -48,6 +48,7 @@ $currentsection = ""; $options->para = false; + $options->noclean = true; foreach ($resources as $resource) { if ($course->format == "weeks" or $course->format == "topics") { $printsection = ""; @@ -71,12 +72,12 @@ if (!$resource->visible) { // Show dimmed if the mod is hidden $table->data[] = array ($printsection, "coursemodule\">".format_string($resource->name,true)."", - format_text($resource->summary, FORMAT_MOODLE, $options) ); + format_text($resource->intro, $resource->introformat, $options) ); } else { //Show normal if the mod is visible $table->data[] = array ($printsection, "coursemodule\">".format_string($resource->name,true)."", - format_text($resource->summary, FORMAT_MOODLE, $options) ); + format_text($resource->intro, $resource->introformat, $options) ); } } diff --git a/mod/resource/mod_form.php b/mod/resource/mod_form.php index 7df033326a..5078e7cf0a 100644 --- a/mod/resource/mod_form.php +++ b/mod/resource/mod_form.php @@ -38,9 +38,9 @@ class mod_resource_mod_form extends moodleform_mod { } $mform->addRule('name', null, 'required', null, 'client'); - $mform->addElement('htmleditor', 'summary', get_string('summary')); - $mform->setType('summary', PARAM_RAW); - $mform->setHelpButton('summary', array('summary', get_string('summary'), 'resource')); + $mform->addElement('htmleditor', 'intro', get_string('summary')); + $mform->setType('intro', PARAM_RAW); + $mform->setHelpButton('intro', array('summary', get_string('summary'), 'resource')); // summary should be optional again MDL-9485 //$mform->addRule('summary', get_string('required'), 'required', null, 'client'); diff --git a/mod/resource/restorelib.php b/mod/resource/restorelib.php index 5c382e27e8..6d78e4316b 100644 --- a/mod/resource/restorelib.php +++ b/mod/resource/restorelib.php @@ -37,7 +37,7 @@ $resource->name = backup_todb($info['MOD']['#']['NAME']['0']['#']); $resource->type = $info['MOD']['#']['TYPE']['0']['#']; $resource->reference = backup_todb($info['MOD']['#']['REFERENCE']['0']['#']); - $resource->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']); + $resource->intro = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']); $resource->alltext = backup_todb($info['MOD']['#']['ALLTEXT']['0']['#']); $resource->popup = backup_todb($info['MOD']['#']['POPUP']['0']['#']); $resource->options = backup_todb($info['MOD']['#']['OPTIONS']['0']['#']); @@ -203,14 +203,14 @@ global $CFG, $DB; $status = true; - if ($resources = $DB->get_records('resource', array('course'=>$restore->course_id), '', "id, alltext, summary, reference")) { + if ($resources = $DB->get_records('resource', array('course'=>$restore->course_id), '', "id, alltext, intro, reference")) { $i = 0; //Counter to send some output to the browser to avoid timeouts foreach ($resources as $resource) { //Increment counter $i++; $content1 = $resource->alltext; - $content2 = $resource->summary; + $content2 = $resource->intro; $content3 = $resource->reference; $result1 = restore_decode_content_links_worker($content1,$restore); $result2 = restore_decode_content_links_worker($content2,$restore); @@ -219,7 +219,7 @@ if ($result1 != $content1 || $result2 != $content2 || $result3 != $content3) { //Update record $resource->alltext = $result1; - $resource->summary = $result2; + $resource->intro = $result2; $resource->reference = $result3; $status = $DB->update_record("resource",$resource); if (debugging()) { diff --git a/mod/resource/type/directory/resource.class.php b/mod/resource/type/directory/resource.class.php index 23bac67571..f6a2eda765 100644 --- a/mod/resource/type/directory/resource.class.php +++ b/mod/resource/type/directory/resource.class.php @@ -90,8 +90,8 @@ function display() { navmenu($course, $cm)); - if (trim(strip_tags($resource->summary))) { - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center"); + if (trim(strip_tags($resource->intro))) { + print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center"); print_spacer(10,10); } diff --git a/mod/resource/type/file/resource.class.php b/mod/resource/type/file/resource.class.php index af0fa10b68..3a63b42248 100644 --- a/mod/resource/type/file/resource.class.php +++ b/mod/resource/type/file/resource.class.php @@ -364,8 +364,8 @@ class resource_file extends resource_base { echo "\n-->\n"; echo ''; - if (trim(strip_tags($resource->summary))) { - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center"); + if (trim(strip_tags($resource->intro))) { + print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center"); } $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" " @@ -427,7 +427,7 @@ class resource_file extends resource_base { function resizeEmbeddedHtml() { //calculate new embedded html height size '; - if (!empty($resource->summary)) { + if (!empty($resource->intro)) { echo' objectheight = YAHOO.util.Dom.getViewportHeight() - 230; '; } @@ -449,9 +449,9 @@ class resource_file extends resource_base { '; - ///print the summary - if (!empty($resource->summary)) { - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center"); + ///print the intro + if (!empty($resource->intro)) { + print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center"); } echo ""; exit; @@ -491,7 +491,8 @@ class resource_file extends resource_base { $options = new object(); $options->para = false; - echo '
'.format_text($resource->summary, FORMAT_HTML, $options).'
'; + $options->noclean = true; + echo '
'.format_text($resource->intro, $resource->introformat, $options).'
'; if (!empty($localpath)) { // Show some help echo ''; } - if (trim($resource->summary)) { - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center"); + if (trim($resource->intro)) { + print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center"); } if ($inpopup) { diff --git a/mod/resource/type/html/resource.class.php b/mod/resource/type/html/resource.class.php index a97e13b76e..20097e0fff 100644 --- a/mod/resource/type/html/resource.class.php +++ b/mod/resource/type/html/resource.class.php @@ -102,8 +102,8 @@ function display() { echo "\n//]]>\n"; echo ''; - if (trim(strip_tags($resource->summary))) { - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center clearfix"); + if (trim(strip_tags($resource->intro))) { + print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center"); } $link = "
wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true).""; diff --git a/mod/resource/type/ims/resource.class.php b/mod/resource/type/ims/resource.class.php index 2e97e3c4a7..0a31abb649 100644 --- a/mod/resource/type/ims/resource.class.php +++ b/mod/resource/type/ims/resource.class.php @@ -434,8 +434,8 @@ class resource_ims extends resource_base { echo "\n-->\n"; echo ''; - if (trim(strip_tags($resource->summary))) { - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center"); + if (trim(strip_tags($resource->intro))) { + print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center"); } $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true).""; diff --git a/mod/resource/type/repository/resource.class.php b/mod/resource/type/repository/resource.class.php index dc665510af..f610d336c6 100644 --- a/mod/resource/type/repository/resource.class.php +++ b/mod/resource/type/repository/resource.class.php @@ -313,9 +313,9 @@ function display() { echo "\n-->\n"; echo ''; - if (trim(strip_tags($resource->summary))) { + if (trim(strip_tags($resource->intro))) { $formatoptions->noclean = true; - print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center"); + print_simple_box(format_text($resource->intro, $resource->introformat, $formatoptions, $course->id), "center"); } $link = "wwwroot/mod/resource/view.php?inpopup=true&id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true).""; @@ -365,7 +365,7 @@ function display() { print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent")); - echo '
'.format_text($resource->summary, FORMAT_HTML, $formatoptions).'
'; + echo '
'.format_text($resource->intro, $resource->introformat, $formatoptions).'
'; if (!empty($localpath)) { // Show some help echo '