You are here

class DateIcalIcalcreatorComponent in Date iCal 7.2

A wrapper on iCalcreator component class.

Hierarchy

Expanded class hierarchy of DateIcalIcalcreatorComponent

File

includes/DateIcalIcalcreatorParser.inc, line 358
Classes implementing Date iCal's iCalcreator-based parser functionality.

View source
class DateIcalIcalcreatorComponent implements DateIcalComponentInterface {
  public $component;
  private $_serialized_component;

  /**
   * Constructor.
   *
   * @param
   *   vcalendar component configured, but not yet parsed into Feeds-readable data.
   */
  public function __construct(calendarComponent $component) {
    $this->component = $component;
  }

  /**
   * Serialization helper.
   */
  public function __sleep() {
    $this->_serialized_component = serialize($this->component);
    return array(
      '_serialized_component',
    );
  }

  /**
   * Unserialization helper.
   */
  public function __wakeup() {
    DateIcalIcalcreatorParser::loadLibrary();
    $this->component = unserialize($this->_serialized_component);
  }
  public function getComponentType() {
    return $this->component->objName;
  }
  public function getProperty($name) {
    return $this->component
      ->getProperty($name, FALSE, TRUE);
  }

  // $args should be an array of arguments to be sent to the set$Name()
  // function of calendarComponent. If $args is not an array, it'll be
  // wrapped as one. This is necessary because the iCalcreator API has different
  // parameter lists for the set$Name() functions of different properties.
  public function setProperty($name, $args) {
    if (!is_array($args)) {
      $args = array(
        $args,
      );
    }

    // Call the setProperty() method on $this->component with the arguments: $name + $args.
    call_user_func_array(array(
      $this->component,
      "setProperty",
    ), array(
      $name,
    ) + $args);
  }

  // Special set functions, because using component->setRrule() and similar always add an *additional*
  // RRULE/RDATE/EXDATE, rather than changing the existing one. This may be a bug in iCalcreator, or
  // I may just be calling the functions wrong.
  public function setRrule($rrule) {
    return $this->component->rrule[0] = $rrule;
  }
  public function getRrule() {
    return trim($this->component
      ->createRrule());
  }
  public function setRdate($rdate) {
    return $this->component->rdate[0] = $rdate;
  }
  public function getRdate() {
    return trim($this->component
      ->createRdate());
  }
  public function setExdate($exdate) {
    return $this->component->exdate[0] = $exdate;
  }
  public function getExdate() {
    return trim($this->component
      ->createExdate());
  }

}

Members