Changeset 7740
- Timestamp:
- 01/14/13 10:29:47 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/webservice/api/rest/calendar/EventsResource.php
r7489 r7740 29 29 30 30 $return = array(); 31 32 for( $j = (int)$start_date_arr[2]; $j <= (int)$end_date_arr[2]; $j++ ) 31 32 33 $start_year = (int)$start_date_arr[2]; 34 $end_year = (int)$end_date_arr[2]; 35 36 for( $j = $start_year; $j <= $end_year; $j++ ) 33 37 { 34 for( $i = (int)$start_date_arr[1]; $i <= (int)$end_date_arr[1]; $i++ ) 38 $start_month = (int)$start_date_arr[1]; 39 $end_month = (int)$end_date_arr[1]; 40 41 if ($start_year != $end_year) { 42 if ($j == $start_year) { 43 $end_month = 12; 44 } else { 45 $start_month = 1; 46 } 47 } 48 49 for( $i = $start_month; $i <= $end_month; $i++ ) 35 50 { 36 51 if( (int)$i < 10 ) … … 38 53 else 39 54 $result = $this->getEvents($i,$j); 40 55 56 41 57 if( count($result) > 0 ) 42 58 { … … 46 62 } 47 63 64 65 48 66 if( count($return) > 0 ) 49 67 { … … 52 70 for( $j = 0 ; $j < count( $return); $j++) 53 71 { 54 foreach( $return[$j] as $key => $ value)72 foreach( $return[$j] as $key => $event ) 55 73 { 56 $events[$i]['eventID'] = "".$value[0]['id']; 57 $events[$i]['eventDate'] = "".$key; 58 $events[$i]['eventName'] = mb_convert_encoding("".$value[0]['title'],"UTF8","ISO_8859-1"); 59 $events[$i]['eventDescription'] = mb_convert_encoding("".$value[0]['description'], "UTF8","ISO_8859-1"); 60 $events[$i]['eventLocation'] = mb_convert_encoding("".$value[0]['location'], "UTF8","ISO_8859-1"); 61 $events[$i]['eventParticipants']= $value[0]['participants']; 62 63 $starttime = $this->makeTime($value[0]['start']); 64 $endtime = $this->makeTime($value[0]['end']); 65 $actualdate = mktime(0,0,0,substr($key,4,2),substr($key, 6 ),substr($key,0,4)); 66 $rawdate_offset = $actualdate - $this->getTimezoneOffset(); 67 $nextday = mktime(0,0,0,substr($key,4,2),substr($key, 6 )+1,substr($key,0,4)) - $this->getTimezoneOffset(); 68 69 if( $starttime <= $rawdate_offset && $endtime >= $nextday - 60 ) 70 { 71 $events[$i]['eventStartDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 00:00"; 72 $events[$i]['eventEndDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 23:59"; 73 $events[$i]['eventAllDay'] = "1"; 74 } 75 else 76 { 77 if( $value[0]['start']['mday'] === $value[0]['end']['mday'] ) 74 75 foreach ($event as $value) { 76 77 78 $events[$i]['eventID'] = "".$value['id']; 79 $events[$i]['eventDate'] = "".$key; 80 $events[$i]['eventName'] = mb_convert_encoding("".$value['title'],"UTF8","ISO_8859-1"); 81 $events[$i]['eventDescription'] = mb_convert_encoding("".$value['description'], "UTF8","ISO_8859-1"); 82 $events[$i]['eventLocation'] = mb_convert_encoding("".$value['location'], "UTF8","ISO_8859-1"); 83 $events[$i]['eventParticipants']= $value['participants']; 84 85 $starttime = $this->makeTime($value['start']); 86 $endtime = $this->makeTime($value['end']); 87 $actualdate = mktime(0,0,0,substr($key,4,2),substr($key, 6 ),substr($key,0,4)); 88 $rawdate_offset = $actualdate - $this->getTimezoneOffset(); 89 $nextday = mktime(0,0,0,substr($key,4,2),substr($key, 6 )+1,substr($key,0,4)) - $this->getTimezoneOffset(); 90 91 if( $starttime <= $rawdate_offset && $endtime >= $nextday - 60 ) 78 92 { 79 $hour_start = (((int)$value[0]['start']['hour'] < 10 ) ? "0".$value[0]['start']['hour'] : $value[0]['start']['hour']).":".(((int)$value[0]['start']['min'] < 10 ) ? "0".$value[0]['start']['min'] : $value[0]['start']['min'] ); 80 $hour_end = (((int)$value[0]['end']['hour'] < 10 ) ? "0".$value[0]['end']['hour'] : $value[0]['end']['hour']).":".(((int)$value[0]['end']['min'] < 10 ) ? "0".$value[0]['end']['min'] : $value[0]['end']['min'] ); 93 $events[$i]['eventStartDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 00:00"; 94 $events[$i]['eventEndDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." 23:59"; 95 $events[$i]['eventAllDay'] = "1"; 81 96 } 82 97 else 83 98 { 84 if( $ events[$i-1] && $events[$i-1]['eventAllDay'] == "1")99 if( $value['start']['mday'] === $value['end']['mday'] ) 85 100 { 86 $hour_start = "00:00";87 $hour_end = (((int)$value[ 0]['end']['hour'] < 10 ) ? "0".$value[0]['end']['hour'] : $value[0]['end']['hour']).":".(((int)$value[0]['end']['min'] < 10 ) ? "0".$value[0]['end']['min'] : $value[0]['end']['min'] );101 $hour_start = (((int)$value['start']['hour'] < 10 ) ? "0".$value['start']['hour'] : $value['start']['hour']).":".(((int)$value['start']['min'] < 10 ) ? "0".$value['start']['min'] : $value['start']['min'] ); 102 $hour_end = (((int)$value['end']['hour'] < 10 ) ? "0".$value['end']['hour'] : $value['end']['hour']).":".(((int)$value['end']['min'] < 10 ) ? "0".$value['end']['min'] : $value['end']['min'] ); 88 103 } 89 104 else 90 105 { 91 $hour_start = (((int)$value[0]['start']['hour'] < 10 ) ? "0".$value[0]['start']['hour'] : $value[0]['start']['hour']).":".(((int)$value[0]['start']['min'] < 10 ) ? "0".$value[0]['start']['min'] : $value[0]['start']['min'] ); 92 $hour_end = "23:59"; 106 if( $events[$i-1] && $events[$i-1]['eventAllDay'] == "1" ) 107 { 108 $hour_start = "00:00"; 109 $hour_end = (((int)$value['end']['hour'] < 10 ) ? "0".$value['end']['hour'] : $value['end']['hour']).":".(((int)$value['end']['min'] < 10 ) ? "0".$value['end']['min'] : $value['end']['min'] ); 110 } 111 else 112 { 113 $hour_start = (((int)$value['start']['hour'] < 10 ) ? "0".$value['start']['hour'] : $value['start']['hour']).":".(((int)$value['start']['min'] < 10 ) ? "0".$value['start']['min'] : $value['start']['min'] ); 114 $hour_end = "23:59"; 115 } 93 116 } 117 118 $events[$i]['eventStartDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_start; 119 $events[$i]['eventEndDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_end; 120 $events[$i]['eventAllDay'] = "0"; 94 121 } 95 96 $events[$i]['eventStartDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_start; 97 $events[$i]['eventEndDate'] = substr($key, 6 )."/".substr($key,4,2)."/".substr($key,0,4)." ".$hour_end; 98 $events[$i]['eventAllDay'] = "0"; 122 123 $events[$i++]['eventExParticipants'] = $value['ex_participants']; 99 124 } 100 101 $events[$i++]['eventExParticipants'] = $value[0]['ex_participants']; 125 102 126 } 127 103 128 } 104 129
Note: See TracChangeset
for help on using the changeset viewer.