Better support for TEXT types, and a few more tags, parameters, and values.

This commit is contained in:
skeeter 2001-07-03 03:32:09 +00:00
parent a192c68f3a
commit 4f833d20d2
2 changed files with 52 additions and 18 deletions

View File

@ -246,12 +246,12 @@ class vCalendar
if(ereg("^[\=\:]",$char)) if(ereg("^[\=\:]",$char))
{ {
$found = True; $found = True;
$ret_str = rawurldecode(substr($str,0,$i)); $ret_str = str_replace('=3D','=',str_replace('%20',' ',substr($str,0,$i)));
$return_value[] = $ret_str; $return_value[] = $ret_str;
$ret_array = $this->explode_param(substr($str,$i + 1),'"',False); $ret_array = $this->explode_param(substr($str,$i + 1),'"',False);
while(list($key,$value) = each($ret_array)) while(list($key,$value) = each($ret_array))
{ {
$return_value[] = rawurldecode($value); $return_value[] = str_replace('=3D','=',str_replace('%20',' ',$value));
} }
$i = $str_len; $i = $str_len;
} }
@ -259,7 +259,7 @@ class vCalendar
} }
if(!$found) if(!$found)
{ {
$return_value[] = rawurldecode($str); $return_value[] = str_replace('=3D','=',str_replace('%20',' ',$str));
} }
} }
else else
@ -299,7 +299,6 @@ class vCalendar
function parse_text(&$event,$value) function parse_text(&$event,$value)
{ {
echo "VALUE = ".$value."<br>\n";
$return_value = $this->explode_param($value,'"',True); $return_value = $this->explode_param($value,'"',True);
if(count($return_value) > 0) if(count($return_value) > 0)
{ {
@ -312,17 +311,14 @@ class vCalendar
case 'altrep': case 'altrep':
case 'fmttype': case 'fmttype':
case 'cid': case 'cid':
echo "Setting ".$type[0]." = ".$type[1]."<br>\n";
$this->set_var($event,strtolower($type[0]),$type[1]); $this->set_var($event,strtolower($type[0]),$type[1]);
break; break;
case 'encoding': case 'encoding':
echo "Setting ".$type[0]." = ".$type[1]."<br>\n";
$this->set_var($event,strtolower($type[0]),$this->switch_encoding($type[1])); $this->set_var($event,strtolower($type[0]),$this->switch_encoding($type[1]));
break; break;
case 'value': case 'value':
break; break;
default: default:
echo "Setting value(0) = ".$type[0]."<br>\n";
$this->set_var($event,'value',$type[0]); $this->set_var($event,'value',$type[0]);
break; break;
} }
@ -330,7 +326,6 @@ class vCalendar
} }
elseif($value <> '\n') elseif($value <> '\n')
{ {
echo "Setting value(text) = ".$value."<br>\n";
$this->set_var($event,'value',$value); $this->set_var($event,'value',$value);
} }
} }
@ -616,6 +611,9 @@ class vCalendar
$type[0] = str_replace('-','_',$type[0]); $type[0] = str_replace('-','_',$type[0]);
$val = $this->split_address($type[1]); $val = $this->split_address($type[1]);
break; break;
case 'dir':
$val = $type[1];
break;
default: default:
$val = $type[1]; $val = $type[1];
break; break;
@ -639,6 +637,25 @@ class vCalendar
} }
} }
function from_text($str)
{
$str = str_replace("\\,",",",$str);
$str = str_replace("\\;",";",$str);
$str = str_replace("\\N","\n",$str);
$str = str_replace("\\n","\n",$str);
$str = str_replace("\\\\","\\",$str);
return $str;
}
function to_text($str)
{
$str = str_replace("\\","\\\\",$str);
$str = str_replace(",","\\,",$str);
$str = str_replace(";","\\;",$str);
$str = str_replace("\n","\\n",$str);
return $str;
}
function new_vcal() function new_vcal()
{ {
return new vCal; return new vCal;
@ -680,7 +697,6 @@ class vCalendar
// When unfolded becomes, // When unfolded becomes,
//vcal_text[$i] = 'UID:040000008200E00074C5B7101A82E0080000000040A12C0042A2C0010000000000000000100000009BDFF7C7650ED5118DD700805FA71291' //vcal_text[$i] = 'UID:040000008200E00074C5B7101A82E0080000000040A12C0042A2C0010000000000000000100000009BDFF7C7650ED5118DD700805FA71291'
echo "LINE : ".$vcal_text[$i]."<br>\n";
$colon = strpos($vcal_text[$i],':'); $colon = strpos($vcal_text[$i],':');
if($colon == 0) if($colon == 0)
{ {
@ -726,12 +742,13 @@ class vCalendar
$this->set_var($vcal,$majortype,$value); $this->set_var($vcal,$majortype,$value);
break; break;
case 'description': case 'description':
echo "Setting Description!<br>\n";
$event->$majortype = new class_text; $event->$majortype = new class_text;
$this->parse_text($event->$majortype,$value); $this->parse_text($event->$majortype,$this->from_text($value));
break;
case 'location':
$this->set_var($event,$majortype,$this->from_text($value));
break; break;
case 'attach': case 'attach':
echo "Setting Attachment!<br>\n";
$attach = new class_text; $attach = new class_text;
$this->parse_text($attach,$value); $this->parse_text($attach,$value);
$event->attach[] = $attach; $event->attach[] = $attach;
@ -798,7 +815,7 @@ echo "Setting Attachment!<br>\n";
} }
if(!empty($event->dir)) if(!empty($event->dir))
{ {
$str .= ';DIR="'.str_replace(' ','%20',$event->dir).'"'; $str .= ';DIR="'.str_replace('=','=3D',str_replace(' ','%20',$event->dir)).'"';
} }
if(!empty($event->role)) if(!empty($event->role))
{ {
@ -844,14 +861,13 @@ echo "Setting Attachment!<br>\n";
} }
if(!empty($event->value)) if(!empty($event->value))
{ {
$str .= ':'.$event->value; $str .= ':'.$this->to_text($event->value);
} }
else else
{ {
$str .= ':\n'; $str .= ':\n';
} }
echo "TEXT = ".$str."<br>\n";
return $str; return $str;
} }
@ -862,7 +878,7 @@ echo "Setting Attachment!<br>\n";
// Still need to build recurrence portion...... // Still need to build recurrence portion......
iF(!empty($event->location)) iF(!empty($event->location))
{ {
$str .= $this->fold('LOCATION:'.$event->location); $str .= $this->fold('LOCATION:'.$this->to_text($event->location));
} }
else else
{ {

View File

@ -6,7 +6,7 @@ BEGIN:VEVENT
ATTENDEE;CN="Doe John (Marketing)";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:John.Doe@somewhere.com ATTENDEE;CN="Doe John (Marketing)";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:John.Doe@somewhere.com
ATTENDEE;CN="Jones Bill (IT)";ROLE=REQ-PARTICIPANT;RSVP=TRUE;DELEGATED-FROM="MAILTO:immud@host3.com":MAILTO:Bill.Jones@somewhere.com ATTENDEE;CN="Jones Bill (IT)";ROLE=REQ-PARTICIPANT;RSVP=TRUE;DELEGATED-FROM="MAILTO:immud@host3.com":MAILTO:Bill.Jones@somewhere.com
ATTENDEE;CN="Smith Mary (PR)";ROLE=NON-PARTICIPANT;RSVP=FALSE:MAILTO:Mary.Smith@elsewhere.com ATTENDEE;CN="Smith Mary (PR)";ROLE=NON-PARTICIPANT;RSVP=FALSE:MAILTO:Mary.Smith@elsewhere.com
ORGANIZER;DIR="ldap://host.com:6666/o=eDABC%20Industries,c=3DUS??(cn=3DBJim%20Dolittle)":MAILTO:John.Doe@somewhere.com ORGANIZER;DIR="ldap://host.com:6666/o=3DABC%20Industries,c=3DUS??(cn=3DJim%20Dolittle)":MAILTO:John.Doe@somewhere.com
DTSTART:20010302T150000Z DTSTART:20010302T150000Z
DTEND:20010302T153000Z DTEND:20010302T153000Z
LOCATION:Conference Room #2 LOCATION:Conference Room #2
@ -39,10 +39,28 @@ SUMMARY:Web Site Redesign (2)
PRIORITY:2 PRIORITY:2
CLASS:PRIVATE CLASS:PRIVATE
END:VEVENT END:VEVENT
BEGIN:VEVENT
ATTENDEE;CN="Peters Mark A SSgt AFPC/DPDMR";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:Mark.Peters@afpc.randolph.af.mil
ATTENDEE;CN=bright;ROLE=OPT-PARTICIPANT;RSVP=TRUE:MAILTO:Brent.Bright@afpc.randolph.af.mil
ORGANIZER:MAILTO:Mark.Peters@afpc.randolph.af.mil
DTSTART;VALUE=DATE:20010319
DTEND;VALUE=DATE:20010324
LOCATION:AFPC\, Randolph AFB\, TX
TRANSP:OPAQUE
SEQUENCE:0
UID:040000008200E00074C5B7101A82E00800000000804A2FBBA470C0010000000000000000100
00000D8ACD927C6DCD411804200C04F757A66
DTSTAMP:20001228T140358Z
DESCRIPTION:P DPD OLSEN\, JOHN SSGT 19 - 23 Mar 01 2476 Mr Marr (GS-11) \nA
DPD PETERS\, MARK SSGT 19 - 23 Mar 01 2314 TSgt Bright \n \n
SUMMARY:Alternate - Front Desk Duty
PRIORITY:5
CLASS:PUBLIC
END:VEVENT
BEGIN:VTODO BEGIN:VTODO
DTSTART:20010301T160000Z DTSTART:20010301T160000Z
DTEND:20010301T163000Z DTEND:20010301T163000Z
LOCATION:My Desk LOCATION:My Desk\, or the conference room
DTSTAMP:20010301T172312Z DTSTAMP:20010301T172312Z
DESCRIPTION:\n DESCRIPTION:\n
SUMMARY:Prepare for tomrrow's meeting SUMMARY:Prepare for tomrrow's meeting