Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 3 /// This file allows to manage the default behaviour of the display formats 4 5 require_once("../../config.php"); 6 require_once($CFG->libdir.'/adminlib.php'); 7 require_once ("lib.php"); 8 9 $id = required_param('id', PARAM_INT); 10 $mode = optional_param('mode', '', PARAM_ALPHANUMEXT); 11 12 $url = new moodle_url('/mod/glossary/formats.php', array('id'=>$id)); 13 if ($mode !== '') { 14 $url->param('mode', $mode); 15 } 16 $PAGE->set_url($url); 17 18 admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it 19 20 if ( !$displayformat = $DB->get_record("glossary_formats", array("id"=>$id))) { 21 print_error('invalidglossaryformat', 'glossary'); 22 } 23 24 $form = data_submitted(); 25 if ( $mode == 'visible' and confirm_sesskey()) { 26 if ( $displayformat ) { 27 if ( $displayformat->visible ) { 28 $displayformat->visible = 0; 29 } else { 30 $displayformat->visible = 1; 31 } 32 $DB->update_record("glossary_formats",$displayformat); 33 } 34 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header"); 35 die; 36 } elseif ( $mode == 'edit' and $form and confirm_sesskey()) { 37 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; 44 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; 50 51 $DB->update_record("glossary_formats",$displayformat); 52 redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header"); 53 die; 54 } 55 56 $strmodulename = get_string("modulename", "glossary"); 57 $strdisplayformats = get_string("displayformats","glossary"); 58 59 echo $OUTPUT->header(); 60 61 echo $OUTPUT->heading($strmodulename . ': ' . get_string("displayformats","glossary")); 62 63 echo $OUTPUT->box(get_string("configwarning", 'admin'), "generalbox boxaligncenter boxwidthnormal"); 64 echo "<br />"; 65 66 $yes = get_string("yes"); 67 $no = get_string("no"); 68 69 echo '<form method="post" action="formats.php" id="form">'; 70 echo '<table width="90%" align="center" class="generalbox">'; 71 ?> 72 <tr> 73 <td colspan="3" align="center"><strong> 74 <?php echo get_string('displayformat'.$displayformat->name,'glossary'); ?> 75 </strong></td> 76 </tr> 77 <tr valign="top"> 78 <td align="right" width="20%"><?php echo html_writer::label(get_string('popupformat','glossary'), 'menupopupformatname'); ?></td> 79 <td> 80 <?php 81 // Get available formats. 82 $recformats = $DB->get_records("glossary_formats"); 83 84 $formats = array(); 85 86 //Take names 87 foreach ($recformats as $format) { 88 $formats[$format->name] = get_string("displayformat$format->name", "glossary"); 89 } 90 //Sort it 91 asort($formats); 92 93 echo html_writer::select($formats, 'popupformatname', $displayformat->popupformatname, false); 94 ?> 95 </td> 96 <td width="60%"> 97 <?php print_string("cnfrelatedview", "glossary") ?><br /><br /> 98 </td> 99 </tr> 100 <tr valign="top"> 101 <td align="right" width="20%"><label for="defaultmode"><?php print_string('defaultmode','glossary'); ?></label></td> 102 <td> 103 <select size="1" id="defaultmode" name="defaultmode"> 104 <?php 105 $sletter = ''; 106 $scat = ''; 107 $sauthor = ''; 108 $sdate = ''; 109 switch ( strtolower($displayformat->defaultmode) ) { 110 case 'letter': 111 $sletter = ' selected="selected" '; 112 break; 113 114 case 'cat': 115 $scat = ' selected="selected" '; 116 break; 117 118 case 'date': 119 $sdate = ' selected="selected" '; 120 break; 121 122 case 'author': 123 $sauthor = ' selected="selected" '; 124 break; 125 } 126 ?> 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> 131 </select> 132 </td> 133 <td width="60%"> 134 <?php print_string("cnfdefaultmode", "glossary") ?><br /><br /> 135 </td> 136 </tr> 137 <tr valign="top"> 138 <td align="right" width="20%"><label for="defaulthook"><?php print_string('defaulthook','glossary'); ?></label></td> 139 <td> 140 <select size="1" id="defaulthook" name="defaulthook"> 141 <?php 142 $sall = ''; 143 $sspecial = ''; 144 $sallcategories = ''; 145 $snocategorised = ''; 146 switch ( strtolower($displayformat->defaulthook) ) { 147 case 'all': 148 $sall = ' selected="selected" '; 149 break; 150 151 case 'special': 152 $sspecial = ' selected="selected" '; 153 break; 154 155 case '0': 156 $sallcategories = ' selected="selected" '; 157 break; 158 159 case '-1': 160 $snocategorised = ' selected="selected" '; 161 break; 162 } 163 ?> 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> 168 </select> 169 </td> 170 <td width="60%"> 171 <?php print_string("cnfdefaulthook", "glossary") ?><br /><br /> 172 </td> 173 </tr> 174 <tr valign="top"> 175 <td align="right" width="20%"><label for="sortkey"><?php print_string('defaultsortkey','glossary'); ?></label></td> 176 <td> 177 <select size="1" id="sortkey" name="sortkey"> 178 <?php 179 $sfname = ''; 180 $slname = ''; 181 $supdate = ''; 182 $screation = ''; 183 switch ( strtolower($displayformat->sortkey) ) { 184 case 'firstname': 185 $sfname = ' selected="selected" '; 186 break; 187 188 case 'lastname': 189 $slname = ' selected="selected" '; 190 break; 191 192 case 'creation': 193 $screation = ' selected="selected" '; 194 break; 195 196 case 'update': 197 $supdate = ' selected="selected" '; 198 break; 199 } 200 ?> 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> 205 </select> 206 </td> 207 <td width="60%"> 208 <?php print_string("cnfsortkey", "glossary") ?><br /><br /> 209 </td> 210 </tr> 211 <tr valign="top"> 212 <td align="right" width="20%"><label for="sortorder"><?php print_string('defaultsortorder','glossary'); ?></label></td> 213 <td> 214 <select size="1" id="sortorder" name="sortorder"> 215 <?php 216 $sasc = ''; 217 $sdesc = ''; 218 switch ( strtolower($displayformat->sortorder) ) { 219 case 'asc': 220 $sasc = ' selected="selected" '; 221 break; 222 223 case 'desc': 224 $sdesc = ' selected="selected" '; 225 break; 226 } 227 ?> 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> 230 </select> 231 </td> 232 <td width="60%"> 233 <?php print_string("cnfsortorder", "glossary") ?><br /><br /> 234 </td> 235 </tr> 236 <tr valign="top"> 237 <td align="right" width="20%"><label for="showgroup"><?php print_string("includegroupbreaks", "glossary"); ?>:</label></td> 238 <td> 239 <select size="1" id="showgroup" name="showgroup"> 240 <?php 241 $yselected = ""; 242 $nselected = ""; 243 if ($displayformat->showgroup) { 244 $yselected = " selected=\"selected\" "; 245 } else { 246 $nselected = " selected=\"selected\" "; 247 } 248 ?> 249 <option value="1" <?php echo $yselected ?>><?php p($yes)?></option> 250 <option value="0" <?php echo $nselected ?>><?php p($no)?></option> 251 </select> 252 </td> 253 <td width="60%"> 254 <?php print_string("cnfshowgroup", "glossary") ?><br /><br /> 255 </td> 256 </tr> 257 <tr> 258 <td align="right" width="20%"><label for="visibletabs"><?php print_string("visibletabs", "glossary"); ?></label></td> 259 <td> 260 <?php 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)); 266 ?> 267 <select id="visibletabs" name="visibletabs[]" size="<?php echo $size ?>" multiple="multiple"> 268 <?php 269 $selected = ""; 270 foreach ($glossarytabs as $tabkey => $tabvalue) { 271 if (in_array($tabkey, $visibletabs)) { 272 ?> 273 <option value="<?php echo $tabkey ?>" selected="selected"><?php echo $tabvalue ?></option> 274 <?php 275 } else { 276 ?> 277 <option value="<?php echo $tabkey ?>"><?php echo $tabvalue ?></option> 278 <?php 279 } 280 } 281 ?> 282 </select> 283 </td> 284 <td width="60%"> 285 <?php print_string("cnftabs", "glossary") ?><br/><br/> 286 </td> 287 </tr> 288 <tr> 289 <td colspan="3" align="center"> 290 <input type="submit" value="<?php print_string("savechanges") ?>" /></td> 291 </tr> 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" /> 295 <?php 296 297 echo '</table></form>'; 298 299 echo $OUTPUT->footer(); 300 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body