PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Zend/Feed/Writer/Deleted.php

https://bitbucket.org/andrewjleavitt/magestudy
PHP | 202 lines | 114 code | 18 blank | 70 comment | 24 complexity | ee4316ec5bde88ede0a4cd8183e95d6f MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-2.1, GPL-2.0, WTFPL
  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_Feed_Writer
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id: Deleted.php 22662 2010-07-24 17:37:36Z mabe $
  20. */
  21. #require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php';
  22. /**
  23. * @category Zend
  24. * @package Zend_Feed_Writer
  25. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  26. * @license http://framework.zend.com/license/new-bsd New BSD License
  27. */
  28. class Zend_Feed_Writer_Deleted
  29. {
  30. /**
  31. * Internal array containing all data associated with this entry or item.
  32. *
  33. * @var array
  34. */
  35. protected $_data = array();
  36. /**
  37. * Holds the value "atom" or "rss" depending on the feed type set when
  38. * when last exported.
  39. *
  40. * @var string
  41. */
  42. protected $_type = null;
  43. /**
  44. * Set the feed character encoding
  45. *
  46. * @return string|null
  47. */
  48. public function setEncoding($encoding)
  49. {
  50. if (empty($encoding) || !is_string($encoding)) {
  51. #require_once 'Zend/Feed/Exception.php';
  52. throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string');
  53. }
  54. $this->_data['encoding'] = $encoding;
  55. }
  56. /**
  57. * Get the feed character encoding
  58. *
  59. * @return string|null
  60. */
  61. public function getEncoding()
  62. {
  63. if (!array_key_exists('encoding', $this->_data)) {
  64. return 'UTF-8';
  65. }
  66. return $this->_data['encoding'];
  67. }
  68. /**
  69. * Unset a specific data point
  70. *
  71. * @param string $name
  72. */
  73. public function remove($name)
  74. {
  75. if (isset($this->_data[$name])) {
  76. unset($this->_data[$name]);
  77. }
  78. }
  79. /**
  80. * Set the current feed type being exported to "rss" or "atom". This allows
  81. * other objects to gracefully choose whether to execute or not, depending
  82. * on their appropriateness for the current type, e.g. renderers.
  83. *
  84. * @param string $type
  85. */
  86. public function setType($type)
  87. {
  88. $this->_type = $type;
  89. }
  90. /**
  91. * Retrieve the current or last feed type exported.
  92. *
  93. * @return string Value will be "rss" or "atom"
  94. */
  95. public function getType()
  96. {
  97. return $this->_type;
  98. }
  99. public function setReference($reference)
  100. {
  101. if (empty($reference) || !is_string($reference)) {
  102. #require_once 'Zend/Feed/Exception.php';
  103. throw new Zend_Feed_Exception('Invalid parameter: reference must be a non-empty string');
  104. }
  105. $this->_data['reference'] = $reference;
  106. }
  107. public function getReference()
  108. {
  109. if (!array_key_exists('reference', $this->_data)) {
  110. return null;
  111. }
  112. return $this->_data['reference'];
  113. }
  114. public function setWhen($date = null)
  115. {
  116. $zdate = null;
  117. if ($date === null) {
  118. $zdate = new Zend_Date;
  119. } elseif (ctype_digit($date) && strlen($date) == 10) {
  120. $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP);
  121. } elseif ($date instanceof Zend_Date) {
  122. $zdate = $date;
  123. } else {
  124. #require_once 'Zend/Feed/Exception.php';
  125. throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter');
  126. }
  127. $this->_data['when'] = $zdate;
  128. }
  129. public function getWhen()
  130. {
  131. if (!array_key_exists('when', $this->_data)) {
  132. return null;
  133. }
  134. return $this->_data['when'];
  135. }
  136. public function setBy(array $by)
  137. {
  138. $author = array();
  139. if (!array_key_exists('name', $by)
  140. || empty($by['name'])
  141. || !is_string($by['name'])
  142. ) {
  143. #require_once 'Zend/Feed/Exception.php';
  144. throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value');
  145. }
  146. $author['name'] = $by['name'];
  147. if (isset($by['email'])) {
  148. if (empty($by['email']) || !is_string($by['email'])) {
  149. #require_once 'Zend/Feed/Exception.php';
  150. throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string');
  151. }
  152. $author['email'] = $by['email'];
  153. }
  154. if (isset($by['uri'])) {
  155. if (empty($by['uri'])
  156. || !is_string($by['uri'])
  157. || !Zend_Uri::check($by['uri'])
  158. ) {
  159. #require_once 'Zend/Feed/Exception.php';
  160. throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI');
  161. }
  162. $author['uri'] = $by['uri'];
  163. }
  164. $this->_data['by'] = $author;
  165. }
  166. public function getBy()
  167. {
  168. if (!array_key_exists('by', $this->_data)) {
  169. return null;
  170. }
  171. return $this->_data['by'];
  172. }
  173. public function setComment($comment)
  174. {
  175. $this->_data['comment'] = $comment;
  176. }
  177. public function getComment()
  178. {
  179. if (!array_key_exists('comment', $this->_data)) {
  180. return null;
  181. }
  182. return $this->_data['comment'];
  183. }
  184. }