PluginProbe
ActivityPub / 5.3.1
ActivityPub v5.3.1
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
activitypub / includes / activity / class-base-object.php

class-base-object.php in ActivityPub 5.3.1, at includes/activity/class-base-object.php

444 lines 10.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Inspired by the PHP ActivityPub Library by @Landrok
4 *
5 * @link https://github.com/landrok/activitypub
6 *
7 * @package Activitypub
8 */
9
10 namespace Activitypub\Activity;
11
12 /**
13 * Base_Object is an implementation of one of the
14 * Activity Streams Core Types.
15 *
16 * The Object is the primary base type for the Activity Streams
17 * vocabulary.
18 *
19 * Note: Object is a reserved keyword in PHP. It has been suffixed with
20 * 'Base_' for this reason.
21 *
22 * @see https://www.w3.org/TR/activitystreams-core/#object
23 */
24 class Base_Object extends Generic_Object {
25 /**
26 * The JSON-LD context for the object.
27 *
28 * @var array
29 */
30 const JSON_LD_CONTEXT = array(
31 'https://www.w3.org/ns/activitystreams',
32 array(
33 'Hashtag' => 'as:Hashtag',
34 'sensitive' => 'as:sensitive',
35 ),
36 );
37
38 /**
39 * The type of the object.
40 *
41 * @var string
42 */
43 protected $type = 'Object';
44
45 /**
46 * A resource attached or related to an object that potentially
47 * requires special handling.
48 * The intent is to provide a model that is at least semantically
49 * similar to attachments in email.
50 *
51 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attachment
52 *
53 * @var string|null
54 */
55 protected $attachment;
56
57 /**
58 * One or more entities to which this object is attributed.
59 * The attributed entities might not be Actors. For instance, an
60 * object might be attributed to the completion of another activity.
61 *
62 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-attributedto
63 *
64 * @var string|null
65 */
66 protected $attributed_to;
67
68 /**
69 * One or more entities that represent the total population of
70 * entities for which the object can considered to be relevant.
71 *
72 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-audience
73 *
74 * @var string|null
75 */
76 protected $audience;
77
78 /**
79 * The content or textual representation of the Object encoded as a
80 * JSON string. By default, the value of content is HTML.
81 * The mediaType property can be used in the object to indicate a
82 * different content type.
83 *
84 * The content MAY be expressed using multiple language-tagged
85 * values.
86 *
87 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content
88 *
89 * @var string|null
90 */
91 protected $content;
92
93 /**
94 * The context within which the object exists or an activity was
95 * performed.
96 * The notion of "context" used is intentionally vague.
97 * The intended function is to serve as a means of grouping objects
98 * and activities that share a common originating context or
99 * purpose. An example could be all activities relating to a common
100 * project or event.
101 *
102 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-context
103 *
104 * @var string|null
105 */
106 protected $context;
107
108 /**
109 * The content MAY be expressed using multiple language-tagged
110 * values.
111 *
112 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-content
113 *
114 * @var array|null
115 */
116 protected $content_map;
117
118 /**
119 * A simple, human-readable, plain-text name for the object.
120 * HTML markup MUST NOT be included.
121 *
122 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-name
123 *
124 * @var string|null xsd:string
125 */
126 protected $name;
127
128 /**
129 * The name MAY be expressed using multiple language-tagged values.
130 *
131 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-name
132 *
133 * @var array|null rdf:langString
134 */
135 protected $name_map;
136
137 /**
138 * The date and time describing the actual or expected ending time
139 * of the object.
140 * When used with an Activity object, for instance, the endTime
141 * property specifies the moment the activity concluded or
142 * is expected to conclude.
143 *
144 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-endtime
145 *
146 * @var string|null
147 */
148 protected $end_time;
149
150 /**
151 * The entity (e.g. an application) that generated the object.
152 *
153 * @var string|null
154 */
155 protected $generator;
156
157 /**
158 * An entity that describes an icon for this object.
159 * The image should have an aspect ratio of one (horizontal)
160 * to one (vertical) and should be suitable for presentation
161 * at a small size.
162 *
163 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-icon
164 *
165 * @var string|array|null
166 */
167 protected $icon;
168
169 /**
170 * An entity that describes an image for this object.
171 * Unlike the icon property, there are no aspect ratio
172 * or display size limitations assumed.
173 *
174 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-image-term
175 *
176 * @var string|array|null
177 */
178 protected $image;
179
180 /**
181 * One or more entities for which this object is considered a
182 * response.
183 *
184 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-inreplyto
185 *
186 * @var string|null
187 */
188 protected $in_reply_to;
189
190 /**
191 * One or more physical or logical locations associated with the
192 * object.
193 *
194 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-location
195 *
196 * @var string|null
197 */
198 protected $location;
199
200 /**
201 * An entity that provides a preview of this object.
202 *
203 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-preview
204 *
205 * @var string|null
206 */
207 protected $preview;
208
209 /**
210 * The date and time at which the object was published
211 *
212 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-published
213 *
214 * @var string|null xsd:dateTime
215 */
216 protected $published;
217
218 /**
219 * The date and time describing the actual or expected starting time
220 * of the object.
221 * When used with an Activity object, for instance, the startTime
222 * property specifies the moment the activity began
223 * or is scheduled to begin.
224 *
225 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-starttime
226 *
227 * @var string|null xsd:dateTime
228 */
229 protected $start_time;
230
231 /**
232 * A natural language summarization of the object encoded as HTML.
233 * Multiple language tagged summaries MAY be provided.
234 *
235 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary
236 *
237 * @var string|null
238 */
239 protected $summary;
240
241 /**
242 * The content MAY be expressed using multiple language-tagged
243 * values.
244 *
245 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-summary
246 *
247 * @var string[]|null
248 */
249 protected $summary_map;
250
251 /**
252 * One or more "tags" that have been associated with an objects.
253 * A tag can be any kind of Object.
254 * The key difference between attachment and tag is that the former
255 * implies association by inclusion, while the latter implies
256 * associated by reference.
257 *
258 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tag
259 *
260 * @var string|null
261 */
262 protected $tag;
263
264 /**
265 * The date and time at which the object was updated
266 *
267 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-updated
268 *
269 * @var string|null xsd:dateTime
270 */
271 protected $updated;
272
273 /**
274 * One or more links to representations of the object.
275 *
276 * @var string|null
277 */
278 protected $url;
279
280 /**
281 * An entity considered to be part of the public primary audience
282 * of an Object
283 *
284 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-to
285 *
286 * @var string|array|null
287 */
288 protected $to;
289
290 /**
291 * An Object that is part of the private primary audience of this
292 * Object.
293 *
294 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-bto
295 *
296 * @var string|array|null
297 */
298 protected $bto;
299
300 /**
301 * An Object that is part of the public secondary audience of this
302 * Object.
303 *
304 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-cc
305 *
306 * @var string|array|null
307 */
308 protected $cc;
309
310 /**
311 * One or more Objects that are part of the private secondary
312 * audience of this Object.
313 *
314 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-bcc
315 *
316 * @var string|array|null
317 */
318 protected $bcc;
319
320 /**
321 * The MIME media type of the value of the content property.
322 * If not specified, the content property is assumed to contain
323 * text/html content.
324 *
325 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-mediatype
326 *
327 * @var string|null
328 */
329 protected $media_type;
330
331 /**
332 * When the object describes a time-bound resource, such as an audio
333 * or video, a meeting, etc, the duration property indicates the
334 * object's approximate duration.
335 * The value MUST be expressed as an xsd:duration as defined by
336 * xmlschema11-2, section 3.3.6 (e.g. a period of 5 seconds is
337 * represented as "PT5S").
338 *
339 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration
340 *
341 * @var string|null
342 */
343 protected $duration;
344
345 /**
346 * Intended to convey some sort of source from which the content
347 * markup was derived, as a form of provenance, or to support
348 * future editing by clients.
349 *
350 * @see https://www.w3.org/TR/activitypub/#source-property
351 *
352 * @var array
353 */
354 protected $source;
355
356 /**
357 * A Collection containing objects considered to be responses to
358 * this object.
359 *
360 * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-replies
361 *
362 * @var string|array|null
363 */
364 protected $replies;
365
366 /**
367 * A Collection containing objects considered to be likes for
368 * this object.
369 *
370 * @see https://www.w3.org/TR/activitypub/#likes
371 *
372 * @var array
373 */
374 protected $likes;
375
376 /**
377 * A Collection containing objects considered to be shares for
378 * this object.
379 *
380 * @see https://www.w3.org/TR/activitypub/#shares
381 *
382 * @var array
383 */
384 protected $shares;
385
386 /**
387 * Used to mark an object as containing sensitive content.
388 * Mastodon displays a content warning, requiring users to click
389 * through to view the content.
390 *
391 * @see https://docs.joinmastodon.org/spec/activitypub/#sensitive
392 *
393 * @var boolean
394 */
395 protected $sensitive;
396
397 /**
398 * Generic getter.
399 *
400 * @param string $key The key to get.
401 *
402 * @return mixed The value.
403 */
404 public function get( $key ) {
405 if ( ! $this->has( $key ) ) {
406 return new \WP_Error( 'invalid_key', __( 'Invalid key', 'activitypub' ), array( 'status' => 404 ) );
407 }
408
409 return parent::get( $key );
410 }
411
412 /**
413 * Generic setter.
414 *
415 * @param string $key The key to set.
416 * @param string $value The value to set.
417 *
418 * @return mixed The value.
419 */
420 public function set( $key, $value ) {
421 if ( ! $this->has( $key ) ) {
422 return new \WP_Error( 'invalid_key', __( 'Invalid key', 'activitypub' ), array( 'status' => 404 ) );
423 }
424
425 return parent::set( $key, $value );
426 }
427
428 /**
429 * Generic adder.
430 *
431 * @param string $key The key to set.
432 * @param mixed $value The value to add.
433 *
434 * @return mixed The value.
435 */
436 public function add( $key, $value ) {
437 if ( ! $this->has( $key ) ) {
438 return new \WP_Error( 'invalid_key', __( 'Invalid key', 'activitypub' ), array( 'status' => 404 ) );
439 }
440
441 return parent::add( $key, $value );
442 }
443 }
444