ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Uri.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\VObject\Property;
4 
7 
17 class Uri extends Text {
18 
25  public $delimiter = null;
26 
35  function getValueType() {
36 
37  return 'URI';
38 
39  }
40 
46  function parameters() {
47 
48  $parameters = parent::parameters();
49  if (!isset($parameters['VALUE']) && in_array($this->name, ['URL', 'PHOTO'])) {
50  // If we are encoding a URI value, and this URI value has no
51  // VALUE=URI parameter, we add it anyway.
52  //
53  // This is not required by any spec, but both Apple iCal and Apple
54  // AddressBook (at least in version 10.8) will trip over this if
55  // this is not set, and so it improves compatibility.
56  //
57  // See Issue #227 and #235
58  $parameters['VALUE'] = new Parameter($this->root, 'VALUE', 'URI');
59  }
60  return $parameters;
61 
62  }
63 
74  function setRawMimeDirValue($val) {
75 
76  // Normally we don't need to do any type of unescaping for these
77  // properties, however.. we've noticed that Google Contacts
78  // specifically escapes the colon (:) with a blackslash. While I have
79  // no clue why they thought that was a good idea, I'm unescaping it
80  // anyway.
81  //
82  // Good thing backslashes are not allowed in urls. Makes it easy to
83  // assume that a backslash is always intended as an escape character.
84  if ($this->name === 'URL') {
85  $regex = '# (?: (\\\\ (?: \\\\ | : ) ) ) #x';
86  $matches = preg_split($regex, $val, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
87  $newVal = '';
88  foreach ($matches as $match) {
89  switch ($match) {
90  case '\:' :
91  $newVal .= ':';
92  break;
93  default :
94  $newVal .= $match;
95  break;
96  }
97  }
98  $this->value = $newVal;
99  } else {
100  $this->value = strtr($val, ['\,' => ',']);
101  }
102 
103  }
104 
110  function getRawMimeDirValue() {
111 
112  if (is_array($this->value)) {
113  $value = $this->value[0];
114  } else {
116  }
117 
118  return strtr($value, [',' => '\,']);
119 
120  }
121 
122 }
parameters()
Returns an iterable list of children.
Definition: Uri.php:46
setRawMimeDirValue($val)
Sets a raw value coming from a mimedir (iCalendar/vCard) file.
Definition: Uri.php:74
URI property.
Definition: Uri.php:17
VObject Parameter.
Definition: Parameter.php:20
getRawMimeDirValue()
Returns a raw mime-dir representation of the value.
Definition: Uri.php:110
Text property.
Definition: Text.php:20
getValueType()
Returns the type of value.
Definition: Uri.php:35