mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
blocks: MDL-19889 Convert blog tags block to use edit_form.php
This commit is contained in:
parent
6526cc3468
commit
603c0789cb
@ -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) {
|
||||
|
@ -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>
|
||||
|
67
blocks/blog_tags/edit_form.php
Normal file
67
blocks/blog_tags/edit_form.php
Normal file
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user