From: willcast Date: Tue, 18 Nov 2003 13:49:31 +0000 (+0000) Subject: - Improved printer-friendly version X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4f3e59c3a2f026e232bbf2482b22f36f3293b997;p=moodle.git - Improved printer-friendly version - Cosmetic change in the main view of a glossary. --- diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 11ddc74909..ad2ee87d5e 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -2,15 +2,13 @@ require_once("../../config.php"); require_once("lib.php"); - global $CFG; require_variable($id); // Course Module ID - require_variable($mode,"letter"); // format to show the entries - optional_variable($sortkey,"UPDATE"); // Sorting key if TAB = GLOSSARY_DATE_VIEW - optional_variable($sortorder,"asc"); // Sorting order if TAB = GLOSSARY_DATE_VIEW - optional_variable($hook,"ALL"); - optional_variable($eid); - optional_variable($search); + require_variable($mode,"letter"); // mode to show the entries + optional_variable($hook,"ALL"); // what to show + optional_variable($sortkey,"UPDATE"); // Sorting key + optional_variable($sortorder,"asc"); // Sorting order + optional_variable($offset); // number of entries to bypass if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); @@ -24,6 +22,11 @@ error("Course module is incorrect"); } + global $CFG; + if ( !$entriesbypage = $glossary->entbypage ) { + $entriesbypage = $CFG->glossary_entbypage; + } + if ($course->category) { require_login($course->id); if (isguest()) { @@ -31,141 +34,184 @@ } } - if ( $eid ) { - $mode = 'entry'; +/// stablishing flag variables + if ( $sortorder = strtolower($sortorder) ) { + if ($sortorder != 'asc' and $sortorder != 'desc') { + $sortorder = ''; + } } -/// Generating the SQL based on the format to show - switch ($mode) { - case "cat": - $where = ''; - if ($hook) { - if ( $hook != GLOSSARY_SHOW_ALL_CATEGORIES and $hook != GLOSSARY_SHOW_NOT_CATEGORISED ) { - $where = 'and c.id = ' . $hook; - } + if ( $sortkey = strtoupper($sortkey) ) { + if ($sortkey != 'CREATION' and + $sortkey != 'UPDATE' and + $sortkey != 'FIRSTNAME' and + $sortkey != 'LASTNAME' + ) { + $sortkey = ''; } - $entries = get_records_sql("SELECT ec.id, c.name pivot, e.* - FROM {$CFG->prefix}glossary_entries e, - {$CFG->prefix}glossary_entries_categories ec, - {$CFG->prefix}glossary_categories as c - WHERE e.id = ec.entryid AND ec.categoryid = c.id AND - (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id) - AND e.approved != 0 $where - ORDER BY c.name, e.concept"); + } + switch ( $mode = strtolower($mode) ) { + case 'entry': /// Looking for a certain entry id + $tab = GLOSSARY_STANDARD_VIEW; break; - - case "date": - //// Valid sorting values - switch ($sortkey) { - case 'CREATION': - $sortkey = 'timecreated'; - break; - - case 'UPDATE': - default: - $sortkey = 'timemodified'; - break; - } - if ($sortorder != 'asc' and $sortorder != 'desc') { - $sortorder = 'asc'; + + case 'cat': /// Looking for a certain cat + $tab = GLOSSARY_CATEGORY_VIEW; + if ( $hook > 0 ) { + $category = get_record("glossary_categories","id",$hook); } + break; - $entries = get_records_sql("SELECT e.timemodified pivot, e.* - FROM {$CFG->prefix}glossary_entries e - WHERE (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id) - AND e.approved != 0 - ORDER BY e.$sortkey $sortorder"); + case 'approval': /// Looking for entries waiting for approval + $tab = GLOSSARY_APPROVAL_VIEW; + if ( !$hook and !$sortkey and !$sortorder) { + $hook = 'ALL'; + } + break; + case 'term': /// Looking for entries that include certain term in its concept, definition or aliases + $tab = GLOSSARY_STANDARD_VIEW; break; - case "letter": - default: - switch ($CFG->dbtype) { - case "postgres7": - $pivot = "substring(e.concept, 1,1)"; - break; - - case "mysql": - $pivot = "left(e.concept,1)"; - break; - default: - $pivot = "e.concept"; - break; - } - if ( $hook ) { - if ($hook != 'ALL' and $hook != 'SPECIAL') { - switch ($CFG->dbtype) { - case 'postgres7': - $where = 'and substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; - break; - case 'mysql': - $where = 'and left(ucase(concept),' . strlen($hook) . ") = '" . strtoupper($hook) . "'"; - break; - default: - $where = ''; - } - } - } elseif ($eid) { - $where = " and e.id = $eid"; + case 'date': + $tab = GLOSSARY_DATE_VIEW; + if ( !$sortkey ) { + $sortkey = 'UPDATE'; + } + if ( !$sortorder ) { + $sortorder = 'desc'; + } + break; + + case 'author': /// Looking for entries, browsed by author + $tab = GLOSSARY_AUTHOR_VIEW; + if ( !$hook ) { + $hook = 'ALL'; + } + if ( !$sortkey ) { + $sortkey = 'FIRSTNAME'; + } + if ( !$sortorder ) { + $sortorder = 'asc'; } - - $entries = get_records_sql("SELECT e.id, $pivot pivot, e.* - FROM {$CFG->prefix}glossary_entries e - WHERE (e.glossaryid = $glossary->id or e.sourceglossaryid = $glossary->id) - AND e.approved != 0 $where - ORDER BY e.concept $sortorder"); break; - } - echo '

' . get_string("course") . ': ' . $course->fullname . '
'; - echo get_string("modulename","glossary") . ': ' . $glossary->name . '

'; + case 'letter': /// Looking for entries that begin with a certain letter, ALL or SPECIAL characters + default: + $tab = GLOSSARY_STANDARD_VIEW; + if ( !$hook ) { + $hook = 'ALL'; + } + break; + } - if ( !$entries ) { - echo get_string("noentries","glossary"); - exit; + include_once("sql.php"); + + $entriesshown = 0; + $currentpivot = ''; + if ( $hook == 'SPECIAL' ) { + $alphabet = explode(",", get_string("alphabet")); } - - $groupheader = ''; $tableisopen = 0; - foreach ($entries as $entry) { + + $site = get_record("course","id",1); + echo '

' . userdate(time()) . '

'; + echo '' . $site->fullname . '
'; + echo get_string("course") . ': ' . $course->fullname . '
'; + echo get_string("modulename","glossary") . ': ' . $glossary->name . '

'; + + foreach ($allentries as $entry) { + /// Setting the pivot for the current entry $pivot = $entry->pivot; - if ( $CFG->dbtype != "postgres7" and $CFG->dbtype != "mysql" and $mode != "cat") { + if ( !$fullpivot ) { $pivot = $pivot[0]; - } + } + + /// + /// Validating special cases not covered by the SQL statement + /// + + /// if we're browsing by alphabet and the current concept does not begin with + /// the letter we are look for. + $showentry = 1; + if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) { + if ( substr($entry->concept, 0, strlen($hook)) != $hook ) { + $showentry = 0; + } + } - if ($mode != "date") { - if (strtoupper($groupheader) != strtoupper($pivot)) { - /// Printing th eheader of the group - - if ($tableisopen) { - echo ''; - echo ''; - $tableisopen = 0; + /// if we're browsing for letter, looking for special characters not covered + /// in the alphabet + if ( $showentry and $hook == 'SPECIAL' ) { + $initial = $entry->concept[0]; + for ($i = 0; $i < count($alphabet); $i++) { + $curletter = $alphabet[$i]; + if ( $curletter == $initial ) { + + $showentry = 0; + break; } - $groupheader = $pivot; - echo '

' . $groupheader . '

'; } - } - if ( !$tableisopen ) { - echo '
'; - echo ''; - $tableisopen = 1; - } + } - echo ''; - echo ''; - echo '
'. $entry->concept . ': '; + /// if we're browsing categories, looking for entries not categorised. + if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { + if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) { + $showentry = 0; + } + } - if ( $entry->attachment) { - glossary_print_entry_attachment($entry); + /// if the entry is not approved, deal with it based on the current view and + /// user. + if ( $showentry and $mode != 'approval' ) { + if ( !$entry->approved and isteacher($course->id, $entry->userid) ) { + $showentry = 0; + } } - echo format_text("$entry->definition",$entry->format); + /// ok, if it's a valid entry.. Print it. + if ( $showentry ) { + + if ( $currentpivot != strtoupper($pivot) ) { + + // print the group break if apply + if ( $printpivot ) { + $currentpivot = strtoupper($pivot); + if ( !$tableisopen ) { + echo ''; + $tableisopen = 1; + } + + echo ''; + $pivottoshow = $currentpivot; + if ( isset($entry->uid) ) { + // printing the user icon if defined (only when browsing authors) + echo ''; + echo ''; + } + } - echo ''; + echo ''; + echo ''; + echo ''; + } } if ($tableisopen) { echo '
'; + $pivottoshow = $entry->uname; + } else { + echo ''; + } + + echo "$pivottoshow" ; + echo '
'. $entry->concept . ': '; + + if ( $entry->attachment) { + glossary_print_entry_attachment($entry); + } + echo strip_tags($entry->definition); + + echo '

'; - echo ''; } + echo '
' . userdate(time()) . '
' ?> diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php new file mode 100644 index 0000000000..030029b009 --- /dev/null +++ b/mod/glossary/sql.php @@ -0,0 +1,202 @@ +id ) { + $userid = "OR ge.userid = $USER->id"; + } + switch ($tab) { + case GLOSSARY_CATEGORY_VIEW: + if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES ) { + + $sqlselect = "SELECT gec.id, gc.name pivot, ge.*"; + $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, + {$CFG->prefix}glossary_entries_categories gec, + {$CFG->prefix}glossary_categories gc"; + $sqlwhere = "WHERE (ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id') AND + ge.id = gec.entryid AND gc.id = gec.categoryid AND + (ge.approved != 0 $userid)"; + + if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) { + $sqlorderby = ' ORDER BY gc.name, ge.timecreated'; + } else { + $sqlorderby = ' ORDER BY gc.name, ge.concept'; + } + + } elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { + + $printpivot = 0; + $sqlselect = "SELECT concept pivot, ge.*"; + $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; + $sqlwhere = "WHERE (glossaryid = '$glossary->id' OR sourceglossaryid = '$glossary->id') AND + (ge.approved != 0 $userid)"; + + + $sqlorderby = ' ORDER BY concept'; + + } else { + + $printpivot = 0; + $sqlselect = "SELECT ce.id, c.name pivot, ge.*"; + $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c"; + $sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = $hook AND + ce.categoryid = c.id AND ge.approved != 0 AND + (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND + (ge.approved != 0 $userid)"; + + $sqlorderby = ' ORDER BY c.name, ge.concept'; + + } + break; + case GLOSSARY_AUTHOR_VIEW: + + $where = ''; + switch ($CFG->dbtype) { + case 'postgres7': + $usernametoshow = "u.firstname || ' ' || u.lastname"; + if ( $sortkey == 'FIRSTNAME' ) { + $usernamefield = "u.firstname || ' ' || u.lastname"; + } else { + $usernamefield = "u.lastname || ' ' || u.firstname"; + } + $where = "AND substr(ucase($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'"; + break; + case 'mysql': + $usernametoshow = "CONCAT(CONCAT(u.firstname,' '), u.lastname)"; + if ( $sortkey == 'FIRSTNAME' ) { + $usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)"; + } else { + $usernamefield = "CONCAT(CONCAT(u.lastname,' '), u.firstname)"; + } + $where = "AND left(ucase($usernamefield)," . strlen($hook) . ") = '$hook'"; + break; + } + if ( $hook == 'ALL' ) { + $where = ''; + } + + $sqlselect = "SELECT ge.id, $usernamefield pivot, $usernametoshow uname, u.id uid, ge.*"; + $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u"; + $sqlwhere = "WHERE ge.userid = u.id AND + (ge.approved != 0 $userid) + $where AND + (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id)"; + $sqlorderby = "ORDER BY $usernamefield $sortorder, ge.concept"; + break; + case GLOSSARY_APPROVAL_VIEW: + $fullpivot = 0; + $printpivot = 0; + + $where = ''; + if ($hook != 'ALL' and $hook != 'SPECIAL') { + switch ($CFG->dbtype) { + case 'postgres7': + $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; + break; + case 'mysql': + $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'"; + break; + } + } + + $sqlselect = "SELECT ge.concept pivot, ge.*"; + $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; + $sqlwhere = "WHERE (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND + ge.approved = 0 $where"; + + if ( $sortkey ) { + $sqlorderby = "ORDER BY $sortkey $sortorder"; + } else { + $sqlorderby = "ORDER BY ge.concept"; + } + break; + case GLOSSARY_DATE_VIEW: + case GLOSSARY_STANDARD_VIEW: + default: + $sqlselect = "SELECT ge.concept pivot, ge.*"; + $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; + + $where = ''; + $fullpivot = 0; + if ($CFG->dbtype == "postgres7") { + $LIKE = "ILIKE"; // case-insensitive + } else { + $LIKE = "LIKE"; + } + + switch ( $mode ) { + case 'search': + $printpivot = 0; + $where = "AND ( ge.concept $LIKE '%$hook%'"; + if ( $fullsearch ) { + $where .= "OR ge.definition $LIKE '%$hook%')"; + } else { + $where .= ")"; + } + break; + + case 'term': + $printpivot = 0; + $sqlfrom .= ", {$CFG->prefix}glossary_alias ga"; + $where = "AND ge.id = ga.entryid AND + (ge.concept = '$hook' OR ga.alias = '$hook' ) + "; + break; + + case 'entry': + $printpivot = 0; + $where = "AND ge.id = $hook"; + break; + + case 'letter': + if ($hook != 'ALL' and $hook != 'SPECIAL') { + switch ($CFG->dbtype) { + case 'postgres7': + $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; + break; + case 'mysql': + $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'"; + break; + } + } + break; + } + + $sqlwhere = "WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) AND + (ge.approved != 0 $userid) + $where"; + switch ( $tab ) { + case GLOSSARY_DATE_VIEW: + $sqlorderby = "ORDER BY $sortkey $sortorder"; + break; + + case GLOSSARY_STANDARD_VIEW: + $sqlorderby = "ORDER BY ge.concept"; + default: + break; + } + break; + } + $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); + $sqllimit = ''; + if ( $offset >= 0 ) { + $sqllimit = " LIMIT $offset, $entriesbypage"; + } + $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); + +?> \ No newline at end of file diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 62626c2166..49adb9526d 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -48,7 +48,7 @@ global $CFG, $THEME, $USER; if ( !$entriesbypage = $glossary->entbypage ) { - $entriesbypage = 10; + $entriesbypage = $CFG->glossary_entbypage; } /// setting the right fram for a "Continuous" glossary @@ -178,24 +178,25 @@ navmenu($course, $cm)); echo '

' . stripslashes_safe($glossary->name); - if ($isuserframe ) { + if ( $isuserframe and $mode != 'search') { /// the "Print" icon - echo " id&tab=$tab&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder\">"; + echo " id&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">"; echo ''; } echo '

'; /// Info box if ( $glossary->intro ) { - print_simple_box_start('center','70%'); + echo '
'; echo format_text($glossary->intro); print_simple_box_end(); } /// Search box - echo '

'; - print_simple_box_start("center", "", $THEME->cellheading); - echo '

'; +// echo '

'; + echo '
'; + + echo '

'; echo ' '; echo ' '; @@ -220,213 +221,7 @@ break; } -/// Creating the SQL statements - -/// Pivot is the field that set the break by groups (category, initial, author name, etc) - -/// fullpivot indicate if the whole pivot should be compared agasint the db or just the first letter -/// printpivot indicate if the pivot should be printed or not - $fullpivot = 1; - $printpivot = 1; - -// global $db; -// $db->debug = true; - $userid = ''; - if ( $USER->id ) { - $userid = "OR ge.userid = $USER->id"; - } - switch ($tab) { - case GLOSSARY_CATEGORY_VIEW: - if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES ) { - - $sqlselect = "SELECT gec.id, gc.name pivot, ge.*"; - $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, - {$CFG->prefix}glossary_entries_categories gec, - {$CFG->prefix}glossary_categories gc"; - $sqlwhere = "WHERE (ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id') AND - ge.id = gec.entryid AND gc.id = gec.categoryid AND - (ge.approved != 0 $userid)"; - - if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) { - $sqlorderby = ' ORDER BY gc.name, ge.timecreated'; - } else { - $sqlorderby = ' ORDER BY gc.name, ge.concept'; - } - - } elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) { - - $printpivot = 0; - $sqlselect = "SELECT concept pivot, ge.*"; - $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; - $sqlwhere = "WHERE (glossaryid = '$glossary->id' OR sourceglossaryid = '$glossary->id') AND - (ge.approved != 0 $userid)"; - - - $sqlorderby = ' ORDER BY concept'; - - } else { - - $printpivot = 0; - $sqlselect = "SELECT ce.id, c.name pivot, ge.*"; - $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c"; - $sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = $hook AND - ce.categoryid = c.id AND ge.approved != 0 AND - (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND - (ge.approved != 0 $userid)"; - - $sqlorderby = ' ORDER BY c.name, ge.concept'; - - } - $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); - $sqllimit = " LIMIT $offset, $entriesbypage"; - $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); - break; - case GLOSSARY_AUTHOR_VIEW: - - $where = ''; - switch ($CFG->dbtype) { - case 'postgres7': - $usernametoshow = "u.firstname || ' ' || u.lastname"; - if ( $sortkey == 'FIRSTNAME' ) { - $usernamefield = "u.firstname || ' ' || u.lastname"; - } else { - $usernamefield = "u.lastname || ' ' || u.firstname"; - } - $where = "AND substr(ucase($usernamefield),1," . strlen($hook) . ") = '" . strtoupper($hook) . "'"; - break; - case 'mysql': - $usernametoshow = "CONCAT(CONCAT(u.firstname,' '), u.lastname)"; - if ( $sortkey == 'FIRSTNAME' ) { - $usernamefield = "CONCAT(CONCAT(u.firstname,' '), u.lastname)"; - } else { - $usernamefield = "CONCAT(CONCAT(u.lastname,' '), u.firstname)"; - } - $where = "AND left(ucase($usernamefield)," . strlen($hook) . ") = '$hook'"; - break; - } - if ( $hook == 'ALL' ) { - $where = ''; - } - - $sqlselect = "SELECT ge.id, $usernamefield pivot, $usernametoshow uname, u.id uid, ge.*"; - $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u"; - $sqlwhere = "WHERE ge.userid = u.id AND - (ge.approved != 0 $userid) - $where AND - (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id)"; - $sqlorderby = "ORDER BY $usernamefield $sortorder, ge.concept"; - - $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); - $sqllimit = " LIMIT $offset, $entriesbypage"; - $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); - break; - case GLOSSARY_APPROVAL_VIEW: - $fullpivot = 0; - $printpivot = 0; - - $where = ''; - if ($hook != 'ALL' and $hook != 'SPECIAL') { - switch ($CFG->dbtype) { - case 'postgres7': - $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; - break; - case 'mysql': - $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'"; - break; - } - } - - $sqlselect = "SELECT ge.concept pivot, ge.*"; - $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; - $sqlwhere = "WHERE (ge.glossaryid = $glossary->id OR ge.sourceglossaryid = $glossary->id) AND - ge.approved = 0 $where"; - - if ( $sortkey ) { - $sqlorderby = "ORDER BY $sortkey $sortorder"; - } else { - $sqlorderby = "ORDER BY ge.concept"; - } - - $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); - $sqllimit = " LIMIT $offset, $entriesbypage"; - $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); - break; - case GLOSSARY_DATE_VIEW: - case GLOSSARY_STANDARD_VIEW: - default: - $sqlselect = "SELECT ge.concept pivot, ge.*"; - $sqlfrom = "FROM {$CFG->prefix}glossary_entries ge"; - - $where = ''; - $fullpivot = 0; - if ($CFG->dbtype == "postgres7") { - $LIKE = "ILIKE"; // case-insensitive - } else { - $LIKE = "LIKE"; - } - - switch ( $mode ) { - case 'search': - $printpivot = 0; - $where = "AND ( ge.concept $LIKE '%$hook%'"; - if ( $fullsearch ) { - $where .= "OR ge.definition $LIKE '%$hook%')"; - } else { - $where .= ")"; - } - break; - - case 'term': - $printpivot = 0; - $sqlfrom .= ", {$CFG->prefix}glossary_alias ga"; - $where = "AND ge.id = ga.entryid AND - (ge.concept = '$hook' OR ga.alias = '$hook' ) - "; -// $where = "AND ge.id = ga.entryid AND ( -// (ge.casesensitive != 0 and ( ge.concept LIKE BINARY '$hook' OR ga.alias LIKE BINARY '$hook' ) ) or -// (ge.casesensitive = 0 and ( ucase(ge.concept) = ucase('$hook') OR ucase(ga.alias) = ucase('$hook') ) ) -// )"; - break; - - case 'entry': - $printpivot = 0; - $where = "AND ge.id = $hook"; - break; - - case 'letter': - if ($hook != 'ALL' and $hook != 'SPECIAL') { - switch ($CFG->dbtype) { - case 'postgres7': - $where = 'AND substr(ucase(concept),1,' . strlen($hook) . ') = \'' . strtoupper($hook) . '\''; - break; - case 'mysql': - $where = 'AND left(ucase(concept),' . strlen($hook) . ") = '$hook'"; - break; - } - } - break; - } - - $sqlwhere = "WHERE (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) AND - (ge.approved != 0 $userid) - $where"; - switch ( $tab ) { - case GLOSSARY_DATE_VIEW: - $sqlorderby = "ORDER BY $sortkey $sortorder"; - break; - - case GLOSSARY_STANDARD_VIEW: - $sqlorderby = "ORDER BY ge.concept"; - default: - break; - } - - $count = count_records_sql("select count(*) $sqlfrom $sqlwhere"); - $sqllimit = " LIMIT $offset, $entriesbypage"; - $allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit"); - - break; - } + include_once("sql.php"); /// printing the entries $entriesshown = 0; @@ -436,23 +231,31 @@ } if ($allentries) { /// printing the paging links - $paging = ''; + $paging = get_string("allentries","glossary"); + if ( $offset < 0 ) { + $paging = '' . $paging . ''; + } else { + $paging = "" . $paging . ''; + } if ($count > $entriesbypage ) { for ($i = 0; ($i*$entriesbypage) < $count ; $i++ ) { if ( $paging != '' ) { - if ($i % 20 == 0) { + if ($i % 20 == 0 and $i) { $paging .= '
'; } else { $paging .= ' | '; } } + $pagenumber = (string) ($i + 1 ); if ($offset / $entriesbypage == $i) { - $paging .= '' . ($i + 1 ) . ''; + $paging .= '' . $pagenumber . ''; } else { - $paging .= "" . ($i+1) . ''; + $paging .= "" . $pagenumber . ''; } } $paging = "

" . get_string ("jumpto") . " $paging
"; + } else { + $paging = ''; } echo $paging;