]> git.mjollnir.org Git - moodle.git/commitdiff
blocks: MDL-19889 Convert blog tags block to use edit_form.php
authortjhunt <tjhunt>
Wed, 29 Jul 2009 05:12:47 +0000 (05:12 +0000)
committertjhunt <tjhunt>
Wed, 29 Jul 2009 05:12:47 +0000 (05:12 +0000)
blocks/blog_tags/block_blog_tags.php
blocks/blog_tags/config_instance.html [deleted file]
blocks/blog_tags/edit_form.php [new file with mode: 0644]

index 3a1286e9f26dd9854253e4d42e1d912e09d43929..6b410d4bf882941e618d3b6cbe5f7605d82bcb90 100644 (file)
@@ -150,38 +150,6 @@ class block_blog_tags extends block_base {
         }
         return $this->content;
     }
-
-    function instance_config_print() {
-        global $CFG;
-
-    /// set up the numberoftags select field
-        $numberoftags = array();
-        for($i=1;$i<=50;$i++) $numberoftags[$i] = $i;
-
-    //// set up the timewithin select field
-        $timewithin = array();
-        $timewithin[10]  = get_string('numdays', '', 10);
-        $timewithin[30]  = get_string('numdays', '', 30);
-        $timewithin[60]  = get_string('numdays', '', 60);
-        $timewithin[90]  = get_string('numdays', '', 90);
-        $timewithin[120] = get_string('numdays', '', 120);
-        $timewithin[240] = get_string('numdays', '', 240);
-        $timewithin[365] = get_string('numdays', '', 365);
-
-    /// set up sort select field
-        $sort = array();
-        $sort['name'] = get_string('tagtext', 'blog');
-        $sort['id']   = get_string('tagdatelastused', 'blog');
-
-
-        if (is_file($CFG->dirroot .'/blocks/'. $this->name() .'/config_instance.html')) {
-            print_simple_box_start('center', '', '', 5, 'blockconfigglobal');
-            include($CFG->dirroot .'/blocks/'. $this->name() .'/config_instance.html');
-            print_simple_box_end();
-        } else {
-            notice(get_string('blockconfigbad'), str_replace('blockaction=', 'dummy=', qualified_me()));
-        }
-    }
 }
 
 function blog_tags_sort($a, $b) {
diff --git a/blocks/blog_tags/config_instance.html b/blocks/blog_tags/config_instance.html
deleted file mode 100644 (file)
index dd1eb66..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-    if (empty($this->config->title)) {
-        $this->config->title = get_string('blogtags', 'blog');
-    }
-    if (empty($this->config->timewithin)) {
-        $this->config->timewithin = BLOGDEFAULTTIMEWITHIN;
-    }
-    if (empty($this->config->numberoftags)) {
-        $this->config->numberoftags = BLOGDEFAULTNUMBEROFTAGS;
-    }
-    if (empty($this->config->sort)) {
-        $this->config->sort = BLOGDEFAULTSORT;
-    }
-?>
-
-<table cellpadding="9" cellspacing="0" class="blockconfigtable">
-
-<tr valign="top">
-<td align="right"><?php print_string("blocktitle","blog") ?>:</td>
-<td><input type="text" name="title" size="50" value="<?php p($this->config->title) ?>" /></td>
-</tr>
-
-<tr valign="top">
-<td align="right"><?php print_string("numberoftags","blog") ?>:</td>
-<td><?php choose_from_menu($numberoftags,"numberoftags",$this->config->numberoftags) ?></td>
-</tr>
-
-<tr valign="top">
-<td align="right"><?php print_string("timewithin","blog") ?>:</td>
-<td><?php choose_from_menu($timewithin,"timewithin",$this->config->timewithin) ?></td>
-</tr>
-
-<tr valign="top">
-<td align="right"><?php print_string("tagsort","blog") ?>:</td>
-<td><?php choose_from_menu($sort,"sort",$this->config->sort) ?></td>
-</tr>
-
-<tr>
-    <td colspan="2" align="center"><input type="submit" value="<?php print_string("savechanges") ?>" /></td>
-</tr>
-
-</table>
-
diff --git a/blocks/blog_tags/edit_form.php b/blocks/blog_tags/edit_form.php
new file mode 100644 (file)
index 0000000..dfdf772
--- /dev/null
@@ -0,0 +1,67 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/ 
+// 
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Form for editing HTML block instances.
+ *
+ * @package   moodlecore
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/**
+ * Form for editing HTML block instances.
+ *
+ * @copyright 2009 Tim Hunt
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class block_blog_tags_edit_form extends block_edit_form {
+    protected function specific_definition($mform) {
+        // Fields for editing HTML block title and contents.
+        $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
+
+        $mform->addElement('text', 'config_title', get_string('blocktitle', 'blog'));
+        $mform->setDefault('config_title', get_string('blogtags', 'blog'));
+        $mform->setType('config_title', PARAM_MULTILANG);
+
+        $numberoftags = array();
+        for($i = 1; $i <= 50; $i++) {
+            $numberoftags[$i] = $i;
+        }
+        $mform->addElement('select', 'config_numberoftags', get_string('numberoftags', 'blog'), $numberoftags);
+        $mform->setDefault('config_numberoftags', BLOGDEFAULTNUMBEROFTAGS);
+
+        $timewithin = array(
+            10  => get_string('numdays', '', 10),
+            30  => get_string('numdays', '', 30),
+            60  => get_string('numdays', '', 60),
+            90  => get_string('numdays', '', 90),
+            120 => get_string('numdays', '', 120),
+            240 => get_string('numdays', '', 240),
+            365 => get_string('numdays', '', 365),
+        );
+        $mform->addElement('select', 'config_timewithin', get_string('timewithin', 'blog'), $timewithin);
+        $mform->setDefault('config_timewithin', BLOGDEFAULTTIMEWITHIN);
+
+        $sort = array(
+            'name' => get_string('tagtext', 'blog'),
+            'id'   => get_string('tagdatelastused', 'blog'),
+        );
+        $mform->addElement('select', 'config_sort', get_string('tagsort', 'blog'), $sort);
+        $mform->setDefault('config_sort', BLOGDEFAULTSORT);
+    }
+}
\ No newline at end of file