Back to index

awl  0.53
Public Member Functions | Public Attributes
iCalProp Class Reference

List of all members.

Public Member Functions

 iCalProp ($propstring=null)
 

@-


 ParseFrom ($propstring)
 The constructor parses the incoming string, which is formatted as per RFC2445 as a propname[;param1=pval1[; ...
 Name ($newname=null)
 Get/Set name property.
 Value ($newvalue=null)
 Get/Set the content of the property.
 Parameters ($newparams=null)
 Get/Set parameters in their entirety.
 TextMatch ($search)
 Test if our value contains a string.
 GetParameterValue ($name)
 Get the value of a parameter.
 SetParameterValue ($name, $value)
 Set the value of a parameter.
 RenderParameters ()
 Render the set of parameters as key1=value1[;key2=value2[; ...]] with any colons or semicolons escaped.
 Render ()
 Render a suitably escaped RFC2445 content string.

Public Attributes

 $name
 $parameters
 $content
 $rendered

Detailed Description

Definition at line 57 of file iCalendar.php.


Member Function Documentation

Get the value of a parameter.

Parameters:
string$nameThe name of the parameter to retrieve the value for
Returns:
string The value of the parameter

Definition at line 215 of file iCalendar.php.

                                      {
    if ( isset($this->parameters[$name]) ) return $this->parameters[$name];
  }
iCalProp::iCalProp ( propstring = null)

@-

The constructor parses the incoming string, which is formatted as per RFC2445 as a propname[;param1=pval1[; ... ]]:propvalue however we allow ourselves to assume that the RFC2445 content unescaping has already happened when iCalComponent::ParseFrom() called iCalComponent::UnwrapComponent().

Parameters:
string$propstringThe string from the iCalendar which contains this property.

Definition at line 100 of file iCalendar.php.

                                          {
    $this->name = "";
    $this->content = "";
    $this->parameters = array();
    unset($this->rendered);
    if ( $propstring != null && gettype($propstring) == 'string' ) {
      $this->ParseFrom($propstring);
    }
  }

Here is the call graph for this function:

iCalProp::Name ( newname = null)

Get/Set name property.

Parameters:
string$newname[optional] A new name for the property
Returns:
string The name for the property.

Definition at line 151 of file iCalendar.php.

                                   {
    if ( $newname != null ) {
      $this->name = $newname;
      if ( isset($this->rendered) ) unset($this->rendered);
//      dbg_error_log('iCalendar', " iCalProp::Name(%s)", $this->name );
    }
    return $this->name;
  }
iCalProp::Parameters ( newparams = null)

Get/Set parameters in their entirety.

Parameters:
array$newparamsAn array of new parameter key/value pairs
Returns:
array The current array of parameters for the property.

Definition at line 184 of file iCalendar.php.

                                           {
    if ( $newparams != null ) {
      $this->parameters = $newparams;
      if ( isset($this->rendered) ) unset($this->rendered);
    }
    return $this->parameters;
  }
iCalProp::ParseFrom ( propstring)

The constructor parses the incoming string, which is formatted as per RFC2445 as a propname[;param1=pval1[; ...

]]:propvalue however we allow ourselves to assume that the RFC2445 content unescaping has already happened when iCalComponent::ParseFrom() called iCalComponent::UnwrapComponent().

Parameters:
string$propstringThe string from the iCalendar which contains this property.

Definition at line 119 of file iCalendar.php.

                                    {
    $this->rendered = (strlen($propstring) < 72 ? $propstring : null);  // Only pre-rendered if we didn't unescape it

    $unescaped = preg_replace( '{\\\\[nN]}', "\n", $propstring);
 
    // Split into two parts on : which is not preceded by a \
    list( $start, $values) = preg_split( '{(?<!\\\\):}', $unescaped, 2);
    $this->content = preg_replace( "/\\\\([,;:\"\\\\])/", '$1', $values);

    // Split on ; which is not preceded by a \
    $parameters = preg_split( '{(?<!\\\\);}', $start);

    $parameters = explode(';',$start);
    $this->name = array_shift( $parameters );
    $this->parameters = array();
    foreach( $parameters AS $k => $v ) {
      $pos = strpos($v,'=');
      $name = substr( $v, 0, $pos);
      $value = substr( $v, $pos + 1);
      $this->parameters[$name] = $value;
    }
//    dbg_error_log('iCalendar', " iCalProp::ParseFrom found '%s' = '%s' with %d parameters", $this->name, substr($this->content,0,200), count($this->parameters) );
  }

Here is the caller graph for this function:

Render a suitably escaped RFC2445 content string.

Content escaping does not apply to these properties culled from RFC2445

Content escaping applies by default to other properties

Definition at line 248 of file iCalendar.php.

                    {
    // If we still have the string it was parsed in from, it hasn't been screwed with
    // and we can just return that without modification.
    if ( isset($this->rendered) ) return $this->rendered;

    $property = preg_replace( '/[;].*$/', '', $this->name );
    $escaped = $this->content;
    switch( $property ) {
      case 'ATTACH':                case 'GEO':                       case 'PERCENT-COMPLETE':      case 'PRIORITY':
      case 'DURATION':              case 'FREEBUSY':                  case 'TZOFFSETFROM':          case 'TZOFFSETTO':
      case 'TZURL':                 case 'ATTENDEE':                  case 'ORGANIZER':             case 'RECURRENCE-ID':
      case 'URL':                   case 'EXRULE':                    case 'SEQUENCE':              case 'CREATED':
      case 'RRULE':                 case 'REPEAT':                    case 'TRIGGER':
        break;

      case 'COMPLETED':             case 'DTEND':
      case 'DUE':                   case 'DTSTART':
      case 'DTSTAMP':               case 'LAST-MODIFIED':
      case 'CREATED':               case 'EXDATE':
      case 'RDATE':
        if ( isset($this->parameters['VALUE']) && $this->parameters['VALUE'] == 'DATE' ) {
          $escaped = substr( $escaped, 0, 8);
        }
        break;

      default:
        $escaped = str_replace( '\\', '\\\\', $escaped);
        $escaped = preg_replace( '/\r?\n/', '\\n', $escaped);
        $escaped = preg_replace( "/([,;])/", '\\\\$1', $escaped);
    }
    $property = sprintf( "%s%s:", $this->name, $this->RenderParameters() );
    if ( (strlen($property) + strlen($escaped)) <= 72 ) {
      $this->rendered = $property . $escaped;
    }
    else if ( (strlen($property) + strlen($escaped)) > 72 && (strlen($property) < 72) && (strlen($escaped) < 72) ) {
      $this->rendered = $property . "\r\n " . $escaped;
    }
    else {
      $this->rendered = preg_replace( '/(.{72})/u', '$1'."\r\n ", $property . $escaped );
    }
    return $this->rendered;
  }

Here is the call graph for this function:

Render the set of parameters as key1=value1[;key2=value2[; ...]] with any colons or semicolons escaped.

Definition at line 235 of file iCalendar.php.

                              {
    $rendered = "";
    foreach( $this->parameters AS $k => $v ) {
      $escaped = preg_replace( "/([;:])/", '\\\\$1', $v);
      $rendered .= sprintf( ";%s=%s", $k, $escaped );
    }
    return $rendered;
  }

Here is the caller graph for this function:

iCalProp::SetParameterValue ( name,
value 
)

Set the value of a parameter.

Parameters:
string$nameThe name of the parameter to set the value for
string$valueThe value of the parameter

Definition at line 226 of file iCalendar.php.

                                              {
    if ( isset($this->rendered) ) unset($this->rendered);
    $this->parameters[$name] = $value;
  }
iCalProp::TextMatch ( search)

Test if our value contains a string.

Parameters:
string$searchThe needle which we shall search the haystack for.
Returns:
string The name for the property.

Definition at line 200 of file iCalendar.php.

                                {
    if ( isset($this->content) ) {
      return (stristr( $this->content, $search ) !== false);      
    }
    return false;
  }
iCalProp::Value ( newvalue = null)

Get/Set the content of the property.

Parameters:
string$newvalue[optional] A new value for the property
Returns:
string The value of the property.

Definition at line 168 of file iCalendar.php.

                                     {
    if ( $newvalue != null ) {
      $this->content = $newvalue;
      if ( isset($this->rendered) ) unset($this->rendered);
    }
    return $this->content;
  }

Member Data Documentation

Definition at line 81 of file iCalendar.php.

Definition at line 67 of file iCalendar.php.

Definition at line 74 of file iCalendar.php.

Definition at line 88 of file iCalendar.php.


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