]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18910 normalised module intro and introformat
authorskodak <skodak>
Mon, 20 Apr 2009 19:42:38 +0000 (19:42 +0000)
committerskodak <skodak>
Mon, 20 Apr 2009 19:42:38 +0000 (19:42 +0000)
13 files changed:
mod/resource/backuplib.php
mod/resource/db/install.xml
mod/resource/db/upgrade.php
mod/resource/index.php
mod/resource/mod_form.php
mod/resource/restorelib.php
mod/resource/type/directory/resource.class.php
mod/resource/type/file/resource.class.php
mod/resource/type/html/resource.class.php
mod/resource/type/ims/resource.class.php
mod/resource/type/repository/resource.class.php
mod/resource/type/text/resource.class.php
mod/resource/version.php

index 73ad6b43603c69939d0f60a9643000c5412565fb..fdd9d373b220a811c3bcf5bad1340c8485c2bf14 100644 (file)
@@ -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));
index 865f9ce323e9946209b46645bcbcb82e93fe6283..546fcd03fe563d552294a084e2baa1a661a8d0c9 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/resource/db" VERSION="20070120" COMMENT="XMLDB file for Moodle mod/resource"
+<XMLDB PATH="mod/resource/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/resource"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
         <FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
         <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="type"/>
         <FIELD NAME="type" TYPE="char" LENGTH="30" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="reference"/>
-        <FIELD NAME="reference" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="type" NEXT="summary"/>
-        <FIELD NAME="summary" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="reference" NEXT="alltext"/>
-        <FIELD NAME="alltext" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="summary" NEXT="popup"/>
+        <FIELD NAME="reference" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="type" NEXT="intro"/>
+        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" ENUM="false" PREVIOUS="reference" NEXT="introformat"/>
+        <FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="alltext"/>
+        <FIELD NAME="alltext" TYPE="text" LENGTH="medium" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="popup"/>
         <FIELD NAME="popup" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="alltext" NEXT="options"/>
         <FIELD NAME="options" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="popup" NEXT="timemodified"/>
         <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="options"/>
       </FIELDS>
       <KEYS>
-        <KEY NAME="primary" TYPE="primary" FIELDS="id" />
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 8a00a2c7c1a84d90b0aaccfcbf454414f22c3217..fe60af212801af15ee128561e0621231dc7b85ad 100644 (file)
@@ -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;
 }
 
index 36810f67dc218c8b55d6b46f1572f9586a534710..15d85d9e4e88455dd401a98047d40744afce8a9d 100644 (file)
@@ -48,6 +48,7 @@
 
     $currentsection = "";
     $options->para = false;
+    $options->noclean = true;
     foreach ($resources as $resource) {
         if ($course->format == "weeks" or $course->format == "topics") {
             $printsection = "";
         if (!$resource->visible) {      // Show dimmed if the mod is hidden
             $table->data[] = array ($printsection, 
                     "<a class=\"dimmed\" $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
-                    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, 
                     "<a $extra href=\"view.php?id=$resource->coursemodule\">".format_string($resource->name,true)."</a>",
-                    format_text($resource->summary, FORMAT_MOODLE, $options) );
+                    format_text($resource->intro, $resource->introformat, $options) );
         }
     }
 
index 7df033326af10b6ba0db8cab1b1183c943e19362..5078e7cf0a026b42a087da39bf6b1d67553c9f8d 100644 (file)
@@ -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');
 
index 5c382e27e868101fa11d04ab381e23cedaf5c880..6d78e4316b624cf75a831b1ff48446e50099c337 100644 (file)
@@ -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']['#']);
         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);
                 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()) {
index 23bac67571b80d1e62f48220daf02f4708c4e398..f6a2eda765b9dd1d31bf9db440d0e621b361f9a4 100644 (file)
@@ -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);
     }
 
index af0fa10b68e129f1c6c19c71d1c7983f765b4412..3a63b422487721a652790bf5db52bdb69eba9d2f 100644 (file)
@@ -364,8 +364,8 @@ class resource_file extends resource_base {
             echo "\n-->\n";
             echo '</script>';
 
-            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 = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;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 {
                       </script>
                 ';
 
-            ///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 "</body></html>";
                 exit;
@@ -491,7 +491,8 @@ class resource_file extends resource_base {
 
             $options = new object();
             $options->para = false;
-            echo '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $options).'</div>';
+            $options->noclean = true;
+            echo '<div class="summary">'.format_text($resource->intro, $resource->introformat, $options).'</div>';
             if (!empty($localpath)) {  // Show some help
                 echo '<div class="mdl-right helplink">';
                 link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'),
@@ -704,8 +705,8 @@ class resource_file extends resource_base {
                 echo '</div>';
             }
 
-            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) {
index a97e13b76e321574bd129359d3e159a51451520a..20097e0fffa18d2e21798bb5f939e690bcefb342 100644 (file)
@@ -102,8 +102,8 @@ function display() {
                 echo "\n//]]>\n";
                 echo '</script>';
 
-                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 = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
index 2e97e3c4a71c20f15059dd56b604bc85de966d73..0a31abb64993b4f1b15cead0e850ac591fda7cf9 100644 (file)
@@ -434,8 +434,8 @@ class resource_ims extends resource_base {
             echo "\n-->\n";
             echo '</script>';
 
-            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 = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
index dc665510af871e0ab0ae96b63b17c6fec079d855..f610d336c6bb2c26f07dc75b605b18f49007af0c 100644 (file)
@@ -313,9 +313,9 @@ function display() {
         echo "\n-->\n";
         echo '</script>';
 
-        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 = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
@@ -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 '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $formatoptions).'</div>';
+        echo '<div class="summary">'.format_text($resource->intro, $resource->introformat, $formatoptions).'</div>';
         if (!empty($localpath)) {  // Show some help
             echo '<div class="mdl-right helplink">';
             link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
index fd6fb20a5510a183255e5f8f2b87023310a36420..01aa639eb07f21d17676e9767af7f41d9418802b 100644 (file)
@@ -100,8 +100,8 @@ function display() {
                 echo "\n//]]>\n";
                 echo '</script>';
 
-                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");
                 }
 
                 $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" onclick=\"this.target='resource{$resource->id}'; return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
index 5d5ddbc697aa08bbbaec398d4b8e508947835556..dfebaf1e04f09ee82469e76e2cf608c7ff482f5e 100644 (file)
@@ -5,8 +5,8 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2008081100;
-$module->requires = 2008080701;  // Requires this Moodle version
+$module->version  = 2009042001;
+$module->requires = 2009041700;  // Requires this Moodle version
 $module->cron     = 0;
 
 ?>