Back to index

awl  0.53
Public Member Functions | Static Public Member Functions | Public Attributes
iCalendar Class Reference

List of all members.

Public Member Functions

 iCalendar ($args)
 

@-


 SaveTimeZones ()
 : This class will be removed soon.
 DefaultPropertyList ()
 An array of property names that we should always want when rendering an iCalendar.
 JustThisBitPlease ($type, $count=1)
ParseSomeLines ($type)
 BuildFromText ($icalendar)
 RFC2445ContentUnescape ($escaped)
 Returns a content string with the RFC2445 escaping removed.
 DealWithTimeZones ()
 Do what must be done with time zones from on file.
 Get ($key)
 Get the value of a property in the first non-VTIMEZONE : This class will be removed soon.
 Set ($key, $value)
 Set the value of a property : This class will be removed soon.
 Add ($key, $value, $parameters=null)
 : This class will be removed soon.
 GetComponents ($type=null, $normal_match=true)
 : This class will be removed soon.
 ClearComponents ($type=null)
 : This class will be removed soon.
 SetComponents ($new_component, $type=null)
 : This class will be removed soon.
 AddComponent ($new_component)
 : This class will be removed soon.
 MaskComponents ($keep)
 : This class will be removed soon.
 RFC2445ContentEscape ($name, $value)
 : This class will be removed soon.
 ExtractSubComponent ($component, $type, $count=9999)
 : This class will be removed soon.
 ExtractProperty ($component, $type, $count=9999)
 : This class will be removed soon.
 ApplyFilter ($filter, $value)
 : This class will be removed soon.
 TestFilter ($filters)
 : This class will be removed soon.
 Render ($as_calendar=true, $type=null, $restrict_properties=null)
 : This class will be removed soon.

Static Public Member Functions

static HttpDateFormat ()
 : This class will be removed soon.
static SqlDateFormat ()
 : This class will be removed soon.
static SqlUTCFormat ()
 : This class will be removed soon.
static SqlDurationFormat ()
 : This class will be removed soon.
static iCalHeader ()
 : This class will be removed soon.
static iCalFooter ()
 : This class will be removed soon.

Public Attributes

 $component
 $properties
 $lines
 $tz_locn
 $type

Detailed Description

Definition at line 899 of file iCalendar.php.


Member Function Documentation

iCalendar::Add ( key,
value,
parameters = null 
)

: This class will be removed soon.

Add a new property/value, regardless of whether it exists already

Parameters:
string$keyThe property key
string$valueThe property value
string$parametersAny parameters to set for the property, as an array of key/value pairs

Definition at line 1351 of file iCalendar.php.

                                                   {
    deprecated('iCalendar::Add' );
    if ( $value == "" ) return;
    $key = strtoupper($key);
    $property = new iCalProp();
    $property->Name($key);
    $property->Value($value);
    if ( isset($parameters) && is_array($parameters) ) {
      $property->parameters = $parameters;
    }
    $component =& $this->component->FirstNonTimezone();
    $component->AddProperty($property);
    if (isset($this->component->rendered) ) unset( $this->component->rendered );
  }
iCalendar::AddComponent ( new_component)

: This class will be removed soon.

Adds a new subcomponent

Parameters:
iCalComponent$new_componentThe new component to append to the set

Definition at line 1412 of file iCalendar.php.

                                          {
    deprecated('iCalendar::AddComponent' );
    $this->component->AddComponent($new_component);
  }
iCalendar::ApplyFilter ( filter,
value 
)

: This class will be removed soon.

Applies the filter conditions, possibly recursively, to the value which will be either a single property, or an array of lines of the component under test.

Todo:
Eventually we need to handle all of these possibilities, which will mean writing several routines:
  • Get Property from Component
  • Get Parameter from Property
  • Test TimeRange For the moment we will leave these, until there is a perceived need.
Parameters:
array$filterAn array of XMLElement defining the filter(s)
mixed$valueEither a string which is the single property, or an array of lines, for the component.
Returns:
boolean Whether the filter passed / failed.

todo:: While this is unimplemented here at present, most time-range tests should occur at the SQL level.

Definition at line 1580 of file iCalendar.php.

                                          {
    deprecated('iCalendar::ApplyFilter' );
    foreach( $filter AS $k => $v ) {
      $tag = $v->GetNSTag();
      $value_type = gettype($value);
      $value_defined = (isset($value) && $value_type == 'string') || ($value_type == 'array' && count($value) > 0 );
      if ( $tag == 'urn:ietf:params:xml:ns:caldav:is-not-defined' && $value_defined ) {
        dbg_error_log( 'iCalendar', ":ApplyFilter: Value is set ('%s'), want unset, for filter %s", count($value), $tag );
        return false;
      }
      elseif ( $tag == 'urn:ietf:params:xml:ns:caldav:is-defined' && !$value_defined ) {
        dbg_error_log( 'iCalendar', ":ApplyFilter: Want value, but it is not set for filter %s", $tag );
        return false;
      }
      else {
        dbg_error_log( 'iCalendar', ":ApplyFilter: Have values for '%s' filter", $tag );
        switch( $tag ) {
          case 'urn:ietf:params:xml:ns:caldav:time-range':
            break;
          case 'urn:ietf:params:xml:ns:caldav:text-match':
            $search = $v->GetContent();
            // In this case $value will either be a string, or an array of iCalProp objects
            // since TEXT-MATCH does not apply to COMPONENT level - only property/parameter
            if ( !is_string($value) ) {
              if ( is_array($value) ) {
                $match = false;
                foreach( $value AS $k1 => $v1 ) {
                  // $v1 MUST be an iCalProp object
                  if ( $match = $v1->TextMatch($search)) break;
                }
              }
              else {
                dbg_error_log( 'iCalendar', ":ApplyFilter: TEXT-MATCH will only work on strings or arrays of iCalProp.  %s unsupported", gettype($value) );
                return true;  // We return _true_ in this case, so the client sees the item
              }
            }
            else {
              $match = (stristr( $value, $search ) !== false);      
            }
            $negate = $v->GetAttribute("negate-condition");
            if ( isset($negate) && strtolower($negate) == "yes" ) $match = !$match;
//            dbg_error_log( 'iCalendar', ":ApplyFilter: TEXT-MATCH returning %s", ($match?"yes":"no") );
            return $match;
            break;
          case 'urn:ietf:params:xml:ns:caldav:comp-filter':
            $subfilter = $v->GetContent();
            $component = $this->ExtractSubComponent($value,$v->GetAttribute("name"));
            if ( ! $this->ApplyFilter($subfilter,$component) ) return false;
            break;
          case 'urn:ietf:params:xml:ns:caldav:prop-filter':
            $subfilter = $v->GetContent();
            $properties = $this->ExtractProperty($value,$v->GetAttribute("name"));
            if ( ! $this->ApplyFilter($subfilter,$properties) ) return false;
            break;
          case 'urn:ietf:params:xml:ns:caldav:param-filter':
            $subfilter = $v->GetContent();
            $parameter = $this->ExtractParameter($value,$v->GetAttribute("NAME"));
            if ( ! $this->ApplyFilter($subfilter,$parameter) ) return false;
            break;
        }
      }
    }
    return true;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

iCalendar::BuildFromText ( icalendar)

This unescapes the (CRLF + linear space) wrapping specified in RFC2445. According to RFC2445 we should always end with CRLF but the CalDAV spec says that normalising XML parsers often muck with it and may remove the CR.

Our 'type' is the type of non-timezone inside a VCALENDAR

Definition at line 1200 of file iCalendar.php.

                                       {
    deprecated('iCalendar::BuildFromText' );
    $icalendar = preg_replace('/\r?\n[ \t]/', '', $icalendar );

    $this->lines = preg_split('/\r?\n/', $icalendar );

    $this->_current_parse_line = 0;
    $this->properties = $this->ParseSomeLines('');

    if ( isset($this->properties['VCALENDAR'][0]['INSIDE']) ) {
      foreach ( $this->properties['VCALENDAR'][0]['INSIDE']  AS $k => $v ) {
        if ( $v == 'VTIMEZONE' ) continue;
        $this->type = $v;
        break;
      }
    }

  }

Here is the call graph for this function:

iCalendar::ClearComponents ( type = null)

: This class will be removed soon.

Clear all components, or the components matching a particular type

Parameters:
string$typeThe type of component - omit for all components

Definition at line 1387 of file iCalendar.php.

                                           {
    deprecated('iCalendar::ClearComponents' );
    $this->component->ClearComponents($type);
  }

Do what must be done with time zones from on file.

Attempt to turn them into something that PostgreSQL can understand...

: This class will be removed soon.

Todo:
Remove this function.

In case there was no X-LIC-LOCATION defined, let's hope there is something in the TZID that we can use. We are looking for a string like "Pacific/Auckland" if possible.

Unfortunately this kind of thing will never work well :-(

 if ( strstr( $tzname, ' ' ) ) {
   $words = preg_split('/\s/', $tzname );
   $tzabbr = '';
   foreach( $words AS $i => $word ) {
     $tzabbr .= substr( $word, 0, 1);
   }
   $this->tz_locn = $tzabbr;
 }

Definition at line 1254 of file iCalendar.php.

                               {
    global $c;

    deprecated('iCalendar::DealWithTimeZones' );
    $tzid = $this->Get('TZID');
    if ( isset($c->save_time_zone_defs) && $c->save_time_zone_defs ) {
      $qry = new AwlQuery( "SELECT tz_locn FROM time_zone WHERE tz_id = ?;", $tzid );
      if ( $qry->Exec('iCalendar') && $qry->rows() == 1 ) {
        $row = $qry->Fetch();
        $this->tz_locn = $row->tz_locn;
      }
      dbg_error_log( 'iCalendar', " TZCrap2: TZID '%s', DB Rows=%d, Location '%s'", $tzid, $qry->rows(), $this->tz_locn );
    }

    if ( (!isset($this->tz_locn) || $this->tz_locn == '') && $tzid != '' ) {
      $tzname = preg_replace('#^(.*[^a-z])?([a-z]+/[a-z]+)$#i','$1',$tzid );
      if ( preg_match( '#\S+/\S+#', $tzname) ) {
        $this->tz_locn = $tzname;
      }
      dbg_error_log( 'iCalendar', " TZCrap3: TZID '%s', Location '%s', Perhaps: %s", $tzid, $this->tz_locn, $tzname );
    }

    if ( $tzid != '' && isset($c->save_time_zone_defs) && $c->save_time_zone_defs && $qry->rows() != 1 && isset($this->vtimezone) && $this->vtimezone != "" ) {
      $qry2 = new AwlQuery( "INSERT INTO time_zone (tz_id, tz_locn, tz_spec) VALUES( ?, ?, ? );",
                                   $tzid, $this->tz_locn, $this->vtimezone );
      $qry2->Exec('iCalendar');
    }

    if ( (!isset($this->tz_locn) || $this->tz_locn == "") && isset($c->local_tzid) ) {
      $this->tz_locn = $c->local_tzid;
    }
  }

Here is the call graph for this function:

An array of property names that we should always want when rendering an iCalendar.

: This class will be removed soon.

Todo:
Remove this function.

Definition at line 1076 of file iCalendar.php.

                                 {
    dbg_error_log( "LOG", " iCalendar: Call to deprecated method '%s'", 'DefaultPropertyList' );
    return array( "UID" => 1, "DTSTAMP" => 1, "DTSTART" => 1, "DURATION" => 1,
                  "LAST-MODIFIED" => 1,"CLASS" => 1, "TRANSP" => 1, "SEQUENCE" => 1,
                  "DUE" => 1, "SUMMARY" => 1, "RRULE" => 1 );
  }
iCalendar::ExtractProperty ( component,
type,
count = 9999 
)

: This class will be removed soon.

Extract a particular property from the provided component. In doing so we assume that the content was unescaped when iCalComponent::ParseFrom() called iCalComponent::UnwrapComponent().

Parameters:
array$componentAn array of lines of this component
string$typeThe type of parameter
Returns:
array An array of iCalProperty objects

Definition at line 1548 of file iCalendar.php.

                                                             {
    deprecated('iCalendar::ExtractProperty' );
    $answer = array();
    dbg_error_log( 'iCalendar', ":ExtractProperty: Looking for %d properties of type %s", $count, $type );
    reset($component);
    foreach( $component AS $k => $v ) {
      if ( preg_match( "/$type"."[;:]/i", $v ) ) {
        $answer[] = new iCalProp($v);
        dbg_error_log( 'iCalendar', ":ExtractProperty: Found property %s", $type );
        if ( --$count < 1 ) return $answer;
      }
    }
    return $answer;
  }

Here is the caller graph for this function:

iCalendar::ExtractSubComponent ( component,
type,
count = 9999 
)

: This class will be removed soon.

Return all sub-components of the given type, which are part of the component we pass in as an array of lines.

Parameters:
array$componentThe component to be parsed
string$typeThe type of sub-components to be extracted
int$countThe number of sub-components to extract (default: 9999)
Returns:
array The sub-component lines

Definition at line 1512 of file iCalendar.php.

                                                                 {
    deprecated('iCalendar::ExtractSubComponent' );
    $answer = array();
    $intags = false;
    $start = "BEGIN:$type";
    $finish = "END:$type";
    dbg_error_log( 'iCalendar', ":ExtractSubComponent: Looking for %d subsets of type %s", $count, $type );
    reset($component);
    foreach( $component AS $k => $v ) {
      if ( !$intags && $v == $start ) {
        $answer[] = $v;
        $intags = true;
      }
      else if ( $intags && $v == $finish ) {
        $answer[] = $v;
        $intags = false;
      }
      else if ( $intags ) {
        $answer[] = $v;
      }
    }
    return $answer;
  }

Here is the caller graph for this function:

iCalendar::Get ( key)

Get the value of a property in the first non-VTIMEZONE : This class will be removed soon.

The property we work on is the first non-VTIMEZONE we find.

Definition at line 1308 of file iCalendar.php.

                       {
    deprecated('iCalendar::Get' );
    if ( strtoupper($key) == 'TZID' ) {
      // backward compatibility hack
      dbg_error_log( 'iCalendar', " Get(TZID): TZID '%s', Location '%s'", (isset($this->tzid)?$this->tzid:"[not set]"), $this->tz_locn );
      if ( isset($this->tzid) ) return $this->tzid;
      return $this->tz_locn;
    }
    $component =& $this->component->FirstNonTimezone();
    if ( $component === false ) return null;
    return $component->GetPValue(strtoupper($key));
  }

Here is the caller graph for this function:

iCalendar::GetComponents ( type = null,
normal_match = true 
)

: This class will be removed soon.

Get all sub-components, or at least get those matching a type, or failling to match, should the second parameter be set to false.

Parameters:
string$typeThe type to match (default: All)
boolean$normal_matchSet to false to invert the match (default: true)
Returns:
array an array of the sub-components

Definition at line 1376 of file iCalendar.php.

                                                               {
    deprecated('iCalendar::GetComponents' );
    return $this->component->GetComponents($type,$normal_match);
  }
static iCalendar::HttpDateFormat ( ) [static]

: This class will be removed soon.

Returns a PostgreSQL Date Format string suitable for returning HTTP (RFC2068) dates Preferred is "Sun, 06 Nov 1994 08:49:37 GMT" so we do that.

Definition at line 1434 of file iCalendar.php.

                                   {
    return "'Dy, DD Mon IYYY HH24:MI:SS \"GMT\"'";
  }
iCalendar::iCalendar ( args)

@-

: This class will be removed soon. The constructor takes an array of args. If there is an element called 'icalendar' then that will be parsed into the iCalendar object. Otherwise the array elements are converted into properties of the iCalendar object directly.

Todo:
Need to handle timezones!!!

Definition at line 942 of file iCalendar.php.

                              {
    global $c;

    deprecated('iCalendar::iCalendar');
    $this->tz_locn = "";
    if ( !isset($args) || !(is_array($args) || is_object($args)) ) return;
    if ( is_object($args) ) {
      settype($args,'array');
    }

    $this->component = new iCalComponent();
    if ( isset($args['icalendar']) ) {
      $this->component->ParseFrom($args['icalendar']);
      $this->lines = preg_split('/\r?\n/', $args['icalendar'] );
      $this->SaveTimeZones();
      $first =& $this->component->FirstNonTimezone();
      if ( $first ) {
        $this->type = $first->GetType();
        $this->properties = $first->GetProperties();
      }
      else {
        $this->properties = array();
      }
      $this->properties['VCALENDAR'] = array('***ERROR*** This class is being referenced in an unsupported way!');
      return;
    }

    if ( isset($args['type'] ) ) {
      $this->type = $args['type'];
      unset( $args['type'] );
    }
    else {
      $this->type = 'VEVENT';  // Default to event
    }
    $this->component->SetType('VCALENDAR');
    $this->component->SetProperties(
        array(
          new iCalProp('PRODID:-//davical.org//NONSGML AWL Calendar//EN'),
          new iCalProp('VERSION:2.0'),
          new iCalProp('CALSCALE:GREGORIAN')
        )
    );
    $first = new iCalComponent();
    $first->SetType($this->type);
    $this->properties = array();

    foreach( $args AS $k => $v ) {
      dbg_error_log( 'iCalendar', ":Initialise: %s to >>>%s<<<", $k, $v );
      $property = new iCalProp();
      $property->Name($k);
      $property->Value($v);
      $this->properties[] = $property;
    }
    $first->SetProperties($this->properties);
    $this->component->SetComponents( array($first) );

    $this->properties['VCALENDAR'] = array('***ERROR*** This class is being referenced in an unsupported way!');

    if ( $this->tz_locn == "" ) {
      $this->tz_locn = $this->Get("tzid");
      if ( (!isset($this->tz_locn) || $this->tz_locn == "") && isset($c->local_tzid) ) {
        $this->tz_locn = $c->local_tzid;
      }
    }
  }

Here is the call graph for this function:

static iCalendar::iCalFooter ( ) [static]

: This class will be removed soon.

Returns the footer we always use at the finish of our iCalendar resources

Todo:
Remove this function.

Definition at line 1701 of file iCalendar.php.

                               {
    deprecated('iCalendar::iCalFooter' );
    return "END:VCALENDAR\r\n";
  }
static iCalendar::iCalHeader ( ) [static]

: This class will be removed soon.

Returns the header we always use at the start of our iCalendar resources

Todo:
Remove this function.

Definition at line 1683 of file iCalendar.php.

                               {
    deprecated('iCalendar::iCalHeader' );
    return <<<EOTXT
BEGIN:VCALENDAR\r
PRODID:-//davical.org//NONSGML AWL Calendar//EN\r
VERSION:2.0\r

EOTXT;
  }
iCalendar::JustThisBitPlease ( type,
count = 1 
)

Definition at line 1095 of file iCalendar.php.

                                                {
    deprecated('iCalendar::JustThisBitPlease' );
    $answer = "";
    $intags = false;
    $start = "BEGIN:$type";
    $finish = "END:$type";
    dbg_error_log( 'iCalendar', ":JTBP: Looking for %d subsets of type %s", $count, $type );
    reset($this->lines);
    foreach( $this->lines AS $k => $v ) {
      if ( !$intags && $v == $start ) {
        $answer .= $v . "\n";
        $intags = true;
      }
      else if ( $intags && $v == $finish ) {
        $answer .= $v . "\n";
        $intags = false;
      }
      else if ( $intags ) {
        $answer .= $v . "\n";
      }
    }
    return $answer;
  }

: This class will be removed soon.

Mask components, removing any that are not of the types in the list

Parameters:
array$keepAn array of component types to be kept

Definition at line 1423 of file iCalendar.php.

                                   {
    deprecated('iCalendar::MaskComponents' );
    $this->component->MaskComponents($keep);
  }

Definition at line 1129 of file iCalendar.php.

                                    {
    deprecated('iCalendar::ParseSomeLines' );
    $props = array();
    $properties =& $props;
    while( isset($this->lines[$this->_current_parse_line]) ) {
      $i = $this->_current_parse_line++;
      $line =& $this->lines[$i];
      dbg_error_log( 'iCalendar', ":Parse:%s LINE %03d: >>>%s<<<", $type, $i, $line );
      if ( $this->parsing_vtimezone ) {
        $this->vtimezone .= $line."\n";
      }
      if ( preg_match( '/^(BEGIN|END):([^:]+)$/', $line, $matches ) ) {
        if ( $matches[1] == 'END' && $matches[2] == $type ) {
          if ( $type == 'VTIMEZONE' ) {
            $this->parsing_vtimezone = false;
          }
          return $properties;
        }
        else if( $matches[1] == 'END' ) {
          dbg_error_log("ERROR"," iCalendar: parse error: Unexpected END:%s when we were looking for END:%s", $matches[2], $type );
          return $properties;
        }
        else if( $matches[1] == 'BEGIN' ) {
          $subtype = $matches[2];
          if ( $subtype == 'VTIMEZONE' ) {
            $this->parsing_vtimezone = true;
            $this->vtimezone = $line."\n";
          }
          if ( !isset($properties['INSIDE']) ) $properties['INSIDE'] = array();
          $properties['INSIDE'][] = $subtype;
          if ( !isset($properties[$subtype]) ) $properties[$subtype] = array();
          $properties[$subtype][] = $this->ParseSomeLines($subtype);
        }
      }
      else {
        // Parse the property
        @list( $property, $value ) = explode(':', $line, 2 );
        if ( strpos( $property, ';' ) > 0 ) {
          $parameterlist = explode(';', $property );
          $property = array_shift($parameterlist);
          foreach( $parameterlist AS $pk => $pv ) {
            if ( $pv == "VALUE=DATE" ) {
              $value .= 'T000000';
            }
            elseif ( preg_match('/^([^;:=]+)=([^;:=]+)$/', $pv, $matches) ) {
              switch( $matches[1] ) {
                case 'TZID': $properties['TZID'] = $matches[2];  break;
                default:
                  dbg_error_log( 'iCalendar', " FYI: Ignoring Resource '%s', Property '%s', Parameter '%s', Value '%s'", $type, $property, $matches[1], $matches[2] );
              }
            }
          }
        }
        if ( $this->parsing_vtimezone && (!isset($this->tz_locn) || $this->tz_locn == "") && $property == 'X-LIC-LOCATION' ) {
          $this->tz_locn = $value;
        }
        $properties[strtoupper($property)] = $this->RFC2445ContentUnescape($value);
      }
    }
    return $properties;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

iCalendar::Render ( as_calendar = true,
type = null,
restrict_properties = null 
)

: This class will be removed soon.

Render the iCalendar object as a text string which is a single VEVENT (or other)

Parameters:
boolean$as_calendarWhether or not to wrap the event in a VCALENDAR
string$typeThe type of iCalendar object (VEVENT, VTODO, VFREEBUSY etc.)
array$restrict_propertiesThe names of the properties we want in our rendered result.

Definition at line 1715 of file iCalendar.php.

                                                                                    {
    deprecated('iCalendar::Render' );
    if ( $as_calendar ) {
      return $this->component->Render();
    }
    else {
      $components = $this->component->GetComponents($type);
      $rendered = "";
      foreach( $components AS $k => $v ) {
        $rendered .= $v->Render($restrict_properties);
      }
      return $rendered;
    }
  }
iCalendar::RFC2445ContentEscape ( name,
value 
)

: This class will be removed soon.

Returns a suitably escaped RFC2445 content string.

Parameters:
string$nameThe incoming name[;param] prefixing the string.
string$valueThe incoming string to be escaped.
Deprecated:
This function is deprecated and will be removed eventually.
Todo:
Remove this function.

Content escaping does not apply to these properties culled from RFC2445

Content escaping applies by default to other properties

Definition at line 1477 of file iCalendar.php.

                                                 {
    deprecated('iCalendar::RFC2445ContentEscape' );
    $property = preg_replace( '/[;].*$/', '', $name );
    switch( $property ) {
      case 'ATTACH':                case 'GEO':                       case 'PERCENT-COMPLETE':      case 'PRIORITY':
      case 'COMPLETED':             case 'DTEND':                     case 'DUE':                   case 'DTSTART':
      case 'DURATION':              case 'FREEBUSY':                  case 'TZOFFSETFROM':          case 'TZOFFSETTO':
      case 'TZURL':                 case 'ATTENDEE':                  case 'ORGANIZER':             case 'RECURRENCE-ID':
      case 'URL':                   case 'EXDATE':                    case 'EXRULE':                case 'RDATE':
      case 'RRULE':                 case 'REPEAT':                    case 'TRIGGER':               case 'CREATED':
      case 'DTSTAMP':               case 'LAST-MODIFIED':             case 'SEQUENCE':
        break;

      default:
        $value = str_replace( '\\', '\\\\', $value);
        $value = preg_replace( '/\r?\n/', '\\n', $value);
        $value = preg_replace( "/([,;:\"])/", '\\\\$1', $value);
    }
    $result = preg_replace( '/(.{72})/u', '$1'."\r\n ", $name.':'.$value ) ."\r\n";
    return $result;
  }

Returns a content string with the RFC2445 escaping removed.

Parameters:
string$escapedThe incoming string to be escaped.
Returns:
string The string with RFC2445 content escaping removed.

: This class will be removed soon.

Todo:
Remove this function.

Definition at line 1237 of file iCalendar.php.

                                              {
    deprecated( 'RFC2445ContentUnescape' );
    $unescaped = str_replace( '\\n', "\n", $escaped);
    $unescaped = str_replace( '\\N', "\n", $unescaped);
    $unescaped = preg_replace( "/\\\\([,;:\"\\\\])/", '$1', $unescaped);
    return $unescaped;
  }

Here is the caller graph for this function:

: This class will be removed soon.

Save any timezones by TZID in the PostgreSQL database for future re-use.

Definition at line 1016 of file iCalendar.php.

                           {
    global $c;

    deprecated('iCalendar::SaveTimeZones');
    $this->tzid_list = array_keys($this->component->CollectParameterValues('TZID'));
    if ( ! isset($this->tzid) && count($this->tzid_list) > 0 ) {
      dbg_error_log( 'iCalendar', "::TZID_List[0] = '%s', count=%d", $this->tzid_list[0], count($this->tzid_list) );
      $this->tzid = $this->tzid_list[0];
    }

    $timezones = $this->component->GetComponents('VTIMEZONE');
    if ( $timezones === false || count($timezones) == 0 ) return;
    $this->vtimezone = $timezones[0]->Render();  // Backward compatibility

    $tzid = $this->Get('TZID');
    if ( isset($c->save_time_zone_defs) && $c->save_time_zone_defs ) {
      foreach( $timezones AS $k => $tz ) {
        $tzid = $tz->GetPValue('TZID');

        $qry = new AwlQuery( "SELECT tz_locn FROM time_zone WHERE tz_id = ?;", $tzid );
        if ( $qry->Exec('iCalendar') && $qry->rows() == 1 ) {
          $row = $qry->Fetch();
          if ( !isset($first_tzid) ) $first_tzid = $row->tz_locn;
          continue;
        }

        if ( $tzid != "" && $qry->rows() == 0 ) {

          $tzname = $tz->GetPValue('X-LIC-LOCATION');
          if ( !isset($tzname) ) $tzname = olson_from_tzstring($tzid);

          $qry2 = new AwlQuery( "INSERT INTO time_zone (tz_id, tz_locn, tz_spec) VALUES( ?, ?, ? );",
                                      $tzid, $tzname, $tz->Render() );
          $qry2->Exec('iCalendar');
        }
      }
    }
    if ( ! isset($this->tzid) && isset($first_tzid) ) $this->tzid = $first_tzid;

    if ( (!isset($this->tz_locn) || $this->tz_locn == '') && isset($first_tzid) && $first_tzid != '' ) {
      $tzname = preg_replace('#^(.*[^a-z])?([a-z]+/[a-z]+)$#i','$2', $first_tzid );
      if ( preg_match( '#\S+/\S+#', $tzname) ) {
        $this->tz_locn = $tzname;
      }
      dbg_error_log( 'iCalendar', " TZCrap1: TZID '%s', Location '%s', Perhaps: %s", $tzid, $this->tz_locn, $tzname );
    }

    if ( (!isset($this->tz_locn) || $this->tz_locn == "") && isset($c->local_tzid) ) {
      $this->tz_locn = $c->local_tzid;
    }
    if ( ! isset($this->tzid) && isset($this->tz_locn) ) $this->tzid = $this->tz_locn;
  }

Here is the call graph for this function:

Here is the caller graph for this function:

iCalendar::Set ( key,
value 
)

Set the value of a property : This class will be removed soon.

Definition at line 1329 of file iCalendar.php.

                               {
    deprecated('iCalendar::Set' );
    if ( $value == "" ) return;
    $key = strtoupper($key);
    $property = new iCalProp();
    $property->Name($key);
    $property->Value($value);
    if (isset($this->component->rendered) ) unset( $this->component->rendered );
    $component =& $this->component->FirstNonTimezone();
    $component->SetProperties( array($property), $key);
    return $this->Get($key);
  }

Here is the call graph for this function:

iCalendar::SetComponents ( new_component,
type = null 
)

: This class will be removed soon.

Sets some or all sub-components of the component to the supplied new components

Parameters:
arrayof iCalComponent $new_components The new components to replace the existing ones
string$typeThe type of components to be replaced. Defaults to null, which means all components will be replaced.

Definition at line 1400 of file iCalendar.php.

                                                         {
    deprecated('iCalendar::SetComponents' );
    $this->component->SetComponents( $new_component, $type );
  }
static iCalendar::SqlDateFormat ( ) [static]

: This class will be removed soon.

Returns a PostgreSQL Date Format string suitable for returning iCal dates

Definition at line 1443 of file iCalendar.php.

                                  {
    return "'YYYYMMDD\"T\"HH24MISS'";
  }
static iCalendar::SqlDurationFormat ( ) [static]

: This class will be removed soon.

Returns a PostgreSQL Date Format string suitable for returning iCal durations

  • this doesn't work for negative intervals, but events should not have such!

Definition at line 1463 of file iCalendar.php.

                                      {
    return "'\"PT\"HH24\"H\"MI\"M\"'";
  }
static iCalendar::SqlUTCFormat ( ) [static]

: This class will be removed soon.

Returns a PostgreSQL Date Format string suitable for returning dates which have been cast to UTC

Definition at line 1453 of file iCalendar.php.

                                 {
    return "'YYYYMMDD\"T\"HH24MISS\"Z\"'";
  }
iCalendar::TestFilter ( filters)

: This class will be removed soon.

Test a PROP-FILTER or COMP-FILTER and return a true/false COMP-FILTER (is-defined | is-not-defined | (time-range?, prop-filter*, comp-filter*)) PROP-FILTER (is-defined | is-not-defined | ((time-range | text-match)?, param-filter*))

Parameters:
array$filterAn array of XMLElement defining the filter
Returns:
boolean Whether or not this iCalendar passes the test

Definition at line 1656 of file iCalendar.php.

                                  {
    deprecated('iCalendar::TestFilter' );

//    dbg_error_log('iCalendar', ':TestFilter we have %d filters to test', count($filters) );
    foreach( $filters AS $k => $v ) {
      $tag = $v->GetNSTag();
//      dbg_error_log('iCalendar', ':TestFilter working on tag "%s" %s"', $k, $tag );
      $name = $v->GetAttribute("name");
      $filter = $v->GetContent();
      if ( $tag == "urn:ietf:params:xml:ns:caldav:prop-filter" ) {
        $value = $this->ExtractProperty($this->lines,$name);
      }
      else {
        $value = $this->ExtractSubComponent($this->lines,$v->GetAttribute("name"));
      }
      if ( count($value) == 0 ) unset($value);
      if ( ! $this->ApplyFilter($filter,$value) ) return false;
    }
    return true;
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 908 of file iCalendar.php.

Definition at line 920 of file iCalendar.php.

Definition at line 914 of file iCalendar.php.

Definition at line 932 of file iCalendar.php.

Definition at line 926 of file iCalendar.php.


The documentation for this class was generated from the following file: