fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / Feed / Writer / Extension / ITunes / Entry.php
blobc06e8a97021894f9d92caa4270fd1bc42e81365e
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Feed\Writer\Extension\ITunes;
12 use Zend\Feed\Writer;
13 use Zend\Feed\Writer\Extension;
14 use Zend\Stdlib\StringUtils;
15 use Zend\Stdlib\StringWrapper\StringWrapperInterface;
17 /**
19 class Entry
21 /**
22 * Array of Feed data for rendering by Extension's renderers
24 * @var array
26 protected $data = array();
28 /**
29 * Encoding of all text values
31 * @var string
33 protected $encoding = 'UTF-8';
35 /**
36 * The used string wrapper supporting encoding
38 * @var StringWrapperInterface
40 protected $stringWrapper;
42 public function __construct()
44 $this->stringWrapper = StringUtils::getWrapper($this->encoding);
47 /**
48 * Set feed encoding
50 * @param string $enc
51 * @return Entry
53 public function setEncoding($enc)
55 $this->stringWrapper = StringUtils::getWrapper($enc);
56 $this->encoding = $enc;
57 return $this;
60 /**
61 * Get feed encoding
63 * @return string
65 public function getEncoding()
67 return $this->encoding;
70 /**
71 * Set a block value of "yes" or "no". You may also set an empty string.
73 * @param string
74 * @return Entry
75 * @throws Writer\Exception\InvalidArgumentException
77 public function setItunesBlock($value)
79 if (!ctype_alpha($value) && strlen($value) > 0) {
80 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only'
81 . ' contain alphabetic characters');
84 if ($this->stringWrapper->strlen($value) > 255) {
85 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "block" may only'
86 . ' contain a maximum of 255 characters');
88 $this->data['block'] = $value;
91 /**
92 * Add authors to itunes entry
94 * @param array $values
95 * @return Entry
97 public function addItunesAuthors(array $values)
99 foreach ($values as $value) {
100 $this->addItunesAuthor($value);
102 return $this;
106 * Add author to itunes entry
108 * @param string $value
109 * @return Entry
110 * @throws Writer\Exception\InvalidArgumentException
112 public function addItunesAuthor($value)
114 if ($this->stringWrapper->strlen($value) > 255) {
115 throw new Writer\Exception\InvalidArgumentException('invalid parameter: any "author" may only'
116 . ' contain a maximum of 255 characters each');
118 if (!isset($this->data['authors'])) {
119 $this->data['authors'] = array();
121 $this->data['authors'][] = $value;
122 return $this;
126 * Set duration
128 * @param int $value
129 * @return Entry
130 * @throws Writer\Exception\InvalidArgumentException
132 public function setItunesDuration($value)
134 $value = (string) $value;
135 if (!ctype_digit($value)
136 && !preg_match("/^\d+:[0-5]{1}[0-9]{1}$/", $value)
137 && !preg_match("/^\d+:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$/", $value)
139 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "duration" may only'
140 . ' be of a specified [[HH:]MM:]SS format');
142 $this->data['duration'] = $value;
143 return $this;
147 * Set "explicit" flag
149 * @param bool $value
150 * @return Entry
151 * @throws Writer\Exception\InvalidArgumentException
153 public function setItunesExplicit($value)
155 if (!in_array($value, array('yes', 'no', 'clean'))) {
156 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "explicit" may only'
157 . ' be one of "yes", "no" or "clean"');
159 $this->data['explicit'] = $value;
160 return $this;
164 * Set keywords
166 * @param array $value
167 * @return Entry
168 * @throws Writer\Exception\InvalidArgumentException
170 public function setItunesKeywords(array $value)
172 if (count($value) > 12) {
173 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "keywords" may only'
174 . ' contain a maximum of 12 terms');
177 $concat = implode(',', $value);
178 if ($this->stringWrapper->strlen($concat) > 255) {
179 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "keywords" may only'
180 . ' have a concatenated length of 255 chars where terms are delimited'
181 . ' by a comma');
183 $this->data['keywords'] = $value;
184 return $this;
188 * Set subtitle
190 * @param string $value
191 * @return Entry
192 * @throws Writer\Exception\InvalidArgumentException
194 public function setItunesSubtitle($value)
196 if ($this->stringWrapper->strlen($value) > 255) {
197 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "subtitle" may only'
198 . ' contain a maximum of 255 characters');
200 $this->data['subtitle'] = $value;
201 return $this;
205 * Set summary
207 * @param string $value
208 * @return Entry
209 * @throws Writer\Exception\InvalidArgumentException
211 public function setItunesSummary($value)
213 if ($this->stringWrapper->strlen($value) > 4000) {
214 throw new Writer\Exception\InvalidArgumentException('invalid parameter: "summary" may only'
215 . ' contain a maximum of 4000 characters');
217 $this->data['summary'] = $value;
218 return $this;
222 * Overloading to itunes specific setters
224 * @param string $method
225 * @param array $params
226 * @throws Writer\Exception\BadMethodCallException
227 * @return mixed
229 public function __call($method, array $params)
231 $point = lcfirst(substr($method, 9));
232 if (!method_exists($this, 'setItunes' . ucfirst($point))
233 && !method_exists($this, 'addItunes' . ucfirst($point))
235 throw new Writer\Exception\BadMethodCallException(
236 'invalid method: ' . $method
239 if (!array_key_exists($point, $this->data)
240 || empty($this->data[$point])
242 return;
244 return $this->data[$point];