2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /****************************************************************************/
\r
14 define('AT_INCLUDE_PATH', '../../../../include/');
\r
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
\r
17 authenticate(AT_PRIV_GLOSSARY);
\r
20 if (isset($_POST['edit'], $_POST['word_id'])) {
\r
21 header('Location: edit.php?gid='.$_POST['word_id']);
\r
23 } else if (isset($_POST['delete'], $_POST['word_id'])) {
\r
24 header('Location: delete.php?gid='.$_POST['word_id']);
\r
26 } else if (!empty($_POST)) {
\r
27 $msg->addError('NO_ITEM_SELECTED');
\r
30 require(AT_INCLUDE_PATH.'header.inc.php');
\r
33 $sql = "SELECT * FROM ".TABLE_PREFIX."glossary WHERE course_id=$_SESSION[course_id] ORDER BY word";
\r
34 $result= mysql_query($sql, $db);
\r
36 $gloss_results = array();
\r
37 while ($row = mysql_fetch_assoc($result)) {
\r
38 $gloss_results[] = $row;
\r
40 $num_results = count($gloss_results);
\r
41 $results_per_page = 25;
\r
42 $num_pages = ceil($num_results / $results_per_page);
\r
43 $page = intval($_GET['p']);
\r
48 $count = (($page-1) * $results_per_page) + 1;
\r
49 $gloss_results = array_slice($gloss_results, ($page-1)*$results_per_page, $results_per_page);
\r
51 if($num_pages > 1) {
\r
52 echo _AT('page').': ';
\r
53 for ($i=1; $i<=$num_pages; $i++) {
\r
55 echo '<strong>'.$i.'</strong>';
\r
57 echo ' | <a href="'.$_SERVER['PHP_SELF'].'?p='.$i.'#list">'.$i.'</a>';
\r
62 if(!empty($gloss_results)) {
\r
63 foreach ($gloss_results as $row) {
\r
64 //get related term name
\r
66 if ($row['related_word_id']) {
\r
67 $sql = "SELECT word FROM ".TABLE_PREFIX."glossary WHERE word_id=".$row['related_word_id']." AND course_id=".$_SESSION['course_id'];
\r
68 $result = mysql_query($sql, $db);
\r
69 if ($row_related = mysql_fetch_array($result)) {
\r
70 $related_word = $row_related['word'];
\r
74 $def_trunc = validate_length($row['definition'], 70, VALIDATE_LENGTH_FOR_DISPLAY);
\r
75 $gloss_results_row[] = $row;
\r
78 $savant->assign('gloss_results_row', $gloss_results_row);
\r
79 $savant->assign('related_word', $related_word);
\r
80 $savant->assign('def_trunc', $def_trunc);
\r
82 $savant->display('instructor/glossary/index.tmpl.php');
\r
83 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>