2 /// This file allows to manage the default behaviour of the display formats
4 require_once("../../config.php");
5 require_once("lib.php");
8 $id = required_param('id', PARAM_INT
);
9 $mode = optional_param('mode');
12 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM
, SITEID
));
14 if (!$site = get_site()) {
15 error("Site isn't defined!");
18 if ( !$displayformat = get_record("glossary_formats","id",$id) ) {
19 error ("Invalid Glossary Format");
22 $form = data_submitted();
23 if ( $mode == 'visible' ) {
24 if ( $displayformat ) {
25 if ( $displayformat->visible
) {
26 $displayformat->visible
= 0;
28 $displayformat->visible
= 1;
30 update_record("glossary_formats",$displayformat);
32 redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats");
34 } elseif ( $mode == 'edit' and $form) {
36 $displayformat->popupformatname
= $form->popupformatname
;
37 $displayformat->showgroup
= $form->showgroup
;
38 $displayformat->defaultmode
= $form->defaultmode
;
39 $displayformat->defaulthook
= $form->defaulthook
;
40 $displayformat->sortkey
= $form->sortkey
;
41 $displayformat->sortorder
= $form->sortorder
;
43 update_record("glossary_formats",$displayformat);
44 redirect("../../$CFG->admin/module.php?sesskey=$USER->sesskey&module=glossary#formats");
48 $stradmin = get_string("administration");
49 $strconfiguration = get_string("configuration");
50 $strmanagemodules = get_string("managemodules");
51 $strmodulename = get_string("modulename", "glossary");
52 $strdisplayformats = get_string("displayformats","glossary");
55 $navlinks[] = array('name' => $stradmin, 'link' => "../../$CFG->admin/index.php", 'type' => 'core');
56 $navlinks[] = array('name' => $strconfiguration, 'link' => "../../$CFG->admin/configure.php", 'type' => 'core');
57 $navlinks[] = array('name' => $strmanagemodules, 'link' => "../../$CFG->admin/modules.php", 'type' => 'core');
58 $navlinks[] = array('name' => $strmodulename, 'link' => "../../$CFG->admin/module.php?module=glossary&sesskey=$USER->sesskey", 'type' => 'core');
59 $navlinks[] = array('name' => $strdisplayformats, 'link' => '', 'type' => 'core');
61 $navigation = build_navigation($navlinks);
63 print_header("$strmodulename: $strconfiguration", $site->fullname
, $navigation);
65 print_heading($strmodulename . ': ' . get_string("displayformats","glossary"));
67 print_simple_box("<center>".get_string("configwarning", 'admin')."</center>", "center", "60%");
70 $yes = get_string("yes");
71 $no = get_string("no");
73 echo '<form method="post" action="formats.php" id="form">';
74 echo '<table width="90%" align="center" class="generalbox">';
77 <td colspan
="3" align
="center"><strong
>
78 <?php
echo get_string('displayformat'.$displayformat->name
,'glossary'); ?
>
82 <td align
="right" width
="20%"><?php
print_string('popupformat','glossary'); ?
></td
>
85 //get and update available formats
86 $recformats = glossary_get_available_formats();
91 foreach ($recformats as $format) {
92 $formats[$format->name
] = get_string("displayformat$format->name", "glossary");
97 choose_from_menu($formats,'popupformatname',$displayformat->popupformatname
);
101 <?php
print_string("cnfrelatedview", "glossary") ?
><br
/><br
/>
105 <td align
="right" width
="20%"><?php
print_string('defaultmode','glossary'); ?
></td
>
107 <select size
="1" name
="defaultmode">
113 switch ( strtolower($displayformat->defaultmode
) ) {
115 $sletter = ' selected="selected" ';
119 $scat = ' selected="selected" ';
123 $sdate = ' selected="selected" ';
127 $sauthor = ' selected="selected" ';
131 <option value
="letter" <?php
p($sletter)?
>>letter
</option
>
132 <option value
="cat" <?php
p($scat)?
>>cat
</option
>
133 <option value
="date" <?php
p($sdate)?
>>date
</option
>
134 <option value
="author" <?php
p($sauthor)?
>>author
</option
>
138 <?php
print_string("cnfdefaultmode", "glossary") ?
><br
/><br
/>
142 <td align
="right" width
="20%"><?php
print_string('defaulthook','glossary'); ?
></td
>
144 <select size
="1" name
="defaulthook">
148 $sallcategories = '';
149 $snocategorised = '';
150 switch ( strtolower($displayformat->defaulthook
) ) {
152 $sall = ' selected="selected" ';
156 $sspecial = ' selected="selected" ';
160 $sallcategories = ' selected="selected" ';
164 $snocategorised = ' selected="selected" ';
168 <option value
="ALL" <?php
p($sall)?
>><?php
p(get_string("allentries","glossary"))?
></option
>
169 <option value
="SPECIAL" <?php
p($sspecial)?
>><?php
p(get_string("special","glossary"))?
></option
>
170 <option value
="0" <?php
p($sallcategories)?
>><?php
p(get_string("allcategories","glossary"))?
></option
>
171 <option value
="-1" <?php
p($snocategorised)?
>><?php
p(get_string("notcategorised","glossary"))?
></option
>
175 <?php
print_string("cnfdefaulthook", "glossary") ?
><br
/><br
/>
179 <td align
="right" width
="20%"><?php
print_string('defaultsortkey','glossary'); ?
></td
>
181 <select size
="1" name
="sortkey">
187 switch ( strtolower($displayformat->sortkey
) ) {
189 $sfname = ' selected="selected" ';
193 $slname = ' selected="selected" ';
197 $screation = ' selected="selected" ';
201 $supdate = ' selected="selected" ';
205 <option value
="CREATION" <?php
p($screation)?
>><?php
p(get_string("sortbycreation","glossary"))?
></option
>
206 <option value
="UPDATE" <?php
p($supdate)?
>><?php
p(get_string("sortbylastupdate","glossary"))?
></option
>
207 <option value
="FIRSTNAME" <?php
p($sfname)?
>><?php
p(get_string("firstname"))?
></option
>
208 <option value
="LASTNAME" <?php
p($slname)?
>><?php
p(get_string("lastname"))?
></option
>
212 <?php
print_string("cnfsortkey", "glossary") ?
><br
/><br
/>
216 <td align
="right" width
="20%"><?php
print_string('defaultsortorder','glossary'); ?
></td
>
218 <select size
="1" name
="sortorder">
222 switch ( strtolower($displayformat->sortorder
) ) {
224 $sasc = ' selected="selected" ';
228 $sdesc = ' selected="selected" ';
232 <option value
="asc" <?php
p($sasc)?
>><?php
p(get_string("ascending","glossary"))?
></option
>
233 <option value
="desc" <?php
p($sdesc)?
>><?php
p(get_string("descending","glossary"))?
></option
>
237 <?php
print_string("cnfsortorder", "glossary") ?
><br
/><br
/>
241 <td align
="right" width
="20%">Include Group Breaks
:</td
>
243 <select size
="1" name
="showgroup">
247 if ($displayformat->showgroup
) {
248 $yselected = " selected=\"selected\" ";
250 $nselected = " selected=\"selected\" ";
253 <option value
="1" <?php
echo $yselected ?
>><?php
p($yes)?
></option
>
254 <option value
="0" <?php
echo $nselected ?
>><?php
p($no)?
></option
>
258 <?php
print_string("cnfshowgroup", "glossary") ?
><br
/><br
/>
262 <td colspan
="3" align
="center">
263 <input type
="submit" value
="<?php print_string("savechanges
") ?>" /></td
>
265 <input type
="hidden" name
="id" value
="<?php p($id) ?>" />
266 <input type
="hidden" name
="mode" value
="edit" />
269 echo '</table></form>';