3 /// This file allows to manage the default behaviour of the display formats
5 require_once("../../config.php");
6 require_once($CFG->libdir
.'/adminlib.php');
7 require_once("lib.php");
9 $id = required_param('id', PARAM_INT
);
10 $mode = optional_param('mode', '', PARAM_ALPHANUMEXT
);
12 $url = new moodle_url('/mod/glossary/formats.php', array('id'=>$id));
14 $url->param('mode', $mode);
18 admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it
20 if ( !$displayformat = $DB->get_record("glossary_formats", array("id"=>$id))) {
21 throw new \
moodle_exception('invalidglossaryformat', 'glossary');
24 $form = data_submitted();
25 if ( $mode == 'visible' and confirm_sesskey()) {
26 if ( $displayformat ) {
27 if ( $displayformat->visible
) {
28 $displayformat->visible
= 0;
30 $displayformat->visible
= 1;
32 $DB->update_record("glossary_formats",$displayformat);
34 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
36 } elseif ( $mode == 'edit' and $form and confirm_sesskey()) {
38 $displayformat->popupformatname
= $form->popupformatname
;
39 $displayformat->showgroup
= $form->showgroup
;
40 $displayformat->defaultmode
= $form->defaultmode
;
41 $displayformat->defaulthook
= $form->defaulthook
;
42 $displayformat->sortkey
= $form->sortkey
;
43 $displayformat->sortorder
= $form->sortorder
;
45 // Extract visible tabs from array into comma separated list.
46 $visibletabs = implode(',', $form->visibletabs
);
47 // Include 'standard' tab by default along with other tabs.
48 // This way we don't run into the risk of users not selecting any tab for displayformat.
49 $displayformat->showtabs
= GLOSSARY_STANDARD
.','.$visibletabs;
51 $DB->update_record("glossary_formats",$displayformat);
52 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
56 $strmodulename = get_string("modulename", "glossary");
57 $strdisplayformats = get_string("displayformats","glossary");
59 echo $OUTPUT->header();
61 echo $OUTPUT->heading($strmodulename . ': ' . get_string("displayformats","glossary"));
63 echo $OUTPUT->box(get_string("configwarning", 'admin'), "generalbox boxaligncenter boxwidthnormal");
66 $yes = get_string("yes");
67 $no = get_string("no");
69 echo '<form method="post" action="formats.php" id="form">';
70 echo '<table width="90%" align="center" class="generalbox">';
73 <td colspan
="3" align
="center"><strong
>
74 <?php
echo get_string('displayformat'.$displayformat->name
,'glossary'); ?
>
78 <td align
="right" width
="20%"><?php
echo html_writer
::label(get_string('popupformat','glossary'), 'menupopupformatname'); ?
></td
>
81 // Get available formats.
82 $recformats = $DB->get_records("glossary_formats");
87 foreach ($recformats as $format) {
88 $formats[$format->name
] = get_string("displayformat$format->name", "glossary");
93 echo html_writer
::select($formats, 'popupformatname', $displayformat->popupformatname
, false);
97 <?php
print_string("cnfrelatedview", "glossary") ?
><br
/><br
/>
101 <td align
="right" width
="20%"><label
for="defaultmode"><?php
print_string('defaultmode','glossary'); ?
></label
></td
>
103 <select size
="1" id
="defaultmode" name
="defaultmode">
109 switch ( strtolower($displayformat->defaultmode
) ) {
111 $sletter = ' selected="selected" ';
115 $scat = ' selected="selected" ';
119 $sdate = ' selected="selected" ';
123 $sauthor = ' selected="selected" ';
127 <option value
="letter" <?php
p($sletter)?
>><?php
print_string("letter", "glossary"); ?
></option
>
128 <option value
="cat" <?php
p($scat)?
>><?php
print_string("cat", "glossary"); ?
></option
>
129 <option value
="date" <?php
p($sdate)?
>><?php
print_string("date", "glossary"); ?
></option
>
130 <option value
="author" <?php
p($sauthor)?
>><?php
print_string("author", "glossary"); ?
></option
>
134 <?php
print_string("cnfdefaultmode", "glossary") ?
><br
/><br
/>
138 <td align
="right" width
="20%"><label
for="defaulthook"><?php
print_string('defaulthook','glossary'); ?
></label
></td
>
140 <select size
="1" id
="defaulthook" name
="defaulthook">
144 $sallcategories = '';
145 $snocategorised = '';
146 switch ( strtolower($displayformat->defaulthook
) ) {
148 $sall = ' selected="selected" ';
152 $sspecial = ' selected="selected" ';
156 $sallcategories = ' selected="selected" ';
160 $snocategorised = ' selected="selected" ';
164 <option value
="ALL" <?php
p($sall)?
>><?php
p(get_string("allentries","glossary"))?
></option
>
165 <option value
="SPECIAL" <?php
p($sspecial)?
>><?php
p(get_string("special","glossary"))?
></option
>
166 <option value
="0" <?php
p($sallcategories)?
>><?php
p(get_string("allcategories","glossary"))?
></option
>
167 <option value
="-1" <?php
p($snocategorised)?
>><?php
p(get_string("notcategorised","glossary"))?
></option
>
171 <?php
print_string("cnfdefaulthook", "glossary") ?
><br
/><br
/>
175 <td align
="right" width
="20%"><label
for="sortkey"><?php
print_string('defaultsortkey','glossary'); ?
></label
></td
>
177 <select size
="1" id
="sortkey" name
="sortkey">
183 switch ( strtolower($displayformat->sortkey
) ) {
185 $sfname = ' selected="selected" ';
189 $slname = ' selected="selected" ';
193 $screation = ' selected="selected" ';
197 $supdate = ' selected="selected" ';
201 <option value
="CREATION" <?php
p($screation)?
>><?php
p(get_string("sortbycreation","glossary"))?
></option
>
202 <option value
="UPDATE" <?php
p($supdate)?
>><?php
p(get_string("sortbylastupdate","glossary"))?
></option
>
203 <option value
="FIRSTNAME" <?php
p($sfname)?
>><?php
p(get_string("firstname"))?
></option
>
204 <option value
="LASTNAME" <?php
p($slname)?
>><?php
p(get_string("lastname"))?
></option
>
208 <?php
print_string("cnfsortkey", "glossary") ?
><br
/><br
/>
212 <td align
="right" width
="20%"><label
for="sortorder"><?php
print_string('defaultsortorder','glossary'); ?
></label
></td
>
214 <select size
="1" id
="sortorder" name
="sortorder">
218 switch ( strtolower($displayformat->sortorder
) ) {
220 $sasc = ' selected="selected" ';
224 $sdesc = ' selected="selected" ';
228 <option value
="asc" <?php
p($sasc)?
>><?php
p(get_string("ascending","glossary"))?
></option
>
229 <option value
="desc" <?php
p($sdesc)?
>><?php
p(get_string("descending","glossary"))?
></option
>
233 <?php
print_string("cnfsortorder", "glossary") ?
><br
/><br
/>
237 <td align
="right" width
="20%"><label
for="showgroup"><?php
print_string("includegroupbreaks", "glossary"); ?
>:</label
></td
>
239 <select size
="1" id
="showgroup" name
="showgroup">
243 if ($displayformat->showgroup
) {
244 $yselected = " selected=\"selected\" ";
246 $nselected = " selected=\"selected\" ";
249 <option value
="1" <?php
echo $yselected ?
>><?php
p($yes)?
></option
>
250 <option value
="0" <?php
echo $nselected ?
>><?php
p($no)?
></option
>
254 <?php
print_string("cnfshowgroup", "glossary") ?
><br
/><br
/>
258 <td align
="right" width
="20%"><label
for="visibletabs"><?php
print_string("visibletabs", "glossary"); ?
></label
></td
>
261 // Get all glossary tabs.
262 $glossarytabs = glossary_get_all_tabs();
263 // Extract showtabs value in an array.
264 $visibletabs = glossary_get_visible_tabs($displayformat);
265 $size = min(10, count($glossarytabs));
267 <select id
="visibletabs" name
="visibletabs[]" size
="<?php echo $size ?>" multiple
="multiple">
270 foreach ($glossarytabs as $tabkey => $tabvalue) {
271 if (in_array($tabkey, $visibletabs)) {
273 <option value
="<?php echo $tabkey ?>" selected
="selected"><?php
echo $tabvalue ?
></option
>
277 <option value
="<?php echo $tabkey ?>"><?php
echo $tabvalue ?
></option
>
285 <?php
print_string("cnftabs", "glossary") ?
><br
/><br
/>
289 <td colspan
="3" align
="center">
290 <input type
="submit" value
="<?php print_string("savechanges
") ?>" /></td
>
292 <input type
="hidden" name
="id" value
="<?php p($id) ?>" />
293 <input type
="hidden" name
="sesskey" value
="<?php echo sesskey() ?>" />
294 <input type
="hidden" name
="mode" value
="edit" />
297 echo '</table></form>';
299 echo $OUTPUT->footer();