/
preview.php
190 lines (122 loc) · 6.21 KB
/
preview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?PHP
/**
*
* preview page, allows the site to make a preview page for a xerte module
*
* @author Patrick Lockley
* @version 1.0
* @params array row_play - The array from the last mysql query
* @copyright Copyright (c) 2008,2009 University of Nottingham
* @package
*/
/**
*
* Function show_preview_code
* This function creates folders needed when creating a template
* @param array $row - an array from a mysql query for the template
* @param array $row_username - an array from a mysql query for the username
* @version 1.0
* @author Patrick Lockley
*/
function show_preview_code($row, $row_username){
global $xerte_toolkits_site;
require_once(dirname(__FILE__) . '/module_functions.php');
/*
* Format the XML strings to provide data to the engine
*/
if(!file_exists($xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row_username['username'] . "-" . $row['template_name'] . "/preview.inc")){
}
if(isset($_POST['save_path'])){
$data = array();
$data['simile_description'] = strip_tags($_POST['simile_description'],"<p><a><img>");
$data['simile_start'] = htmlentities(strip_tags($_POST['simile_start']));
$data['simile_stop'] = htmlentities(strip_tags($_POST['simile_stop']));
$counter = 0;
$save_counter = 0;
$data['zones'] = array();
while(isset($_POST['simile_zone_width_' . $counter])){
$zone = array();
if($_POST['simile_zone_delete_' . $counter]!="on"){
$zone['simile_zone_start_' . $save_counter] = $_POST['simile_zone_start_' . $counter];
$zone['simile_zone_stop_' . $save_counter] = $_POST['simile_zone_stop_' . $counter];
$zone['simile_zone_width_' . $save_counter] = $_POST['simile_zone_width_' . $counter];
$zone['simile_zone_interval_pixels_' . $save_counter] = $_POST['simile_zone_interval_pixels_' . $counter];
$zone['simile_zone_unit_' . $save_counter] = $_POST['simile_zone_unit_' . $counter];
$zone['simile_zone_sync_' . $save_counter] = $_POST['simile_zones_sync_' . $counter];
if($_POST['simile_zone_width_' . $counter]!=""){
$zone = array_filter($zone);
array_push($data['zones'], $zone);
$save_counter++;
}
}
$counter++;
}
$data['zone_labels'] = array();
$counter = 0;
$save_counter = 0;
while(isset($_POST['simile_zone_label_startdate_' . $counter])){
$zone_label = array();
if(!isset($_POST['simile_zone_label_delete_' . $counter])){
$zone_label['simile_zone_label_startdate_' . $save_counter] = $_POST['simile_zone_label_startdate_' . $counter];
$zone_label['simile_zone_label_enddate_' . $save_counter] = $_POST['simile_zone_label_enddate_' . $counter];
$zone_label['simile_zone_label_startlabel_' . $save_counter] = $_POST['simile_zone_label_startlabel_' . $counter];
$zone_label['simile_zone_label_endlabel_' . $save_counter] = $_POST['simile_zone_label_endlabel_' . $counter];
$zone_label['simile_zone_label_colour_' . $save_counter] = $_POST['simile_zone_label_colour_' . $counter];
$zone_label['simile_zone_label_opacity_' . $save_counter] = $_POST['simile_zone_label_opacity_' . $counter];
$zone_label['simile_event_label_zones_' . $save_counter] = $_POST['simile_event_label_zones_' . $counter];
if($_POST['simile_zone_label_startdate_' . $counter]!=""){
$zone_label = array_filter($zone_label);
array_push($data['zone_labels'], $zone_label);
$save_counter++;
}
}
$counter++;
}
$data['events'] = array();
$counter = 0;
$save_counter = 0;
while(isset($_POST['simile_event_title_' . $counter])){
$event = array();
if($_POST['simile_event_delete_' . $counter]!="on"){
$event['simile_event_title_' . $save_counter] = stripslashes($_POST['simile_event_title_' . $counter]);
$event['simile_event_description_' . $save_counter] = $_POST['simile_event_description_' . $counter];
$event['simile_event_link_' . $save_counter] = $_POST['simile_event_link_' . $counter];
$event['simile_event_image_' . $save_counter] = $_POST['simile_event_image_' . $counter];
$event['simile_event_start_' . $save_counter] = $_POST['simile_event_start_' . $counter];
$event['simile_event_lateststart_' . $save_counter] = $_POST['simile_event_lateststart_' . $counter];
$event['simile_event_earliestend_' . $save_counter] = $_POST['simile_event_earliestend_' . $counter];
$event['simile_event_end_' . $save_counter] = $_POST['simile_event_end_' . $counter];
$event['simile_event_durationevent_' . $save_counter] = $_POST['simile_event_durationevent_' . $counter];
$event['simile_event_color_' . $save_counter] = $_POST['simile_event_color_' . $counter];
$event['simile_event_textcolor_' . $save_counter] = $_POST['simile_event_textcolor_' . $counter];
$event['simile_event_opacity_' . $save_counter] = $_POST['simile_event_opacity_' . $counter];
$event['simile_event_zones_' . $save_counter] = $_POST['simile_event_zones_' . $counter];
if($_POST['simile_event_title_' . $counter]!=""){
$event = array_filter($event);
array_push($data['events'], $event);
$save_counter++;
}
}
$counter++;
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?PHP echo SIMILE_EDIT_TITLE; ?></title>
<link href="website_code/styles/frontpage.css" media="screen" type="text/css" rel="stylesheet" />
<script src="http://static.simile.mit.edu/timeline/api-2.3.0/timeline-api.js?bundle=true" type="text/javascript"></script>
</head>
<body>
<?PHP
if(isset($_POST['save_path'])){
?><p><a href="edit.php?template_id=<?PHP echo $row['template_id']; ?>">Return to editor</a></p><?PHP
file_put_contents($_POST['save_path'] . "/preview.inc", serialize($data));
display_timeline($data);
}else{
display_timeline(unserialize(file_get_contents($xerte_toolkits_site->users_file_area_short . $row['template_id'] . "-" . $row_username['username'] . "-" . $row['template_name'] . "/preview.inc")));
}
}
?>