PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / sabre / vobject / lib / Document.php
ameliabooking / vendor / sabre / vobject / lib Last commit date
Component 6 months ago ITip 6 months ago Parser 6 months ago Property 6 months ago Recur 6 months ago Splitter 6 months ago TimezoneGuesser 6 months ago timezonedata 1 year ago BirthdayCalendarGenerator.php 6 months ago Cli.php 6 months ago Component.php 6 months ago DateTimeParser.php 6 months ago Document.php 6 months ago ElementList.php 6 months ago EofException.php 6 months ago FreeBusyData.php 6 months ago FreeBusyGenerator.php 6 months ago InvalidDataException.php 6 months ago Node.php 6 months ago PHPUnitAssertions.php 6 months ago Parameter.php 6 months ago ParseException.php 6 months ago Property.php 6 months ago Reader.php 6 months ago Settings.php 6 months ago StringUtil.php 6 months ago TimeZoneUtil.php 6 months ago UUIDUtil.php 6 months ago VCardConverter.php 6 months ago Version.php 6 months ago Writer.php 6 months ago
Document.php
240 lines
1 <?php
2
3 namespace AmeliaVendor\Sabre\VObject;
4
5 /**
6 * Document.
7 *
8 * A document is just like a component, except that it's also the top level
9 * element.
10 *
11 * Both a VCALENDAR and a VCARD are considered documents.
12 *
13 * This class also provides a registry for document types.
14 *
15 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
16 * @author Evert Pot (http://evertpot.com/)
17 * @license http://sabre.io/license/ Modified BSD License
18 */
19 abstract class Document extends Component
20 {
21 /**
22 * Unknown document type.
23 */
24 const UNKNOWN = 1;
25 /**
26 * vCalendar 1.0.
27 */
28 const VCALENDAR10 = 2;
29 /**
30 * iCalendar 2.0.
31 */
32 const ICALENDAR20 = 3;
33 /**
34 * vCard 2.1.
35 */
36 const VCARD21 = 4;
37 /**
38 * vCard 3.0.
39 */
40 const VCARD30 = 5;
41 /**
42 * vCard 4.0.
43 */
44 const VCARD40 = 6;
45 /**
46 * The default name for this component.
47 *
48 * This should be 'VCALENDAR' or 'VCARD'.
49 *
50 * @var string
51 */
52 public static $defaultName;
53 /**
54 * List of properties, and which classes they map to.
55 *
56 * @var array
57 */
58 public static $propertyMap = [];
59 /**
60 * List of components, along with which classes they map to.
61 *
62 * @var array
63 */
64 public static $componentMap = [];
65 /**
66 * List of value-types, and which classes they map to.
67 *
68 * @var array
69 */
70 public static $valueMap = [];
71 /**
72 * Creates a new document.
73 *
74 * We're changing the default behavior slightly here. First, we don't want
75 * to have to specify a name (we already know it), and we want to allow
76 * children to be specified in the first argument.
77 *
78 * But, the default behavior also works.
79 *
80 * So the two sigs:
81 *
82 * new Document(array $children = [], $defaults = true);
83 * new Document(string $name, array $children = [], $defaults = true)
84 */
85 public function __construct()
86 {
87 $args = func_get_args();
88 $name = static::$defaultName;
89 if (0 === count($args) || is_array($args[0])) {
90 $children = isset($args[0]) ? $args[0] : [];
91 $defaults = isset($args[1]) ? $args[1] : true;
92 } else {
93 $name = $args[0];
94 $children = isset($args[1]) ? $args[1] : [];
95 $defaults = isset($args[2]) ? $args[2] : true;
96 }
97 parent::__construct($this, $name, $children, $defaults);
98 }
99 /**
100 * Returns the current document type.
101 *
102 * @return int
103 */
104 public function getDocumentType()
105 {
106 return self::UNKNOWN;
107 }
108 /**
109 * Creates a new component or property.
110 *
111 * If it's a known component, we will automatically call createComponent.
112 * otherwise, we'll assume it's a property and call createProperty instead.
113 *
114 * @param string $name
115 * @param string $arg1,... Unlimited number of args
116 *
117 * @return mixed
118 */
119 public function create($name)
120 {
121 if (isset(static::$componentMap[strtoupper($name)])) {
122 return call_user_func_array([$this, 'createComponent'], func_get_args());
123 } else {
124 return call_user_func_array([$this, 'createProperty'], func_get_args());
125 }
126 }
127 /**
128 * Creates a new component.
129 *
130 * This method automatically searches for the correct component class, based
131 * on its name.
132 *
133 * You can specify the children either in key=>value syntax, in which case
134 * properties will automatically be created, or you can just pass a list of
135 * Component and Property object.
136 *
137 * By default, a set of sensible values will be added to the component. For
138 * an iCalendar object, this may be something like CALSCALE:GREGORIAN. To
139 * ensure that this does not happen, set $defaults to false.
140 *
141 * @param string $name
142 * @param array $children
143 * @param bool $defaults
144 *
145 * @return Component
146 */
147 public function createComponent($name, ?array $children = null, $defaults = true)
148 {
149 $name = strtoupper($name);
150 $class = Component::class;
151 if (isset(static::$componentMap[$name])) {
152 $class = static::$componentMap[$name];
153 }
154 if (is_null($children)) {
155 $children = [];
156 }
157 return new $class($this, $name, $children, $defaults);
158 }
159 /**
160 * Factory method for creating new properties.
161 *
162 * This method automatically searches for the correct property class, based
163 * on its name.
164 *
165 * You can specify the parameters either in key=>value syntax, in which case
166 * parameters will automatically be created, or you can just pass a list of
167 * Parameter objects.
168 *
169 * @param string $name
170 * @param mixed $value
171 * @param array $parameters
172 * @param string $valueType Force a specific valuetype, such as URI or TEXT
173 */
174 public function createProperty($name, $value = null, ?array $parameters = null, $valueType = null, ?int $lineIndex = null, ?string $lineString = null): Property
175 {
176 // If there's a . in the name, it means it's prefixed by a groupname.
177 if (false !== $i = strpos($name, '.')) {
178 $group = substr($name, 0, $i);
179 $name = strtoupper(substr($name, $i + 1));
180 } else {
181 $name = strtoupper($name);
182 $group = null;
183 }
184 $class = null;
185 if ($valueType) {
186 // The valueType argument comes first to figure out the correct
187 // class.
188 $class = $this->getClassNameForPropertyValue($valueType);
189 }
190 if (is_null($class)) {
191 // If a VALUE parameter is supplied, we should use that.
192 if (isset($parameters['VALUE'])) {
193 $class = $this->getClassNameForPropertyValue($parameters['VALUE']);
194 if (is_null($class)) {
195 throw new InvalidDataException('Unsupported VALUE parameter for ' . $name . ' property. You supplied "' . $parameters['VALUE'] . '"');
196 }
197 } else {
198 $class = $this->getClassNameForPropertyName($name);
199 }
200 }
201 if (is_null($parameters)) {
202 $parameters = [];
203 }
204 return new $class($this, $name, $value, $parameters, $group, $lineIndex, $lineString);
205 }
206 /**
207 * This method returns a full class-name for a value parameter.
208 *
209 * For instance, DTSTART may have VALUE=DATE. In that case we will look in
210 * our valueMap table and return the appropriate class name.
211 *
212 * This method returns null if we don't have a specialized class.
213 *
214 * @param string $valueParam
215 *
216 * @return string|null
217 */
218 public function getClassNameForPropertyValue($valueParam)
219 {
220 $valueParam = strtoupper($valueParam);
221 if (isset(static::$valueMap[$valueParam])) {
222 return static::$valueMap[$valueParam];
223 }
224 }
225 /**
226 * Returns the default class for a property name.
227 *
228 * @param string $propertyName
229 *
230 * @return string
231 */
232 public function getClassNameForPropertyName($propertyName)
233 {
234 if (isset(static::$propertyMap[$propertyName])) {
235 return static::$propertyMap[$propertyName];
236 } else {
237 return \AmeliaVendor\Sabre\VObject\Property\Unknown::class;
238 }
239 }
240 }