[ Index ] |
PHP Cross Reference of vtigercrm-6.1.0 |
[Summary view] [Print] [Text view]
1 <?php 2 3 class iCal { 4 5 var $folders; 6 7 function iCal() { 8 $this->folders = 'cache/import/'; 9 } 10 11 function iCalReader($filename,$root_directory='') { 12 $iCaltoArray = $this->iCalDecoder($filename,$root_directory); 13 return $iCaltoArray; 14 } 15 16 function iCalDecoder($file,$root_directory) { 17 $ical = file_get_contents($root_directory.$this->folders.$file); 18 preg_match_all('/BEGIN:VEVENT.*?END:VEVENT/si', $ical, $eventresult, PREG_PATTERN_ORDER); 19 preg_match_all('/BEGIN:VTODO.*?END:VTODO/si', $ical, $todoresult, PREG_PATTERN_ORDER); 20 for ($i = 0; $i < count($eventresult[0]); $i++) { 21 $tmpbyline = explode("\r\n", $eventresult[0][$i]); 22 $begin = false; 23 $key=NULL; 24 foreach ($tmpbyline as $item) { 25 $tmpholderarray = explode(":",$item,2); 26 27 if (count($tmpholderarray) >1) { 28 if($tmpholderarray[0]=='BEGIN'){ 29 if($begin==false){ 30 $begin = true; 31 $majorarray['TYPE']=$tmpholderarray[1]; 32 } else { 33 $majorarray[$tmpholderarray[1]]=array(); 34 $key = $tmpholderarray[1]; 35 } 36 } else if($tmpholderarray[0]=='END'){ 37 if(!empty($key)){ 38 $key = NULL; 39 } 40 } else { 41 if(!empty($key)){ 42 $majorarray[$key][$tmpholderarray[0]] = $tmpholderarray[1]; 43 } else { 44 $majorarray[$tmpholderarray[0]] = $tmpholderarray[1]; 45 } 46 } 47 } 48 49 } 50 $icalarray[] = $majorarray; 51 unset($majorarray); 52 } 53 54 for ($i = 0; $i < count($todoresult[0]); $i++) { 55 $tmpbyline = explode("\r\n", $todoresult[0][$i]); 56 $begin = false; 57 $key=NULL; 58 foreach ($tmpbyline as $item) { 59 $tmpholderarray = explode(":",$item); 60 61 if (count($tmpholderarray) >1) { 62 if($tmpholderarray[0]=='BEGIN'){ 63 if($begin==false){ 64 $begin = true; 65 $majorarray['TYPE']=$tmpholderarray[1]; 66 } else { 67 $majorarray[$tmpholderarray[1]]=array(); 68 $key = $tmpholderarray[1]; 69 } 70 } else if($tmpholderarray[0]=='END'){ 71 if(!empty($key)){ 72 $key = NULL; 73 } 74 } else { 75 if(!empty($key)){ 76 $majorarray[$key][$tmpholderarray[0]] = $tmpholderarray[1]; 77 } else { 78 $majorarray[$tmpholderarray[0]] = $tmpholderarray[1]; 79 } 80 } 81 } 82 83 } 84 $icalarray[] = $majorarray; 85 unset($majorarray); 86 } 87 return $icalarray; 88 } 89 } 90 91 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:08:37 2014 | Cross-referenced by PHPXref 0.7.1 |