PageRenderTime 59ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/moodle/blog/edit_form.php

https://bitbucket.org/geek745/moodle-db2
PHP | 90 lines | 75 code | 14 blank | 1 comment | 1 complexity | 0a9fefee1c91121c5f237e9bb5848a71 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-3-Clause, LGPL-2.0
  1. <?php // $Id: edit_form.php,v 1.8.2.5 2008/02/25 05:30:44 moodler Exp $
  2. require_once($CFG->libdir.'/formslib.php');
  3. class blog_edit_form extends moodleform {
  4. function definition() {
  5. global $CFG, $COURSE, $USER;
  6. $mform =& $this->_form;
  7. $post = $this->_customdata['existing'];
  8. $sitecontext = $this->_customdata['sitecontext'];
  9. // the upload manager is used directly in entry processing, moodleform::save_files() is not used yet
  10. $this->set_upload_manager(new upload_manager('attachment', true, false, $COURSE, false, 0, true, true, false));
  11. $mform->addElement('header', 'general', get_string('general', 'form'));
  12. $mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), 'size="60"');
  13. $mform->setType('subject', PARAM_TEXT);
  14. $mform->addRule('subject', get_string('emptytitle', 'blog'), 'required', null, 'client');
  15. $mform->addElement('htmleditor', 'summary', get_string('entrybody', 'blog'), array('rows'=>25));
  16. $mform->setType('summary', PARAM_RAW);
  17. $mform->addRule('summary', get_string('emptybody', 'blog'), 'required', null, 'client');
  18. $mform->setHelpButton('summary', array('writing', 'richtext'), false, 'editorhelpbutton');
  19. $mform->addElement('format', 'format', get_string('format'));
  20. $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
  21. $mform->addElement('select', 'publishstate', get_string('publishto', 'blog'), blog_applicable_publish_states());
  22. $mform->setHelpButton('publishstate', array('publish_state', get_string('publishto', 'blog'), 'blog'));
  23. if (!empty($CFG->usetags)) {
  24. $mform->addElement('header', 'tagshdr', get_string('tags', 'tag'));
  25. $mform->createElement('select', 'otags', get_string('otags','tag'));
  26. $js_escape = array(
  27. "\r" => '\r',
  28. "\n" => '\n',
  29. "\t" => '\t',
  30. "'" => "\\'",
  31. '"' => '\"',
  32. '\\' => '\\\\'
  33. );
  34. $otagsselEl =& $mform->addElement('select', 'otags', get_string('otags', 'tag'), array(), 'size="5"');
  35. $otagsselEl->setMultiple(true);
  36. $this->otags_select_setup();
  37. $mform->addElement('textarea', 'ptags', get_string('ptags', 'tag'), array('cols'=>'40', 'rows'=>'5'));
  38. $mform->setType('ptagsadd', PARAM_NOTAGS);
  39. }
  40. $this->add_action_buttons();
  41. $mform->addElement('hidden', 'action');
  42. $mform->setType('action', PARAM_ACTION);
  43. $mform->setDefault('action', '');
  44. $mform->addElement('hidden', 'courseid');
  45. $mform->setType('courseid', PARAM_INT);
  46. $mform->addElement('hidden', 'id');
  47. $mform->setType('id', PARAM_INT);
  48. $mform->setDefault('id', 0);
  49. }
  50. /**
  51. * This function sets up options of otag select element. This is called from definition and also
  52. * after adding new official tags with the add tag button.
  53. *
  54. */
  55. function otags_select_setup(){
  56. global $CFG;
  57. $mform =& $this->_form;
  58. if ($otagsselect =& $mform->getElement('otags')) {
  59. $otagsselect->removeOptions();
  60. }
  61. $namefield = empty($CFG->keeptagnamecase) ? 'name' : 'rawname';
  62. if ($otags = get_records_sql_menu('SELECT id, '.$namefield.' from '.$CFG->prefix.'tag WHERE tagtype=\'official\' ORDER by name ASC')){
  63. $otagsselect->loadArray($otags);
  64. }
  65. }
  66. }
  67. ?>