remove old readme
[atutor.git] / mods / _core / themes / version_history.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 define('AT_INCLUDE_PATH', '../../../include/');
16 require (AT_INCLUDE_PATH.'vitals.inc.php');
17 admin_authenticate(AT_ADMIN_PRIV_ADMIN);
18 require(AT_INCLUDE_PATH.'../mods/_core/themes/classes/ThemeListParser.class.php');
19
20 if (isset($_POST["cancel"]))
21 {
22         header('Location: '.AT_BASE_HREF.'mods/_core/themes/install_themes.php');
23         exit;
24 }
25
26 // check the connection to server update.atutor.ca
27 $update_server = "update.atutor.ca"; 
28 $connection_test_file = "http://" . $update_server . '/index.php';
29 $connection = @file_get_contents($connection_test_file);
30
31 if (!$connection) 
32 {
33         $infos = array('CANNOT_CONNECT_SERVER', $update_server);
34         $msg->addError($infos);
35         
36         require(AT_INCLUDE_PATH.'header.inc.php');
37   $msg->printAll();
38         require(AT_INCLUDE_PATH.'footer.inc.php');
39         exit;
40 }
41
42 if (isset($_GET["id"])) $id = intval($_GET["id"]);
43 else if (isset($_POST["id"])) $id = intval($_POST["id"]);
44
45 // get theme list
46 $theme_folder = "http://" . $update_server . '/themes/';
47
48 $theme_list_xml = @file_get_contents($theme_folder . 'theme_list.xml');
49
50 if ($theme_list_xml) 
51 {
52         $themeListParser = new ThemeListParser();
53         $themeListParser->parse($theme_list_xml);
54         $theme_list_array = $themeListParser->getParsedArray();
55 }
56 // end of get theme list
57
58 $theme_content_folder = AT_CONTENT_DIR . "theme";
59
60 //debug($_POST["vid"]);
61 //exit;
62 // download process
63 if (isset($_POST["download"]) && !isset($_POST["vid"]))
64 {
65         $msg->addError('NO_ITEM_SELECTED');
66 }
67 else if ($_POST['download'])
68 {
69         $vid = intval($_POST['vid']);
70         $file_content = @file_get_contents($theme_folder . $theme_list_array[$id]['history'][$vid]['location'].$theme_list_array[$id]['history'][$vid]['filename']);
71
72         if (!$file_content)
73         {
74                 $msg->addError('FILE_NOT_EXIST');
75         }
76         else
77         {
78                 header('Content-Type: application/x-zip');
79                 header('Content-transfer-encoding: binary'); 
80                 header('Content-Disposition: attachment; filename="'.htmlspecialchars($theme_list_array[$id]['history'][$vid]['filename']).'"');
81                 header('Expires: 0');
82                 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
83                 header('Pragma: public');
84                 header('Content-Length: '.strlen($file_content));
85         
86                 echo $file_content;
87                 exit;
88         }
89 }
90
91 require (AT_INCLUDE_PATH.'header.inc.php');
92
93 $msg->printErrors();
94 ?>
95
96 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
97 <div class="input-form">
98
99 <?php 
100 ?>
101 <input type="hidden" name="id" value="<?php echo $id; ?>" />
102 <table class="data" summary="" style="width: 100%" rules="cols">
103 <thead>
104         <tr>
105                 <th scope="col">&nbsp;</th>
106                 <th scope="col"><?php echo _AT('version');?></th>
107                 <th scope="col"><?php echo _AT('atutor_version_tested_with');?></th>
108                 <th scope="col"><?php echo _AT('publish_date');?></th>
109                 <th scope="col"><?php echo _AT('state');?></th>
110                 <th scope="col"><?php echo _AT('maintainers');?></th>
111                 <th scope="col"><?php echo _AT('notes');?></th>
112         </tr>
113 </thead>
114
115 <tfoot>
116 <tr>
117         <td colspan="7">
118                 <input type="submit" name="download" value="<?php echo _AT('download'); ?>" />
119                 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
120         </td>
121 </tr>
122 </tfoot>
123
124 <tbody>
125 <?php 
126 $num_of_versions = count($theme_list_array[$id]['history']);
127
128 if ($num_of_versions == 0)
129 {
130 ?>
131
132 <tr>
133         <td colspan="7">
134 <?php 
135         echo _AT('none_found');
136 ?>
137         </td>
138 </tr>
139
140 <?php 
141 }
142 else
143 {
144         // display version list
145         if(is_array($theme_list_array[$id]['history']))
146         {
147                 for ($i=0; $i < $num_of_versions; $i++)
148                 {
149 ?>
150         <tr onmousedown="document.form['m<?php echo $i; ?>'].checked = true; rowselect(this);"  id="r_<?php echo $i; ?>">
151                 <td><input type="radio" name="vid" value="<?php echo $i; ?>" id="m<?php echo $i; ?>" /></td>
152                 <td><label for="m<?php echo $i; ?>"><?php echo $theme_list_array[$id]["name"] . ' ' .$theme_list_array[$id]['history'][$i]["version"]; ?></label></td>
153                 <td><?php echo $theme_list_array[$id]['history'][$i]["atutor_version"]; ?></td>
154                 <td><?php echo $theme_list_array[$id]['history'][$i]["date"]; ?></td>
155                 <td><?php echo $theme_list_array[$id]['history'][$i]["state"]; ?></td>
156                 <td><?php echo $theme_list_array[$id]['history'][$i]["maintainer"]; ?></td>
157                 <td><?php echo $theme_list_array[$id]['history'][$i]["notes"]; ?></td>
158         </tr>
159
160 <?php 
161                 }
162         }
163
164 ?>
165 </tbody>
166
167 <?php 
168 }
169 ?>
170 </table>
171
172 </div>
173 </form>
174
175 <?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>