]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18910 normalised module intro and introformat
authorskodak <skodak>
Mon, 20 Apr 2009 20:14:15 +0000 (20:14 +0000)
committerskodak <skodak>
Mon, 20 Apr 2009 20:14:15 +0000 (20:14 +0000)
mod/wiki/backuplib.php
mod/wiki/db/install.xml
mod/wiki/db/upgrade.php
mod/wiki/index.php
mod/wiki/mod_form.php
mod/wiki/restorelib.php
mod/wiki/version.php
mod/wiki/view.php

index 80ea626527f31b4bc02125b823a883eb62282244..78b2d12a2a82e535837038785cb3e074b0506857 100644 (file)
@@ -55,7 +55,7 @@
         fwrite ($bf,full_tag("ID",4,false,$wiki->id));
         fwrite ($bf,full_tag("MODTYPE",4,false,"wiki"));
         fwrite ($bf,full_tag("NAME",4,false,$wiki->name));
-        fwrite ($bf,full_tag("SUMMARY",4,false,$wiki->summary));
+        fwrite ($bf,full_tag("SUMMARY",4,false,$wiki->intro));
         fwrite ($bf,full_tag("PAGENAME",4,false,$wiki->pagename));
         fwrite ($bf,full_tag("WTYPE",4,false,$wiki->wtype));
         fwrite ($bf,full_tag("EWIKIPRINTTITLE",4,false,$wiki->ewikiprinttitle));
index 742ec0f2b55b6d525efb2e7d3defda2ee3a63f60..21095d0a8ef1672a40b1be08722a8e50e2d4f1f5 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/wiki/db" VERSION="20060925" COMMENT="XMLDB file for Moodle mod/wiki"
+<XMLDB PATH="mod/wiki/db" VERSION="20090420" COMMENT="XMLDB file for Moodle mod/wiki"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
@@ -8,9 +8,10 @@
       <FIELDS>
         <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
         <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="summary"/>
-        <FIELD NAME="summary" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="pagename"/>
-        <FIELD NAME="pagename" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="summary" NEXT="wtype"/>
+        <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="intro"/>
+        <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="introformat"/>
+        <FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="intro text field format" PREVIOUS="intro" NEXT="pagename"/>
+        <FIELD NAME="pagename" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="introformat" NEXT="wtype"/>
         <FIELD NAME="wtype" TYPE="char" LENGTH="20" NOTNULL="true" DEFAULT="group" SEQUENCE="false" ENUM="true" ENUMVALUES="'teacher', 'group', 'student'" PREVIOUS="pagename" NEXT="ewikiprinttitle"/>
         <FIELD NAME="ewikiprinttitle" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" ENUM="false" PREVIOUS="wtype" NEXT="htmlmode"/>
         <FIELD NAME="htmlmode" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="ewikiprinttitle" NEXT="ewikiacceptbinary"/>
@@ -24,7 +25,7 @@
         <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="initialcontent"/>
       </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"/>
@@ -94,4 +95,4 @@
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 86bb4c28e48a4d0946cd56b39716d003ab6747ad..0120a1aa5835cc5d78a928ebcca94d8413fab16b 100644 (file)
@@ -28,6 +28,32 @@ function xmldb_wiki_upgrade($oldversion) {
 
 //===== 1.9.0 upgrade line ======//
 
+    if ($result && $oldversion < 2009042000) {
+
+    /// Rename field summary on table wiki to intro
+        $table = new xmldb_table('wiki');
+        $field = new xmldb_field('summary', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
+
+    /// Launch rename field summary
+        $dbman->rename_field($table, $field, 'intro');
+
+    /// wiki savepoint reached
+        upgrade_mod_savepoint($result, 2009042000, 'wiki');
+    }
+
+    if ($result && $oldversion < 2009042001) {
+
+    /// Define field introformat to be added to wiki
+        $table = new xmldb_table('wiki');
+        $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);
+
+    /// wiki savepoint reached
+        upgrade_mod_savepoint($result, 2009042001, 'wiki');
+    }
+
     return $result;
 }
 
index 89a2fe9c377ffac689778e91e917884dca37396d..35e1888b5421d0ffbe908eb8b8f979c70ad2e7b6 100644 (file)
@@ -68,7 +68,8 @@
         }
 
         $timmod = '<span class="smallinfo">'.userdate($wiki->timemodified).'</span>';
-        $summary = '<div class="smallinfo">'.format_text($wiki->summary).'</div>';
+        $options = (object)array('noclean'=>true);
+        $summary = '<div class="smallinfo">'.format_text($wiki->intro, $wiki->introformat, $options).'</div>';
 
         $site = get_site();
         switch ($wiki->wtype) {
index 7f2b86f06ecec064b426093d8dba613b9f2efc00..7a2115121171dd06a4cebea0bdff104362518f0c 100644 (file)
@@ -21,10 +21,10 @@ class mod_wiki_mod_form extends moodleform_mod {
         $mform->setType('name', PARAM_NOTAGS);
         $mform->addRule('name', null, 'required', null, 'client');
 
-        $mform->addElement('htmleditor', 'summary', get_string('summary'));
-        $mform->setType('summary', PARAM_RAW);
-        $mform->setHelpButton('summary', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
-        $mform->addRule('summary', get_string('required'), 'required', null, 'client');
+        $mform->addElement('htmleditor', 'intro', get_string('summary'));
+        $mform->setType('intro', PARAM_RAW);
+        $mform->setHelpButton('intro', array('writing', 'questions', 'richtext2'), false, 'editorhelpbutton');
+        $mform->addRule('intro', get_string('required'), 'required', null, 'client');
 
         if (!$wikihasentries){
             asort($WIKI_TYPES);
index 43dbe15b06ee1974de4d4d86519985deac022eab..c2f989f747f305641a6e4a1a4bfdce78e7c97098 100644 (file)
@@ -44,7 +44,7 @@
             //Now, build the wiki record structure
             $wiki->course = $restore->course_id;
             $wiki->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
-            $wiki->summary = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
+            $wiki->intro = backup_todb($info['MOD']['#']['SUMMARY']['0']['#']);
             $wiki->pagename = backup_todb($info['MOD']['#']['PAGENAME']['0']['#']);
             $wiki->wtype = backup_todb($info['MOD']['#']['WTYPE']['0']['#']);
             $wiki->ewikiprinttitle = backup_todb($info['MOD']['#']['EWIKIPRINTTITLE']['0']['#']);
index 5e54bf758428682597a3e7b9714d2af6d7d6f03b..a452a7e55e88505013e4040a694ebdcbfd207130 100644 (file)
@@ -5,8 +5,8 @@
 ///  This fragment is called by moodle_needs_upgrading() and /admin/index.php
 /////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007101509;  // The current module version (Date: YYYYMMDDXX)
-$module->requires = 2007101509;  // The current module version (Date: YYYYMMDDXX)
+$module->version  = 2009042001;  // The current module version (Date: YYYYMMDDXX)
+$module->requires = 2009041700;  // The current module version (Date: YYYYMMDDXX)
 $module->cron     = 3600;        // Period for cron to check this module (secs)
 
 ?>
index d92e416d002bc97e25cff98059ba067b8e04d2e2..33dccfafedb0c7fabd63467a11a2adafccb461bc 100644 (file)
     <div id="wiki-view" class="mwiki">
     ';
 
-    if($wiki_entry && $ewiki_title==$wiki_entry->pagename && !empty($wiki->summary)) {
-      if (trim(strip_tags($wiki->summary))) {
-          print_box(format_text($wiki->summary, FORMAT_MOODLE), 'generalbox', 'intro');
+    if($wiki_entry && $ewiki_title==$wiki_entry->pagename && !empty($wiki->intro)) {
+      if (trim(strip_tags($wiki->intro))) {
+          $options = (object)array('noclean'=>true);
+          print_box(format_text($wiki->intro, $wiki->introformat, $options), 'generalbox', 'intro');
       }
     }