Completed
Branch master (c3ca5f)
by Seth
04:51
created
phpicalendar/functions/parse/parse_tzs.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	$nextline = ereg_replace("[\r\n]", '', $nextline);
16 16
 	#handle continuation lines that start with either a space or a tab (MS Outlook)
17 17
 	while (isset($nextline{0}) && ($nextline{0} == ' ' || $nextline{0} == "\t")) { 
18
-		$line = $line . substr($nextline, 1);
18
+		$line = $line.substr($nextline, 1);
19 19
 		$nextline = fgets($ifile, 1024);
20 20
 		$nextline = ereg_replace("[\r\n]", '', $nextline);
21 21
 	}
@@ -56,12 +56,12 @@  discard block
 block discarded – undo
56 56
 			break;
57 57
 		default:
58 58
 			unset ($field, $data, $prop_pos, $property);
59
-			if (ereg ('([^:]+):(.*)', $line, $line)){
59
+			if (ereg('([^:]+):(.*)', $line, $line)) {
60 60
 				$field = $line[1];
61 61
 				$data = $line[2];				
62 62
 				$property = strtoupper($field);
63
-				$prop_pos = strpos($property,';');
64
-				if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
63
+				$prop_pos = strpos($property, ';');
64
+				if ($prop_pos !== false) $property = substr($property, 0, $prop_pos);
65 65
 				switch ($property) {		
66 66
 					case 'TZID':
67 67
 						$tz_id = $data;
@@ -73,18 +73,18 @@  discard block
 block discarded – undo
73 73
 						$offset_to = $data;
74 74
 						break;
75 75
 					case 'DTSTART':
76
-						if($is_std || $is_daylight){
76
+						if ($is_std || $is_daylight) {
77 77
 							$datetime = extractDateTime($data, $property, $field); 
78 78
 							$start_unixtime = $datetime[0];
79 79
 							$start_date = $datetime[1];
80
-							$year = substr($start_date,0,4);
81
-							if($is_std) $begin_std[$year] = $data;
82
-							if($is_daylight) $begin_daylight[$year] = $data;
80
+							$year = substr($start_date, 0, 4);
81
+							if ($is_std) $begin_std[$year] = $data;
82
+							if ($is_daylight) $begin_daylight[$year] = $data;
83 83
 						}
84 84
 						break;
85 85
 					case 'TZNAME':
86
-						if($is_std) $st_name = $data;
87
-						if($is_daylight) $dt_name = $data;
86
+						if ($is_std) $st_name = $data;
87
+						if ($is_daylight) $dt_name = $data;
88 88
 						break;
89 89
 				}
90 90
 			}	
Please login to merge, or discard this patch.
Braces   +21 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 $ifile = @fopen($filename, 'r');
3
-if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $filename));
3
+if ($ifile == FALSE) {
4
+	exit(error($lang['l_error_cantopen'], $filename));
5
+}
4 6
 $nextline = fgets($ifile);
5 7
 #if (trim($nextline) != 'BEGIN:VCALENDAR') exit(error($lang['l_error_invalidcal'], $filename));
6 8
 
@@ -43,7 +45,9 @@  discard block
 block discarded – undo
43 45
 			$is_daylight = false;
44 46
 			break;
45 47
 		case 'END:VTIMEZONE':
46
-			if (!isset($offset_d) && isset($offset_s)) $offset_d = $offset_s;
48
+			if (!isset($offset_d) && isset($offset_s)) {
49
+				$offset_d = $offset_s;
50
+			}
47 51
 			$tz_array[$tz_id] = array(
48 52
 				0	=> @$offset_s, 
49 53
 				1	=> @$offset_d,
@@ -61,7 +65,9 @@  discard block
 block discarded – undo
61 65
 				$data = $line[2];				
62 66
 				$property = strtoupper($field);
63 67
 				$prop_pos = strpos($property,';');
64
-				if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
68
+				if ($prop_pos !== false) {
69
+					$property = substr($property,0,$prop_pos);
70
+				}
65 71
 				switch ($property) {		
66 72
 					case 'TZID':
67 73
 						$tz_id = $data;
@@ -78,13 +84,21 @@  discard block
 block discarded – undo
78 84
 							$start_unixtime = $datetime[0];
79 85
 							$start_date = $datetime[1];
80 86
 							$year = substr($start_date,0,4);
81
-							if($is_std) $begin_std[$year] = $data;
82
-							if($is_daylight) $begin_daylight[$year] = $data;
87
+							if($is_std) {
88
+								$begin_std[$year] = $data;
89
+							}
90
+							if($is_daylight) {
91
+								$begin_daylight[$year] = $data;
92
+							}
83 93
 						}
84 94
 						break;
85 95
 					case 'TZNAME':
86
-						if($is_std) $st_name = $data;
87
-						if($is_daylight) $dt_name = $data;
96
+						if($is_std) {
97
+							$st_name = $data;
98
+						}
99
+						if($is_daylight) {
100
+							$dt_name = $data;
101
+						}
88 102
 						break;
89 103
 				}
90 104
 			}	
Please login to merge, or discard this patch.
phpicalendar/functions/parse/end_vevent.php 2 patches
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 // CLASS support
16 16
 if (isset($class)) {
17 17
 	if ($class == 'PRIVATE') {
18
-		$summary ='**PRIVATE**';
19
-		$description ='**PRIVATE**';
18
+		$summary = '**PRIVATE**';
19
+		$description = '**PRIVATE**';
20 20
 	} elseif ($class == 'CONFIDENTIAL') {
21
-		$summary ='**CONFIDENTIAL**';
22
-		$description ='**CONFIDENTIAL**';
21
+		$summary = '**CONFIDENTIAL**';
22
+		$description = '**CONFIDENTIAL**';
23 23
 	}
24 24
 }
25 25
 
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 	$uid = $uid_counter;
29 29
 	$uid_counter++;
30 30
 	$uid_valid = false;
31
-}elseif(in_array($uid, $uid_list)) {
31
+}elseif (in_array($uid, $uid_list)) {
32 32
 	# UID seen before. If sequence is the default, bump it.
33 33
 	if ($sequence == 0) $sequence++;
34
-}else{
34
+} else {
35 35
 	$uid_valid = true;
36 36
 }
37 37
 $uid_list[] = $uid;
38 38
 
39 39
 # Handle DURATION
40 40
 if (!isset($end_unixtime)) {
41
-	if(!isset($the_duration)) $the_duration = 0;
42
-	$end_unixtime 	= $start_unixtime + $the_duration;
43
-	$end_time 	= date ('Hi', $end_unixtime);
41
+	if (!isset($the_duration)) $the_duration = 0;
42
+	$end_unixtime = $start_unixtime + $the_duration;
43
+	$end_time = date('Hi', $end_unixtime);
44 44
 }
45 45
 # at this point $end_unixtime should be set
46 46
 # adjust event start and end times
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 }
54 54
 # look for events that span more than one day
55
-if (isset($start_unixtime,$end_unixtime) && date('Ymd',$start_unixtime) < date('Ymd',$end_unixtime)) {
55
+if (isset($start_unixtime, $end_unixtime) && date('Ymd', $start_unixtime) < date('Ymd', $end_unixtime)) {
56 56
 	$spans_day = true;
57 57
 	$bleed_check = (($start_unixtime - $end_unixtime) <= (60*60*24)) ? '-1' : '0';
58 58
 } else {
@@ -61,14 +61,14 @@  discard block
 block discarded – undo
61 61
 }
62 62
 
63 63
 $length = $end_unixtime - $start_unixtime;
64
-if ($length < 0){ 
64
+if ($length < 0) { 
65 65
 	$length = 0;
66 66
 	$end_time = $start_time;
67 67
 }
68 68
 # get hour and minute adjusted to allowed grid times
69 69
 $drawKey = drawEventTimes($start_time, $end_time, ($length >= (60*60*24)));
70
-preg_match ('/([0-9]{2})([0-9]{2})/', $drawKey['draw_start'], $time3);
71
-preg_match ('/([0-9]{2})([0-9]{2})/', $drawKey['draw_end'], $time4);
70
+preg_match('/([0-9]{2})([0-9]{2})/', $drawKey['draw_start'], $time3);
71
+preg_match('/([0-9]{2})([0-9]{2})/', $drawKey['draw_end'], $time4);
72 72
 $hour = $time3[1];
73 73
 $minute = $time3[2];
74 74
 $end_hour = $time4[1];
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 $freq_type = 'none';
105 105
 # Load $rrule_array
106 106
 foreach ($rrule_array as $key => $val) {
107
-	switch($key) {
107
+	switch ($key) {
108 108
 		case 'FREQ':
109 109
 			switch ($val) {
110
-				case 'YEARLY':		$freq_type = 'year';	break;
111
-				case 'MONTHLY':		$freq_type = 'month';	break;
112
-				case 'WEEKLY':		$freq_type = 'week';	break;
113
-				case 'DAILY':		$freq_type = 'day';		break;
114
-				case 'HOURLY':		$freq_type = 'hour';	break;
115
-				case 'MINUTELY':	$freq_type = 'minute';	break;
116
-				case 'SECONDLY':	$freq_type = 'second';	break;
110
+				case 'YEARLY':		$freq_type = 'year'; break;
111
+				case 'MONTHLY':		$freq_type = 'month'; break;
112
+				case 'WEEKLY':		$freq_type = 'week'; break;
113
+				case 'DAILY':		$freq_type = 'day'; break;
114
+				case 'HOURLY':		$freq_type = 'hour'; break;
115
+				case 'MINUTELY':	$freq_type = 'minute'; break;
116
+				case 'SECONDLY':	$freq_type = 'second'; break;
117 117
 			}
118 118
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = strtolower($val);
119 119
 			break;
@@ -123,51 +123,51 @@  discard block
 block discarded – undo
123 123
 			break;
124 124
 		case 'UNTIL':
125 125
 			# UNTIL must be in UTC
126
-			$until = date("YmdHis",strtotime($val)); 
127
-			ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})', $until, $regs);
128
-			$until_unixtime = mktime($regs[4],@$regs[5],@$regs[6],$regs[2],$regs[3],$regs[1]);
129
-			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = localizeDate($dateFormat_week,$until);
126
+			$until = date("YmdHis", strtotime($val)); 
127
+			ereg('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})', $until, $regs);
128
+			$until_unixtime = mktime($regs[4], @$regs[5], @$regs[6], $regs[2], $regs[3], $regs[1]);
129
+			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = localizeDate($dateFormat_week, $until);
130 130
 			break;
131 131
 		case 'INTERVAL':
132
-			if ($val > 0){
132
+			if ($val > 0) {
133 133
 			$interval = $val;
134 134
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $interval;
135 135
 			}
136 136
 			break;
137 137
 		case 'BYSECOND':
138
-			$bysecond = split (',', $val);
138
+			$bysecond = split(',', $val);
139 139
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysecond;
140 140
 			break;
141 141
 		case 'BYMINUTE':
142
-			$byminute = split (',', $val);
142
+			$byminute = split(',', $val);
143 143
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byminute;
144 144
 			break;
145 145
 		case 'BYHOUR':
146
-			$byhour = split (',', $val);
146
+			$byhour = split(',', $val);
147 147
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byhour;
148 148
 			break;
149 149
 		case 'BYDAY':
150
-			$byday = split (',', $val);
150
+			$byday = split(',', $val);
151 151
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byday;
152 152
 			break;
153 153
 		case 'BYMONTHDAY':
154
-			$bymonthday = split (',', $val);
154
+			$bymonthday = split(',', $val);
155 155
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonthday;
156 156
 			break;					
157 157
 		case 'BYYEARDAY':
158
-			$byyearday = split (',', $val);
158
+			$byyearday = split(',', $val);
159 159
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byyearday;
160 160
 			break;
161 161
 		case 'BYWEEKNO':
162
-			$byweekno = split (',', $val);
162
+			$byweekno = split(',', $val);
163 163
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $byweekno;
164 164
 			break;
165 165
 		case 'BYMONTH':
166
-			$bymonth = split (',', $val);
166
+			$bymonth = split(',', $val);
167 167
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bymonth;
168 168
 			break;
169 169
 		case 'BYSETPOS':
170
-			$bysetpos = split (',', $val);
170
+			$bysetpos = split(',', $val);
171 171
 			$recur_array[($start_date)][($hour.$minute)][$uid]['recur'][$key] = $bysetpos;
172 172
 			break;
173 173
 		case 'WKST':
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
 }
179 179
 # convert wkst to a 3 char day for strtotime to work		
180 180
 $wkst3char = two2threeCharDays($wkst);
181
-if($current_view == 'search') $freq_type = 'none'; 
181
+if ($current_view == 'search') $freq_type = 'none'; 
182 182
 # $recur is the recurrence info that goes into the master array for this VEVENT
183
-$recur ='';
183
+$recur = '';
184 184
 if (isset($recur_array[($start_date)][($hour.$minute)][$uid]['recur'])) $recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur']; 
185 185
 
186 186
 /* ============================ Load $recur_data ============================
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
 	!isset($rrule_array['FREQ']) 	- only iterate once, set the end_range_unixtime to the end_date_unixtime
203 203
 Note that start_range_unixtime and end_range_unixtime are not the same as start_date_unixtime and end_date_unixtime */
204 204
 
205
-$end_range_unixtime = $mArray_end+60*60*24;
205
+$end_range_unixtime = $mArray_end + 60*60*24;
206 206
 $start_date_unixtime = strtotime($start_date);
207 207
 $next_range_unixtime = $start_date_unixtime;
208 208
 
209 209
 # conditions where we don't need to iterate over the whole range
210 210
 # 	if repeating without limit, and steps are by 1, don't go back before the mArray beginning.
211
-if($count == 1000000 && $interval == 1 && $mArray_begin > $next_range_unixtime) $next_range_unixtime = $mArray_begin;
211
+if ($count == 1000000 && $interval == 1 && $mArray_begin > $next_range_unixtime) $next_range_unixtime = $mArray_begin;
212 212
 
213 213
 # 	if the beginning of our range is less than the start of the item, we may as well set the range to start at start_time
214 214
 if ($next_range_unixtime < $start_date_unixtime) $next_range_unixtime = $start_date_unixtime;
215 215
 
216 216
 # 	stop at the until limit if set
217
-if(isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime;else $until_unixtime = $mArray_end;
217
+if (isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime; else $until_unixtime = $mArray_end;
218 218
 
219 219
 # 	more adjustments
220
-switch ($freq_type){
220
+switch ($freq_type) {
221 221
 	case 'week':
222 222
 		# need to get the first value of $next_range_unixtime onto the right day of the week
223 223
 		$next_range_unixtime = strtotime("this ".date("D", $start_date_unixtime), $next_range_unixtime);
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 }
229 229
 
230 230
 #nonrepeating events can stop at the first instance
231
-if(!isset($rrule_array['FREQ']) && isset($end_date)){ 
231
+if (!isset($rrule_array['FREQ']) && isset($end_date)) { 
232 232
 	$end_range_unixtime = strtotime($end_date);
233 233
 	$count = 1;
234 234
 }
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 while ($next_range_unixtime <= $end_range_unixtime && $count > 0) {
242 242
 	$year = date("Y", $next_range_unixtime); 
243 243
 	$month = date('m', $next_range_unixtime); 
244
-	$time = mktime(12,0,0,$month,date("d",$start_unixtime),$year);
245
-	switch ($freq_type){
244
+	$time = mktime(12, 0, 0, $month, date("d", $start_unixtime), $year);
245
+	switch ($freq_type) {
246 246
 		case 'day':
247 247
 			add_recur($next_range_unixtime);
248 248
 			break;
@@ -250,18 +250,18 @@  discard block
 block discarded – undo
250 250
 			add_recur(expand_byday($next_range_unixtime));
251 251
 			break;
252 252
 		case 'month':
253
-			if(!empty($bymonthday)) $time = mktime(12,0,0,$month,1,$year);
254
-			$times = expand_bymonthday(array($time));#echo "\n $month exp bymonthday";dump_times($times);
255
-			foreach($times as $time){ 
253
+			if (!empty($bymonthday)) $time = mktime(12, 0, 0, $month, 1, $year);
254
+			$times = expand_bymonthday(array($time)); #echo "\n $month exp bymonthday";dump_times($times);
255
+			foreach ($times as $time) { 
256 256
 				add_recur(expand_byday($time));
257 257
 			}
258 258
 			break;
259 259
 		case 'year':
260
-			$times = expand_bymonth($time);      #echo "exp bymonth";dump_times($times);
261
-			$times = expand_byweekno($times);    #echo "exp byweekno";dump_times($times);
262
-			$times = expand_byyearday($times);   #echo "exp byyearday";dump_times($times);
263
-			$times = expand_bymonthday($times);  #echo "\nexp bymonthday";dump_times($times);
264
-			foreach($times as $time){ 
260
+			$times = expand_bymonth($time); #echo "exp bymonth";dump_times($times);
261
+			$times = expand_byweekno($times); #echo "exp byweekno";dump_times($times);
262
+			$times = expand_byyearday($times); #echo "exp byyearday";dump_times($times);
263
+			$times = expand_bymonthday($times); #echo "\nexp bymonthday";dump_times($times);
264
+			foreach ($times as $time) { 
265 265
 				add_recur(expand_byday($time));
266 266
 			}
267 267
 			break;
@@ -284,22 +284,22 @@  discard block
 block discarded – undo
284 284
 $hour and $minute are the values from the start_time, rounded to the nearest grid time.
285 285
 
286 286
 */
287
-$recur_data_hour = @substr($start_time,0,2);
288
-$recur_data_minute = @substr($start_time,2,2);
289
-if (isset($allday_start) && $allday_start != ''){
287
+$recur_data_hour = @substr($start_time, 0, 2);
288
+$recur_data_minute = @substr($start_time, 2, 2);
289
+if (isset($allday_start) && $allday_start != '') {
290 290
 	$recur_data_hour = '00';
291 291
 	$recur_data_minute = '00';
292 292
 }
293
-foreach($recur_data as $recur_data_unixtime) {
293
+foreach ($recur_data as $recur_data_unixtime) {
294 294
 	$recur_data_year 	= date('Y', $recur_data_unixtime);
295
-	$recur_data_month 	= date('m', $recur_data_unixtime);
296
-	$recur_data_day 	= date('d', $recur_data_unixtime);
295
+	$recur_data_month = date('m', $recur_data_unixtime);
296
+	$recur_data_day = date('d', $recur_data_unixtime);
297 297
 	$recur_data_date 	= $recur_data_year.$recur_data_month.$recur_data_day;
298 298
 	
299 299
 	# initialize the loop range	to the recur date + grid time
300
-	$next_range_unixtime = mktime($recur_data_hour,$recur_data_minute,0,$recur_data_month,$recur_data_day,$recur_data_year);
300
+	$next_range_unixtime = mktime($recur_data_hour, $recur_data_minute, 0, $recur_data_month, $recur_data_day, $recur_data_year);
301 301
 	$end_range_unixtime = $next_range_unixtime + $length;
302
-	$end_date_tmp = date("Ymd",$end_range_unixtime);
302
+	$end_date_tmp = date("Ymd", $end_range_unixtime);
303 303
 	#echo "<pre>$summary ".date("Ymd H:i:s",$next_range_unixtime)." ".date("Ymd H:i:s",$end_range_unixtime)."\n";
304 304
 
305 305
 	# default the time_key to -1 for allday events, overwrite as needed
@@ -308,31 +308,31 @@  discard block
 block discarded – undo
308 308
 	$start_unixtime_tmp = strtotime($recur_data_date.$start_time);
309 309
 	$end_unixtime_tmp = strtotime($end_date_tmp.$end_time);
310 310
 	while (date("Ymd", $next_range_unixtime) <= $end_date_tmp) {
311
-		$this_date_tmp = date('Ymd',$next_range_unixtime);	
312
-		$next_range_unixtime = strtotime('+1 day',$next_range_unixtime);
311
+		$this_date_tmp = date('Ymd', $next_range_unixtime);	
312
+		$next_range_unixtime = strtotime('+1 day', $next_range_unixtime);
313 313
 		
314 314
 		if (!isset($allday_start) || $allday_start == '') $time_key = $hour.$minute;
315 315
 		$display_end_tmp = $end_hour.$end_minute;
316
-		if($time_key > -1){
316
+		if ($time_key > -1) {
317 317
 			# the day is not the first day of the recurrence
318 318
 			if ($this_date_tmp > $recur_data_date) $time_key = '0000';
319 319
 			# the day is not the last day of the recurrence
320 320
 			if ($this_date_tmp < $end_date_tmp) $display_end_tmp = '2400';
321 321
 		}
322
-		if($this_date_tmp == $end_date_tmp && ($end_time == '0000')) continue;
323
-		if(!isset($master_array[$this_date_tmp][$time_key][$uid]['sequence']) || 
324
-			$sequence >  $master_array[$this_date_tmp][$time_key][$uid]['sequence']
325
-			){
326
-			$master_array[$this_date_tmp][$time_key][$uid] = array (
327
-				'event_start' => $start_time,                	# hhmm
328
-				'event_end' => $end_time,                    	# hhmm
329
-				'display_start' => $time_key,                   # hhmm
330
-				'display_end' => $display_end_tmp,            	# hhmm
331
-				'start_unixtime' => $start_unixtime_tmp,      	# start unixtime for this recurrence
332
-				'end_unixtime' => $end_unixtime_tmp,          	# end unixtime for this recurrence
333
-				'event_text' => $summary,                    	#
334
-				'event_length' => $length,                    	# length in seconds
335
-				'event_overlap' => 0,                        	# checkOverlap modifies this
322
+		if ($this_date_tmp == $end_date_tmp && ($end_time == '0000')) continue;
323
+		if (!isset($master_array[$this_date_tmp][$time_key][$uid]['sequence']) || 
324
+			$sequence > $master_array[$this_date_tmp][$time_key][$uid]['sequence']
325
+			) {
326
+			$master_array[$this_date_tmp][$time_key][$uid] = array(
327
+				'event_start' => $start_time, # hhmm
328
+				'event_end' => $end_time, # hhmm
329
+				'display_start' => $time_key, # hhmm
330
+				'display_end' => $display_end_tmp, # hhmm
331
+				'start_unixtime' => $start_unixtime_tmp, # start unixtime for this recurrence
332
+				'end_unixtime' => $end_unixtime_tmp, # end unixtime for this recurrence
333
+				'event_text' => $summary, #
334
+				'event_length' => $length, # length in seconds
335
+				'event_overlap' => 0, # checkOverlap modifies this
336 336
 				'description' => $description, 
337 337
 				'status' => $status, 
338 338
 				'class' => $class, 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 				'recur' => $recur
352 352
 				);
353 353
 		}
354
-		if($time_key > -1) checkOverlap($this_date_tmp, $time_key, $uid);
354
+		if ($time_key > -1) checkOverlap($this_date_tmp, $time_key, $uid);
355 355
 	}
356 356
 } # end foreach recur_data 
357 357
 unset($recur_data);
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
 // Added for version 0.9.5 modified in 2.22 remove anything that doesn't have an event_start
362 362
 if (is_array($except_dates)) {
363 363
 	foreach ($except_dates as $key => $value) {
364
-		if (isset ($master_array[$value])){
365
-			foreach ($master_array[$value] as $time => $value2){
366
-				if (!isset($value2[$uid]['event_start'])){
364
+		if (isset ($master_array[$value])) {
365
+			foreach ($master_array[$value] as $time => $value2) {
366
+				if (!isset($value2[$uid]['event_start'])) {
367 367
 					unset($master_array[$value][$time][$uid]);
368 368
 				}
369 369
 			}
Please login to merge, or discard this patch.
Braces   +46 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 2. Build recur_data array
11 11
 3. Add occurrences to master_array
12 12
 */
13
-if (!isset($start_date)) $start_date = "19700101";
13
+if (!isset($start_date)) {
14
+	$start_date = "19700101";
15
+}
14 16
 
15 17
 // CLASS support
16 18
 if (isset($class)) {
@@ -28,17 +30,21 @@  discard block
 block discarded – undo
28 30
 	$uid = $uid_counter;
29 31
 	$uid_counter++;
30 32
 	$uid_valid = false;
31
-}elseif(in_array($uid, $uid_list)) {
33
+} elseif(in_array($uid, $uid_list)) {
32 34
 	# UID seen before. If sequence is the default, bump it.
33
-	if ($sequence == 0) $sequence++;
34
-}else{
35
+	if ($sequence == 0) {
36
+		$sequence++;
37
+	}
38
+	} else{
35 39
 	$uid_valid = true;
36 40
 }
37 41
 $uid_list[] = $uid;
38 42
 
39 43
 # Handle DURATION
40 44
 if (!isset($end_unixtime)) {
41
-	if(!isset($the_duration)) $the_duration = 0;
45
+	if(!isset($the_duration)) {
46
+		$the_duration = 0;
47
+	}
42 48
 	$end_unixtime 	= $start_unixtime + $the_duration;
43 49
 	$end_time 	= date ('Hi', $end_unixtime);
44 50
 }
@@ -178,10 +184,14 @@  discard block
 block discarded – undo
178 184
 }
179 185
 # convert wkst to a 3 char day for strtotime to work		
180 186
 $wkst3char = two2threeCharDays($wkst);
181
-if($current_view == 'search') $freq_type = 'none'; 
187
+if($current_view == 'search') {
188
+	$freq_type = 'none';
189
+}
182 190
 # $recur is the recurrence info that goes into the master array for this VEVENT
183 191
 $recur ='';
184
-if (isset($recur_array[($start_date)][($hour.$minute)][$uid]['recur'])) $recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur']; 
192
+if (isset($recur_array[($start_date)][($hour.$minute)][$uid]['recur'])) {
193
+	$recur = $recur_array[($start_date)][($hour.$minute)][$uid]['recur'];
194
+}
185 195
 
186 196
 /* ============================ Load $recur_data ============================
187 197
 $recur_data is an array of unix times for days of recurrences of an event.  This code handles repeats at the day level or above.  The next loop handles the times.
@@ -208,13 +218,21 @@  discard block
 block discarded – undo
208 218
 
209 219
 # conditions where we don't need to iterate over the whole range
210 220
 # 	if repeating without limit, and steps are by 1, don't go back before the mArray beginning.
211
-if($count == 1000000 && $interval == 1 && $mArray_begin > $next_range_unixtime) $next_range_unixtime = $mArray_begin;
221
+if($count == 1000000 && $interval == 1 && $mArray_begin > $next_range_unixtime) {
222
+	$next_range_unixtime = $mArray_begin;
223
+}
212 224
 
213 225
 # 	if the beginning of our range is less than the start of the item, we may as well set the range to start at start_time
214
-if ($next_range_unixtime < $start_date_unixtime) $next_range_unixtime = $start_date_unixtime;
226
+if ($next_range_unixtime < $start_date_unixtime) {
227
+	$next_range_unixtime = $start_date_unixtime;
228
+}
215 229
 
216 230
 # 	stop at the until limit if set
217
-if(isset($until) && $end_range_unixtime > $until_unixtime) $end_range_unixtime = $until_unixtime;else $until_unixtime = $mArray_end;
231
+if(isset($until) && $end_range_unixtime > $until_unixtime) {
232
+	$end_range_unixtime = $until_unixtime;
233
+} else {
234
+	$until_unixtime = $mArray_end;
235
+}
218 236
 
219 237
 # 	more adjustments
220 238
 switch ($freq_type){
@@ -250,7 +268,9 @@  discard block
 block discarded – undo
250 268
 			add_recur(expand_byday($next_range_unixtime));
251 269
 			break;
252 270
 		case 'month':
253
-			if(!empty($bymonthday)) $time = mktime(12,0,0,$month,1,$year);
271
+			if(!empty($bymonthday)) {
272
+				$time = mktime(12,0,0,$month,1,$year);
273
+			}
254 274
 			$times = expand_bymonthday(array($time));#echo "\n $month exp bymonthday";dump_times($times);
255 275
 			foreach($times as $time){ 
256 276
 				add_recur(expand_byday($time));
@@ -311,15 +331,23 @@  discard block
 block discarded – undo
311 331
 		$this_date_tmp = date('Ymd',$next_range_unixtime);	
312 332
 		$next_range_unixtime = strtotime('+1 day',$next_range_unixtime);
313 333
 		
314
-		if (!isset($allday_start) || $allday_start == '') $time_key = $hour.$minute;
334
+		if (!isset($allday_start) || $allday_start == '') {
335
+			$time_key = $hour.$minute;
336
+		}
315 337
 		$display_end_tmp = $end_hour.$end_minute;
316 338
 		if($time_key > -1){
317 339
 			# the day is not the first day of the recurrence
318
-			if ($this_date_tmp > $recur_data_date) $time_key = '0000';
340
+			if ($this_date_tmp > $recur_data_date) {
341
+				$time_key = '0000';
342
+			}
319 343
 			# the day is not the last day of the recurrence
320
-			if ($this_date_tmp < $end_date_tmp) $display_end_tmp = '2400';
344
+			if ($this_date_tmp < $end_date_tmp) {
345
+				$display_end_tmp = '2400';
346
+			}
347
+		}
348
+		if($this_date_tmp == $end_date_tmp && ($end_time == '0000')) {
349
+			continue;
321 350
 		}
322
-		if($this_date_tmp == $end_date_tmp && ($end_time == '0000')) continue;
323 351
 		if(!isset($master_array[$this_date_tmp][$time_key][$uid]['sequence']) || 
324 352
 			$sequence >  $master_array[$this_date_tmp][$time_key][$uid]['sequence']
325 353
 			){
@@ -351,7 +379,9 @@  discard block
 block discarded – undo
351 379
 				'recur' => $recur
352 380
 				);
353 381
 		}
354
-		if($time_key > -1) checkOverlap($this_date_tmp, $time_key, $uid);
382
+		if($time_key > -1) {
383
+			checkOverlap($this_date_tmp, $time_key, $uid);
384
+		}
355 385
 	}
356 386
 } # end foreach recur_data 
357 387
 unset($recur_data);
Please login to merge, or discard this patch.
phpicalendar/functions/parse/recur_functions.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 
11 11
 function add_recur($times, $freq = '') {
12 12
 	global $recur_data;
13
-	global $count, $mArray_begin, $mArray_end, $except_dates, $start_date, $start_date_unixtime,$end_range_unixtime,$until_unixtime, $day_offset, $current_view;
13
+	global $count, $mArray_begin, $mArray_end, $except_dates, $start_date, $start_date_unixtime, $end_range_unixtime, $until_unixtime, $day_offset, $current_view;
14 14
 	if (!is_array($times)) $times = array($times);
15 15
 	/*	BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS	*/
16 16
 #dump_times($times);
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 		// Why are we arbitrarily setting the time to noon?
32 32
 		$date = date('Ymd', $time);
33
-		$time = strtotime($date . ' 12:00:00');
33
+		$time = strtotime($date.' 12:00:00');
34 34
 		$until_date = date('Ymd', $until_unixtime);
35
-		$until_unixtime = strtotime($until_date . ' 12:00:00');
35
+		$until_unixtime = strtotime($until_date.' 12:00:00');
36 36
 
37 37
 		# day offset fixes shifts across day boundaries due to time diffs.
38 38
 		# These are already fixed for the initial instance, but need to be fixed for recurrences
39
-		if (date('Ymd', $time) != $start_date) $time = $time + ($day_offset * 24 * 60 * 60);
39
+		if (date('Ymd', $time) != $start_date) $time = $time + ($day_offset*24*60*60);
40 40
 		if ((isset($time)) &&
41 41
 			(!in_array($time, $recur_data)) &&
42 42
 			(!in_array($date, $except_dates)) &&
@@ -79,12 +79,12 @@  discard block
 block discarded – undo
79 79
 	if ($freq_type != 'year') return $times;
80 80
 	if (empty($byweekno)) return $times;
81 81
 	$total_weeks = date('W', mktime(12, 0, 0, 12, 24, $year)) + 1;
82
-	$w1_start = strtotime('this ' . $wkst3char, mktime(12, 0, 0, 1, 1, $year));
82
+	$w1_start = strtotime('this '.$wkst3char, mktime(12, 0, 0, 1, 1, $year));
83 83
 	foreach ($byweekno as $weekno) {
84 84
 		if ($weekno < 0) {
85 85
 			$weekno = $weekno + $total_weeks;
86 86
 		}
87
-		$new_times[] = strtotime('+' . (($weekno - 1) * 7) . ' days', $w1_start);
87
+		$new_times[] = strtotime('+'.(($weekno - 1)*7).' days', $w1_start);
88 88
 	}
89 89
 	#dump_times($new_times);
90 90
 	return $new_times;
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
 function expand_byyearday($times) {
94 94
 	global $byyearday, $year;
95 95
 	if (empty($byyearday)) return $times;
96
-	$py = $year-1;
97
-	$ny = $year+1;
96
+	$py = $year - 1;
97
+	$ny = $year + 1;
98 98
 	$new_times = array();
99
-	foreach ($times as $time){
99
+	foreach ($times as $time) {
100 100
 		foreach ($byyearday as $yearday) {
101 101
 			if ($yearday > 0) {
102
-				$day = strtotime('+' . $yearday . ' days Dec 31, ' . $py);
102
+				$day = strtotime('+'.$yearday.' days Dec 31, '.$py);
103 103
 			}
104 104
 			else {
105
-				$day = strtotime('Jan 1 ' . $ny . ' ' . $yearday . ' days');
105
+				$day = strtotime('Jan 1 '.$ny.' '.$yearday.' days');
106 106
 			}
107 107
 			if (date('Y', $day == $year)) $new_times[] = $day;
108 108
 		}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 }
128 128
 
129 129
 function expand_byday($time) {
130
-	global $freq_type, $byday, $bymonth,$byweekno, $wkst3char, $year, $month, $start_unixtime, $summary;
130
+	global $freq_type, $byday, $bymonth, $byweekno, $wkst3char, $year, $month, $start_unixtime, $summary;
131 131
 	if (empty($byday)) return array($time);
132 132
 	$times = array();
133 133
 	$the_sunday = dateOfWeek(date('Ymd', $time), $wkst3char);
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
 				[2] => 4 number
139 139
 				[3] => TH day abbr
140 140
 		*/
141
-		ereg ('([-\+]{0,1})?([0-9]+)?([A-Z]{2})', $day, $byday_arr);
141
+		ereg('([-\+]{0,1})?([0-9]+)?([A-Z]{2})', $day, $byday_arr);
142 142
 		$on_day = two2threeCharDays($byday_arr[3]);
143 143
 		switch ($freq_type) {
144 144
 			case 'week':
145 145
 				#need to find the first day of the appropriate week.
146
-				$next_date_time = strtotime('this ' . $on_day, strtotime($the_sunday)) + (12 * 60 * 60);
146
+				$next_date_time = strtotime('this '.$on_day, strtotime($the_sunday)) + (12*60*60);
147 147
 				$times[] = $next_date_time;
148 148
 				break;
149 149
 			case 'month':
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 			case 'year':
153 153
 				if (empty($byweekno)) {
154 154
 					$week_arr = array(1, 2, 3, 4, 5);
155
-					if(isset($byday_arr[2]) && $byday_arr[2] !='') $week_arr = array($byday_arr[2]);
156
-					$month_start = strtotime(date('Ym01', $time)) - (24 * 60 * 60);
157
-					$month_end = strtotime(date('Ymt', $time)) + (36 * 60 * 60);
155
+					if (isset($byday_arr[2]) && $byday_arr[2] != '') $week_arr = array($byday_arr[2]);
156
+					$month_start = strtotime(date('Ym01', $time)) - (24*60*60);
157
+					$month_end = strtotime(date('Ymt', $time)) + (36*60*60);
158 158
 					if ($freq_type == 'year' && empty($bymonth)) {
159 159
 						$month_start = mktime(12, 0, 0, 1, 0, $year);
160 160
 						$month_end   = mktime(12, 0, 0, 1, 1, $year + 1);
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 					$month_start_day = strtolower(date('D', $month_start));
163 163
 					foreach ($week_arr as $week) {
164 164
 						if ($byday_arr[1] == '-') {
165
-							$next_date_time = strtotime($byday_arr[1] . $week . $on_day, $month_end);
165
+							$next_date_time = strtotime($byday_arr[1].$week.$on_day, $month_end);
166 166
 						}
167 167
 						else {
168 168
 							# we need this special offset in case the event day coincides with the month start day
169 169
 							# eg: month starts on a Sunday, our event is the Nth Sunday of the month... without this
170 170
 							# special offset, the event will be added to the (N+1)th Sunday of the month
171
-							$special_offset = ($month_start_day == $on_day) ? (24 * 60 * 60) : 0;
172
-							$next_date_time = strtotime($byday_arr[1] . $week . $on_day, ($month_start + $special_offset));
171
+							$special_offset = ($month_start_day == $on_day) ? (24*60*60) : 0;
172
+							$next_date_time = strtotime($byday_arr[1].$week.$on_day, ($month_start + $special_offset));
173 173
 						}
174 174
 						# check that we're still in the same month
175 175
 						if (date('m', $next_date_time) == date('m', $time)) $times[] = $next_date_time;
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 				}
178 178
 				else {
179 179
 					# byweekno should act like freq_type = week
180
-					$next_date_time = strtotime('this ' . $on_day, strtotime($the_sunday)) + (12 * 60 * 60);
180
+					$next_date_time = strtotime('this '.$on_day, strtotime($the_sunday)) + (12*60*60);
181 181
 					$times[] = $next_date_time;
182 182
 				}
183 183
 				break;
184 184
 			default:
185 185
 				$month_start = strtotime(date('Ym01', $time));
186
-				$next_date_time = strtotime($byday_arr[1] . $byday_arr[2] . $on_day, $month_start);
186
+				$next_date_time = strtotime($byday_arr[1].$byday_arr[2].$on_day, $month_start);
187 187
 				break;
188 188
 		}
189 189
 	}
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 				[2] => 4 number
255 255
 				[3] => TH day abbr
256 256
 		*/
257
-		ereg ('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr);
257
+		ereg('([-\+]{0,1})?([0-9]{1})?([A-Z]{2})', $day, $byday_arr);
258 258
 		$byday3[] = two2threeCharDays($byday_arr[3]);
259 259
 	}
260 260
 	$new_times = array();
@@ -278,10 +278,10 @@  discard block
 block discarded – undo
278 278
 # for diagnostics
279 279
 function dump_times($times) {
280 280
 	global $summary;
281
-	echo '<pre>' . $summary . ' times:';
281
+	echo '<pre>'.$summary.' times:';
282 282
 	#var_dump($times);
283 283
 	foreach ($times as $time) {
284
-		echo "\ndate:" . date('Y-m-d H:i:s', $time);
284
+		echo "\ndate:".date('Y-m-d H:i:s', $time);
285 285
 	}
286 286
 	echo '</pre>';
287 287
 }
Please login to merge, or discard this patch.
Braces   +85 added lines, -35 removed lines patch added patch discarded remove patch
@@ -11,7 +11,9 @@  discard block
 block discarded – undo
11 11
 function add_recur($times, $freq = '') {
12 12
 	global $recur_data;
13 13
 	global $count, $mArray_begin, $mArray_end, $except_dates, $start_date, $start_date_unixtime,$end_range_unixtime,$until_unixtime, $day_offset, $current_view;
14
-	if (!is_array($times)) $times = array($times);
14
+	if (!is_array($times)) {
15
+		$times = array($times);
16
+	}
15 17
 	/*	BYMONTH, BYWEEKNO, BYYEARDAY, BYMONTHDAY, BYDAY, BYHOUR, BYMINUTE, BYSECOND and BYSETPOS	*/
16 18
 #dump_times($times);
17 19
 	if ($current_view != 'search') {
@@ -20,13 +22,17 @@  discard block
 block discarded – undo
20 22
 		$times = restrict_byyearday($times, $freq);
21 23
 		$times = restrict_bymonthday($times, $freq);
22 24
 		$times = restrict_byday($times, $freq);
23
-		if ($start_date_unixtime > $mArray_begin) $times[] = $start_date_unixtime;
25
+		if ($start_date_unixtime > $mArray_begin) {
26
+			$times[] = $start_date_unixtime;
27
+		}
24 28
 		$times = restrict_bysetpos($times, $freq);
25 29
 		$times = array_unique($times);
26 30
 		sort($times);
27 31
 	}
28 32
 	foreach ($times as $time) {
29
-		if (!isset($time) || $time == '') continue;
33
+		if (!isset($time) || $time == '') {
34
+			continue;
35
+		}
30 36
 
31 37
 		// Why are we arbitrarily setting the time to noon?
32 38
 		$date = date('Ymd', $time);
@@ -36,7 +42,9 @@  discard block
 block discarded – undo
36 42
 
37 43
 		# day offset fixes shifts across day boundaries due to time diffs.
38 44
 		# These are already fixed for the initial instance, but need to be fixed for recurrences
39
-		if (date('Ymd', $time) != $start_date) $time = $time + ($day_offset * 24 * 60 * 60);
45
+		if (date('Ymd', $time) != $start_date) {
46
+			$time = $time + ($day_offset * 24 * 60 * 60);
47
+		}
40 48
 		if ((isset($time)) &&
41 49
 			(!in_array($time, $recur_data)) &&
42 50
 			(!in_array($date, $except_dates)) &&
@@ -49,8 +57,7 @@  discard block
 block discarded – undo
49 57
 				($count >= 0)) {
50 58
 				$recur_data[] = $time;
51 59
 			}
52
-		}
53
-		else if (in_array($date, $except_dates)) {
60
+		} else if (in_array($date, $except_dates)) {
54 61
 			$count--;
55 62
 		}
56 63
 	}
@@ -60,10 +67,16 @@  discard block
 block discarded – undo
60 67
 
61 68
 function expand_bymonth($time) {
62 69
 	global $bymonth, $byweekno, $bymonthday, $year, $start_unixtime, $freq_type;
63
-	if (!empty($byweekno)) return $time;
64
-	if (empty($bymonth)) $bymonth = array(date('m', $start_unixtime));
70
+	if (!empty($byweekno)) {
71
+		return $time;
72
+	}
73
+	if (empty($bymonth)) {
74
+		$bymonth = array(date('m', $start_unixtime));
75
+	}
65 76
 	$d = date('d', $start_unixtime);
66
-	if (!empty($bymonthday)) $d = 1;
77
+	if (!empty($bymonthday)) {
78
+		$d = 1;
79
+	}
67 80
 	foreach ($bymonth as $m) {
68 81
 		$time = mktime(12, 0, 0, $m, $d, $year);
69 82
 		$times[] = $time;
@@ -76,8 +89,12 @@  discard block
 block discarded – undo
76 89
 	# byweekno is only used when repeat is yearly
77 90
 	# when it's set, the input times are irrelevant
78 91
 	# it also needs a byday.
79
-	if ($freq_type != 'year') return $times;
80
-	if (empty($byweekno)) return $times;
92
+	if ($freq_type != 'year') {
93
+		return $times;
94
+	}
95
+	if (empty($byweekno)) {
96
+		return $times;
97
+	}
81 98
 	$total_weeks = date('W', mktime(12, 0, 0, 12, 24, $year)) + 1;
82 99
 	$w1_start = strtotime('this ' . $wkst3char, mktime(12, 0, 0, 1, 1, $year));
83 100
 	foreach ($byweekno as $weekno) {
@@ -92,7 +109,9 @@  discard block
 block discarded – undo
92 109
 
93 110
 function expand_byyearday($times) {
94 111
 	global $byyearday, $year;
95
-	if (empty($byyearday)) return $times;
112
+	if (empty($byyearday)) {
113
+		return $times;
114
+	}
96 115
 	$py = $year-1;
97 116
 	$ny = $year+1;
98 117
 	$new_times = array();
@@ -100,11 +119,12 @@  discard block
 block discarded – undo
100 119
 		foreach ($byyearday as $yearday) {
101 120
 			if ($yearday > 0) {
102 121
 				$day = strtotime('+' . $yearday . ' days Dec 31, ' . $py);
103
-			}
104
-			else {
122
+			} else {
105 123
 				$day = strtotime('Jan 1 ' . $ny . ' ' . $yearday . ' days');
106 124
 			}
107
-			if (date('Y', $day == $year)) $new_times[] = $day;
125
+			if (date('Y', $day == $year)) {
126
+				$new_times[] = $day;
127
+			}
108 128
 		}
109 129
 	}
110 130
 #	dump_times($new_times);
@@ -113,7 +133,9 @@  discard block
 block discarded – undo
113 133
 
114 134
 function expand_bymonthday($times) {
115 135
 	global $bymonthday, $year;
116
-	if (empty($bymonthday)) return $times;
136
+	if (empty($bymonthday)) {
137
+		return $times;
138
+	}
117 139
 	foreach ($times as $time) {
118 140
 		$month = date('m', $time);
119 141
 		foreach ($bymonthday as $monthday) {
@@ -128,7 +150,9 @@  discard block
 block discarded – undo
128 150
 
129 151
 function expand_byday($time) {
130 152
 	global $freq_type, $byday, $bymonth,$byweekno, $wkst3char, $year, $month, $start_unixtime, $summary;
131
-	if (empty($byday)) return array($time);
153
+	if (empty($byday)) {
154
+		return array($time);
155
+	}
132 156
 	$times = array();
133 157
 	$the_sunday = dateOfWeek(date('Ymd', $time), $wkst3char);
134 158
 	foreach ($byday as $key => $day) {
@@ -152,7 +176,9 @@  discard block
 block discarded – undo
152 176
 			case 'year':
153 177
 				if (empty($byweekno)) {
154 178
 					$week_arr = array(1, 2, 3, 4, 5);
155
-					if(isset($byday_arr[2]) && $byday_arr[2] !='') $week_arr = array($byday_arr[2]);
179
+					if(isset($byday_arr[2]) && $byday_arr[2] !='') {
180
+						$week_arr = array($byday_arr[2]);
181
+					}
156 182
 					$month_start = strtotime(date('Ym01', $time)) - (24 * 60 * 60);
157 183
 					$month_end = strtotime(date('Ymt', $time)) + (36 * 60 * 60);
158 184
 					if ($freq_type == 'year' && empty($bymonth)) {
@@ -163,8 +189,7 @@  discard block
 block discarded – undo
163 189
 					foreach ($week_arr as $week) {
164 190
 						if ($byday_arr[1] == '-') {
165 191
 							$next_date_time = strtotime($byday_arr[1] . $week . $on_day, $month_end);
166
-						}
167
-						else {
192
+						} else {
168 193
 							# we need this special offset in case the event day coincides with the month start day
169 194
 							# eg: month starts on a Sunday, our event is the Nth Sunday of the month... without this
170 195
 							# special offset, the event will be added to the (N+1)th Sunday of the month
@@ -172,10 +197,11 @@  discard block
 block discarded – undo
172 197
 							$next_date_time = strtotime($byday_arr[1] . $week . $on_day, ($month_start + $special_offset));
173 198
 						}
174 199
 						# check that we're still in the same month
175
-						if (date('m', $next_date_time) == date('m', $time)) $times[] = $next_date_time;
200
+						if (date('m', $next_date_time) == date('m', $time)) {
201
+							$times[] = $next_date_time;
202
+						}
176 203
 					}
177
-				}
178
-				else {
204
+				} else {
179 205
 					# byweekno should act like freq_type = week
180 206
 					$next_date_time = strtotime('this ' . $on_day, strtotime($the_sunday)) + (12 * 60 * 60);
181 207
 					$times[] = $next_date_time;
@@ -192,20 +218,28 @@  discard block
 block discarded – undo
192 218
 
193 219
 function restrict_bymonth($times, $freq = '') {
194 220
 	global $bymonth, $byyearday;
195
-	if (empty($bymonth) || !empty($byyearday)) return $times;
221
+	if (empty($bymonth) || !empty($byyearday)) {
222
+		return $times;
223
+	}
196 224
 	$new_times = array();
197 225
 	foreach ($times as $time) {
198
-		if (in_array(date('m', $time), $bymonth)) $new_times[] = $time;
226
+		if (in_array(date('m', $time), $bymonth)) {
227
+			$new_times[] = $time;
228
+		}
199 229
 	}
200 230
 	return $new_times;
201 231
 }
202 232
 
203 233
 function restrict_byweekno($times, $freq = '') {
204 234
 	global $byweekno;
205
-	if (empty($byweekno)) return $times;
235
+	if (empty($byweekno)) {
236
+		return $times;
237
+	}
206 238
 	$new_times = array();
207 239
 	foreach ($times as $time) {
208
-		if (in_array(date('W', $time), $byweekno)) $new_times[] = $time;
240
+		if (in_array(date('W', $time), $byweekno)) {
241
+			$new_times[] = $time;
242
+		}
209 243
 	}
210 244
 	return $new_times;
211 245
 
@@ -213,25 +247,33 @@  discard block
 block discarded – undo
213 247
 
214 248
 function restrict_byyearday($times, $freq = '') {
215 249
 	global $byyearday;
216
-	if (empty($byyearday)) return $times;
250
+	if (empty($byyearday)) {
251
+		return $times;
252
+	}
217 253
 	$new_times = array();
218 254
 	foreach ($times as $time) {
219 255
 		foreach ($byyearday as $yearday) {
220 256
 			if ($yearday < 0) {
221 257
 				$yearday = 365 + $yearday + 1;
222
-				if (date('L', $time)) $yearday += 1;
258
+				if (date('L', $time)) {
259
+					$yearday += 1;
260
+				}
223 261
 			}
224 262
 			$yearday_arr[] = $yearday;
225 263
 		}
226 264
 		# date('z', $time) gives 0 for Jan 1
227
-		if (in_array((date('z', $time) + 1), $yearday_arr)) $new_times[] = $time;
265
+		if (in_array((date('z', $time) + 1), $yearday_arr)) {
266
+			$new_times[] = $time;
267
+		}
228 268
 	}
229 269
 	return $new_times;
230 270
 }
231 271
 
232 272
 function restrict_bymonthday($times, $freq = '') {
233 273
 	global $bymonthday;
234
-	if (empty($bymonthday)) return $times;
274
+	if (empty($bymonthday)) {
275
+		return $times;
276
+	}
235 277
 	$new_times = array();
236 278
 	foreach ($times as $time) {
237 279
 		foreach ($bymonthday as $monthday) {
@@ -240,13 +282,17 @@  discard block
 block discarded – undo
240 282
 			}
241 283
 			$monthday_arr[] = $monthday;
242 284
 		}
243
-		if (in_array(date('j', $time), $monthday_arr)) $new_times[] = $time;
285
+		if (in_array(date('j', $time), $monthday_arr)) {
286
+			$new_times[] = $time;
287
+		}
244 288
 	}
245 289
 	return $new_times;
246 290
 }
247 291
 function restrict_byday($times, $freq = '') {
248 292
 	global $byday;
249
-	if (empty($byday)) return $times;
293
+	if (empty($byday)) {
294
+		return $times;
295
+	}
250 296
 	foreach ($byday as $key => $day) {
251 297
 		/* set $byday_arr
252 298
 				[0] => byday string, e.g. 4TH
@@ -259,14 +305,18 @@  discard block
 block discarded – undo
259 305
 	}
260 306
 	$new_times = array();
261 307
 	foreach ($times as $time) {
262
-		if (in_array(strtolower(date('D', $time)), $byday3)) $new_times[] = $time;
308
+		if (in_array(strtolower(date('D', $time)), $byday3)) {
309
+			$new_times[] = $time;
310
+		}
263 311
 	}
264 312
 	return $new_times;
265 313
 }
266 314
 
267 315
 function restrict_bysetpos($times, $freq = '') {
268 316
 	global $bysetpos;
269
-	if (empty($bysetpos)) return $times;
317
+	if (empty($bysetpos)) {
318
+		return $times;
319
+	}
270 320
 	sort($times);
271 321
 	$new_times = array();
272 322
 	foreach ($bysetpos as $setpos) {
Please login to merge, or discard this patch.
phpicalendar/functions/calendar_functions.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	// This array keeps track of paths we need to search.
41 41
 	$search_paths = array($phpiCal_config->calendar_path);
42 42
 	// Add web calendars.
43
-	if ($cal_filename_local[0] == $phpiCal_config->ALL_CALENDARS_COMBINED || $admin)	{
43
+	if ($cal_filename_local[0] == $phpiCal_config->ALL_CALENDARS_COMBINED || $admin) {
44 44
 		if (!isset($http_user) && !$admin) {
45 45
 			foreach ($list_webcals as $file) {
46 46
 				// Make sure the URL ends with .ics.
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 // is not printed out by this function.
190 190
 //
191 191
 // $cals	= The calendars (entire path, e.g. from availableCalendars).
192
-function display_ical_list($cals, $pick=FALSE) {
192
+function display_ical_list($cals, $pick = FALSE) {
193 193
 	global $cal, $current_view, $getdate, $lang, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $list_webcals, $phpiCal_config, $master_array;
194 194
 	// Print each calendar option.
195 195
 	$return = '';
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			(substr($cal_tmp, 0, 8) == 'https://') ||
210 210
 			(substr($cal_tmp, 0, 9) == 'webcal://')) {
211 211
 			$cal_tmp2 = str_replace('webcal://', 'http://', $cal_tmp);
212
-			$cal_tmp2 = str_replace('https://',  'http://', $cal_tmp2);
212
+			$cal_tmp2 = str_replace('https://', 'http://', $cal_tmp2);
213 213
 			$num = 1;
214 214
 			foreach ($master_array[-4] as $master_cal) {
215 215
 				if ($master_cal['filename'] == $cal_tmp2) {
@@ -226,20 +226,20 @@  discard block
 block discarded – undo
226 226
 			while (!feof($ifile)) {
227 227
 				$line = fgets($ifile, 1024);
228 228
 				$line = trim($line);
229
-				if (ereg ("([^:]+):(.*)", $line, $regs)){
229
+				if (ereg("([^:]+):(.*)", $line, $regs)) {
230 230
 					$field = $regs[1];
231 231
 					$data = $regs[2];
232 232
 					$property = $field;
233
-					$prop_pos = strpos($property,';');
234
-					if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
233
+					$prop_pos = strpos($property, ';');
234
+					if ($prop_pos !== false) $property = substr($property, 0, $prop_pos);
235 235
 					$property = strtoupper($property);
236
-					if ($property == "X-WR-CALNAME"){
236
+					if ($property == "X-WR-CALNAME") {
237 237
 						$cal_displayname_tmp = stripslashes($data);
238 238
 						break;
239 239
 					}
240 240
 				}	
241 241
 				#stop reading if we find an event or timezone before there's a name
242
-				if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") break;
242
+				if ($line == "BEGIN:VTIMEZONE" || $line == "BEGIN:VEVENT") break;
243 243
 			}
244 244
 			@fclose($ifile);
245 245
 		}
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 
268 268
 		// Encode the calendar path.
269 269
 		$cal_encoded_tmp = urlencode($cal_tmp);
270
-		if(in_array($cal_tmp, $list_webcals)){
271
-			$cal_encoded_tmp = md5($phpiCal_config->salt.$cal_tmp);;
270
+		if (in_array($cal_tmp, $list_webcals)) {
271
+			$cal_encoded_tmp = md5($phpiCal_config->salt.$cal_tmp); ;
272 272
 		}
273 273
 
274 274
 		// Try to detect unselected calendars
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		// The submitted calendar will be encoded, and always use http://
280 280
 		// if it is a webcal. So that is how we perform the comparison when
281 281
 		// trying to figure out if this is the selected calendar.
282
-		if($pick) {
282
+		if ($pick) {
283 283
 			if (in_array($cal_encoded_tmp, explode(",", $cal)) || count($cals) == count(explode(",", $cal))) {
284 284
 				$return .= "<option value=\"$cal_encoded_tmp\" selected=\"selected\">$cal_displayname_tmp</option>\n";
285 285
 			} else {
@@ -297,9 +297,9 @@  discard block
 block discarded – undo
297 297
 	// option to open all (non-web) calenders together
298 298
 	if (!$pick) {
299 299
 		if ($all_cals || $cal == $phpiCal_config->ALL_CALENDARS_COMBINED) {
300
-			$return .=  "<option value=\"$current_view.php?cal=$phpiCal_config->ALL_CALENDARS_COMBINED&amp;getdate=$getdate\" selected=\"selected\">$all_cal_comb_lang</option>";
300
+			$return .= "<option value=\"$current_view.php?cal=$phpiCal_config->ALL_CALENDARS_COMBINED&amp;getdate=$getdate\" selected=\"selected\">$all_cal_comb_lang</option>";
301 301
 		} else {
302
-			$return .=  "<option value=\"$current_view.php?cal=$phpiCal_config->ALL_CALENDARS_COMBINED&amp;getdate=$getdate\">$all_cal_comb_lang</option>";
302
+			$return .= "<option value=\"$current_view.php?cal=$phpiCal_config->ALL_CALENDARS_COMBINED&amp;getdate=$getdate\">$all_cal_comb_lang</option>";
303 303
 		}
304 304
 	}
305 305
 
Please login to merge, or discard this patch.
Braces   +58 added lines, -27 removed lines patch added patch discarded remove patch
@@ -29,10 +29,11 @@  discard block
 block discarded – undo
29 29
 		$unlocked_cals = $locked_map["$username:$password"];
30 30
 	}
31 31
 	// Make a local copy of the requested calendars.
32
-	if (!is_array($cal_filename))
33
-		$cal_filename_local = array($cal_filename);
34
-	else
35
-		$cal_filename_local = $cal_filename;
32
+	if (!is_array($cal_filename)) {
33
+			$cal_filename_local = array($cal_filename);
34
+	} else {
35
+			$cal_filename_local = $cal_filename;
36
+	}
36 37
 
37 38
 	// Create the list of available calendars.
38 39
 	$calendars = array();
@@ -44,7 +45,9 @@  discard block
 block discarded – undo
44 45
 		if (!isset($http_user) && !$admin) {
45 46
 			foreach ($list_webcals as $file) {
46 47
 				// Make sure the URL ends with .ics.
47
-				if (!is_string($file)) continue;			
48
+				if (!is_string($file)) {
49
+					continue;
50
+				}
48 51
 				// Add this calendar.
49 52
 				array_push($calendars, $file);
50 53
 			}
@@ -72,13 +75,16 @@  discard block
 block discarded – undo
72 75
 			// Open the directory.
73 76
 			$dir_handle = opendir($search_path)
74 77
 				or die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
75
-			if ($dir_handle === false)
76
-				die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
78
+			if ($dir_handle === false) {
79
+							die(error(sprintf($lang['l_error_path'], $search_path), implode(',', $cal_filename)));
80
+			}
77 81
 				
78 82
 			// Add each file in the directory that does not begin with a dot.
79 83
 			while (false !== ($file = readdir($dir_handle))) {
80 84
 				// Make sure this is not a dot file.
81
-				if (preg_match("/^\./", $file)) continue;
85
+				if (preg_match("/^\./", $file)) {
86
+					continue;
87
+				}
82 88
 				array_push($files, "$search_path/$file");
83 89
 			}
84 90
 		} else {
@@ -94,24 +100,38 @@  discard block
 block discarded – undo
94 100
 			// Push directories onto the search paths if recursive paths is
95 101
 			// turned on.
96 102
 			if (is_dir($file)) {
97
-				if ($phpiCal_config->recursive_path == 'yes') array_push($search_paths, $file);
103
+				if ($phpiCal_config->recursive_path == 'yes') {
104
+					array_push($search_paths, $file);
105
+				}
98 106
 				continue;
99 107
 			}			
100 108
 			// Make sure the file is real.
101
-			if (!is_file($file)) continue;
109
+			if (!is_file($file)) {
110
+				continue;
111
+			}
102 112
 			// Remove any php files.
103
-			if (preg_match("/^.*\.php$/i", $file)) continue;
113
+			if (preg_match("/^.*\.php$/i", $file)) {
114
+				continue;
115
+			}
104 116
 			# remove publish log file 
105
-			if ($file == 'publish_log.txt') continue;
117
+			if ($file == 'publish_log.txt') {
118
+				continue;
119
+			}
106 120
 			// Make sure this is not a blacklisted calendar.
107 121
 			$cal_name = getCalendarName($file); 
108
-			if (in_array($cal_name, $blacklisted_cals)) continue;
122
+			if (in_array($cal_name, $blacklisted_cals)) {
123
+				continue;
124
+			}
109 125
 			// If HTTP authenticated, make sure this calendar is available
110 126
 			// to the user.
111
-			if (isset($http_user) && isset($apache_map[$http_user]) && !in_array($cal_name, $apache_map[$http_user])) continue;
127
+			if (isset($http_user) && isset($apache_map[$http_user]) && !in_array($cal_name, $apache_map[$http_user])) {
128
+				continue;
129
+			}
112 130
 
113 131
 			// Make sure this calendar is not locked.
114
-			if (!$admin && in_array($cal_name, $locked_cals) && !in_array($cal_name, $unlocked_cals)) continue;
132
+			if (!$admin && in_array($cal_name, $locked_cals) && !in_array($cal_name, $unlocked_cals)) {
133
+				continue;
134
+			}
115 135
 			
116 136
 			// Add this calendar if we're looking for it, and remove it's name
117 137
 			// from the local list because we've found it.
@@ -119,7 +139,9 @@  discard block
 block discarded – undo
119 139
 				array_push($calendars, $file);
120 140
 				$cal_filename_local = array_diff($cal_filename_local, array($cal_name));				
121 141
 				// If the local list is empty, we're done.
122
-				if (empty($cal_filename_local))	break 2;
142
+				if (empty($cal_filename_local)) {
143
+					break 2;
144
+				}
123 145
 			}
124 146
 		}
125 147
 	}
@@ -169,8 +191,9 @@  discard block
 block discarded – undo
169 191
 						
170 192
 			// Pull out the calendar name.
171 193
 			$num_matches = preg_match("/<key>Title<\/key>\s*?<string>(.+?)<\/string>/i", $contents, $matches);
172
-			if ($num_matches > 0)
173
-				return $matches[1];
194
+			if ($num_matches > 0) {
195
+							return $matches[1];
196
+			}
174 197
 		}
175 198
 	}
176 199
 	
@@ -195,7 +218,9 @@  discard block
 block discarded – undo
195 218
 	$return = '';
196 219
 
197 220
 	$all_cals = false;
198
-	if (count($cals) > 1) $all_cals = true;
221
+	if (count($cals) > 1) {
222
+		$all_cals = true;
223
+	}
199 224
 
200 225
 	foreach ($cals as $cal_tmp) {
201 226
 		// Format the calendar path for display.
@@ -204,8 +229,7 @@  discard block
 block discarded – undo
204 229
 		$search_idx = array_search($cal_tmp, $cal_filelist);
205 230
 		if (is_numeric($search_idx)) {
206 231
 			$cal_displayname_tmp = $cal_displaynames[$search_idx];
207
-		}
208
-		else if ((substr($cal_tmp, 0, 7) == 'http://') ||
232
+		} else if ((substr($cal_tmp, 0, 7) == 'http://') ||
209 233
 			(substr($cal_tmp, 0, 8) == 'https://') ||
210 234
 			(substr($cal_tmp, 0, 9) == 'webcal://')) {
211 235
 			$cal_tmp2 = str_replace('webcal://', 'http://', $cal_tmp);
@@ -218,11 +242,12 @@  discard block
 block discarded – undo
218 242
 				}
219 243
 				$num++;
220 244
 			}
221
-		}
222
-		else {
245
+		} else {
223 246
 			# pull the name from the $cal_tmp file
224 247
 			$ifile = @fopen($cal_tmp, 'r');
225
-			if ($ifile == FALSE) exit(error($lang['l_error_cantopen'], $cal_tmp));
248
+			if ($ifile == FALSE) {
249
+				exit(error($lang['l_error_cantopen'], $cal_tmp));
250
+			}
226 251
 			while (!feof($ifile)) {
227 252
 				$line = fgets($ifile, 1024);
228 253
 				$line = trim($line);
@@ -231,7 +256,9 @@  discard block
 block discarded – undo
231 256
 					$data = $regs[2];
232 257
 					$property = $field;
233 258
 					$prop_pos = strpos($property,';');
234
-					if ($prop_pos !== false) $property = substr($property,0,$prop_pos);
259
+					if ($prop_pos !== false) {
260
+						$property = substr($property,0,$prop_pos);
261
+					}
235 262
 					$property = strtoupper($property);
236 263
 					if ($property == "X-WR-CALNAME"){
237 264
 						$cal_displayname_tmp = stripslashes($data);
@@ -239,7 +266,9 @@  discard block
 block discarded – undo
239 266
 					}
240 267
 				}	
241 268
 				#stop reading if we find an event or timezone before there's a name
242
-				if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") break;
269
+				if ($line == "BEGIN:VTIMEZONE" ||$line == "BEGIN:VEVENT") {
270
+					break;
271
+				}
243 272
 			}
244 273
 			@fclose($ifile);
245 274
 		}
@@ -272,7 +301,9 @@  discard block
 block discarded – undo
272 301
 		}
273 302
 
274 303
 		// Try to detect unselected calendars
275
-		if (!in_array($cal_encoded_tmp, explode(",", $cal))) $all_cals = false;
304
+		if (!in_array($cal_encoded_tmp, explode(",", $cal))) {
305
+			$all_cals = false;
306
+		}
276 307
 
277 308
 		// Display the option.
278 309
 		//
Please login to merge, or discard this patch.
phpicalendar/index.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,16 +3,16 @@
 block discarded – undo
3 3
 include_once(BASE.'functions/init.inc.php');
4 4
 
5 5
 if ($phpiCal_config->printview_default == 'yes') {
6
-	$theview ="print.php";
6
+	$theview = "print.php";
7 7
 } else {
8
-	$check = array ('day', 'week', 'month', 'year');
8
+	$check = array('day', 'week', 'month', 'year');
9 9
 	if (in_array($phpiCal_config->default_view, $check)) {
10
-		$theview = $phpiCal_config->default_view . '.php';
10
+		$theview = $phpiCal_config->default_view.'.php';
11 11
 	} else {
12 12
 		die('illegal view');
13 13
 	}
14 14
 }
15
-if(isset($_GET['cpath'])){
15
+if (isset($_GET['cpath'])) {
16 16
 	$theview .= '?cpath='.$_GET['cpath'];
17 17
 }
18 18
 header("Location: $theview");
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('BASE')) define('BASE', './');
2
+if (!defined('BASE')) {
3
+	define('BASE', './');
4
+}
3 5
 include_once(BASE.'functions/init.inc.php');
4 6
 
5 7
 if ($phpiCal_config->printview_default == 'yes') {
Please login to merge, or discard this patch.
phpicalendar/search.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 						foreach ($time_tmp as $uid_tmp => $event_tmp) {
50 50
 							if (is_array($event_tmp)) {
51 51
 								if (!isset($the_arr[$uid_tmp]) || isset($event_tmp['exception'])) {
52
-                                                                        #print_r($format_search_arr);
53
-                                                                        #print_r($event_tmp);
54
-                                                                        #echo "<br>this event:".$event_tmp['event_text']."<br>";
52
+																		#print_r($format_search_arr);
53
+																		#print_r($event_tmp);
54
+																		#echo "<br>this event:".$event_tmp['event_text']."<br>";
55 55
 									$results1 = false;
56 56
 									$results2 = false;
57 57
 									if (isset($event_tmp['event_text'])) {
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		if ($is_false) return false;
217 217
 	}
218 218
 	// if we haven't returned false, then we return true
219
-       # echo "return true<br>";
219
+	   # echo "return true<br>";
220 220
 	return true;
221 221
 }
222 222
 
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('BASE','./');
3
+define('BASE', './');
4 4
 $current_view = 'search';
5 5
 require_once(BASE.'functions/ical_parser.php');
6 6
 require_once(BASE.'functions/list_functions.php');
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 		$formatted_search = $format_search_arr[0];
43 43
 	}
44 44
 	if (isset($master_array) && is_array($master_array)) {
45
-		foreach($master_array as $date_key_tmp => $date_tmp) {
45
+		foreach ($master_array as $date_key_tmp => $date_tmp) {
46 46
 			if (is_array($date_tmp)) {
47
-				foreach($date_tmp as $time_tmp) {
47
+				foreach ($date_tmp as $time_tmp) {
48 48
 					if (is_array($time_tmp)) {
49 49
 						foreach ($time_tmp as $uid_tmp => $event_tmp) {
50 50
 							if (is_array($event_tmp)) {
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 									$results1 = false;
56 56
 									$results2 = false;
57 57
 									if (isset($event_tmp['event_text'])) {
58
-										$results1 = search_boolean($format_search_arr,$event_tmp['event_text']);
58
+										$results1 = search_boolean($format_search_arr, $event_tmp['event_text']);
59 59
 									}
60 60
 
61 61
 									if (!$results1 && isset($event_tmp['description'])) {
62
-										$results2 = search_boolean($format_search_arr,$event_tmp['description']);
62
+										$results2 = search_boolean($format_search_arr, $event_tmp['description']);
63 63
 									}
64 64
 									if ($results1 || $results2) {
65 65
 										$event_tmp['date'] = $date_key_tmp;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 }
86 86
 $search_ended = getmicrotime();
87 87
 
88
-$search_took = number_format(($search_ended-$search_started),3);
88
+$search_took = number_format(($search_ended - $search_started), 3);
89 89
 
90 90
 // takes a boolean search and formats it into an array
91 91
 // use with sister function search_boolean()
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 
99 99
 	$search_str = strtolower($search_str);
100 100
 
101
-	if ($search_str == ' ') return array(false,$and_arr,$or_arr,$not_arr);
101
+	if ($search_str == ' ') return array(false, $and_arr, $or_arr, $not_arr);
102 102
 
103 103
 	// clean up search string
104 104
 	$search_str = trim($search_str);
105 105
 	$search_str = str_replace(' and ', ' ', $search_str);
106 106
 	$search_str = str_replace(' - ', ' ', $search_str);
107
-	$search_str = ereg_replace('[[:space:]]+',' ', $search_str);
107
+	$search_str = ereg_replace('[[:space:]]+', ' ', $search_str);
108 108
 	$search_str = str_replace(' not ', ' -', $search_str);
109 109
 
110 110
 	// start out with an AND array of all the items
@@ -113,16 +113,16 @@  discard block
 block discarded – undo
113 113
 	$j = 0;
114 114
 
115 115
 	// build an OR array from the items in AND
116
-	for($i=0;$i<$count;$i++) {
116
+	for ($i = 0; $i < $count; $i++) {
117 117
 		if ($i != 0 && $and_arr[$i] == 'or') {
118 118
 			while ($and_arr[$i] == 'or') {
119
-				$or_arr[$j][] = $and_arr[$i-1];
120
-				array_splice($and_arr,$i-1,2);
119
+				$or_arr[$j][] = $and_arr[$i - 1];
120
+				array_splice($and_arr, $i - 1, 2);
121 121
  				$i--;
122 122
 			}
123 123
 			if (isset($and_arr[$i])) {
124 124
 				$or_arr[$j][] = $and_arr[$i];
125
-				array_splice($and_arr,$i,1);
125
+				array_splice($and_arr, $i, 1);
126 126
 			}
127 127
 			$or_str_arr[$j] = implode('</b> OR <b>', $or_arr[$j]);
128 128
 			$j++;
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 
132 132
 	// build a NOT array from the items in AND
133
-	foreach($and_arr as $key => $val) {
134
-		if (substr($val,0,1) == '-') {
135
-			$not_arr[] = substr($val,1);
136
-			array_splice($and_arr,$key,1);
137
-		} elseif(substr($val,0,1) == '+') {
138
-			$and_arr[] = substr($val,1);
139
-			array_splice($and_arr,$key,1);
133
+	foreach ($and_arr as $key => $val) {
134
+		if (substr($val, 0, 1) == '-') {
135
+			$not_arr[] = substr($val, 1);
136
+			array_splice($and_arr, $key, 1);
137
+		} elseif (substr($val, 0, 1) == '+') {
138
+			$and_arr[] = substr($val, 1);
139
+			array_splice($and_arr, $key, 1);
140 140
 		}
141 141
 	}
142 142
 
@@ -185,30 +185,30 @@  discard block
 block discarded – undo
185 185
 	$haystack = strtolower($haystack);
186 186
 
187 187
 	// check against the NOT
188
-	foreach($not_arr as $s) {
189
-		if (is_string(strstr($haystack,$s)) == true) {
188
+	foreach ($not_arr as $s) {
189
+		if (is_string(strstr($haystack, $s)) == true) {
190 190
 			return false;
191 191
 		}
192 192
 	}
193 193
 
194 194
 	// check against the AND
195
-	foreach($and_arr as $s) {
195
+	foreach ($and_arr as $s) {
196 196
 			#echo "haystack: $haystack<br>needle: $s<br>";
197
-		if (is_string(strstr($haystack,$s)) == false) {
197
+		if (is_string(strstr($haystack, $s)) == false) {
198 198
 			return false;
199 199
 		}
200 200
 	}
201 201
 
202 202
 	// check against the OR
203
-	foreach($or_arr as $or) {
203
+	foreach ($or_arr as $or) {
204 204
 		$is_false = true;
205
-		foreach($or as $s) {
206
-			if (substr($s,0,1) == '-') {
207
-				if (is_string(strstr($haystack,substr($s,1))) == false) {
205
+		foreach ($or as $s) {
206
+			if (substr($s, 0, 1) == '-') {
207
+				if (is_string(strstr($haystack, substr($s, 1))) == false) {
208 208
 					$is_false = false;
209 209
 					break;
210 210
 				}
211
-			} elseif (is_string(strstr($haystack,$s)) == true) {
211
+			} elseif (is_string(strstr($haystack, $s)) == true) {
212 212
 				$is_false = false;
213 213
 				break;
214 214
 			}
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 		$freq = $format_recur_lang[$freq][$tmp];
236 236
 	}
237 237
 
238
-	if		(isset($arr['COUNT']))	$for = str_replace('%int%',$arr['COUNT'],$format_recur_lang['count']);
239
-	elseif	(isset($arr['UNTIL']))	$for = str_replace('%date%',$arr['UNTIL'], $format_recur_lang['until']);
238
+	if (isset($arr['COUNT']))	$for = str_replace('%int%', $arr['COUNT'], $format_recur_lang['count']);
239
+	elseif (isset($arr['UNTIL']))	$for = str_replace('%date%', $arr['UNTIL'], $format_recur_lang['until']);
240 240
 	else							$for = '';
241 241
 
242 242
 	$print = $format_recur_lang['start'];
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 		$list = '';
249 249
 		$last = count($arr['BYMONTH']) - 1;
250 250
 		foreach ($arr['BYMONTH'] as $key => $month) {
251
-			if ($key == $last)	$list .= $monthsofyear_lang[($month-1)];
252
-			else 				$list .= $monthsofyear_lang[($month-1)].$d;
251
+			if ($key == $last)	$list .= $monthsofyear_lang[($month - 1)];
252
+			else 				$list .= $monthsofyear_lang[($month - 1)].$d;
253 253
 		}
254 254
 		$print .= '<br />'."\n";
255 255
 		$print .= str_replace('%list%', $list, $format_recur_lang['bymonth']);
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 		if ($arr['BYMONTHDAY'][(count($arr['BYMONTHDAY']) - 1)] == '0') unset($arr['BYMONTHDAY'][$last]);
261 261
 		$last = count($arr['BYMONTHDAY']) - 1;
262 262
 		foreach ($arr['BYMONTHDAY'] as $key => $day) {
263
-			ereg('(-{0,1})([0-9]{1,2})',$day,$regs);
264
-			list($junk,$sign,$day) = $regs;
263
+			ereg('(-{0,1})([0-9]{1,2})', $day, $regs);
264
+			list($junk, $sign, $day) = $regs;
265 265
 			if ($sign != '')	$list .= $sign;
266 266
 			if ($key == $last)	$list .= $day;
267 267
 			else				$list .= $day.$d;
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 		$list = '';
275 275
 		$last = count($arr['BYDAY']) - 1;
276 276
 		foreach ($arr['BYDAY'] as $key => $day) {
277
-			ereg('([-\+]{0,1})([0-9]{0,1})([A-Z]{2})',$day,$regs);
278
-			list($junk,$sign,$day_num,$day_txt) = $regs;
279
-			$num = two2threeCharDays($day_txt,false);
277
+			ereg('([-\+]{0,1})([0-9]{0,1})([A-Z]{2})', $day, $regs);
278
+			list($junk, $sign, $day_num, $day_txt) = $regs;
279
+			$num = two2threeCharDays($day_txt, false);
280 280
 			if ($sign != '')	$list .= $sign;
281 281
 			if ($day_num != '')	$list .= $day_num.' ';
282 282
 			if ($key == $last)	$list .= $daysofweek_lang[$num];
Please login to merge, or discard this patch.
Braces   +46 added lines, -17 removed lines patch added patch discarded remove patch
@@ -98,7 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
 	$search_str = strtolower($search_str);
100 100
 
101
-	if ($search_str == ' ') return array(false,$and_arr,$or_arr,$not_arr);
101
+	if ($search_str == ' ') {
102
+		return array(false,$and_arr,$or_arr,$not_arr);
103
+	}
102 104
 
103 105
 	// clean up search string
104 106
 	$search_str = trim($search_str);
@@ -176,10 +178,14 @@  discard block
 block discarded – undo
176 178
 	$or_arr = $needle_arr[2];
177 179
 	$not_arr = $needle_arr[3];
178 180
 
179
-	if (!$needle_arr[0]) return false;
181
+	if (!$needle_arr[0]) {
182
+		return false;
183
+	}
180 184
 	if ((sizeof($and_arr) == 0) &&
181 185
 		(sizeof($or_arr) == 0) &&
182
-		(sizeof($not_arr) == 0)) return false;
186
+		(sizeof($not_arr) == 0)) {
187
+		return false;
188
+	}
183 189
 
184 190
 	// compare lowercase versions of the strings
185 191
 	$haystack = strtolower($haystack);
@@ -213,7 +219,9 @@  discard block
 block discarded – undo
213 219
 				break;
214 220
 			}
215 221
 		}
216
-		if ($is_false) return false;
222
+		if ($is_false) {
223
+			return false;
224
+		}
217 225
 	}
218 226
 	// if we haven't returned false, then we return true
219 227
        # echo "return true<br>";
@@ -235,9 +243,13 @@  discard block
 block discarded – undo
235 243
 		$freq = $format_recur_lang[$freq][$tmp];
236 244
 	}
237 245
 
238
-	if		(isset($arr['COUNT']))	$for = str_replace('%int%',$arr['COUNT'],$format_recur_lang['count']);
239
-	elseif	(isset($arr['UNTIL']))	$for = str_replace('%date%',$arr['UNTIL'], $format_recur_lang['until']);
240
-	else							$for = '';
246
+	if		(isset($arr['COUNT'])) {
247
+		$for = str_replace('%int%',$arr['COUNT'],$format_recur_lang['count']);
248
+	} elseif	(isset($arr['UNTIL'])) {
249
+		$for = str_replace('%date%',$arr['UNTIL'], $format_recur_lang['until']);
250
+	} else {
251
+		$for = '';
252
+	}
241 253
 
242 254
 	$print = $format_recur_lang['start'];
243 255
 	$print = str_replace('%int%', $int, $print);
@@ -248,8 +260,11 @@  discard block
 block discarded – undo
248 260
 		$list = '';
249 261
 		$last = count($arr['BYMONTH']) - 1;
250 262
 		foreach ($arr['BYMONTH'] as $key => $month) {
251
-			if ($key == $last)	$list .= $monthsofyear_lang[($month-1)];
252
-			else 				$list .= $monthsofyear_lang[($month-1)].$d;
263
+			if ($key == $last) {
264
+				$list .= $monthsofyear_lang[($month-1)];
265
+			} else {
266
+				$list .= $monthsofyear_lang[($month-1)].$d;
267
+			}
253 268
 		}
254 269
 		$print .= '<br />'."\n";
255 270
 		$print .= str_replace('%list%', $list, $format_recur_lang['bymonth']);
@@ -257,14 +272,21 @@  discard block
 block discarded – undo
257 272
 
258 273
 	if (isset($arr['BYMONTHDAY'])) {
259 274
 		$list = '';
260
-		if ($arr['BYMONTHDAY'][(count($arr['BYMONTHDAY']) - 1)] == '0') unset($arr['BYMONTHDAY'][$last]);
275
+		if ($arr['BYMONTHDAY'][(count($arr['BYMONTHDAY']) - 1)] == '0') {
276
+			unset($arr['BYMONTHDAY'][$last]);
277
+		}
261 278
 		$last = count($arr['BYMONTHDAY']) - 1;
262 279
 		foreach ($arr['BYMONTHDAY'] as $key => $day) {
263 280
 			ereg('(-{0,1})([0-9]{1,2})',$day,$regs);
264 281
 			list($junk,$sign,$day) = $regs;
265
-			if ($sign != '')	$list .= $sign;
266
-			if ($key == $last)	$list .= $day;
267
-			else				$list .= $day.$d;
282
+			if ($sign != '') {
283
+				$list .= $sign;
284
+			}
285
+			if ($key == $last) {
286
+				$list .= $day;
287
+			} else {
288
+				$list .= $day.$d;
289
+			}
268 290
 		}
269 291
 		$print .= '<br />'."\n";
270 292
 		$print .= str_replace('%list%', $list, $format_recur_lang['bymonthday']);
@@ -277,10 +299,17 @@  discard block
 block discarded – undo
277 299
 			ereg('([-\+]{0,1})([0-9]{0,1})([A-Z]{2})',$day,$regs);
278 300
 			list($junk,$sign,$day_num,$day_txt) = $regs;
279 301
 			$num = two2threeCharDays($day_txt,false);
280
-			if ($sign != '')	$list .= $sign;
281
-			if ($day_num != '')	$list .= $day_num.' ';
282
-			if ($key == $last)	$list .= $daysofweek_lang[$num];
283
-			else				$list .= $daysofweek_lang[$num].$d;
302
+			if ($sign != '') {
303
+				$list .= $sign;
304
+			}
305
+			if ($day_num != '') {
306
+				$list .= $day_num.' ';
307
+			}
308
+			if ($key == $last) {
309
+				$list .= $daysofweek_lang[$num];
310
+			} else {
311
+				$list .= $daysofweek_lang[$num].$d;
312
+			}
284 313
 		}
285 314
 		$print .= '<br />'."\n";
286 315
 		$print .= str_replace('%list%', $list, $format_recur_lang['byday']);
Please login to merge, or discard this patch.
phpicalendar/day.php 3 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,8 +57,8 @@
 block discarded – undo
57 57
 	'header'			=> BASE.'templates/'.$phpiCal_config->template.'/header.tpl',
58 58
 	'event_js'			=> BASE.'functions/event.js',
59 59
 	'footer'			=> BASE.'templates/'.$phpiCal_config->template.'/footer.tpl',
60
-    'sidebar'           => BASE.'templates/'.$phpiCal_config->template.'/sidebar.tpl',
61
-    'search_box'        => BASE.'templates/'.$phpiCal_config->template.'/search_box.tpl'
60
+	'sidebar'           => BASE.'templates/'.$phpiCal_config->template.'/sidebar.tpl',
61
+	'search_box'        => BASE.'templates/'.$phpiCal_config->template.'/search_box.tpl'
62 62
 	));
63 63
 
64 64
 $page->replace_tags(array(
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 
27 27
 $weekstart 		= 1;
28 28
 $unix_time 		= strtotime($getdate);
29
-$today_today 	= date('Ymd', time() + $phpiCal_config->second_offset);  
30
-$next_day		= date('Ymd', strtotime("+1 day",  $unix_time));
31
-$prev_day 		= date('Ymd', strtotime("-1 day",  $unix_time));
29
+$today_today = date('Ymd', time() + $phpiCal_config->second_offset);  
30
+$next_day = date('Ymd', strtotime("+1 day", $unix_time));
31
+$prev_day = date('Ymd', strtotime("-1 day", $unix_time));
32 32
 
33 33
 $display_date = localizeDate($dateFormat_day, $unix_time);
34 34
 $sidebar_date = localizeDate($dateFormat_week_list, $unix_time);
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
 
37 37
 
38 38
 // select for calendars
39
-$available		= availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED);
39
+$available = availableCalendars($username, $password, $phpiCal_config->ALL_CALENDARS_COMBINED);
40 40
 $list_icals 	= display_ical_list($available);
41 41
 $list_years 	= list_years();
42
-$list_months 	= list_months();
42
+$list_months = list_months();
43 43
 $list_weeks 	= list_weeks();
44 44
 $list_jumps 	= list_jumps();
45 45
 $list_calcolors = list_calcolors();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 $current_view = 'day';
3
-if (!defined('BASE')) define('BASE', './');
3
+if (!defined('BASE')) {
4
+	define('BASE', './');
5
+}
4 6
 require_once(BASE.'functions/init.inc.php');
5 7
 header("Content-Type: text/html; charset=$phpiCal_config->charset");
6 8
 if (isset($_GET['jumpto_day'])) {
Please login to merge, or discard this patch.
phpicalendar/default_config.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-class Configs{
2
+class Configs {
3 3
 	private static $instance;
4
-	private function __construct(){
4
+	private function __construct() {
5 5
 		$this->phpicalendar_version = '2.4';
6 6
 	// Configuration file for PHP iCalendar 2.4
7 7
 	//
@@ -10,88 +10,88 @@  discard block
 block discarded – undo
10 10
 #=================Initialize global variables=================================
11 11
 // Define some magic strings.
12 12
 		$this->ALL_CALENDARS_COMBINED = 'all_calendars_combined971';
13
-		$this->template 				= 'default';		// Template support
14
-		$this->default_view 			= 'day';			// Default view for calendars = 'day', 'week', 'month', 'year'
15
-		$this->minical_view 			= 'current';		// Where do the mini-calendars go when clicked? = 'day', 'week', 'month', 'current'
16
-		$this->default_cal 				= $this->ALL_CALENDARS_COMBINED;		// Exact filename of calendar without .ics. Or set to $this->ALL_CALENDARS_COMBINED to open all calenders combined into one.
17
-		$this->language 				= 'English';		// Language support - 'English', 'Polish', 'German', 'French', 'Dutch', 'Danish', 'Italian', 'Japanese', 'Norwegian', 'Spanish', 'Swedish', 'Portuguese', 'Catalan', 'Traditional_Chinese', 'Esperanto', 'Korean'
18
-		$this->week_start_day 			= 'Sunday';			// Day of the week your week starts on
19
-		$this->week_length				= '7';				// Number of days to display in the week view
20
-		$this->day_start 				= '0600';			// Start time for day grid
21
-		$this->day_end					= '2000';			// End time for day grid
22
-		$this->gridLength 				= '15';				// Grid distance in minutes for day view, multiples of 15 preferred
23
-		$this->num_years 				= '1';				// Number of years (up and back) to display in 'Jump to'
24
-		$this->month_event_lines 		= '0';				// Number of lines to wrap each event title in month view, 0 means display all lines.
25
-		$this->tomorrows_events_lines 	= '1';				// Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines.
26
-		$this->allday_week_lines 		= '1';				// Number of lines to wrap each event title in all-day events in week view, 0 means display all lines.
27
-		$this->week_events_lines 		= '1';				// Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines.
28
-		$this->timezone 				= '';				// Set timezone. Read TIMEZONES file for more information
29
-		$this->calendar_path 			= '';				// Leave this blank on most installs, place your full FILE SYSTEM PATH to calendars if they are outside the phpicalendar folder.
30
-		$this->second_offset			= '';				// The time in seconds between your time and your server's time.
31
-		$this->bleed_time				= '-1';				// This allows events past midnight to just be displayed on the starting date, only good up to 24 hours. Range from '0000' to '2359', or '-1' for no bleed time.
32
-		$this->cookie_uri				= ''; 				// The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar -- AUTO SETTING -- Only set if you are having cookie issues.
33
-		$this->download_uri				= ''; 				// The HTTP URL to your calendars directory, ie. http://www.example.com/phpicalendar/calendars -- AUTO SETTING -- Only set if you are having subscribe issues.
34
-		$this->default_path				= ''; 				// The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar
35
-		$this->cpath	     			= ''; 				// optional subdirectory
36
-		$this->charset					= 'UTF-8';			// Character set your calendar is in, suggested UTF-8, or iso-8859-1 for most languages.
13
+		$this->template = 'default'; // Template support
14
+		$this->default_view 			= 'day'; // Default view for calendars = 'day', 'week', 'month', 'year'
15
+		$this->minical_view 			= 'current'; // Where do the mini-calendars go when clicked? = 'day', 'week', 'month', 'current'
16
+		$this->default_cal 				= $this->ALL_CALENDARS_COMBINED; // Exact filename of calendar without .ics. Or set to $this->ALL_CALENDARS_COMBINED to open all calenders combined into one.
17
+		$this->language = 'English'; // Language support - 'English', 'Polish', 'German', 'French', 'Dutch', 'Danish', 'Italian', 'Japanese', 'Norwegian', 'Spanish', 'Swedish', 'Portuguese', 'Catalan', 'Traditional_Chinese', 'Esperanto', 'Korean'
18
+		$this->week_start_day = 'Sunday'; // Day of the week your week starts on
19
+		$this->week_length				= '7'; // Number of days to display in the week view
20
+		$this->day_start 				= '0600'; // Start time for day grid
21
+		$this->day_end = '2000'; // End time for day grid
22
+		$this->gridLength 				= '15'; // Grid distance in minutes for day view, multiples of 15 preferred
23
+		$this->num_years 				= '1'; // Number of years (up and back) to display in 'Jump to'
24
+		$this->month_event_lines 		= '0'; // Number of lines to wrap each event title in month view, 0 means display all lines.
25
+		$this->tomorrows_events_lines = '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines.
26
+		$this->allday_week_lines 		= '1'; // Number of lines to wrap each event title in all-day events in week view, 0 means display all lines.
27
+		$this->week_events_lines 		= '1'; // Number of lines to wrap each event title in the 'Tommorrow's events' box, 0 means display all lines.
28
+		$this->timezone = ''; // Set timezone. Read TIMEZONES file for more information
29
+		$this->calendar_path = ''; // Leave this blank on most installs, place your full FILE SYSTEM PATH to calendars if they are outside the phpicalendar folder.
30
+		$this->second_offset			= ''; // The time in seconds between your time and your server's time.
31
+		$this->bleed_time				= '-1'; // This allows events past midnight to just be displayed on the starting date, only good up to 24 hours. Range from '0000' to '2359', or '-1' for no bleed time.
32
+		$this->cookie_uri				= ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar -- AUTO SETTING -- Only set if you are having cookie issues.
33
+		$this->download_uri				= ''; // The HTTP URL to your calendars directory, ie. http://www.example.com/phpicalendar/calendars -- AUTO SETTING -- Only set if you are having subscribe issues.
34
+		$this->default_path				= ''; // The HTTP URL to the PHP iCalendar directory, ie. http://www.example.com/phpicalendar
35
+		$this->cpath	     			= ''; // optional subdirectory
36
+		$this->charset = 'UTF-8'; // Character set your calendar is in, suggested UTF-8, or iso-8859-1 for most languages.
37 37
 
38 38
 		// Yes/No questions --- 'yes' means Yes, anything else means no. 'yes' must be lowercase.
39
-		$this->allow_webcals 			= 'no';				// Allow http:// and webcal:// prefixed URLs to be used as the $this->cal for remote viewing of "subscribe-able" calendars. This does not have to be enabled to allow specific ones below.
40
-		$this->month_locations  		= 'yes';			// Display location in the month view.
41
-		$this->this_months_events 		= 'yes';			// Display "This month's events" at the bottom off the month page.
42
-		$this->enable_rss				= 'yes';			// Enable RSS access to your calendars (good thing).
43
-		$this->rss_link_to_event		= '';				// Set to yes to have links in the feed popup an event window.  Default is to link to day.php
44
-		$this->show_search				= 'no';			// Show the search box in the sidebar.
45
-		$this->allow_preferences		= 'yes';			// Allow visitors to change various preferences via cookies.
46
-		$this->printview_default		= 'no';				// Set print view as the default view. day, week, and month only supported views for $this->default_view (listed well above).
47
-		$this->show_todos				= 'yes';			// Show your todo list on the side of day and week view.
48
-		$this->show_completed			= 'yes';				// Show completed todos on your todo list.
49
-		$this->event_download			= 'no';				// Show completed todos on your todo list.
50
-		$this->allow_login				= 'no';				// Set to yes to prompt for login to unlock calendars.
51
-		$this->login_cookies			= 'no';			// Set to yes to store authentication information via (unencrypted) cookies. Set to no to use sessions.
52
-		$this->support_ical				= 'no';			// Set to yes to support the Apple iCal calendar database structure.
53
-		$this->recursive_path			= 'no';			// Set to yes to recurse into subdirectories of the calendar path.
39
+		$this->allow_webcals = 'no'; // Allow http:// and webcal:// prefixed URLs to be used as the $this->cal for remote viewing of "subscribe-able" calendars. This does not have to be enabled to allow specific ones below.
40
+		$this->month_locations  		= 'yes'; // Display location in the month view.
41
+		$this->this_months_events = 'yes'; // Display "This month's events" at the bottom off the month page.
42
+		$this->enable_rss = 'yes'; // Enable RSS access to your calendars (good thing).
43
+		$this->rss_link_to_event		= ''; // Set to yes to have links in the feed popup an event window.  Default is to link to day.php
44
+		$this->show_search = 'no'; // Show the search box in the sidebar.
45
+		$this->allow_preferences		= 'yes'; // Allow visitors to change various preferences via cookies.
46
+		$this->printview_default		= 'no'; // Set print view as the default view. day, week, and month only supported views for $this->default_view (listed well above).
47
+		$this->show_todos = 'yes'; // Show your todo list on the side of day and week view.
48
+		$this->show_completed			= 'yes'; // Show completed todos on your todo list.
49
+		$this->event_download			= 'no'; // Show completed todos on your todo list.
50
+		$this->allow_login = 'no'; // Set to yes to prompt for login to unlock calendars.
51
+		$this->login_cookies			= 'no'; // Set to yes to store authentication information via (unencrypted) cookies. Set to no to use sessions.
52
+		$this->support_ical				= 'no'; // Set to yes to support the Apple iCal calendar database structure.
53
+		$this->recursive_path = 'no'; // Set to yes to recurse into subdirectories of the calendar path.
54 54
 
55 55
 		// Calendar Caching (decreases page load times)
56
-		$this->save_parsed_cals 		= 'no';				// Saves a copy of the cal in /tmp after it's been parsed. Improves performance.
57
-		$this->tmp_dir					= '/tmp';			// The temporary directory on your system (/tmp is fine for UNIXes including Mac OS X). Any php-writable folder works.
58
-		$this->webcal_hours				= '24';				// Number of hours to cache webcals. Setting to '0' will always re-parse webcals if they've been modified.
56
+		$this->save_parsed_cals = 'no'; // Saves a copy of the cal in /tmp after it's been parsed. Improves performance.
57
+		$this->tmp_dir = '/tmp'; // The temporary directory on your system (/tmp is fine for UNIXes including Mac OS X). Any php-writable folder works.
58
+		$this->webcal_hours = '24'; // Number of hours to cache webcals. Setting to '0' will always re-parse webcals if they've been modified.
59 59
 
60 60
 		// Webdav style publishing
61
-		$this->phpicalendar_publishing 	= '0';				// Set to '1' to enable remote webdav style publish. See 'calendars/publish.php' for complete information;
61
+		$this->phpicalendar_publishing = '0'; // Set to '1' to enable remote webdav style publish. See 'calendars/publish.php' for complete information;
62 62
 
63 63
 		// Administration settings (/admin/)
64
-		$this->allow_admin				= 'no';			// Set to yes to allow the admin page - remember to change the default password if using 'internal' as the $this->auth_method
65
-		$this->auth_method				= 'internal';			// Valid values are: 'ftp', 'internal', or 'none'. 'ftp' uses the ftp server's username and password as well as ftp commands to delete and copy files. 'internal' uses $this->auth_internal_username and $this->auth_internal_password defined below - CHANGE the password. 'none' uses NO authentication - meant to be used with another form of authentication such as http basic.
66
-		$this->auth_internal_username	= 'admin';			// Only used if $this->auth_method='internal'. The username for the administrator.
67
-		$this->auth_internal_password	= 'admin';			// Only used if $this->auth_method='internal'. The password for the administrator.
68
-		$this->ftp_server				= 'localhost';		// Only used if $this->auth_method='ftp'. The ftp server name. 'localhost' will work for most servers.
69
-		$this->ftp_port					= '21';				// Only used if $this->auth_method='ftp'. The ftp port. '21' is the default for ftp servers.
70
-		$this->ftp_calendar_path		= '';				// Only used if $this->auth_method='ftp'. The full path to the calendar directory on the ftp server. If = '', will attempt to deduce the path based on $this->calendar_path, but may not be accurate depending on ftp server config.
71
-		$this->salt                     = '';
64
+		$this->allow_admin				= 'no'; // Set to yes to allow the admin page - remember to change the default password if using 'internal' as the $this->auth_method
65
+		$this->auth_method				= 'internal'; // Valid values are: 'ftp', 'internal', or 'none'. 'ftp' uses the ftp server's username and password as well as ftp commands to delete and copy files. 'internal' uses $this->auth_internal_username and $this->auth_internal_password defined below - CHANGE the password. 'none' uses NO authentication - meant to be used with another form of authentication such as http basic.
66
+		$this->auth_internal_username	= 'admin'; // Only used if $this->auth_method='internal'. The username for the administrator.
67
+		$this->auth_internal_password	= 'admin'; // Only used if $this->auth_method='internal'. The password for the administrator.
68
+		$this->ftp_server = 'localhost'; // Only used if $this->auth_method='ftp'. The ftp server name. 'localhost' will work for most servers.
69
+		$this->ftp_port = '21'; // Only used if $this->auth_method='ftp'. The ftp port. '21' is the default for ftp servers.
70
+		$this->ftp_calendar_path = ''; // Only used if $this->auth_method='ftp'. The full path to the calendar directory on the ftp server. If = '', will attempt to deduce the path based on $this->calendar_path, but may not be accurate depending on ftp server config.
71
+		$this->salt = '';
72 72
 		// Calendar colors
73 73
 		//
74 74
 		// You can increase the number of unique colors by adding additional images (monthdot_n.gif)
75 75
 		// and in the css file (default.css) classes .alldaybg_n, .eventbg_n and .eventbg2_n
76 76
 		// Colors will repeat from the beginning for calendars past $this->unique_colors (7 by default), with no limit.
77
-		$this->unique_colors			= '7';
77
+		$this->unique_colors = '7';
78 78
 
79 79
 		return true;
80 80
 	}
81 81
 
82
-	public static function getInstance(){
83
-		if (empty(self::$instance)){
82
+	public static function getInstance() {
83
+		if (empty(self::$instance)) {
84 84
 			self::$instance = new Configs;
85 85
 		}
86 86
 		return self::$instance;
87 87
 	}
88 88
 
89 89
 	# val can be an array
90
-	public function setProperty($key,$val){
90
+	public function setProperty($key, $val) {
91 91
 		$this->$key = $val;
92 92
 		return;
93 93
 	}
94
-	public function getProperty($key){
94
+	public function getProperty($key) {
95 95
 		return $this->$key;
96 96
 	}
97 97
 }
Please login to merge, or discard this patch.
phpicalendar/includes/event.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,10 +8,10 @@  discard block
 block discarded – undo
8 8
 # information for the popup is sent via $_POST by a javascript snippet in 
9 9
 # in function openevent() from functions/date_functions.php
10 10
 # character encoding has been problematic with popups.
11
-$event			= unserialize(stripslashes($_POST['event_data']));
12
-$organizer 		= unserialize($event['organizer']);
13
-$attendee 		= unserialize($event['attendee']);
14
-$uid    		= stripslashes($_POST['uid']);
11
+$event = unserialize(stripslashes($_POST['event_data']));
12
+$organizer = unserialize($event['organizer']);
13
+$attendee = unserialize($event['attendee']);
14
+$uid = stripslashes($_POST['uid']);
15 15
 
16 16
 // Format event time
17 17
 // All day
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 }
37 37
 
38 38
 if (isset($organizer) && is_array($organizer)) {
39
-	$i=0;
39
+	$i = 0;
40 40
 	$organizers = array();
41 41
 	foreach ($organizer as $val) {
42 42
 		if (!empty($organizer[$i]["email"])) {
@@ -46,10 +46,10 @@  discard block
 block discarded – undo
46 46
 		}
47 47
 		$i++;
48 48
 	}
49
-	$organizer = implode(', ',$organizers);
49
+	$organizer = implode(', ', $organizers);
50 50
 }
51 51
 if (isset($attendee) && is_array($attendee)) {
52
-	$i=0;
52
+	$i = 0;
53 53
 	$attendees = array();
54 54
 	foreach ($attendee as $val) {
55 55
 		if (!empty($attendee[$i]["email"])) {
@@ -59,36 +59,36 @@  discard block
 block discarded – undo
59 59
 		}
60 60
 		$i++;
61 61
 	}
62
-	$attendee = implode(', ',$attendees);
62
+	$attendee = implode(', ', $attendees);
63 63
 }
64 64
 if (isset($event['location'])) $event['location'] = stripslashes($event['location']);
65 65
 if (sizeof($attendee) == 0) $attendee = '';
66 66
 if (sizeof($organizer) == 0) $organizer = '';
67 67
 if ($event['url'] != '') $event['url'] = '<a href="'.$event['url'].'" target="_blank">'.$event['url'].'</a>';
68 68
 
69
-switch ($event['status']){
69
+switch ($event['status']) {
70 70
 	case 'CONFIRMED':
71
-		$event['status'] =	$lang['l_status_confirmed'] ; 
71
+		$event['status'] = $lang['l_status_confirmed']; 
72 72
 		break;
73 73
 	case 'CANCELLED':
74
-		$event['status'] =	$lang['l_status_cancelled'] ; 
74
+		$event['status'] = $lang['l_status_cancelled']; 
75 75
 		break;
76 76
 	case 'TENTATIVE':
77
-		$event['status'] =	$lang['l_status_tentative'] ; 
77
+		$event['status'] = $lang['l_status_tentative']; 
78 78
 		break;
79 79
 	default:	
80
-		$event['status'] =	'' ; 
80
+		$event['status'] = ''; 
81 81
 }
82 82
 
83 83
 $event_download = '';
84
-if($phpiCal_config->event_download == 'yes') $event_download = "
84
+if ($phpiCal_config->event_download == 'yes') $event_download = "
85 85
 <form action='' method='post'>
86 86
 <input type=hidden name='event_data' value = '".$_POST['event_data']."' />
87 87
 <input type=hidden name='uid' value = '".$_POST['uid']."' />
88 88
 <input type='submit' name='submit' value='".$lang['l_download_event']."' />
89 89
 <form>";
90 90
 
91
-if (isset($_POST['submit'])){
91
+if (isset($_POST['submit'])) {
92 92
 header("Content-Type: text/calendar; charset=utf-8; name=$uid");
93 93
 header("Content-Disposition: attachment; filename=$uid");
94 94
 echo 
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
 UID:$uid
100 100
 SUMMARY:".$event['event_text']."
101 101
 CATEGORIES:".$event['calname']."
102
-DTSTART;TZID=".$event['timezone'].":".date("Ymd\THis",$event['start_unixtime'])."
103
-DTEND;TZID=".$event['timezone'].":".date("Ymd\THis",$event['start_unixtime'])."
102
+DTSTART;TZID=".$event['timezone'].":".date("Ymd\THis", $event['start_unixtime'])."
103
+DTEND;TZID=".$event['timezone'].":".date("Ymd\THis", $event['start_unixtime'])."
104 104
 CLASS:".$event['class']."
105 105
 ".$event['other']."
106 106
 SEQUENCE:1
Please login to merge, or discard this patch.
Braces   +23 added lines, -9 removed lines patch added patch discarded remove patch
@@ -19,13 +19,17 @@  discard block
 block discarded – undo
19 19
 	$start = localizeDate($dateFormat_week, $event['start_unixtime']);
20 20
 	$end   = localizeDate($dateFormat_week, ($event['end_unixtime'] - 60));
21 21
 	$event_times = $lang['l_all_day']." $start";
22
-	if ($start != $end) $event_times = "$start - $end";
23
-} else {
22
+	if ($start != $end) {
23
+		$event_times = "$start - $end";
24
+	}
25
+	} else {
24 26
 	$start = date($timeFormat, $event['start_unixtime']);
25 27
 	$end   = date($timeFormat, $event['end_unixtime']);
26 28
 	$event_times = "$start";
27
-	if ($start != $end) $event_times = "$start - $end";
28
-}
29
+	if ($start != $end) {
30
+		$event_times = "$start - $end";
31
+	}
32
+	}
29 33
 
30 34
 $event['event_text']  = sanitizeForWeb(urldecode($event['event_text']));
31 35
 $event['description'] = sanitizeForWeb(urldecode($event['description']));
@@ -61,10 +65,18 @@  discard block
 block discarded – undo
61 65
 	}
62 66
 	$attendee = implode(', ',$attendees);
63 67
 }
64
-if (isset($event['location'])) $event['location'] = stripslashes($event['location']);
65
-if (sizeof($attendee) == 0) $attendee = '';
66
-if (sizeof($organizer) == 0) $organizer = '';
67
-if ($event['url'] != '') $event['url'] = '<a href="'.$event['url'].'" target="_blank">'.$event['url'].'</a>';
68
+if (isset($event['location'])) {
69
+	$event['location'] = stripslashes($event['location']);
70
+}
71
+if (sizeof($attendee) == 0) {
72
+	$attendee = '';
73
+}
74
+if (sizeof($organizer) == 0) {
75
+	$organizer = '';
76
+}
77
+if ($event['url'] != '') {
78
+	$event['url'] = '<a href="'.$event['url'].'" target="_blank">'.$event['url'].'</a>';
79
+}
68 80
 
69 81
 switch ($event['status']){
70 82
 	case 'CONFIRMED':
@@ -81,12 +93,14 @@  discard block
 block discarded – undo
81 93
 }
82 94
 
83 95
 $event_download = '';
84
-if($phpiCal_config->event_download == 'yes') $event_download = "
96
+if($phpiCal_config->event_download == 'yes') {
97
+	$event_download = "
85 98
 <form action='' method='post'>
86 99
 <input type=hidden name='event_data' value = '".$_POST['event_data']."' />
87 100
 <input type=hidden name='uid' value = '".$_POST['uid']."' />
88 101
 <input type='submit' name='submit' value='".$lang['l_download_event']."' />
89 102
 <form>";
103
+}
90 104
 
91 105
 if (isset($_POST['submit'])){
92 106
 header("Content-Type: text/calendar; charset=utf-8; name=$uid");
Please login to merge, or discard this patch.