2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 require (AT_INCLUDE_PATH.'header.inc.php');
19 $sql = "SELECT word_id, related_word_id FROM ".TABLE_PREFIX."glossary WHERE related_word_id>0 AND course_id=$_SESSION[course_id] ORDER BY related_word_id";
20 $result = mysql_query($sql, $db);
21 while ($row = mysql_fetch_array($result)) {
22 $glossary_related[$row['related_word_id']][] = $row['word_id'];
25 $_GET['w'] = isset($_GET['w']) ? stripslashes($_GET['w']) : '';
28 $sql = "SELECT * FROM ".TABLE_PREFIX."glossary WHERE course_id=$_SESSION[course_id] AND word='".addslashes(urldecode($_GET['w']))."'";
30 $sql = "SELECT * FROM ".TABLE_PREFIX."glossary WHERE course_id=$_SESSION[course_id] ORDER BY word";
33 $result= mysql_query($sql, $db);
35 if(mysql_num_rows($result) > 0){
37 $gloss_results = array();
38 while ($row = mysql_fetch_assoc($result)) {
39 $gloss_results[] = $row;
41 $num_results = count($gloss_results);
42 $results_per_page = 25;
43 $num_pages = ceil($num_results / $results_per_page);
44 $page = isset($_GET['p']) ? intval($_GET['p']) : 0;
49 $count = (($page-1) * $results_per_page) + 1;
50 $gloss_results = array_slice($gloss_results, ($page-1)*$results_per_page, $results_per_page);
56 <?php for ($i=1; $i<=$num_pages; $i++): ?>
58 <?php if ($i == $page) : ?>
59 <a class="current" href="<?php echo url_rewrite('mods/_core/glossary/index.php?p='.$i.'#list'); ?>"><strong><?php echo $i; ?></strong></a>
61 <a href="<?php echo url_rewrite('mods/_core/glossary/index.php?p='.$i.'#list'); ?>"><?php echo $i; ?></a>
73 foreach ($gloss_results as $item):
74 $item['word'] = AT_print($item['word'], 'glossary.word');
76 if ($current_letter != $strtoupper($substr($item['word'], 0, 1))):
77 if ($current_letter != '') {
80 $current_letter = $strtoupper($substr($item['word'], 0, 1)); ?>
81 <h3 style="padding-bottom:5px;"><a name="<?php echo $current_letter; ?>"></a><?php echo $current_letter; ?></h3>
82 <dl style="margin:0px;">
86 <?php if ($_GET['w']): ?>
89 <a name="<?php echo urlencode($item['word']); ?>"></a>
91 <strong><?php echo stripslashes($item['word']); ?>
93 <?php if (($item['related_word_id'] != 0) || (isset($glossary_related) && is_array($glossary_related[urlencode($item['word_id'])]) )):
94 echo ' ('._AT('see').': ';
98 if ($item['related_word_id'] != 0) {
99 echo '<a href="'.$_SERVER['PHP_SELF'].'?w='.addslashes(urlencode($glossary_ids[$item['related_word_id']])).'#term">'.urldecode($glossary_ids[$item['related_word_id']]).'</a>';
103 if (is_array($glossary_related[urlencode($item['word_id'])]) ) {
104 $my_related = $glossary_related[$item['word_id']];
106 $num_related = count($my_related);
107 for ($i=0; $i<$num_related; $i++) {
108 if ($glossary_ids[$my_related[$i]] == $glossary_ids[$item['related_word_id']]) {
115 echo '<a href="'.$_SERVER['PHP_SELF'].'?w='.urlencode($glossary_ids[$my_related[$i]]).'#term">'.urldecode($glossary_ids[$my_related[$i]]).'</a>';
124 <dd><?php echo AT_print($item['definition'], 'glossary.definition'); ?><br /><br /></dd>
133 echo '<br /><br /><a href="mods/_core/glossary/index.php">'._AT('view_all').'</a>';
135 if ($_GET['g_cid']) {
136 $path = $contentManager->getContentPath(intval($_GET['g_cid']));
137 echo ' | '._AT('back_to').' <a href="'.url_rewrite('content.php?cid='.intval($_GET['g_cid'])).'">'.$path[0]['title'].'</a>';
142 echo '<p>'._AT('no_glossary_items').'</p>';
145 require(AT_INCLUDE_PATH.'footer.inc.php');