2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 if (!defined('AT_INCLUDE_PATH')) { exit; }
15 global $contentManager;
19 global $strlen, $substr, $strtolower;
23 if (isset($_GET['cid'])) {
24 $result = $contentManager->getContentPage($_GET['cid']);
26 if ($result && ($row = mysql_fetch_array($result))) {
27 $matches = find_terms($row['text']);
28 $matches = $matches[0];
29 $words = str_replace(array('[?]', '[/?]'), '', $matches);
30 $words = str_replace("\n", ' ', $words);
32 //case-insensitive, unique array of words
33 for($i=0;$i<count($words);$i++) {
34 $words[$i] = $strtolower($words[$i]);
36 $words = array_unique($words);
38 if (count($words) > 0) {
41 $glossary_key_lower = array_change_key_case($glossary);
42 foreach ($words as $k => $v) {
44 $v = $strtolower($v); //array_change_key_case change everything to lowercase, including encoding.
45 if (isset($glossary_key_lower[$v]) && $glossary_key_lower[$v] != '') {
46 $v_formatted = urldecode(array_search($glossary_key_lower[$v], $glossary));
48 $def = AT_print($glossary_key_lower[$v], 'glossary.definition');
51 echo '<a class="tooltip" href="'.$_base_path.'mods/_core/glossary/index.php?g_cid='.$_SESSION['s_cid'].htmlentities(SEP).'w='.urlencode($original_v).'#term" title="'.htmlentities_utf8($v_formatted).': '.$def.'">';
52 if ($strlen($original_v) > 26 ) {
53 $v_formatted = $substr($v_formatted, 0, 26-4).'...';
55 echo AT_print($v_formatted, 'glossary.word').'</a>';
61 /* there are defn's, but they're not defined in the glossary */
62 echo '<strong>'._AT('no_terms_found').'</strong>';
65 /* there are no glossary terms on this page */
66 echo '<strong>'._AT('no_terms_found').'</strong>';
69 /* there are no glossary terms in the system for this course or error */
70 echo '<strong>'._AT('na').'</strong>';
73 $savant->assign('dropdown_contents', ob_get_contents());
76 $savant->assign('title', _AT('glossary'));
77 $savant->display('include/box.tmpl.php');