Пример #1
0
 public function __construct($name, $values)
 {
     parent::__construct($name, $values);
     $this->_name = "VALUE";
     $this->_valueDoubleQuote = false;
     if (count($values) > 1) {
         trigger_error("VALUE parameter must only have one value", E_USER_WARNING);
     }
     foreach ($values as $v) {
         switch ($v) {
             case "BINARY":
             case "BOOLEAN":
             case "CAL-ADDRESS":
             case "DATE":
             case "DATE-TIME":
             case "DURATION":
             case "FLOAT":
             case "INTEGER":
             case "PERIOD":
             case "RECUR":
             case "TEXT":
             case "TIME":
             case "URI":
             case "UTC-OFFSET":
                 $this->_values[] = new File_iCal_ValueDataType_Text($v);
                 break;
             default:
                 trigger_error("VALUE parameter {$v} is unknown type", E_USER_WARNING);
         }
     }
 }
Пример #2
0
 /**
  * Create a new ContentLine
  *
  * @access  public
  * @param   mixed   $line   The parameter can be of a few types:
  *                          1) a File_iCal_Property object
  *                          2) a line of text in an iCal file
  */
 public function __construct($line)
 {
     //if we ar econstructing a contentline out of an existing property
     if (is_a($line, "File_iCal_Property")) {
         $this->_property = $line;
     } else {
         //remove all special characters from beginning and end
         $line = trim($line);
         //now it is time again to rewrite the tokenizer (for the 4th time)
         $tokens = array();
         //array of strings which represent tokens
         $i = 0;
         //string position
         $l = strlen($line);
         //every entry will start looking for a new token
         do {
             $t = "";
             //our new token
             $begin = $i;
             //behave differently depending on what type of character we encounter
             switch ($line[$i]) {
                 case '\\"':
                     //encounter the beginning of a double quoted string
                     $valid = true;
                     while ($valid) {
                         $i = strpos($line, '\\"', $i);
                         if ($line[$i - 1] == '\\') {
                             $valid = false;
                         }
                     }
                     $t = substr($line, $begin, $i - $begin);
                     $i++;
                     break;
                 case ':':
                 case ';':
                     $t = $line[$i];
                     $i++;
                     break;
                 default:
                     //if we don't have a semicolon or colon in the tokens array yet, we are reading the name string
                     $present_colon = in_array(':', $tokens);
                     $present_semi = in_array(';', $tokens);
                     if (!$present_colon && !$present_semi) {
                         $m;
                         preg_match("/^([\\w\\d-]+)[;:]?/", $line, $m);
                         //$m[1] contains the name
                         $t = $m[1];
                         $i += strlen($t);
                     } else {
                         if ($present_colon && $tokens[count($tokens) - 1] == ':') {
                             //if the last token is a colon, read out the value
                             $t = substr($line, $i);
                             $i += strlen($t);
                         } else {
                             if ($present_semi && $tokens[count($tokens) - 1] == ';') {
                                 //if the last token is a semicolon
                                 $t = substr($line, $i, strpos($line, ':', $i) - $i);
                                 $i += strlen($t);
                             } else {
                                 $t = $line[$i];
                                 $i++;
                             }
                         }
                     }
             }
             $tokens[] = $t;
         } while ($i < $l);
         //print_r($tokens);
         $colon_key = array_search(':', $tokens);
         $name_string = $tokens[0];
         $value_string = $tokens[$colon_key + 1];
         $params = array();
         if ($tokens[1] == ';') {
             $arr = explode(';', $tokens[2]);
             foreach ($arr as $v) {
                 $val = explode('=', $v);
                 $name = $val[0];
                 $values = array($val[1]);
                 $params[] = File_iCal_Parameter::getParameter($name, $values);
             }
         }
         $this->_property = File_iCal_Property::getProperty($name_string, $params, $value_string);
     }
 }