Permalink
Browse files

MDL-38599 glossary: Reformat settings form

  • Loading branch information...
1 parent 0cdc5fc commit f3aadb1cd0e397ec8cfbda92c6c54c26713981ad @FMCorz FMCorz committed Mar 25, 2013
Showing with 44 additions and 25 deletions.
  1. +1 −0 lang/en/moodle.php
  2. +2 −2 mod/glossary/lang/en/glossary.php
  3. +41 −23 mod/glossary/mod_form.php
View
@@ -140,6 +140,7 @@
$string['answer'] = 'Answer';
$string['any'] = 'Any';
$string['approve'] = 'Approve';
+$string['appearance'] = 'Appearance';
$string['areyousuretorestorethis'] = 'Do you want to continue?';
$string['areyousuretorestorethisinfo'] = 'Later in this process you will have a choice of adding this backup to an existing course or creating a completely new course.';
$string['asc'] = 'Ascending';
@@ -130,7 +130,7 @@
$string['displayformatssetup'] = 'Display formats setup';
$string['duplicatecategory'] = 'Duplicate category';
$string['duplicateentry'] = 'Duplicate entry';
-$string['editalways'] = 'Edit always';
+$string['editalways'] = 'Always allow editing';
$string['editalways_help'] = 'This setting specifies whether entries are always editable or whether students can only edit their entries during a configured editing time (usually 30 minutes).';
$string['editcategories'] = 'Edit categories';
$string['editentry'] = 'Edit entry';
@@ -264,7 +264,7 @@
$string['secondaryglossary'] = 'Secondary glossary';
$string['showall'] = 'Show \'ALL\' link';
$string['showall_help'] = 'If enabled, participants can browse all entries at once.';
-$string['showalphabet'] = 'Show alphabet';
+$string['showalphabet'] = 'Show alphabet links';
$string['showalphabet_help'] = 'If enabled, participants can browse the glossary by letters of the alphabet.';
$string['showspecial'] = 'Show \'Special\' link';
$string['showspecial_help'] = 'If enabled, participants can browse the glossary by special characters, such as @ and #.';
View
@@ -25,11 +25,6 @@ function definition() {
$this->add_intro_editor(true);
- $mform->addElement('text', 'entbypage', get_string('entbypage', 'glossary'));
- $mform->setDefault('entbypage', 10);
- $mform->addRule('entbypage', null, 'required', null, 'client');
- $mform->addRule('entbypage', null, 'numeric', null, 'client');
-
if (has_capability('mod/glossary:manageentries', context_system::instance())) {
$mform->addElement('checkbox', 'globalglossary', get_string('isglobal', 'glossary'));
$mform->addHelpButton('globalglossary', 'isglobal', 'glossary');
@@ -44,6 +39,17 @@ function definition() {
$mform->addHelpButton('mainglossary', 'glossarytype', 'glossary');
$mform->setDefault('mainglossary', 0);
+ // ----------------------------------------------------------------------
+ $mform->addElement('header', 'entrieshdr', get_string('entries', 'glossary'));
+
+ $mform->addElement('selectyesno', 'defaultapproval', get_string('defaultapproval', 'glossary'));
+ $mform->setDefault('defaultapproval', $CFG->glossary_defaultapproval);
+ $mform->addHelpButton('defaultapproval', 'defaultapproval', 'glossary');
+
+ $mform->addElement('selectyesno', 'editalways', get_string('editalways', 'glossary'));
+ $mform->setDefault('editalways', 0);
+ $mform->addHelpButton('editalways', 'editalways', 'glossary');
+
$mform->addElement('selectyesno', 'allowduplicatedentries', get_string('allowduplicatedentries', 'glossary'));
$mform->setDefault('allowduplicatedentries', $CFG->glossary_dupentries);
$mform->addHelpButton('allowduplicatedentries', 'allowduplicatedentries', 'glossary');
@@ -52,28 +58,19 @@ function definition() {
$mform->setDefault('allowcomments', $CFG->glossary_allowcomments);
$mform->addHelpButton('allowcomments', 'allowcomments', 'glossary');
- $mform->addElement('selectyesno', 'allowprintview', get_string('allowprintview', 'glossary'));
- $mform->setDefault('allowprintview', 1);
- $mform->addHelpButton('allowprintview', 'allowprintview', 'glossary');
-
$mform->addElement('selectyesno', 'usedynalink', get_string('usedynalink', 'glossary'));
$mform->setDefault('usedynalink', $CFG->glossary_linkbydefault);
$mform->addHelpButton('usedynalink', 'usedynalink', 'glossary');
- $mform->addElement('selectyesno', 'defaultapproval', get_string('defaultapproval', 'glossary'));
- $mform->setDefault('defaultapproval', $CFG->glossary_defaultapproval);
- $mform->addHelpButton('defaultapproval', 'defaultapproval', 'glossary');
+ // ----------------------------------------------------------------------
+ $mform->addElement('header', 'appearancehdr', get_string('appearance'));
- //get and update available formats
+ // Get and update available formats.
$recformats = glossary_get_available_formats();
-
$formats = array();
-
- //Take names
foreach ($recformats as $format) {
$formats[$format->name] = get_string('displayformat'.$format->name, 'glossary');
}
- //Sort it
asort($formats);
$mform->addElement('select', 'displayformat', get_string('displayformat', 'glossary'), $formats);
$mform->setDefault('displayformat', 'dictionary');
@@ -85,9 +82,9 @@ function definition() {
$mform->setDefault('approvaldisplayformat', 'default');
$mform->addHelpButton('approvaldisplayformat', 'approvaldisplayformat', 'glossary');
- $mform->addElement('selectyesno', 'showspecial', get_string('showspecial', 'glossary'));
- $mform->setDefault('showspecial', 1);
- $mform->addHelpButton('showspecial', 'showspecial', 'glossary');
+ $mform->addElement('text', 'entbypage', get_string('entbypage', 'glossary'));
+ $mform->setDefault('entbypage', $this->get_default_entbypage());
+ $mform->addRule('entbypage', null, 'numeric', null, 'client');
$mform->addElement('selectyesno', 'showalphabet', get_string('showalphabet', 'glossary'));
$mform->setDefault('showalphabet', 1);
@@ -97,9 +94,13 @@ function definition() {
$mform->setDefault('showall', 1);
$mform->addHelpButton('showall', 'showall', 'glossary');
- $mform->addElement('selectyesno', 'editalways', get_string('editalways', 'glossary'));
- $mform->setDefault('editalways', 0);
- $mform->addHelpButton('editalways', 'editalways', 'glossary');
+ $mform->addElement('selectyesno', 'showspecial', get_string('showspecial', 'glossary'));
+ $mform->setDefault('showspecial', 1);
+ $mform->addHelpButton('showspecial', 'showspecial', 'glossary');
+
+ $mform->addElement('selectyesno', 'allowprintview', get_string('allowprintview', 'glossary'));
+ $mform->setDefault('allowprintview', 1);
+ $mform->addHelpButton('allowprintview', 'allowprintview', 'glossary');
if ($CFG->enablerssfeeds && isset($CFG->glossary_enablerssfeeds) && $CFG->glossary_enablerssfeeds) {
//-------------------------------------------------------------------------------
@@ -163,6 +164,13 @@ function definition_after_data() {
function data_preprocessing(&$default_values){
parent::data_preprocessing($default_values);
+ // Fallsback on the default setting if 'Entries shown per page' has been left blank.
+ // This prevents the field from being required and expand its section which should not
+ // be the case if there is a default value defined.
+ if (empty($default_values['entbypage']) || $default_values['entbypage'] < 0) {
+ $default_values['entbypage'] = $this->get_default_entbypage();
+ }
+
// Set up the completion checkboxes which aren't part of standard data.
// We also make the default value (if you turn on the checkbox) for those
// numbers to be 1, this will not apply unless checkbox is ticked.
@@ -203,5 +211,15 @@ function get_data() {
return $data;
}
+ /**
+ * Returns the default value for 'Entries shown per page'.
+ *
+ * @return int default for number of entries per page.
+ */
+ protected function get_default_entbypage() {
+ global $CFG;
+ return !empty($CFG->glossary_entbypage) ? $CFG->glossary_entbypage : 10;
+ }
+
}

0 comments on commit f3aadb1

Please sign in to comment.