Watchlist.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Service
  17. * @subpackage Simpy
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * @see Zend_Service_Simpy_WatchlistFilterSet
  24. */
  25. require_once 'Zend/Service/Simpy/WatchlistFilterSet.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Service
  29. * @subpackage Simpy
  30. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Service_Simpy_Watchlist
  34. {
  35. /**
  36. * Identifier for the watchlist
  37. *
  38. * @var int
  39. */
  40. protected $_id;
  41. /**
  42. * Name of the watchlist
  43. *
  44. * @var string
  45. */
  46. protected $_name;
  47. /**
  48. * Description of the watchlist
  49. *
  50. * @var string
  51. */
  52. protected $_description;
  53. /**
  54. * Timestamp for when the watchlist was added
  55. *
  56. * @var string
  57. */
  58. protected $_addDate;
  59. /**
  60. * Number of new links in the watchlist
  61. *
  62. * @var int
  63. */
  64. protected $_newLinks;
  65. /**
  66. * List of usernames for users included in the watchlist
  67. *
  68. * @var array
  69. */
  70. protected $_users;
  71. /**
  72. * List of filters included in the watchlist
  73. *
  74. * @var Zend_Service_Simpy_WatchlistFilterSet
  75. */
  76. protected $_filters;
  77. /**
  78. * Constructor to initialize the object with data
  79. *
  80. * @param DOMNode $node Individual <watchlist> node from a parsed
  81. * response from a GetWatchlists or GetWatchlist
  82. * operation
  83. * @return void
  84. */
  85. public function __construct($node)
  86. {
  87. $map =& $node->attributes;
  88. $this->_id = $map->getNamedItem('id')->nodeValue;
  89. $this->_name = $map->getNamedItem('name')->nodeValue;
  90. $this->_description = $map->getNamedItem('description')->nodeValue;
  91. $this->_addDate = $map->getNamedItem('addDate')->nodeValue;
  92. $this->_newLinks = $map->getNamedItem('newLinks')->nodeValue;
  93. $this->_users = array();
  94. $this->_filters = new Zend_Service_Simpy_WatchlistFilterSet();
  95. $childNode = $node->firstChild;
  96. while ($childNode !== null) {
  97. if ($childNode->nodeName == 'user') {
  98. $this->_users[] = $childNode->attributes->getNamedItem('username')->nodeValue;
  99. } elseif ($childNode->nodeName == 'filter') {
  100. $filter = new Zend_Service_Simpy_WatchlistFilter($childNode);
  101. $this->_filters->add($filter);
  102. }
  103. $childNode = $childNode->nextSibling;
  104. }
  105. }
  106. /**
  107. * Returns the identifier for the watchlist
  108. *
  109. * @return int
  110. */
  111. public function getId()
  112. {
  113. return $this->_id;
  114. }
  115. /**
  116. * Returns the name of the watchlist
  117. *
  118. * @return string
  119. */
  120. public function getName()
  121. {
  122. return $this->_name;
  123. }
  124. /**
  125. * Returns the description of the watchlist
  126. *
  127. * @return string
  128. */
  129. public function getDescription()
  130. {
  131. return $this->_description;
  132. }
  133. /**
  134. * Returns a timestamp for when the watchlist was added
  135. *
  136. * @return string
  137. */
  138. public function getAddDate()
  139. {
  140. return $this->_addDate;
  141. }
  142. /**
  143. * Returns the number of new links in the watchlist
  144. *
  145. * @return int
  146. */
  147. public function getNewLinks()
  148. {
  149. return $this->_newLinks;
  150. }
  151. /**
  152. * Returns a list of usernames for users included in the watchlist
  153. *
  154. * @return array
  155. */
  156. public function getUsers()
  157. {
  158. return $this->_users;
  159. }
  160. /**
  161. * Returns a list of filters included in the watchlist
  162. *
  163. * @return Zend_Service_Simpy_WatchlistFilterSet
  164. */
  165. public function getFilters()
  166. {
  167. return $this->_filters;
  168. }
  169. }