From: tjhunt Date: Wed, 29 Jul 2009 05:12:47 +0000 (+0000) Subject: blocks: MDL-19889 Convert blog tags block to use edit_form.php X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=603c0789cb2d60c4d11d65a6d354f2b5c4338178;p=moodle.git blocks: MDL-19889 Convert blog tags block to use edit_form.php --- diff --git a/blocks/blog_tags/block_blog_tags.php b/blocks/blog_tags/block_blog_tags.php index 3a1286e9f2..6b410d4bf8 100644 --- a/blocks/blog_tags/block_blog_tags.php +++ b/blocks/blog_tags/block_blog_tags.php @@ -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 index dd1eb665b4..0000000000 --- a/blocks/blog_tags/config_instance.html +++ /dev/null @@ -1,43 +0,0 @@ -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; - } -?> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
:
:config->numberoftags) ?>
:config->timewithin) ?>
:config->sort) ?>
" />
- diff --git a/blocks/blog_tags/edit_form.php b/blocks/blog_tags/edit_form.php new file mode 100644 index 0000000000..dfdf772cbc --- /dev/null +++ b/blocks/blog_tags/edit_form.php @@ -0,0 +1,67 @@ +. + +/** + * 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