/** * Defines forms elements */ public function definition() { global $COURSE; $mform = $this->_form; // Adding the "general" fieldset, where all the common settings are showed. $mform->addElement('header', 'general', get_string('general', 'form')); // Adding the standard "name" field. $mform->addElement('text', 'name', get_string('contentname', 'content'), array('class' => 'input-xxlarge')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEAN); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); $mform->addHelpButton('name', 'contentname', 'content'); // Adding the standard "intro" and "introformat" fields. $this->add_intro_editor(); $mform->addElement('text', 'copyright', get_string('copyright', 'content'), array('class' => 'input-xxlarge')); $mform->setType('copyright', PARAM_RAW); $mform->addHelpButton('copyright', 'copyright', 'content'); // Appearance. $mform->addElement('header', 'appearancehdr', get_string('appearance')); $filemanager_options = array(); $filemanager_options['accepted_types'] = array('.jpg', '.png'); $filemanager_options['maxbytes'] = $COURSE->maxbytes; $filemanager_options['maxfiles'] = 1; $filemanager_options['subdirs'] = 0; $mform->addElement('filemanager', 'bgimage', get_string('bgimage', 'content'), null, $filemanager_options); $mform->setType('bgimage', PARAM_INT); $mform->addHelpButton('bgimage', 'bgimagehelp', 'content'); $mform->addElement('text', 'bgcolor', get_string('bgcolor', 'content'), array('class' => 'color', 'value' => 'FCFCFC')); $mform->setType('bgcolor', PARAM_TEXT); $mform->addHelpButton('bgcolor', 'bgcolorhelp', 'content'); $mform->addElement('text', 'bordercolor', get_string('bordercolor', 'content'), array('class' => 'color', 'value' => 'E4E4E4')); $mform->setType('bordercolor', PARAM_TEXT); $mform->addHelpButton('bordercolor', 'bordercolorhelp', 'content'); $options = content_add_borderwidth_options(); $mform->addElement('select', 'borderwidth', get_string('borderwidth', 'content'), $options); $mform->setType('borderwidth', PARAM_INT); $mform->addHelpButton('borderwidth', 'borderwidthhelp', 'content'); $mform->setDefault('borderwidth', 1); $mform->addElement('text', 'maxpages', get_string('maxpages', 'content'), array('class' => 'x-large')); $mform->setType('maxpages', PARAM_INT); $mform->addHelpButton('maxpages', 'maxpageshelp', 'content'); $mform->addRule('maxpages', null, 'numeric', null, 'client'); $mform->addRule('maxpages', get_string('maximumdigits', 'content', 3), 'maxlength', 3, 'client'); $mform->setDefault('maxpages', 55); $mform->addElement('selectyesno', 'progressbar', get_string('progressbar', 'content')); $mform->addHelpButton('progressbar', 'progressbar', 'content'); $mform->setType('progressbar', PARAM_INT); $mform->setDefault('progressbar', 1); // Grade. $this->standard_grading_coursemodule_elements(); // Add standard elements, common to all modules. $this->standard_coursemodule_elements(); // Add standard buttons, common to all modules. $this->add_action_buttons(); }
function definition() { global $CFG, $COURSE; $page = $this->_customdata['page']; $pagecontentoptions = $this->_customdata['pagecontentoptions']; // Disabled subchapter option when editing first node. $disabledmsg = null; $disabled = null; if ($page->pagenum == 1) { $disabledmsg = get_string('subpagenotice', 'content'); $disabled = array('disabled' => 'disabled'); } $mform = $this->_form; if (!empty($page->id)) { $mform->addElement('header', 'general', get_string('editingpage', 'content')); $timemodified = time(); $timecreated = 0; } else { $mform->addElement('header', 'general', get_string('addafter', 'content')); $timecreated = time(); $timemodified = 0; } $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->setDefault('id', $page->id); $mform->addElement('hidden', 'contentid'); $mform->setType('contentid', PARAM_INT); $mform->setDefault('contentid', $page->contentid); $mform->addElement('hidden', 'cmid'); $mform->setType('cmid', PARAM_INT); $mform->setDefault('cmid', $page->cmid); $mform->addElement('hidden', 'pagenum'); $mform->setType('pagenum', PARAM_INT); $mform->setDefault('pagenum', $page->pagenum); $mform->addElement('hidden', 'timemodified'); $mform->setType('timemodified', PARAM_INT); $mform->setDefault('timemodified', $timemodified); $mform->addElement('hidden', 'timecreated'); $mform->setType('timecreated', PARAM_INT); $mform->setDefault('timecreated', $timecreated); $mform->addElement('text', 'title', get_string('pagetitle', 'content'), array('class' => 'input-xxlarge')); $mform->setType('title', PARAM_RAW); $mform->addRule('title', null, 'required', null, 'client'); $mform->addElement('checkbox', 'subpage', get_string('subpage', 'content'), $disabledmsg, $disabled); $mform->addHelpButton('subpage', 'subpage', 'content'); $mform->setType('subpage', PARAM_INT); $mform->setDefault('subpage', 0); $mform->addElement('editor', 'pagecontent_editor', get_string('content', 'mod_content'), null, $pagecontentoptions); $mform->setType('pagecontent_editor', PARAM_RAW); $mform->addRule('pagecontent_editor', get_string('required'), 'required', null, 'client'); $mform->addElement('header', 'appearance', get_string('appearance')); $mform->addElement('advcheckbox', 'showtitle', get_string('showtitle', 'content')); $mform->addHelpButton('showtitle', 'showtitle', 'content'); $mform->setType('showtitle', PARAM_INT); $mform->setDefault('showtitle', 1); $mform->addElement('advcheckbox', 'showbgimage', get_string('showbgimage', 'content')); $mform->addHelpButton('showbgimage', 'showbgimage', 'content'); $mform->setType('showbgimage', PARAM_INT); $mform->setDefault('showbgimage', 1); $filemanager_options = array(); $filemanager_options['accepted_types'] = array('.jpg', '.png'); $filemanager_options['maxbytes'] = $COURSE->maxbytes; $filemanager_options['maxfiles'] = 1; $filemanager_options['subdirs'] = 0; $mform->addElement('filemanager', 'bgimage', get_string('bgimage', 'content'), null, $filemanager_options); $mform->setType('bgimage', PARAM_INT); $mform->addHelpButton('bgimage', 'bgimagepagehelp', 'content'); //$mform->disabledIf('bgimage', 'showbgimage'); $mform->addElement('text', 'bgcolor', get_string('bgcolor', 'content'), array('class' => 'color', 'value' => 'FCFCFC')); $mform->setType('bgcolor', PARAM_TEXT); $mform->addHelpButton('bgcolor', 'bgcolorpagehelp', 'content'); $mform->addElement('text', 'bordercolor', get_string('bordercolor', 'content'), array('class' => 'color', 'value' => 'E4E4E4')); $mform->setType('bordercolor', PARAM_TEXT); $mform->addHelpButton('bordercolor', 'bordercolorpagehelp', 'content'); $opts = content_add_borderwidth_options(); $mform->addElement('select', 'borderwidth', get_string('borderwidth', 'content'), $opts); $mform->setType('borderwidth', PARAM_INT); $mform->addHelpButton('borderwidth', 'borderwidthpagehelp', 'content'); $mform->setDefault('borderwidth', 1); $mform->addElement('header', 'effects', get_string('effects', 'content')); $effects = array('blind' => 'Blind', 'bounce' => 'Bounce', 'clip' => 'Clip', 'drop' => 'Drop', 'explode' => 'Explode', 'fade' => 'Fade', 'fold' => 'Fold', 'highlight' => 'Highlight', 'puff' => 'Puff', 'pulsate' => 'Pulsate', 'scale' => 'Scale', 'shake' => 'Shake', 'size' => 'Size', 'slide' => 'Slide', 'transfer' => 'Transfer'); $mform->addElement('select', 'nexttransitiontype', get_string('nexttransitiontype', 'content'), $effects); $mform->addHelpButton('nexttransitiontype', 'nexttransitiontypehelp', 'content'); $mform->addElement('select', 'prevtransitiontype', get_string('prevtransitiontype', 'content'), $effects); $mform->addHelpButton('prevtransitiontype', 'prevtransitiontypehelp', 'content'); $mform->addElement('select', 'texttransitiontype', get_string('texttransitiontype', 'content'), $effects); $mform->addHelpButton('texttransitiontype', 'texttransitiontypehelp', 'content'); $mform->addElement('select', 'imagetransitiontype', get_string('imagetransitiontype', 'content'), $effects); $mform->addHelpButton('imagetransitiontype', 'imagetransitiontypehelp', 'content'); $this->add_action_buttons(true); // set the defaults $this->set_data($page); }