Skip to content

Commit

Permalink
MDL-18910 normalised module intro and introformat
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Apr 20, 2009
1 parent 9f0e60e commit 8b6f809
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion mod/wiki/backuplib.php
Expand Up @@ -55,7 +55,7 @@ function wiki_backup_one_mod($bf,$preferences,$wiki) {
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));
Expand Down
13 changes: 7 additions & 6 deletions mod/wiki/db/install.xml
@@ -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"
>
Expand All @@ -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"/>
Expand All @@ -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"/>
Expand Down Expand Up @@ -94,4 +95,4 @@
</INDEXES>
</TABLE>
</TABLES>
</XMLDB>
</XMLDB>
26 changes: 26 additions & 0 deletions mod/wiki/db/upgrade.php
Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion mod/wiki/index.php
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions mod/wiki/mod_form.php
Expand Up @@ -21,10 +21,10 @@ function definition() {
$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);
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/restorelib.php
Expand Up @@ -44,7 +44,7 @@ function wiki_restore_mods($mod,$restore) {
//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']['#']);
Expand Down
4 changes: 2 additions & 2 deletions mod/wiki/version.php
Expand Up @@ -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)

?>
7 changes: 4 additions & 3 deletions mod/wiki/view.php
Expand Up @@ -345,9 +345,10 @@
<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');
}
}

Expand Down

0 comments on commit 8b6f809

Please sign in to comment.