function block_advance_print_page($advance, $return = false) { //add page title global $OUTPUT, $COURSE; $display = $OUTPUT->heading($advance->pagetitle); $display .= $OUTPUT->box_start(); //date display if ($advance->displaydate) { $display .= html_writer::start_tag('div', array('class' => 'advance displaydate')); $display .= userdate($advance->displaydate); $display .= html_writer::end_tag('div'); } //display text $display .= clean_text($advance->displaytext); //close the box $display .= $OUTPUT->box_end(); //display picture if ($advance->displaypicture) { $display .= $OUTPUT->box_start(); $images = block_advance_images(); $display .= $images[$advance->picture]; $display .= html_writer::start_tag('p'); $display .= clean_text($advance->description); $display .= html_writer::end_tag('p'); $display .= $OUTPUT->box_end(); } //display it if ($return) { return $display; } else { echo $display; } }
function definition() { global $CFG; $mform =& $this->_form; //add group for text area $mform->addElement('header', 'displayinfo', get_string('textfields', 'block_advance')); //add page title element $mform->addElement('text', 'pagetitle', get_string('pagetitle', 'block_advance')); $mform->addRule('pagetitle', null, 'required', null, 'client'); $mform->setType('pagetitle', PARAM_RAW); //add display text field $mform->addElement('htmleditor', 'displaytext', get_string('displayedhtml', 'block_advance')); $mform->setType('displaytext', PARAM_RAW); $mform->addRule('displaytext', null, 'required', null, 'client'); //for mandatory field to be checked at client side //file upload $mform->addElement('filepicker', 'filename', get_string('file'), null, array('accepted_typew' => '*')); //fieldset header $mform->addElement('header', 'picfield', get_string('picturefield', 'block_advance'), null, false); //display yes or no $mform->addElement('selectyesno', 'displaypicture', get_string('displaypicture', 'block_advance')); $mform->setDefault('displaypicture', 1); //radio button using the function from /blocks/advance/lib.php $images = block_advance_images(); $radioarray = array(); for ($i = 0; $i < count($images); $i++) { $radioarray[] =& $mform->createElement('radio', 'picture', '', $images[$i], $i); } $mform->addGroup($radioarray, 'radioar', get_string('pictureselect', 'block_advance'), array(' '), false); //ALT Text input - add description field $attributes = array('size' => '50', 'maxlength' => '100'); $mform->addElement('text', 'description', get_string('picturedesc', 'block_advance'), $attributes); $mform->setType('description', PARAM_TEXT); //Date time selector //add optional grouping $mform->addElement('header', 'optional', get_string('optional', 'form'), null, false); //add date time selector to form area $mform->addElement('date_time_selector', 'displaydate', get_string('displaydate', 'block_advance'), array('optional' => 'true')); $mform->setAdvanced('optional'); //add state variable // hidden elements $mform->addElement('hidden', 'blockid'); $mform->addElement('hidden', 'courseid'); $mform->setType('blockid', PARAM_RAW); $mform->setType('courseid', PARAM_RAW); //edit hideen field $mform->addElement('hidden', 'id', 0); $mform->setType('id', PARAM_RAW); //button $this->add_action_buttons(); }