File indexing completed on 2024-12-22 05:36:40
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Feed_Writer 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 * @version $Id$ 0020 */ 0021 0022 // require_once 'Zend/Feed/Writer/Feed/FeedAbstract.php'; 0023 0024 /** 0025 * @category Zend 0026 * @package Zend_Feed_Writer 0027 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0028 * @license http://framework.zend.com/license/new-bsd New BSD License 0029 */ 0030 class Zend_Feed_Writer_Deleted 0031 { 0032 0033 /** 0034 * Internal array containing all data associated with this entry or item. 0035 * 0036 * @var array 0037 */ 0038 protected $_data = array(); 0039 0040 /** 0041 * Holds the value "atom" or "rss" depending on the feed type set when 0042 * when last exported. 0043 * 0044 * @var string 0045 */ 0046 protected $_type = null; 0047 0048 /** 0049 * Set the feed character encoding 0050 * 0051 * @return string|null 0052 */ 0053 public function setEncoding($encoding) 0054 { 0055 if (empty($encoding) || !is_string($encoding)) { 0056 // require_once 'Zend/Feed/Exception.php'; 0057 throw new Zend_Feed_Exception('Invalid parameter: parameter must be a non-empty string'); 0058 } 0059 $this->_data['encoding'] = $encoding; 0060 } 0061 0062 /** 0063 * Get the feed character encoding 0064 * 0065 * @return string|null 0066 */ 0067 public function getEncoding() 0068 { 0069 if (!array_key_exists('encoding', $this->_data)) { 0070 return 'UTF-8'; 0071 } 0072 return $this->_data['encoding']; 0073 } 0074 0075 /** 0076 * Unset a specific data point 0077 * 0078 * @param string $name 0079 */ 0080 public function remove($name) 0081 { 0082 if (isset($this->_data[$name])) { 0083 unset($this->_data[$name]); 0084 } 0085 } 0086 0087 /** 0088 * Set the current feed type being exported to "rss" or "atom". This allows 0089 * other objects to gracefully choose whether to execute or not, depending 0090 * on their appropriateness for the current type, e.g. renderers. 0091 * 0092 * @param string $type 0093 */ 0094 public function setType($type) 0095 { 0096 $this->_type = $type; 0097 } 0098 0099 /** 0100 * Retrieve the current or last feed type exported. 0101 * 0102 * @return string Value will be "rss" or "atom" 0103 */ 0104 public function getType() 0105 { 0106 return $this->_type; 0107 } 0108 0109 public function setReference($reference) 0110 { 0111 if (empty($reference) || !is_string($reference)) { 0112 // require_once 'Zend/Feed/Exception.php'; 0113 throw new Zend_Feed_Exception('Invalid parameter: reference must be a non-empty string'); 0114 } 0115 $this->_data['reference'] = $reference; 0116 } 0117 0118 public function getReference() 0119 { 0120 if (!array_key_exists('reference', $this->_data)) { 0121 return null; 0122 } 0123 return $this->_data['reference']; 0124 } 0125 0126 public function setWhen($date = null) 0127 { 0128 $zdate = null; 0129 if ($date === null) { 0130 $zdate = new Zend_Date; 0131 } elseif ($date instanceof Zend_Date) { 0132 $zdate = $date; 0133 } elseif (ctype_digit((string)$date)) { 0134 $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); 0135 } else { 0136 // require_once 'Zend/Feed/Exception.php'; 0137 throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); 0138 } 0139 $this->_data['when'] = $zdate; 0140 } 0141 0142 public function getWhen() 0143 { 0144 if (!array_key_exists('when', $this->_data)) { 0145 return null; 0146 } 0147 return $this->_data['when']; 0148 } 0149 0150 public function setBy(array $by) 0151 { 0152 $author = array(); 0153 if (!array_key_exists('name', $by) 0154 || empty($by['name']) 0155 || !is_string($by['name']) 0156 ) { 0157 // require_once 'Zend/Feed/Exception.php'; 0158 throw new Zend_Feed_Exception('Invalid parameter: author array must include a "name" key with a non-empty string value'); 0159 } 0160 $author['name'] = $by['name']; 0161 if (isset($by['email'])) { 0162 if (empty($by['email']) || !is_string($by['email'])) { 0163 // require_once 'Zend/Feed/Exception.php'; 0164 throw new Zend_Feed_Exception('Invalid parameter: "email" array value must be a non-empty string'); 0165 } 0166 $author['email'] = $by['email']; 0167 } 0168 if (isset($by['uri'])) { 0169 if (empty($by['uri']) 0170 || !is_string($by['uri']) 0171 || !Zend_Uri::check($by['uri']) 0172 ) { 0173 // require_once 'Zend/Feed/Exception.php'; 0174 throw new Zend_Feed_Exception('Invalid parameter: "uri" array value must be a non-empty string and valid URI/IRI'); 0175 } 0176 $author['uri'] = $by['uri']; 0177 } 0178 $this->_data['by'] = $author; 0179 } 0180 0181 public function getBy() 0182 { 0183 if (!array_key_exists('by', $this->_data)) { 0184 return null; 0185 } 0186 return $this->_data['by']; 0187 } 0188 0189 public function setComment($comment) 0190 { 0191 $this->_data['comment'] = $comment; 0192 } 0193 0194 public function getComment() 0195 { 0196 if (!array_key_exists('comment', $this->_data)) { 0197 return null; 0198 } 0199 return $this->_data['comment']; 0200 } 0201 0202 }