2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto */
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 /************************************************************************/
13 // $Id: glossary.inc.php 5252 2005-08-09 16:39:26Z heidi $
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
16 global $contentManager;
20 global $strlen, $substr, $strtolower;
24 if (isset($_GET['cid'])) {
25 $result = $contentManager->getContentPage($_GET['cid']);
27 if ($result && ($row = mysql_fetch_array($result))) {
28 $matches = find_terms($row['text']);
29 $matches = $matches[0];
30 $words = str_replace(array('[?]', '[/?]'), '', $matches);
31 $words = str_replace("\n", ' ', $words);
33 //case-insensitive, unique array of words
34 for($i=0;$i<count($words);$i++) {
35 $words[$i] = $strtolower($words[$i]);
37 $words = array_unique($words);
39 if (count($words) > 0) {
42 $glossary_key_lower = array_change_key_case($glossary);
44 foreach ($words as $k => $v) {
46 $v = $strtolower(urlencode($v)); //array_change_key_case change everything to lowercase, including encoding.
48 if (isset($glossary_key_lower[$v]) && $glossary_key_lower[$v] != '') {
50 $v_formatted = urldecode(array_search($glossary_key_lower[$v], $glossary));
52 $def = htmlentities(AT_print($glossary_key_lower[$v], 'glossary.definition'), ENT_QUOTES, 'UTF-8');
55 echo '<a class="tooltip" href="'.$_base_path.'glossary/index.php?g_cid='.$_SESSION['s_cid'].htmlentities(SEP).'w='.urlencode($original_v).'#term" title="'.addslashes($v_formatted).': '.$def.'">';
56 if ($strlen($original_v) > 26 ) {
57 $v_formatted = $substr($v_formatted, 0, 26-4).'...';
59 echo AT_print($v_formatted, 'glossary.word').'</a>';
65 /* there are defn's, but they're not defined in the glossary */
66 echo '<em>'._AT('no_terms_found').'</em>';
69 /* there are no glossary terms on this page */
70 echo '<em>'._AT('no_terms_found').'</em>';
73 /* there are no glossary terms in the system for this course or error */
74 echo '<em>'._AT('na').'</em>';
77 $savant->assign('dropdown_contents', ob_get_contents());
80 $savant->assign('title', _AT('glossary'));
81 $savant->display('include/box.tmpl.php');