1121b3312c80bf55d316a236a99cbc2db46d8781
[atutor.git] / docs / mods / _core / editor / editor_tabs / glossary.inc.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
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$
14
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
16
17
18 ?>
19
20 <div class="row"><?php
21         if ($num_terms == 0) {
22                 echo _AT('no_terms_found');
23         }
24
25         $num_glossary = count($glossary_ids);
26
27         for ($i=0; $i<$num_terms; $i++) {
28                 for ($j=0;$j<$i;$j++) {
29                         if ($strtolower($word[$j]) == $strtolower($word[$i])) {
30                                 /* skip multiple occurances of the same word: */
31                                 continue 2;
32                         }
33                 }
34
35                 ?><table cellspacing="1" cellpadding="0" border="0" class="bodyline" summary="" align="center">
36                 <tr>
37                         <td align="right" class="row1"><strong><?php 
38                                 $key = in_array_cin($word[$i], $glossary_ids);
39
40                                 if ($key === false) {
41                                         echo '<strong>'._AT('new').'</strong> ';
42                                         $current_word = $word[$i];
43                                         $current_defn = $_POST['glossary_defs'][$word[$i]];
44                                 } else {
45                                         $current_word = $glossary_ids[$key];
46                                         if (!$_POST['glossary_defs'][$word[$i]]) {
47                                                 $current_defn = $glossary[$glossary_ids[$key]];
48                                         } else {
49                                                 $current_defn = $_POST['glossary_defs'][$word[$i]];
50                                         }
51                                 }
52
53                                 echo _AT('glossary_term'); ?>:</strong></td>
54                         <td class="row1"><?php echo AT_print(urldecode($current_word), 'glossary.word'); ?></td>
55                 </tr>
56                 <?php if ($strlen(urldecode($current_word)) > 60): ?>
57                 <tr>
58                         <td>&nbsp;</td>
59                         <td><strong><?php echo _AT('glossary_term_limit'); ?></strong></td>
60                 </tr>
61                 <?php else: ?>
62                 <tr>
63                         <td valign="top" align="right" class="row1"><label for="body<?php echo $i; ?>"><strong><?php echo _AT('glossary_definition');  ?>:</strong></label></td>
64                         <td class="row1">
65                                 <textarea name="glossary_defs[<?php echo AT_print($word[$i], 'glossary.word'); ?>]" class="formfield" cols="55" rows="4" id="body<?php echo $i; ?>"><?php 
66                                         echo ContentManager::cleanOutput($current_defn); 
67                 
68                 ?></textarea></td>
69                 </tr>
70                 <tr>
71                         <td valign="top" align="right" class="row1"><label for="r<?php echo $i; ?>"><strong><?php echo _AT('glossary_related');  ?>:</strong></label></td>
72                         <td class="row1"><?php
73
74                                 if ($num_glossary > 1) {
75                                         echo '<select name="related_term['.AT_print($word[$i], 'glossary.word').']" id="r'.$i.'">';
76                                         echo '<option value="0"></option>';
77                                         foreach ($glossary_ids as $id => $term) {
78                                                 if ($term == $word[$i]) {
79                                                         continue;
80                                                 }
81                                                 echo '<option value="'.$id.'"';
82                                                 if ($_POST['related_term'][$word[$i]] == $id) {
83                                                         echo ' selected="selected"';
84                                                 }
85                                                 echo '>'.AT_print(urldecode($term), 'glossary.word').'</option>';
86                                         }
87                                         echo '</select>';
88                                 } else {
89                                         echo _AT('none_available');
90                                 }
91
92                                 ?></td>
93                 </tr>
94                 <?php endif; ?>
95                 </table><br />
96         <?php } ?>
97                 
98         </div>