2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2006 by Greg Gay, Joel Kronenberg & Heidi Hazelton */
\r
6 /* Adaptive Technology Resource Centre / University of Toronto */
\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
19 require (AT_INCLUDE_PATH.'lib/links.inc.php');
\r
21 if (isset($_POST['edit'], $_POST['word_id'])) {
\r
22 header('Location: edit.php?gid='.$_POST['word_id']);
\r
24 } else if (isset($_POST['delete'], $_POST['word_id'])) {
\r
25 header('Location: delete.php?gid='.$_POST['word_id']);
\r
27 } else if (!empty($_POST)) {
\r
28 $msg->addError('NO_ITEM_SELECTED');
\r
31 require(AT_INCLUDE_PATH.'header.inc.php');
\r
34 $sql = "SELECT * FROM ".TABLE_PREFIX."glossary WHERE course_id=$_SESSION[course_id] ORDER BY word";
\r
35 $result= mysql_query($sql, $db);
\r
37 $gloss_results = array();
\r
38 while ($row = mysql_fetch_assoc($result)) {
\r
39 $gloss_results[] = $row;
\r
41 $num_results = count($gloss_results);
\r
42 $results_per_page = 25;
\r
43 $num_pages = ceil($num_results / $results_per_page);
\r
44 $page = intval($_GET['p']);
\r
49 $count = (($page-1) * $results_per_page) + 1;
\r
50 $gloss_results = array_slice($gloss_results, ($page-1)*$results_per_page, $results_per_page);
\r
52 if($num_pages > 1) {
\r
53 echo _AT('page').': ';
\r
54 for ($i=1; $i<=$num_pages; $i++) {
\r
56 echo '<strong>'.$i.'</strong>';
\r
58 echo ' | <a href="'.$_SERVER['PHP_SELF'].'?p='.$i.'#list">'.$i.'</a>';
\r
64 <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
\r
66 <table class="data" summary="" rules="cols" style="width: 90%;">
\r
69 <th scope="col"> </th>
\r
70 <th scope="col"><?php echo _AT('glossary_term'); ?></th>
\r
71 <th scope="col"><?php echo _AT('glossary_definition'); ?></th>
\r
72 <th scope="col"><?php echo _AT('glossary_related'); ?></th>
\r
77 <td colspan="4"><input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" /> <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /></td>
\r
82 if(!empty($gloss_results)) {
\r
83 foreach ($gloss_results as $row) {
\r
84 //get related term name
\r
86 if ($row['related_word_id']) {
\r
87 $sql = "SELECT word FROM ".TABLE_PREFIX."glossary WHERE word_id=".$row['related_word_id']." AND course_id=".$_SESSION['course_id'];
\r
88 $result = mysql_query($sql, $db);
\r
89 if ($row_related = mysql_fetch_array($result)) {
\r
90 $related_word = $row_related['word'];
\r
94 $def_trunc = substr($row['definition'], 0, 70);
\r
95 if (strlen($def_trunc) < strlen($row['definition'])) {
\r
96 $def_trunc .= ' …';
\r
99 <tr onmousedown="document.form['m<?php echo $row['word_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['word_id']; ?>">
\r
100 <td valign="top" width="10"><input type="radio" name="word_id" value="<?php echo $row['word_id']; ?>" id="m<?php echo $row['word_id']; ?>" /></td>
\r
101 <td valign="top"><label for="m<?php echo $row['word_id']; ?>"><?php echo AT_print($row['word'], 'glossary.word'); ?></label></td>
\r
102 <td style="whitespace:nowrap;"><?php echo AT_print($def_trunc, 'glossary.definition'); ?></td>
\r
103 <td valign="top"><?php echo AT_print($related_word, 'glossary.word'); ?></td>
\r
110 <td colspan="5"><?php echo _AT('none_found'); ?></td>
\r
120 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>