Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / glossary / formats.php
blobe8e22839bb32bd82577165e5035fb2d585a94124
1 <?php // $Id$
2 /// This file allows to manage the default behaviour of the display formats
4 require_once("../../config.php");
5 require_once($CFG->libdir.'/adminlib.php');
6 require_once("lib.php");
8 $id = required_param('id', PARAM_INT);
9 $mode = optional_param('mode');
11 admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it
13 if ( !$displayformat = get_record("glossary_formats","id",$id) ) {
14 error ("Invalid Glossary Format");
17 $form = data_submitted();
18 if ( $mode == 'visible' ) {
19 if ( $displayformat ) {
20 if ( $displayformat->visible ) {
21 $displayformat->visible = 0;
22 } else {
23 $displayformat->visible = 1;
25 update_record("glossary_formats",$displayformat);
27 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
28 die;
29 } elseif ( $mode == 'edit' and $form) {
31 $displayformat->popupformatname = $form->popupformatname;
32 $displayformat->showgroup = $form->showgroup;
33 $displayformat->defaultmode = $form->defaultmode;
34 $displayformat->defaulthook = $form->defaulthook;
35 $displayformat->sortkey = $form->sortkey;
36 $displayformat->sortorder = $form->sortorder;
38 update_record("glossary_formats",$displayformat);
39 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
40 die;
43 $strmodulename = get_string("modulename", "glossary");
44 $strdisplayformats = get_string("displayformats","glossary");
46 admin_externalpage_print_header();
48 print_heading($strmodulename . ': ' . get_string("displayformats","glossary"));
50 print_simple_box("<center>".get_string("configwarning", 'admin')."</center>", "center", "60%");
51 echo "<br />";
53 $yes = get_string("yes");
54 $no = get_string("no");
56 echo '<form method="post" action="formats.php" id="form">';
57 echo '<table width="90%" align="center" class="generalbox">';
59 <tr>
60 <td colspan="3" align="center"><strong>
61 <?php echo get_string('displayformat'.$displayformat->name,'glossary'); ?>
62 </strong></td>
63 </tr>
64 <tr valign="top">
65 <td align="right" width="20%"><?php print_string('popupformat','glossary'); ?></td>
66 <td>
67 <?php
68 //get and update available formats
69 $recformats = glossary_get_available_formats();
71 $formats = array();
73 //Take names
74 foreach ($recformats as $format) {
75 $formats[$format->name] = get_string("displayformat$format->name", "glossary");
77 //Sort it
78 asort($formats);
80 choose_from_menu($formats,'popupformatname',$displayformat->popupformatname);
82 </td>
83 <td width="60%">
84 <?php print_string("cnfrelatedview", "glossary") ?><br /><br />
85 </td>
86 </tr>
87 <tr valign="top">
88 <td align="right" width="20%"><?php print_string('defaultmode','glossary'); ?></td>
89 <td>
90 <select size="1" name="defaultmode">
91 <?php
92 $sletter = '';
93 $scat = '';
94 $sauthor = '';
95 $sdate = '';
96 switch ( strtolower($displayformat->defaultmode) ) {
97 case 'letter':
98 $sletter = ' selected="selected" ';
99 break;
101 case 'cat':
102 $scat = ' selected="selected" ';
103 break;
105 case 'date':
106 $sdate = ' selected="selected" ';
107 break;
109 case 'author':
110 $sauthor = ' selected="selected" ';
111 break;
114 <option value="letter" <?php p($sletter)?>><?php print_string("letter", "glossary"); ?></option>
115 <option value="cat" <?php p($scat)?>><?php print_string("cat", "glossary"); ?></option>
116 <option value="date" <?php p($sdate)?>><?php print_string("date", "glossary"); ?></option>
117 <option value="author" <?php p($sauthor)?>><?php print_string("author", "glossary"); ?></option>
118 </select>
119 </td>
120 <td width="60%">
121 <?php print_string("cnfdefaultmode", "glossary") ?><br /><br />
122 </td>
123 </tr>
124 <tr valign="top">
125 <td align="right" width="20%"><?php print_string('defaulthook','glossary'); ?></td>
126 <td>
127 <select size="1" name="defaulthook">
128 <?php
129 $sall = '';
130 $sspecial = '';
131 $sallcategories = '';
132 $snocategorised = '';
133 switch ( strtolower($displayformat->defaulthook) ) {
134 case 'all':
135 $sall = ' selected="selected" ';
136 break;
138 case 'special':
139 $sspecial = ' selected="selected" ';
140 break;
142 case '0':
143 $sallcategories = ' selected="selected" ';
144 break;
146 case '-1':
147 $snocategorised = ' selected="selected" ';
148 break;
151 <option value="ALL" <?php p($sall)?>><?php p(get_string("allentries","glossary"))?></option>
152 <option value="SPECIAL" <?php p($sspecial)?>><?php p(get_string("special","glossary"))?></option>
153 <option value="0" <?php p($sallcategories)?>><?php p(get_string("allcategories","glossary"))?></option>
154 <option value="-1" <?php p($snocategorised)?>><?php p(get_string("notcategorised","glossary"))?></option>
155 </select>
156 </td>
157 <td width="60%">
158 <?php print_string("cnfdefaulthook", "glossary") ?><br /><br />
159 </td>
160 </tr>
161 <tr valign="top">
162 <td align="right" width="20%"><?php print_string('defaultsortkey','glossary'); ?></td>
163 <td>
164 <select size="1" name="sortkey">
165 <?php
166 $sfname = '';
167 $slname = '';
168 $supdate = '';
169 $screation = '';
170 switch ( strtolower($displayformat->sortkey) ) {
171 case 'firstname':
172 $sfname = ' selected="selected" ';
173 break;
175 case 'lastname':
176 $slname = ' selected="selected" ';
177 break;
179 case 'creation':
180 $screation = ' selected="selected" ';
181 break;
183 case 'update':
184 $supdate = ' selected="selected" ';
185 break;
188 <option value="CREATION" <?php p($screation)?>><?php p(get_string("sortbycreation","glossary"))?></option>
189 <option value="UPDATE" <?php p($supdate)?>><?php p(get_string("sortbylastupdate","glossary"))?></option>
190 <option value="FIRSTNAME" <?php p($sfname)?>><?php p(get_string("firstname"))?></option>
191 <option value="LASTNAME" <?php p($slname)?>><?php p(get_string("lastname"))?></option>
192 </select>
193 </td>
194 <td width="60%">
195 <?php print_string("cnfsortkey", "glossary") ?><br /><br />
196 </td>
197 </tr>
198 <tr valign="top">
199 <td align="right" width="20%"><?php print_string('defaultsortorder','glossary'); ?></td>
200 <td>
201 <select size="1" name="sortorder">
202 <?php
203 $sasc = '';
204 $sdesc = '';
205 switch ( strtolower($displayformat->sortorder) ) {
206 case 'asc':
207 $sasc = ' selected="selected" ';
208 break;
210 case 'desc':
211 $sdesc = ' selected="selected" ';
212 break;
215 <option value="asc" <?php p($sasc)?>><?php p(get_string("ascending","glossary"))?></option>
216 <option value="desc" <?php p($sdesc)?>><?php p(get_string("descending","glossary"))?></option>
217 </select>
218 </td>
219 <td width="60%">
220 <?php print_string("cnfsortorder", "glossary") ?><br /><br />
221 </td>
222 </tr>
223 <tr valign="top">
224 <td align="right" width="20%"><?php print_string("includegroupbreaks", "glossary"); ?>:</td>
225 <td>
226 <select size="1" name="showgroup">
227 <?php
228 $yselected = "";
229 $nselected = "";
230 if ($displayformat->showgroup) {
231 $yselected = " selected=\"selected\" ";
232 } else {
233 $nselected = " selected=\"selected\" ";
236 <option value="1" <?php echo $yselected ?>><?php p($yes)?></option>
237 <option value="0" <?php echo $nselected ?>><?php p($no)?></option>
238 </select>
239 </td>
240 <td width="60%">
241 <?php print_string("cnfshowgroup", "glossary") ?><br /><br />
242 </td>
243 </tr>
244 <tr>
245 <td colspan="3" align="center">
246 <input type="submit" value="<?php print_string("savechanges") ?>" /></td>
247 </tr>
248 <input type="hidden" name="id" value="<?php p($id) ?>" />
249 <input type="hidden" name="mode" value="edit" />
250 <?php
252 echo '</table></form>';
254 print_footer();