MDL-55575 mod_glossary: Allow viewing all entries on one page
This commit is contained in:
@@ -8,6 +8,7 @@ require_once("lib.php");
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$sortorder = optional_param('sortorder', 'asc', PARAM_ALPHA); // Sorting order
|
||||
$offset = optional_param('offset', 0, PARAM_INT); // number of entries to bypass
|
||||
$pagelimit = optional_param('pagelimit', 0, PARAM_INT); // Number of entries per page, 0 if unlimited.
|
||||
$displayformat = optional_param('displayformat',-1, PARAM_INT);
|
||||
|
||||
$mode = required_param('mode', PARAM_ALPHA); // mode to show the entries
|
||||
@@ -47,8 +48,8 @@ if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
if ( !$entriesbypage = $glossary->entbypage ) {
|
||||
$entriesbypage = $CFG->glossary_entbypage;
|
||||
if ($pagelimit < 0) {
|
||||
$pagelimit = 0;
|
||||
}
|
||||
|
||||
require_course_login($course, true, $cm);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* string $sortkey The key to sort the records.
|
||||
* string $sortorder The order of the sorting.
|
||||
* int $offset The number of records to skip.
|
||||
* int $entriesbypage The number of entries per page.
|
||||
* int $pagelimit The number of entries on this page, or 0 if unlimited.
|
||||
* string $mode The mode of browsing.
|
||||
* string $tab The tab selected.
|
||||
*/
|
||||
@@ -43,13 +43,13 @@ switch ($tab) {
|
||||
$pivotkey = 'userid';
|
||||
$field = ($sortkey == 'LASTNAME' ? 'LASTNAME' : 'FIRSTNAME');
|
||||
list($allentries, $count) = glossary_get_entries_by_author($glossary, $context, $hook,
|
||||
$field, $sortorder, $offset, $entriesbypage);
|
||||
$field, $sortorder, $offset, $pagelimit);
|
||||
unset($field);
|
||||
break;
|
||||
|
||||
case GLOSSARY_CATEGORY_VIEW:
|
||||
$hook = (int) $hook; // Make sure it's properly casted to int.
|
||||
list($allentries, $count) = glossary_get_entries_by_category($glossary, $context, $hook, $offset, $entriesbypage);
|
||||
list($allentries, $count) = glossary_get_entries_by_category($glossary, $context, $hook, $offset, $pagelimit);
|
||||
$pivotkey = 'categoryname';
|
||||
if ($hook != GLOSSARY_SHOW_ALL_CATEGORIES) {
|
||||
$printpivot = false;
|
||||
@@ -60,7 +60,7 @@ switch ($tab) {
|
||||
$printpivot = false;
|
||||
$field = ($sortkey == 'CREATION' ? 'CREATION' : 'UPDATE');
|
||||
list($allentries, $count) = glossary_get_entries_by_date($glossary, $context, $field, $sortorder,
|
||||
$offset, $entriesbypage);
|
||||
$offset, $pagelimit);
|
||||
unset($field);
|
||||
break;
|
||||
|
||||
@@ -68,7 +68,7 @@ switch ($tab) {
|
||||
$fullpivot = false;
|
||||
$printpivot = false;
|
||||
list($allentries, $count) = glossary_get_entries_to_approve($glossary, $context, $hook, $sortkey, $sortorder,
|
||||
$offset, $entriesbypage);
|
||||
$offset, $pagelimit);
|
||||
break;
|
||||
|
||||
case GLOSSARY_STANDARD_VIEW:
|
||||
@@ -77,12 +77,12 @@ switch ($tab) {
|
||||
switch ($mode) {
|
||||
case 'search':
|
||||
list($allentries, $count) = glossary_get_entries_by_search($glossary, $context, $hook, $fullsearch,
|
||||
$sortkey, $sortorder, $offset, $entriesbypage);
|
||||
$sortkey, $sortorder, $offset, $pagelimit);
|
||||
break;
|
||||
|
||||
case 'term':
|
||||
$printpivot = false;
|
||||
list($allentries, $count) = glossary_get_entries_by_term($glossary, $context, $hook, $offset, $entriesbypage);
|
||||
list($allentries, $count) = glossary_get_entries_by_term($glossary, $context, $hook, $offset, $pagelimit);
|
||||
break;
|
||||
|
||||
case 'entry':
|
||||
@@ -102,7 +102,7 @@ switch ($tab) {
|
||||
|
||||
case 'letter':
|
||||
default:
|
||||
list($allentries, $count) = glossary_get_entries_by_letter($glossary, $context, $hook, $offset, $entriesbypage);
|
||||
list($allentries, $count) = glossary_get_entries_by_letter($glossary, $context, $hook, $offset, $pagelimit);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
+22
-3
@@ -68,9 +68,13 @@ if ( !$entriesbypage = $glossary->entbypage ) {
|
||||
$entriesbypage = $CFG->glossary_entbypage;
|
||||
}
|
||||
|
||||
/// If we have received a page, recalculate offset
|
||||
if ($page != 0 && $offset == 0) {
|
||||
// If we have received a page, recalculate offset and page size.
|
||||
$pagelimit = $entriesbypage;
|
||||
if ($page > 0 && $offset == 0) {
|
||||
$offset = $page * $entriesbypage;
|
||||
} else if ($page < 0) {
|
||||
$offset = 0;
|
||||
$pagelimit = 0;
|
||||
}
|
||||
|
||||
/// setting the default values for the display mode of the current glossary
|
||||
@@ -343,7 +347,22 @@ if ($showcommonelements) {
|
||||
/// The print icon
|
||||
if ( $showcommonelements and $mode != 'search') {
|
||||
if (has_capability('mod/glossary:manageentries', $context) or $glossary->allowprintview) {
|
||||
echo " <a class='printicon' title =\"". get_string("printerfriendly","glossary") ."\" href=\"print.php?id=$cm->id&mode=$mode&hook=".urlencode($hook)."&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">" . get_string("printerfriendly","glossary")."</a>";
|
||||
$params = array(
|
||||
'id' => $cm->id,
|
||||
'mode' => $mode,
|
||||
'hook' => $hook,
|
||||
'sortkey' => $sortkey,
|
||||
'sortorder' => $sortorder,
|
||||
'offset' => $offset,
|
||||
'pagelimit' => $pagelimit
|
||||
);
|
||||
$printurl = new moodle_url('/mod/glossary/print.php', $params);
|
||||
$printtitle = get_string('printerfriendly', 'glossary');
|
||||
$printattributes = array(
|
||||
'class' => 'printicon',
|
||||
'title' => $printtitle
|
||||
);
|
||||
echo html_writer::link($printurl, $printtitle, $printattributes);
|
||||
}
|
||||
}
|
||||
/// End glossary controls
|
||||
|
||||
Reference in New Issue
Block a user