Exemplo n.º 1
0
 /**
  * Writes the property out in vCalendar format.
  * 
  * @access	public
  * @return	string
  * 
  */
 function write()
 {
     $out = $this->name . "\r\n";
     foreach ($this->parameters as $key => $value) {
         if (is_array($value)) {
             $vals = array();
             foreach ($value as $k => $v) {
                 $value[$k] = vCal::quote($v);
                 $vals[] = $key . '=' . $value[$k];
             }
             //$out .= vCal::fold (join (',', $value)) . "\r\n";
             // it doesn't look like people use commas in other implementations,
             // and it seems that multiple properties and parameters may use
             // the same name, which means hashes don't work so well here.
             //				$out .= vCal::fold (join (';', $value)) . "\r\n";
             $out .= ' ;' . vCal::fold(join("\r\n ;", $vals)) . "\r\n";
         } else {
             $out .= ' ;' . $key . '=';
             $out .= vCal::fold(vCal::quote($value)) . "\r\n";
         }
     }
     if (is_array($this->value)) {
         $numeric = false;
         foreach ($this->value as $key => $value) {
             if (is_numeric($key)) {
                 $numeric = true;
             } else {
                 $numeric = false;
             }
             break;
         }
         $out .= ' :';
         $buf = array();
         foreach ($this->value as $key => $value) {
             // to handle values and parameters whose values are arrays...
             if (is_array($value)) {
                 foreach ($value as $k => $v) {
                     $value[$k] = vCal::quote($v);
                 }
                 $value = join(';', $value);
             }
             if ($numeric) {
                 $buf[] = vCal::fold(vCal::quote($value));
             } else {
                 $buf[] = $key . '=' . vCal::fold(vCal::quote($value));
             }
         }
         //if ($numeric) {
         //$out .= join (',', $buf) . "\r\n";
         //} else {
         $out .= join(';', $buf) . "\r\n";
         //}
     } else {
         $out .= ' :' . vCal::fold($this->value) . "\r\n";
     }
     return $out;
 }