sif2array() public method

Quick hack to convert from text/vcard and text/vcalendar to Sync4J's proprietery sif datatypes and vice versa. For details about the sif format see the appendix of the developer guide on www.sync4j.org.
public sif2array ( string $sif ) : array
$sif string A sif string like v1>v2
return array Assoc array in utf8 like array ('k1' => 'v1>', 'k2' => 'v2');
Example #1
0
 public function sif2vtodo($sif)
 {
     $a = Horde_SyncMl_Device_sync4j::sif2array($sif);
     $iCal = new Horde_Icalendar();
     $iCal->setAttribute('PRODID', '-//The Horde Project//SyncML//EN');
     $iCal->setAttribute('METHOD', 'PUBLISH');
     $vtodo = Horde_Icalendar::newComponent('vtodo', $iCal);
     $vtodo->setAttribute('SUMMARY', $a['Subject']);
     $vtodo->setAttribute('DESCRIPTION', $a['Body']);
     if ($a['Importance'] == 0) {
         $vtodo->setAttribute('PRIORITY', 5);
     } elseif ($a['Importance'] == 2) {
         $vtodo->setAttribute('PRIORITY', 1);
     } else {
         $vtodo->setAttribute('PRIORITY', 3);
     }
     if (!empty($a['StartDate']) && $a['StartDate'] != '45001231T230000Z') {
         $vtodo->setAttribute('DTSTART', $iCal->_parseDateTime($a['StartDate']));
     }
     $dueSet = false;
     if (!empty($a['DueDate']) && $a['DueDate'] != '45001231T230000Z') {
         $vtodo->setAttribute('DUE', $iCal->_parseDateTime($a['DueDate']));
         $dueSet = true;
     }
     if (!empty($a['ReminderSet'])) {
         if (!$dueSet) {
             $vtodo->setAttribute('DUE', $iCal->_parseDateTime($a['ReminderTime']));
         }
         $vtodo->setAttribute('AALARM', $iCal->_parseDateTime($a['ReminderTime']));
     }
     if (!empty($a['Complete'])) {
         $vtodo->setAttribute('STATUS', 'COMPLETED');
     }
     $vtodo->setAttribute('CATEGORIES', isset($a['Categories']) ? $a['Categories'] : '');
     if (isset($a['Sensitivity'])) {
         switch ($a['Sensitivity']) {
             case 0:
                 /* olNormal */
                 $vtodo->setAttribute('CLASS', 'PUBLIC');
                 break;
             case 1:
                 /* olPersonal */
             /* olPersonal */
             case 2:
                 /* olPrivate */
                 $vtodo->setAttribute('CLASS', 'PRIVATE');
                 break;
             case 3:
                 /* olConfidential */
                 $vtodo->setAttribute('CLASS', 'CONFIDENTIAL');
                 break;
         }
     }
     return $vtodo->exportvCalendar();
 }