jsonactivitycollection.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. if (!defined('GNUSOCIAL')) { exit(1); }
  3. /*
  4. * Collection primarily as the root of an Activity Streams doc but can be used as the value
  5. * of extension properties in a variety of situations.
  6. *
  7. * A valid Collection object serialization MUST contain at least the url or items properties.
  8. */
  9. class JSONActivityCollection {
  10. /* Non-negative integer specifying the total number of activities within the stream */
  11. protected $totalItems;
  12. /* An array containing a listing of Objects of any object type */
  13. protected $items;
  14. /* IRI referencing a JSON document containing the full listing of objects in the collection */
  15. protected $url;
  16. /**
  17. * Constructor
  18. *
  19. * @param array $items array of activity items
  20. * @param string $url url of a doc list all the objs in the collection
  21. * @param int $totalItems total number of items in the collection
  22. */
  23. function __construct(array $items=[], $url = null)
  24. {
  25. $this->items = empty($items) ? array() : $items;
  26. $this->totalItems = count($items);
  27. $this->url = $url;
  28. }
  29. /**
  30. * Get the total number of items in the collection
  31. *
  32. * @return int total the total
  33. */
  34. public function getTotalItems()
  35. {
  36. $this->totalItems = count($items);
  37. return $this->totalItems;
  38. }
  39. }