2
0

Note.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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-2012 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. * @category Zend
  24. * @package Zend_Service
  25. * @subpackage Simpy
  26. * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. class Zend_Service_Simpy_Note
  30. {
  31. /**
  32. * Private access type
  33. *
  34. * @var string
  35. */
  36. const ACCESSTYPE_PRIVATE = 'private';
  37. /**
  38. * Public access type
  39. *
  40. * @var string
  41. */
  42. const ACCESSTYPE_PUBLIC = 'public';
  43. /**
  44. * Access type assigned to the note
  45. *
  46. * @var string
  47. */
  48. protected $_accessType;
  49. /**
  50. * ID of the note
  51. *
  52. * @var int
  53. */
  54. protected $_id;
  55. /**
  56. * URI of the note
  57. *
  58. * @var string
  59. */
  60. protected $_uri;
  61. /**
  62. * Date of the last modification made to the note
  63. *
  64. * @var string
  65. */
  66. protected $_modDate;
  67. /**
  68. * Date the note was added
  69. *
  70. * @var string
  71. */
  72. protected $_addDate;
  73. /**
  74. * Title of to the note
  75. *
  76. * @var string
  77. */
  78. protected $_title;
  79. /**
  80. * Tags assigned to the note
  81. *
  82. * @var array
  83. */
  84. protected $_tags;
  85. /**
  86. * Description of the note
  87. *
  88. * @var string
  89. */
  90. protected $_description;
  91. /**
  92. * Constructor to initialize the object with data
  93. *
  94. * @param DOMNode $node Individual <link> node from a parsed response from
  95. * a GetLinks operation
  96. * @return void
  97. */
  98. public function __construct($node)
  99. {
  100. $this->_accessType = $node->attributes->getNamedItem('accessType')->nodeValue;
  101. $doc = new DOMDocument();
  102. $doc->appendChild($doc->importNode($node, true));
  103. $xpath = new DOMXPath($doc);
  104. $this->_uri = $xpath->evaluate('/note/uri')->item(0)->nodeValue;
  105. $this->_id = substr($this->_uri, strrpos($this->_uri, '=') + 1);
  106. $this->_modDate = trim($xpath->evaluate('/note/modDate')->item(0)->nodeValue);
  107. $this->_addDate = trim($xpath->evaluate('/note/addDate')->item(0)->nodeValue);
  108. $this->_title = $xpath->evaluate('/note/title')->item(0)->nodeValue;
  109. $this->_description = $xpath->evaluate('/note/description')->item(0)->nodeValue;
  110. $list = $xpath->query('/note/tags/tag');
  111. $this->_tags = array();
  112. for ($x = 0; $x < $list->length; $x++) {
  113. $this->_tags[$x] = $list->item($x)->nodeValue;
  114. }
  115. }
  116. /**
  117. * Returns the access type assigned to the note
  118. *
  119. * @see ACCESSTYPE_PRIVATE
  120. * @see ACCESSTYPE_PUBLIC
  121. * @return string
  122. */
  123. public function getAccessType()
  124. {
  125. return $this->_accessType;
  126. }
  127. /**
  128. * Returns the ID of the note
  129. *
  130. * @return int
  131. */
  132. public function getId()
  133. {
  134. return $this->_id;
  135. }
  136. /**
  137. * Returns the URI of the note
  138. *
  139. * @return string
  140. */
  141. public function getUri()
  142. {
  143. return $this->_uri;
  144. }
  145. /**
  146. * Returns the date of the last modification made to the note
  147. *
  148. * @return string
  149. */
  150. public function getModDate()
  151. {
  152. return $this->_modDate;
  153. }
  154. /**
  155. * Returns the date the note was added
  156. *
  157. * @return string
  158. */
  159. public function getAddDate()
  160. {
  161. return $this->_addDate;
  162. }
  163. /**
  164. * Returns the title assigned to the note
  165. *
  166. * @return string
  167. */
  168. public function getTitle()
  169. {
  170. return $this->_title;
  171. }
  172. /**
  173. * Returns the tags assigned to the note
  174. *
  175. * @return array
  176. */
  177. public function getTags()
  178. {
  179. return $this->_tags;
  180. }
  181. /**
  182. * Returns the description assigned to the note
  183. *
  184. * @return string
  185. */
  186. public function getDescription()
  187. {
  188. return $this->_description;
  189. }
  190. }