mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 00:16:46 +02:00
MDL-51267 mod: move the changes from the API to the form file
This commit is contained in:
parent
f3eb9951d1
commit
bc577c541f
4 changed files with 12 additions and 11 deletions
|
@ -886,10 +886,9 @@ abstract class moodleform_mod extends moodleform {
|
||||||
* Add an editor for an activity's introduction field.
|
* Add an editor for an activity's introduction field.
|
||||||
*
|
*
|
||||||
* @param null $customlabel Override default label for editor
|
* @param null $customlabel Override default label for editor
|
||||||
* @param array $attributes add custom attributes for the editor, it sets rows size to 10 (default) to text editor.
|
|
||||||
* @throws coding_exception
|
* @throws coding_exception
|
||||||
*/
|
*/
|
||||||
protected function standard_intro_elements($customlabel=null, $attributes = array()) {
|
protected function standard_intro_elements($customlabel=null) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
$required = $CFG->requiremodintro;
|
$required = $CFG->requiremodintro;
|
||||||
|
@ -897,9 +896,7 @@ abstract class moodleform_mod extends moodleform {
|
||||||
$mform = $this->_form;
|
$mform = $this->_form;
|
||||||
$label = is_null($customlabel) ? get_string('moduleintro') : $customlabel;
|
$label = is_null($customlabel) ? get_string('moduleintro') : $customlabel;
|
||||||
|
|
||||||
$attributes['rows'] = !empty($attributes['rows']) ? $attributes['rows'] : 10;
|
$mform->addElement('editor', 'introeditor', $label, array('rows' => 10), array('maxfiles' => EDITOR_UNLIMITED_FILES,
|
||||||
|
|
||||||
$mform->addElement('editor', 'introeditor', $label, $attributes, array('maxfiles' => EDITOR_UNLIMITED_FILES,
|
|
||||||
'noclean' => true, 'context' => $this->context, 'subdirs' => true));
|
'noclean' => true, 'context' => $this->context, 'subdirs' => true));
|
||||||
$mform->setType('introeditor', PARAM_RAW); // no XSS prevention here, users must be trusted
|
$mform->setType('introeditor', PARAM_RAW); // no XSS prevention here, users must be trusted
|
||||||
if ($required) {
|
if ($required) {
|
||||||
|
|
|
@ -55,8 +55,11 @@ class mod_resource_mod_form extends moodleform_mod {
|
||||||
}
|
}
|
||||||
$mform->addRule('name', null, 'required', null, 'client');
|
$mform->addRule('name', null, 'required', null, 'client');
|
||||||
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
||||||
$this->standard_intro_elements(null, array('rows' => 5));
|
$this->standard_intro_elements();
|
||||||
|
$element = $mform->getElement('introeditor');
|
||||||
|
$attributes = $element->getAttributes();
|
||||||
|
$attributes['rows'] = 5;
|
||||||
|
$element->setAttributes($attributes);
|
||||||
$filemanager_options = array();
|
$filemanager_options = array();
|
||||||
$filemanager_options['accepted_types'] = '*';
|
$filemanager_options['accepted_types'] = '*';
|
||||||
$filemanager_options['maxbytes'] = 0;
|
$filemanager_options['maxbytes'] = 0;
|
||||||
|
|
|
@ -3,8 +3,6 @@ information provided here is intended especially for developers.
|
||||||
|
|
||||||
=== 3.1 ===
|
=== 3.1 ===
|
||||||
|
|
||||||
* A new parameter ($attributes) has been added to standard_intro_elements() on course/moodleform_mod.php. The
|
|
||||||
purpose of this parameter is allow developers to pass an array with custom attributes to the text editor.
|
|
||||||
* Old /mod/MODULENAME/pix/icon.gif and enrol/paypal/pix/icon.gif GIF icons have been removed. Please use pix_icon
|
* Old /mod/MODULENAME/pix/icon.gif and enrol/paypal/pix/icon.gif GIF icons have been removed. Please use pix_icon
|
||||||
renderable instead.
|
renderable instead.
|
||||||
* Callback get_types() is deprecated, instead activity modules can define callback get_shortcuts().
|
* Callback get_types() is deprecated, instead activity modules can define callback get_shortcuts().
|
||||||
|
|
|
@ -48,8 +48,11 @@ class mod_url_mod_form extends moodleform_mod {
|
||||||
$mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size'=>'60'), array('usefilepicker'=>true));
|
$mform->addElement('url', 'externalurl', get_string('externalurl', 'url'), array('size'=>'60'), array('usefilepicker'=>true));
|
||||||
$mform->setType('externalurl', PARAM_RAW_TRIMMED);
|
$mform->setType('externalurl', PARAM_RAW_TRIMMED);
|
||||||
$mform->addRule('externalurl', null, 'required', null, 'client');
|
$mform->addRule('externalurl', null, 'required', null, 'client');
|
||||||
$this->standard_intro_elements(null, array('rows' => 5));
|
$this->standard_intro_elements();
|
||||||
|
$element = $mform->getElement('introeditor');
|
||||||
|
$attributes = $element->getAttributes();
|
||||||
|
$attributes['rows'] = 5;
|
||||||
|
$element->setAttributes($attributes);
|
||||||
//-------------------------------------------------------
|
//-------------------------------------------------------
|
||||||
$mform->addElement('header', 'optionssection', get_string('appearance'));
|
$mform->addElement('header', 'optionssection', get_string('appearance'));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue