made a copy
[atutor.git] / include / lib / alternatives_functions.inc.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay & Joel Kronenberg        */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
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 /**
16 * It provides a link to a resource, which opens such a resource in a new window.
17 * @access       public
18 * @param        $resource:                      the name of the file.
19 * @return       
20 * @see          
21 * @author       Silvia Mirri
22 */
23 function link_name_resource($resource){
24         echo '<a href="'.$resource.'" target="_blank">'.$resource.'</a>';
25 }
26  
27 /**
28 * It provides in the page the appropriated checkbox, in order to allow type resource and type alternative specification.
29 * @access       public
30 * @param        $resource_id:           the id of the resource.
31 * @param        $alt:                           it identifies if the resource is a primary or an alternative one.
32 * @param        $kind:                          it identifies the resource type: if the resource is textual or not.
33 * @return       
34 * @see          $db                             in include/vitals.inc.php
35 * @author       Silvia Mirri
36 */
37 function checkbox_types($resource_id, $alt, $kind){
38         global $db;
39         
40         $legend = $alt.'_resource_type';
41         echo '<fieldset>';
42         echo '<legend>'. _AT($legend).'</legend>';
43
44         $sql_types              = "SELECT * FROM ".TABLE_PREFIX."resource_types";
45         $types                  = mysql_query($sql_types, $db);
46
47         $sql_set_types  = "SELECT type_id FROM ".TABLE_PREFIX.$alt."_resources_types where ".$alt."_resource_id=".$resource_id;
48         $set_types              = mysql_query($sql_set_types, $db);
49         
50         $resource_types = false;
51         $j                              = 0;
52         
53         if (mysql_num_rows($set_types) > 0){
54                 while ($set_type = mysql_fetch_assoc($set_types)) {
55                         $resource_types[$j] = $set_type[type_id];
56                         $j++;
57                 }
58         }
59         else echo '<p class="unsaved">'. _AT('define_resource_type').'</p>';
60         
61         while ($type = mysql_fetch_assoc($types)) {
62                 if ((($alt == 'primary')) && ($kind == 'non_textual') && (($type['type'] == 'sign_language')))
63                         continue;
64                 else {
65                         echo '<input type="checkbox" name="checkbox_'.$type['type'].'_'.$resource_id.'_'.$alt.'" value="'.$type['type'].'_'.$resource_id.'_'.$alt.'" id="'.$type['type'].'_'.$resource_id.'_'.$alt.'"';
66                 
67                         $m = count($resource_types);
68                         for ($j=0; $j < $m; $j++){
69                                 if (trim($resource_types[$j]) == trim($type[type_id])){
70                                         echo 'checked="checked"';
71                                         continue;
72                                 }
73                         }
74                         echo '/>';
75                         echo '<label for="'.$type['type'].'_'.$resource_id.'_'.$alt.'">';
76                         if ($type['type']=='auditory')
77                                 echo _AT('auditory');
78                         if ($type['type']=='visual')
79                                 echo _AT('visual');
80                         if ($type['type']=='textual')
81                                 echo _AT('textual');
82                         if ($type['type']=='sign_language')
83                                 echo _AT('sign_language');
84                         echo '</label><br/>';   
85                 }       
86         }       
87         echo '</fieldset>';
88 }
89         
90 /**
91 * It provides, for each alternative, a link through which it is possible to delete such an alternative resource declared for a particular original one.
92 * @access       public
93 * @param        $cid:                           content id.
94 * @param        $resource:                      resource id.
95 * @param        $current_tab:           the current tab id .
96 * @return       
97 * @see          
98 * @author       Silvia Mirri
99 */
100 function delete_alternative($resource, $cid, $current_tab){
101         echo '<a href="'.$_SERVER['PHP_SELF'].'?cid='.$cid. SEP .'tab='.$current_tab . SEP . 'act=delete'. SEP .'id_alt='.$resource[secondary_resource_id].' ">'. _AT('delete').' <strong>'. $resource[secondary_resource].'</strong></a>';
102         
103 }                                               
104                                                 
105