]> git.mjollnir.org Git - moodle.git/commitdiff
migrated journal/mod.html to formslib
authorjamiesensei <jamiesensei>
Tue, 14 Nov 2006 06:01:11 +0000 (06:01 +0000)
committerjamiesensei <jamiesensei>
Tue, 14 Nov 2006 06:01:11 +0000 (06:01 +0000)
mod/journal/mod.html [deleted file]
mod/journal/mod_form.php [new file with mode: 0644]

diff --git a/mod/journal/mod.html b/mod/journal/mod.html
deleted file mode 100644 (file)
index 270e098..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-    if (!isset($form->name)) {
-        $form->name = '';
-    }
-    if (!isset($form->intro)) {
-        $form->intro = '';
-    }
-    if (!isset($form->assessed)) {
-        $form->assessed = '0';
-    }
-    if (!isset($form->days)) {
-        if ($course->format == 'weeks') {
-            $form->days = '7';
-        } else {
-            $form->days = '0';
-        }
-    }
-?>
-
-<form name="form" method="post" action="mod.php">
-<table cellpadding="5">
-<tr valign="top">
-    <td align="right"><strong><?php print_string('journalname', 'journal') ?>:</strong></td>
-    <td>
-        <input type="text" name="name" size="30" value="<?php p($form->name) ?>" alt="<?php print_string('journalname', 'journal') ?>"/>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><strong><?php print_string('journalquestion', 'journal') ?>:</strong>
-     <?php
-        echo '<br />';
-        helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
-        echo '<br />';
-        helpbutton('questions', get_string('helpquestions'), 'moodle', true, true);
-        echo '<br />';
-        if ($usehtmleditor) {
-           helpbutton('richtext', get_string('helprichtext'), 'moodle', true, true);
-        } else {
-           emoticonhelpbutton('form', 'intro');
-        } 
-        echo '<br />';
-      ?>
-    </td>
-    <td>
-    <?php
-       print_textarea($usehtmleditor, 20, 60, 680, 400, 'intro', $form->intro);
-
-       if ($usehtmleditor) {
-           echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
-       } else {
-           echo '<p align="right">';
-           helpbutton('textformat', get_string('formattexttype'));
-           print_string('formattexttype');
-           echo ':&nbsp;';
-           if (!$form->introformat) {
-               $form->introformat = $defaultformat;
-           }
-           choose_from_menu(format_text_menu(), 'introformat', $form->introformat, '');
-           echo "</p>";
-       }
-    ?>
-    </td>
-</tr>
-
-
-<tr valign="top">
-    <td align="right"><strong><?php print_string('grade') ?>:</strong></td>
-    <td>
-        <?php
-        print_grade_menu($course->id, 'assessed', "$form->assessed");
-        ?>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right"><strong><?php print_string('daysavailable', 'journal') ?>:</strong></td>
-    <td>
-    <?php
-        $options = array();
-        $options[0] = get_string('alwaysopen', 'journal');
-        for ($i=1;$i<=13;$i++) {
-            $options[$i] = get_string('numdays', '', $i);
-        }
-        for ($i=2;$i<=16;$i++) {
-            $days = $i * 7;
-            $options[$days] = get_string('numweeks', '', $i);
-        }
-        $options[365] = get_string('numweeks', '', 52);
-        choose_from_menu($options, 'days', "$form->days");
-     ?>
-    </td>
-</tr>
-<?php print_standard_coursemodule_settings($form); ?>
-</table>
-<center>
-<input type="hidden" name="course"        value="<?php p($form->course) ?>" />
-<input type="hidden" name="sesskey"       value="<?php p($form->sesskey) ?>" />
-<input type="hidden" name="coursemodule"  value="<?php p($form->coursemodule) ?>" />
-<input type="hidden" name="section"       value="<?php p($form->section) ?>" />
-<input type="hidden" name="module"        value="<?php p($form->module) ?>" />
-<input type="hidden" name="modulename"    value="<?php p($form->modulename) ?>" />
-<input type="hidden" name="instance"      value="<?php p($form->instance) ?>" />
-<input type="hidden" name="mode"          value="<?php p($form->mode) ?>" />
-<input type="submit" value="<?php print_string('savechanges') ?>" />
-<input type="submit" name="cancel" value="<?php print_string('cancel') ?>" />
-</center>
-</form>
diff --git a/mod/journal/mod_form.php b/mod/journal/mod_form.php
new file mode 100644 (file)
index 0000000..3d67966
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+require_once ($CFG->libdir.'/formslib.php');
+class journal_mod_form extends moodleform_mod {
+
+       function definition() {
+
+               global $CFG, $COURSE;
+               $mform    =& $this->_form;
+               $renderer =& $mform->defaultRenderer();
+
+//-------------------------------------------------------------------------------
+        $mform->addElement('header', 'general', get_string('general', 'form'));
+
+        $mform->addElement('text', 'name', get_string('journalname', 'journal'));
+               $mform->setType('name', PARAM_TEXT);
+               $mform->addRule('name', null, 'required', null, 'client');
+
+       $mform->addElement('htmleditor', 'intro', get_string('journalquestion', 'journal'));
+               $mform->setType('intro', PARAM_RAW);
+               $mform->addRule('intro', get_string('required'), 'required', null, 'client');
+
+        $mform->addElement('format', 'format', get_string('format'));
+
+        $mform->addElement('modgrade', 'assessed', get_string('grade'), false);
+        $mform->setDefault('assessed', 0);
+
+        $options = array();
+        $options[0] = get_string('alwaysopen', 'journal');
+        for ($i=1;$i<=13;$i++) {
+            $options[$i] = get_string('numdays', '', $i);
+        }
+        for ($i=2;$i<=16;$i++) {
+            $days = $i * 7;
+            $options[$days] = get_string('numweeks', '', $i);
+        }
+        $options[365] = get_string('numweeks', '', 52);
+        $mform->addElement('select', 'days', get_string('daysavailable', 'journal'), $options);
+        if ($COURSE->format == 'weeks') {
+            $mform->setDefault('days', '7');
+        } else {
+            $mform->setDefault('days', '0');
+        }
+
+//-------------------------------------------------------------------------------
+               $this->standard_coursemodule_elements();
+//-------------------------------------------------------------------------------
+
+        $buttonarray=array();
+        $buttonarray[] = &MoodleQuickForm::createElement('submit', 'submit', get_string('savechanges'));
+        $buttonarray[] = &MoodleQuickForm::createElement('submit', 'cancel', get_string('cancel'));
+        $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
+               $renderer->addStopFieldsetElements('buttonar');
+       }
+
+
+
+}
+?>
\ No newline at end of file