2006-12-28 09:32:45 +00:00
|
|
|
<?php // $Id$
|
|
|
|
|
|
|
|
require_once($CFG->libdir.'/formslib.php');
|
|
|
|
|
|
|
|
class blog_edit_form extends moodleform {
|
|
|
|
|
2007-05-08 16:11:58 +00:00
|
|
|
function definition() {
|
|
|
|
global $CFG, $COURSE, $USER;
|
2008-06-01 13:48:12 +00:00
|
|
|
|
2007-05-08 16:11:58 +00:00
|
|
|
$mform =& $this->_form;
|
2006-12-28 09:32:45 +00:00
|
|
|
|
2007-05-08 16:11:58 +00:00
|
|
|
$post = $this->_customdata['existing'];
|
2006-12-28 09:32:45 +00:00
|
|
|
$sitecontext = $this->_customdata['sitecontext'];
|
|
|
|
|
|
|
|
$mform->addElement('header', 'general', get_string('general', 'form'));
|
2007-05-08 16:11:58 +00:00
|
|
|
$mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), 'size="60"');
|
|
|
|
$mform->setType('subject', PARAM_TEXT);
|
|
|
|
$mform->addRule('subject', get_string('emptytitle', 'blog'), 'required', null, 'client');
|
2006-12-28 09:32:45 +00:00
|
|
|
|
2007-05-08 16:11:58 +00:00
|
|
|
$mform->addElement('htmleditor', 'summary', get_string('entrybody', 'blog'), array('rows'=>25));
|
|
|
|
$mform->setType('summary', PARAM_RAW);
|
|
|
|
$mform->addRule('summary', get_string('emptybody', 'blog'), 'required', null, 'client');
|
2008-09-25 10:04:01 +00:00
|
|
|
$mform->setHelpButton('summary', array('writing', 'richtext2'), false, 'editorhelpbutton');
|
2006-12-28 09:32:45 +00:00
|
|
|
|
|
|
|
$mform->addElement('format', 'format', get_string('format'));
|
|
|
|
|
|
|
|
$mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
|
|
|
|
|
|
|
|
$mform->addElement('select', 'publishstate', get_string('publishto', 'blog'), blog_applicable_publish_states());
|
2007-11-26 04:10:08 +00:00
|
|
|
$mform->setHelpButton('publishstate', array('publish_state', get_string('publishto', 'blog'), 'blog'));
|
2006-12-28 09:32:45 +00:00
|
|
|
|
2007-08-30 09:13:36 +00:00
|
|
|
|
|
|
|
if (!empty($CFG->usetags)) {
|
2008-02-25 01:58:17 +00:00
|
|
|
$mform->addElement('header', 'tagshdr', get_string('tags', 'tag'));
|
2009-01-16 07:08:58 +00:00
|
|
|
$mform->addElement('tags', 'tags', get_string('tags'));
|
2006-12-28 09:32:45 +00:00
|
|
|
}
|
2009-01-16 07:08:58 +00:00
|
|
|
|
2006-12-28 09:32:45 +00:00
|
|
|
$this->add_action_buttons();
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'action');
|
2007-05-08 16:11:58 +00:00
|
|
|
$mform->setType('action', PARAM_ACTION);
|
|
|
|
$mform->setDefault('action', '');
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'courseid');
|
|
|
|
$mform->setType('courseid', PARAM_INT);
|
|
|
|
|
|
|
|
$mform->addElement('hidden', 'id');
|
|
|
|
$mform->setType('id', PARAM_INT);
|
|
|
|
$mform->setDefault('id', 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function sets up options of otag select element. This is called from definition and also
|
|
|
|
* after adding new official tags with the add tag button.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function otags_select_setup(){
|
2008-06-19 09:21:45 +00:00
|
|
|
global $DB;
|
2008-06-01 13:48:12 +00:00
|
|
|
|
2007-05-08 16:11:58 +00:00
|
|
|
$mform =& $this->_form;
|
2007-08-27 08:46:00 +00:00
|
|
|
if ($otagsselect =& $mform->getElement('otags')) {
|
|
|
|
$otagsselect->removeOptions();
|
|
|
|
}
|
2008-02-25 05:32:10 +00:00
|
|
|
$namefield = empty($CFG->keeptagnamecase) ? 'name' : 'rawname';
|
2008-06-19 09:21:45 +00:00
|
|
|
if ($otags = $DB->get_records_sql_menu("SELECT id, $namefield FROM {tag} WHERE tagtype='official' ORDER by $namefield ASC")) {
|
2006-12-28 09:32:45 +00:00
|
|
|
$otagsselect->loadArray($otags);
|
|
|
|
}
|
2008-06-19 09:21:45 +00:00
|
|
|
|
2007-05-08 16:11:58 +00:00
|
|
|
}
|
2006-12-28 09:32:45 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
?>
|