示例#1
0
 /**
  * Creates an recurrence object with a passed in line.  Parses the line.
  * @param object $line an SG_iCal_Line object which will be parsed to get the
  * desired information.
  */
 public function __construct(SG_iCal_Line $line)
 {
     $this->parseLine($line->getData());
 }
示例#2
0
 /**
  * Parses the feed found in content and calls storeSection to store
  * parsed data
  * @param string $content
  * @param SG_iCal $ical
  */
 private static function _Parse($content, SG_iCal $ical)
 {
     $main_sections = array('vevent', 'vjournal', 'vtodo', 'vtimezone', 'vcalendar');
     $array_idents = array('exdate', 'rdate');
     $sections = array();
     $section = '';
     $current_data = array();
     foreach ($content as $line) {
         $line = new SG_iCal_Line($line);
         if ($line->isBegin()) {
             // New block of data, $section = new block
             $section = strtolower($line->getData());
             $sections[] = strtolower($line->getData());
         } elseif ($line->isEnd()) {
             // End of block of data ($removed = just ended block, $section = new top-block)
             $removed = array_pop($sections);
             $section = end($sections);
             if (array_search($removed, $main_sections) !== false) {
                 self::StoreSection($removed, $current_data[$removed], $ical);
                 $current_data[$removed] = array();
             }
         } else {
             // Data line
             foreach ($main_sections as $s) {
                 // Loops though the main sections
                 if (array_search($s, $sections) !== false) {
                     // This section is in the main section
                     if ($section == $s) {
                         // It _is_ the main section else
                         if (in_array($line->getIdent(), $array_idents)) {
                             //exdate could appears more that once
                             $current_data[$s][$line->getIdent()][] = $line;
                         } else {
                             $current_data[$s][$line->getIdent()] = $line;
                         }
                     } else {
                         // Sub section
                         $current_data[$s][$section][$line->getIdent()] = $line;
                     }
                     break;
                 }
             }
         }
     }
     $current_data = array();
 }
示例#3
0
 /**
  * Calculates the timestamp from a DT line.
  * @param $line SG_iCal_Line
  * @return int
  */
 private function getTimestamp(SG_iCal_Line $line, SG_iCal $ical)
 {
     $ts = strtotime($line->getData());
     if (isset($line['tzid'])) {
         $tz = $ical->getTimeZoneInfo($line['tzid']);
         $offset = $tz->getOffset($ts);
         $ts = strtotime(date('D, d M Y H:i:s', $ts) . ' ' . $offset);
     }
     return $ts;
 }