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
63 <form name="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
\r
65 <table class="data" summary="" rules="cols" style="width: 90%;">
\r
68 <th scope="col"> </th>
\r
69 <th scope="col"><?php echo _AT('glossary_term'); ?></th>
\r
70 <th scope="col"><?php echo _AT('glossary_definition'); ?></th>
\r
71 <th scope="col"><?php echo _AT('glossary_related'); ?></th>
\r
76 <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
81 if(!empty($gloss_results)) {
\r
82 foreach ($gloss_results as $row) {
\r
83 //get related term name
\r
85 if ($row['related_word_id']) {
\r
86 $sql = "SELECT word FROM ".TABLE_PREFIX."glossary WHERE word_id=".$row['related_word_id']." AND course_id=".$_SESSION['course_id'];
\r
87 $result = mysql_query($sql, $db);
\r
88 if ($row_related = mysql_fetch_array($result)) {
\r
89 $related_word = $row_related['word'];
\r
93 /* replaced w/ validate_length()
\r
94 $def_trunc = $substr($row['definition'], 0, 70);
\r
95 if ($strlen($def_trunc) < $strlen($row['definition'])) {
\r
96 $def_trunc .= ' …';
\r
99 $def_trunc = validate_length($row['definition'], 70, VALIDATE_LENGTH_FOR_DISPLAY);
\r
101 <tr onmousedown="document.form['m<?php echo $row['word_id']; ?>'].checked = true; rowselect(this);" id="r_<?php echo $row['word_id']; ?>">
\r
102 <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
103 <td valign="top"><label for="m<?php echo $row['word_id']; ?>"><?php echo AT_print(htmlentities_utf8($row['word']), 'glossary.word'); ?></label></td>
\r
104 <td style="whitespace:nowrap;"><?php echo AT_print(htmlentities_utf8($def_trunc), 'glossary.definition'); ?></td>
\r
105 <td valign="top"><?php echo AT_print(htmlentities_utf8($related_word), 'glossary.word'); ?></td>
\r
112 <td colspan="5"><?php echo _AT('none_found'); ?></td>
\r
122 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>