|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 global $CFG; 00004 00005 require_once("../../config.php"); 00006 require_once("lib.php"); 00007 00008 $id = required_param('id', PARAM_INT); // Course Module ID 00009 $sortorder = optional_param('sortorder', 'asc', PARAM_ALPHA); // Sorting order 00010 $offset = optional_param('offset', 0, PARAM_INT); // number of entries to bypass 00011 $displayformat = optional_param('displayformat',-1, PARAM_INT); 00012 00013 $mode = required_param('mode', PARAM_ALPHA); // mode to show the entries 00014 $hook = optional_param('hook','ALL', PARAM_ALPHANUM); // what to show 00015 $sortkey = optional_param('sortkey','UPDATE', PARAM_ALPHA); // Sorting key 00016 00017 $url = new moodle_url('/mod/glossary/print.php', array('id'=>$id)); 00018 if ($sortorder !== 'asc') { 00019 $url->param('sortorder', $sortorder); 00020 } 00021 if ($offset !== 0) { 00022 $url->param('offset', $offset); 00023 } 00024 if ($displayformat !== -1) { 00025 $url->param('displayformat', $displayformat); 00026 } 00027 if ($sortkey !== 'UPDATE') { 00028 $url->param('sortkey', $sortkey); 00029 } 00030 if ($mode !== 'letter') { 00031 $url->param('mode', $mode); 00032 } 00033 if ($hook !== 'ALL') { 00034 $url->param('hook', $hook); 00035 } 00036 $PAGE->set_url($url); 00037 00038 if (! $cm = get_coursemodule_from_id('glossary', $id)) { 00039 print_error('invalidcoursemodule'); 00040 } 00041 00042 if (! $course = $DB->get_record("course", array("id"=>$cm->course))) { 00043 print_error('coursemisconf'); 00044 } 00045 00046 if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) { 00047 print_error('invalidid', 'glossary'); 00048 } 00049 00050 if ( !$entriesbypage = $glossary->entbypage ) { 00051 $entriesbypage = $CFG->glossary_entbypage; 00052 } 00053 00054 require_course_login($course, true, $cm); 00055 $context = get_context_instance(CONTEXT_MODULE, $cm->id); 00056 00057 // Prepare format_string/text options 00058 $fmtoptions = array( 00059 'context' => $context); 00060 00061 $PAGE->set_pagelayout('print'); 00062 $PAGE->set_title(get_string("modulenameplural", "glossary")); 00063 $PAGE->set_heading($course->fullname); 00064 echo $OUTPUT->header(); 00065 00067 $textlib = textlib_get_instance(); 00068 00069 if (!has_capability('mod/glossary:manageentries', $context) and !$glossary->allowprintview) { 00070 notice(get_string('printviewnotallowed', 'glossary')); 00071 } 00072 00075 if ( $dp = $DB->get_record('glossary_formats', array('name'=>$glossary->displayformat)) ) { 00076 $printpivot = $dp->showgroup; 00077 if ( $mode == '' and $hook == '' and $show == '') { 00078 $mode = $dp->defaultmode; 00079 $hook = $dp->defaulthook; 00080 $sortkey = $dp->sortkey; 00081 $sortorder = $dp->sortorder; 00082 } 00083 } else { 00084 $printpivot = 1; 00085 if ( $mode == '' and $hook == '' and $show == '') { 00086 $mode = 'letter'; 00087 $hook = 'ALL'; 00088 } 00089 } 00090 00091 if ( $displayformat == -1 ) { 00092 $displayformat = $glossary->displayformat; 00093 } 00094 00096 if ( $sortorder = strtolower($sortorder) ) { 00097 if ($sortorder != 'asc' and $sortorder != 'desc') { 00098 $sortorder = ''; 00099 } 00100 } 00101 if ( $sortkey = strtoupper($sortkey) ) { 00102 if ($sortkey != 'CREATION' and 00103 $sortkey != 'UPDATE' and 00104 $sortkey != 'FIRSTNAME' and 00105 $sortkey != 'LASTNAME' 00106 ) { 00107 $sortkey = ''; 00108 } 00109 } 00110 00111 switch ( $mode = strtolower($mode) ) { 00112 case 'entry': 00113 $tab = GLOSSARY_STANDARD_VIEW; 00114 break; 00115 00116 case 'cat': 00117 $tab = GLOSSARY_CATEGORY_VIEW; 00118 if ( $hook > 0 ) { 00119 $category = $DB->get_record("glossary_categories", array("id"=>$hook)); 00120 } 00121 break; 00122 00123 case 'approval': 00124 $tab = GLOSSARY_APPROVAL_VIEW; 00125 if ( !$hook and !$sortkey and !$sortorder) { 00126 $hook = 'ALL'; 00127 } 00128 break; 00129 00130 case 'term': 00131 $tab = GLOSSARY_STANDARD_VIEW; 00132 break; 00133 00134 case 'date': 00135 $tab = GLOSSARY_DATE_VIEW; 00136 if ( !$sortkey ) { 00137 $sortkey = 'UPDATE'; 00138 } 00139 if ( !$sortorder ) { 00140 $sortorder = 'desc'; 00141 } 00142 break; 00143 00144 case 'author': 00145 $tab = GLOSSARY_AUTHOR_VIEW; 00146 if ( !$hook ) { 00147 $hook = 'ALL'; 00148 } 00149 if ( !$sortkey ) { 00150 $sortkey = 'FIRSTNAME'; 00151 } 00152 if ( !$sortorder ) { 00153 $sortorder = 'asc'; 00154 } 00155 break; 00156 00157 case 'letter': 00158 default: 00159 $tab = GLOSSARY_STANDARD_VIEW; 00160 if ( !$hook ) { 00161 $hook = 'ALL'; 00162 } 00163 break; 00164 } 00165 00166 include_once("sql.php"); 00167 00168 $entriesshown = 0; 00169 $currentpivot = ''; 00170 if ( $hook == 'SPECIAL' ) { 00171 $alphabet = explode(",", get_string("alphabet")); 00172 } 00173 00174 $site = $DB->get_record("course", array("id"=>1)); 00175 echo '<p style="text-align:right"><span style="font-size:0.75em">' . userdate(time()) . '</span></p>'; 00176 echo get_string("site") . ': <strong>' . format_string($site->fullname) . '</strong><br />'; 00177 echo get_string("course") . ': <strong>' . format_string($course->fullname) . ' ('. format_string($course->shortname) . ')</strong><br />'; 00178 echo get_string("modulename","glossary") . ': <strong>' . format_string($glossary->name, true) . '</strong>'; 00179 if ( $allentries ) { 00180 foreach ($allentries as $entry) { 00181 00182 // Setting the pivot for the current entry 00183 $pivot = $entry->glossarypivot; 00184 $upperpivot = $textlib->strtoupper($pivot); 00185 $pivottoshow = $textlib->strtoupper(format_string($pivot, true, $fmtoptions)); 00186 // Reduce pivot to 1cc if necessary 00187 if ( !$fullpivot ) { 00188 $upperpivot = $textlib->substr($upperpivot, 0, 1); 00189 $pivottoshow = $textlib->substr($pivottoshow, 0, 1); 00190 } 00191 00192 // If there's group break 00193 if ( $currentpivot != $upperpivot ) { 00194 00195 // print the group break if apply 00196 if ( $printpivot ) { 00197 $currentpivot = $upperpivot; 00198 00199 if ( isset($entry->userispivot) ) { 00200 // printing the user icon if defined (only when browsing authors) 00201 $user = $DB->get_record("user", array("id"=>$entry->userid)); 00202 $pivottoshow = fullname($user); 00203 } 00204 00205 echo "<p class='mdl-align'><strong>".clean_text($pivottoshow)."</strong></p>" ; 00206 } 00207 } 00208 00209 glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat,false,true); 00210 } 00211 } 00212 00213 echo $OUTPUT->footer();