/** * This function renders the form elements when adding a customcert element. * * @param mod_customcert_edit_element_form $mform the edit_form instance */ public function render_form_elements($mform) { global $COURSE; $mform->addElement('select', 'image', get_string('image', 'customcertelement_image'), self::get_images()); $mform->addElement('text', 'width', get_string('width', 'customcertelement_image'), array('size' => 10)); $mform->setType('width', PARAM_INT); $mform->setDefault('width', 0); $mform->addHelpButton('width', 'width', 'customcertelement_image'); $mform->addElement('text', 'height', get_string('height', 'customcertelement_image'), array('size' => 10)); $mform->setType('height', PARAM_INT); $mform->setDefault('height', 0); $mform->addHelpButton('height', 'height', 'customcertelement_image'); $mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10)); $mform->setType('posx', PARAM_INT); $mform->setDefault('posx', '0'); $mform->addHelpButton('posx', 'posx', 'customcert'); $mform->addElement('text', 'posy', get_string('posy', 'customcert'), array('size' => 10)); $mform->setType('posy', PARAM_INT); $mform->setDefault('posy', '0'); $mform->addHelpButton('posy', 'posy', 'customcert'); $filemanageroptions = array('maxbytes' => $COURSE->maxbytes, 'subdirs' => 1, 'accepted_types' => 'image'); $mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '', $filemanageroptions); }
/** * Helper function to render the position elements. * * @param mod_customcert_edit_element_form $mform the edit_form instance. */ public function render_form_element_position($mform) { $mform->addElement('text', 'posx', get_string('posx', 'customcert'), array('size' => 10)); $mform->setType('posx', PARAM_INT); $mform->setDefault('posx', '0'); $mform->addHelpButton('posx', 'posx', 'customcert'); $mform->addElement('text', 'posy', get_string('posy', 'customcert'), array('size' => 10)); $mform->setType('posy', PARAM_INT); $mform->setDefault('posy', '0'); $mform->addHelpButton('posy', 'posy', 'customcert'); $mform->addElement('text', 'width', get_string('elementwidth', 'customcert'), array('size' => 10)); $mform->setType('width', PARAM_INT); $mform->setDefault('width', ''); $mform->addHelpButton('width', 'elementwidth', 'customcert'); $refpointoptions = array(); $refpointoptions[CUSTOMCERT_REF_POINT_TOPLEFT] = get_string('topleft', 'customcert'); $refpointoptions[CUSTOMCERT_REF_POINT_TOPCENTER] = get_string('topcenter', 'customcert'); $refpointoptions[CUSTOMCERT_REF_POINT_TOPRIGHT] = get_string('topright', 'customcert'); $mform->addElement('select', 'refpoint', get_string('refpoint', 'customcert'), $refpointoptions); $mform->setType('refpoint', PARAM_INT); $mform->setDefault('refpoint', ''); $mform->addHelpButton('refpoint', 'refpoint', 'customcert'); $alignoptions = array(); $alignoptions[''] = get_string('alignnone', 'customcert'); $alignoptions['L'] = get_string('alignleft', 'customcert'); $alignoptions['C'] = get_string('aligncenter', 'customcert'); $alignoptions['R'] = get_string('alignright', 'customcert'); $mform->addElement('select', 'align', get_string('align', 'customcert'), $alignoptions); $mform->setType('align', PARAM_ALPHA); $mform->setDefault('align', ''); $mform->addHelpButton('align', 'align', 'customcert'); }