1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\VObject\Property; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\VObject\Property; 6*a1a3b679SAndreas Boehler 7*a1a3b679SAndreas Boehler/** 8*a1a3b679SAndreas Boehler * URI property 9*a1a3b679SAndreas Boehler * 10*a1a3b679SAndreas Boehler * This object encodes URI values. vCard 2.1 calls these URL. 11*a1a3b679SAndreas Boehler * 12*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/). 13*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/) 14*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License 15*a1a3b679SAndreas Boehler */ 16*a1a3b679SAndreas Boehlerclass Uri extends Text { 17*a1a3b679SAndreas Boehler 18*a1a3b679SAndreas Boehler /** 19*a1a3b679SAndreas Boehler * In case this is a multi-value property. This string will be used as a 20*a1a3b679SAndreas Boehler * delimiter. 21*a1a3b679SAndreas Boehler * 22*a1a3b679SAndreas Boehler * @var string|null 23*a1a3b679SAndreas Boehler */ 24*a1a3b679SAndreas Boehler public $delimiter = null; 25*a1a3b679SAndreas Boehler 26*a1a3b679SAndreas Boehler /** 27*a1a3b679SAndreas Boehler * Returns the type of value. 28*a1a3b679SAndreas Boehler * 29*a1a3b679SAndreas Boehler * This corresponds to the VALUE= parameter. Every property also has a 30*a1a3b679SAndreas Boehler * 'default' valueType. 31*a1a3b679SAndreas Boehler * 32*a1a3b679SAndreas Boehler * @return string 33*a1a3b679SAndreas Boehler */ 34*a1a3b679SAndreas Boehler public function getValueType() { 35*a1a3b679SAndreas Boehler 36*a1a3b679SAndreas Boehler return "URI"; 37*a1a3b679SAndreas Boehler 38*a1a3b679SAndreas Boehler } 39*a1a3b679SAndreas Boehler 40*a1a3b679SAndreas Boehler /** 41*a1a3b679SAndreas Boehler * Sets a raw value coming from a mimedir (iCalendar/vCard) file. 42*a1a3b679SAndreas Boehler * 43*a1a3b679SAndreas Boehler * This has been 'unfolded', so only 1 line will be passed. Unescaping is 44*a1a3b679SAndreas Boehler * not yet done, but parameters are not included. 45*a1a3b679SAndreas Boehler * 46*a1a3b679SAndreas Boehler * @param string $val 47*a1a3b679SAndreas Boehler * @return void 48*a1a3b679SAndreas Boehler */ 49*a1a3b679SAndreas Boehler public function setRawMimeDirValue($val) { 50*a1a3b679SAndreas Boehler 51*a1a3b679SAndreas Boehler // Normally we don't need to do any type of unescaping for these 52*a1a3b679SAndreas Boehler // properties, however.. we've noticed that Google Contacts 53*a1a3b679SAndreas Boehler // specifically escapes the colon (:) with a blackslash. While I have 54*a1a3b679SAndreas Boehler // no clue why they thought that was a good idea, I'm unescaping it 55*a1a3b679SAndreas Boehler // anyway. 56*a1a3b679SAndreas Boehler // 57*a1a3b679SAndreas Boehler // Good thing backslashes are not allowed in urls. Makes it easy to 58*a1a3b679SAndreas Boehler // assume that a backslash is always intended as an escape character. 59*a1a3b679SAndreas Boehler if ($this->name === 'URL') { 60*a1a3b679SAndreas Boehler $regex = '# (?: (\\\\ (?: \\\\ | : ) ) ) #x'; 61*a1a3b679SAndreas Boehler $matches = preg_split($regex, $val, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); 62*a1a3b679SAndreas Boehler $newVal = ''; 63*a1a3b679SAndreas Boehler foreach($matches as $match) { 64*a1a3b679SAndreas Boehler switch($match) { 65*a1a3b679SAndreas Boehler case '\:' : 66*a1a3b679SAndreas Boehler $newVal.=':'; 67*a1a3b679SAndreas Boehler break; 68*a1a3b679SAndreas Boehler default : 69*a1a3b679SAndreas Boehler $newVal.=$match; 70*a1a3b679SAndreas Boehler break; 71*a1a3b679SAndreas Boehler } 72*a1a3b679SAndreas Boehler } 73*a1a3b679SAndreas Boehler $this->value = $newVal; 74*a1a3b679SAndreas Boehler } else { 75*a1a3b679SAndreas Boehler $this->value = $val; 76*a1a3b679SAndreas Boehler } 77*a1a3b679SAndreas Boehler 78*a1a3b679SAndreas Boehler } 79*a1a3b679SAndreas Boehler 80*a1a3b679SAndreas Boehler /** 81*a1a3b679SAndreas Boehler * Returns a raw mime-dir representation of the value. 82*a1a3b679SAndreas Boehler * 83*a1a3b679SAndreas Boehler * @return string 84*a1a3b679SAndreas Boehler */ 85*a1a3b679SAndreas Boehler public function getRawMimeDirValue() { 86*a1a3b679SAndreas Boehler 87*a1a3b679SAndreas Boehler if (is_array($this->value)) { 88*a1a3b679SAndreas Boehler return $this->value[0]; 89*a1a3b679SAndreas Boehler } else { 90*a1a3b679SAndreas Boehler return $this->value; 91*a1a3b679SAndreas Boehler } 92*a1a3b679SAndreas Boehler 93*a1a3b679SAndreas Boehler } 94*a1a3b679SAndreas Boehler 95*a1a3b679SAndreas Boehler} 96