~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/Feed/Builder/Header.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Zend Framework
 
5
 *
 
6
 * LICENSE
 
7
 *
 
8
 * This source file is subject to the new BSD license that is bundled
 
9
 * with this package in the file LICENSE.txt.
 
10
 * It is also available through the world-wide-web at this URL:
 
11
 * http://framework.zend.com/license/new-bsd
 
12
 * If you did not receive a copy of the license and are unable to
 
13
 * obtain it through the world-wide-web, please send an email
 
14
 * to license@zend.com so we can send you a copy immediately.
 
15
 *
 
16
 * @category   Zend
 
17
 * @package    Zend_Feed
 
18
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
20
 * @version    $Id: Header.php 8064 2008-02-16 10:58:39Z thomas $
 
21
 */
 
22
 
 
23
 
 
24
/**
 
25
 * @see Zend_Loader
 
26
 */
 
27
require_once 'Zend/Loader.php';
 
28
 
 
29
/**
 
30
 * @see Zend_Feed_Builder_Header_Itunes
 
31
 */
 
32
require_once 'Zend/Feed/Builder/Header/Itunes.php';
 
33
 
 
34
/**
 
35
 * @see Zend_Uri
 
36
 */
 
37
require_once 'Zend/Uri.php';
 
38
 
 
39
 
 
40
/**
 
41
 * Header of a custom build feed
 
42
 *
 
43
 * Classes implementing the Zend_Feed_Builder_Interface interface
 
44
 * uses this class to describe the header of a feed
 
45
 *
 
46
 * @category   Zend
 
47
 * @package    Zend_Feed
 
48
 * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
49
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
50
 */
 
51
class Zend_Feed_Builder_Header extends ArrayObject
 
52
{
 
53
    /**
 
54
     * Constructor
 
55
     *
 
56
     * @param  string $title title of the feed
 
57
     * @param  string $link canonical url of the feed
 
58
     * @param  string $charset charset of the textual data
 
59
     * @return void
 
60
     */
 
61
    public function __construct($title, $link, $charset = 'utf-8')
 
62
    {
 
63
        $this->offsetSet('title', $title);
 
64
        $this->offsetSet('link', $link);
 
65
        $this->offsetSet('charset', $charset);
 
66
        $this->setLastUpdate(time())
 
67
             ->setGenerator('Zend_Feed');
 
68
    }
 
69
 
 
70
    /**
 
71
     * Read only properties accessor
 
72
     *
 
73
     * @param  string $name property to read
 
74
     * @return mixed
 
75
     */
 
76
    public function __get($name)
 
77
    {
 
78
        if (!$this->offsetExists($name)) {
 
79
            return NULL;
 
80
        }
 
81
 
 
82
        return $this->offsetGet($name);
 
83
    }
 
84
 
 
85
    /**
 
86
     * Write properties accessor
 
87
     *
 
88
     * @param string $name  name of the property to set
 
89
     * @param mixed  $value value to set
 
90
     * @return void
 
91
     */
 
92
    public function __set($name, $value)
 
93
    {
 
94
        $this->offsetSet($name, $value);
 
95
    }
 
96
 
 
97
    /**
 
98
     * Isset accessor
 
99
     *
 
100
     * @param  string $key
 
101
     * @return boolean
 
102
     */
 
103
    public function __isset($key)
 
104
    {
 
105
        return $this->offsetExists($key);
 
106
    }
 
107
 
 
108
    /**
 
109
     * Unset accessor
 
110
     *
 
111
     * @param  string $key
 
112
     * @return void
 
113
     */
 
114
    public function __unset($key)
 
115
    {
 
116
        if ($this->offsetExists($key)) {
 
117
            $this->offsetUnset($key);
 
118
        }
 
119
    }
 
120
 
 
121
    /**
 
122
     * Timestamp of the update date
 
123
     *
 
124
     * @param  int $lastUpdate
 
125
     * @return Zend_Feed_Builder_Header
 
126
     */
 
127
    public function setLastUpdate($lastUpdate)
 
128
    {
 
129
        $this->offsetSet('lastUpdate', $lastUpdate);
 
130
        return $this;
 
131
    }
 
132
 
 
133
    /**
 
134
     * Timestamp of the publication date
 
135
     *
 
136
     * @param  int $published
 
137
     * @return Zend_Feed_Builder_Header
 
138
     */
 
139
    public function setPublishedDate($published)
 
140
    {
 
141
        $this->offsetSet('published', $published);
 
142
        return $this;
 
143
    }
 
144
 
 
145
    /**
 
146
     * Short description of the feed
 
147
     *
 
148
     * @param  string $description
 
149
     * @return Zend_Feed_Builder_Header
 
150
     */
 
151
    public function setDescription($description)
 
152
    {
 
153
        $this->offsetSet('description', $description);
 
154
        return $this;
 
155
    }
 
156
 
 
157
    /**
 
158
     * Sets the author of the feed
 
159
     *
 
160
     * @param  string $author
 
161
     * @return Zend_Feed_Builder_Header
 
162
     */
 
163
    public function setAuthor($author)
 
164
    {
 
165
        $this->offsetSet('author', $author);
 
166
        return $this;
 
167
    }
 
168
 
 
169
    /**
 
170
     * Sets the author's email
 
171
     *
 
172
     * @param  string $email
 
173
     * @return Zend_Feed_Builder_Header
 
174
     * @throws Zend_Feed_Builder_Exception
 
175
     */
 
176
    public function setEmail($email)
 
177
    {
 
178
        Zend_Loader::loadClass('Zend_Validate_EmailAddress');
 
179
        $validate = new Zend_Validate_EmailAddress();
 
180
        if (!$validate->isValid($email)) {
 
181
            /**
 
182
             * @see Zend_Feed_Builder_Exception
 
183
             */
 
184
            require_once 'Zend/Feed/Builder/Exception.php';
 
185
            throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the email property");
 
186
        }
 
187
        $this->offsetSet('email', $email);
 
188
        return $this;
 
189
    }
 
190
 
 
191
    /**
 
192
     * Sets the copyright notice
 
193
     *
 
194
     * @param  string $copyright
 
195
     * @return Zend_Feed_Builder_Header
 
196
     */
 
197
    public function setCopyright($copyright)
 
198
    {
 
199
        $this->offsetSet('copyright', $copyright);
 
200
        return $this;
 
201
    }
 
202
 
 
203
    /**
 
204
     * Sets the image of the feed
 
205
     *
 
206
     * @param  string $image
 
207
     * @return Zend_Feed_Builder_Header
 
208
     */
 
209
    public function setImage($image)
 
210
    {
 
211
        $this->offsetSet('image', $image);
 
212
        return $this;
 
213
    }
 
214
 
 
215
    /**
 
216
     * Sets the generator of the feed
 
217
     *
 
218
     * @param  string $generator
 
219
     * @return Zend_Feed_Builder_Header
 
220
     */
 
221
    public function setGenerator($generator)
 
222
    {
 
223
        $this->offsetSet('generator', $generator);
 
224
        return $this;
 
225
    }
 
226
 
 
227
    /**
 
228
     * Sets the language of the feed
 
229
     *
 
230
     * @param  string $language
 
231
     * @return Zend_Feed_Builder_Header
 
232
     */
 
233
    public function setLanguage($language)
 
234
    {
 
235
        $this->offsetSet('language', $language);
 
236
        return $this;
 
237
    }
 
238
 
 
239
    /**
 
240
     * Email address for person responsible for technical issues
 
241
     * Ignored if atom is used
 
242
     *
 
243
     * @param  string $webmaster
 
244
     * @return Zend_Feed_Builder_Header
 
245
     * @throws Zend_Feed_Builder_Exception
 
246
     */
 
247
    public function setWebmaster($webmaster)
 
248
    {
 
249
        Zend_Loader::loadClass('Zend_Validate_EmailAddress');
 
250
        $validate = new Zend_Validate_EmailAddress();
 
251
        if (!$validate->isValid($webmaster)) {
 
252
            /**
 
253
             * @see Zend_Feed_Builder_Exception
 
254
             */
 
255
            require_once 'Zend/Feed/Builder/Exception.php';
 
256
            throw new Zend_Feed_Builder_Exception("you have to set a valid email address into the webmaster property");
 
257
        }
 
258
        $this->offsetSet('webmaster', $webmaster);
 
259
        return $this;
 
260
    }
 
261
 
 
262
    /**
 
263
     * How long in minutes a feed can be cached before refreshing
 
264
     * Ignored if atom is used
 
265
     *
 
266
     * @param  int $ttl
 
267
     * @return Zend_Feed_Builder_Header
 
268
     * @throws Zend_Feed_Builder_Exception
 
269
     */
 
270
    public function setTtl($ttl)
 
271
    {
 
272
        Zend_Loader::loadClass('Zend_Validate_Int');
 
273
        $validate = new Zend_Validate_Int();
 
274
        if (!$validate->isValid($ttl)) {
 
275
            /**
 
276
             * @see Zend_Feed_Builder_Exception
 
277
             */
 
278
            require_once 'Zend/Feed/Builder/Exception.php';
 
279
            throw new Zend_Feed_Builder_Exception("you have to set an integer value to the ttl property");
 
280
        }
 
281
        $this->offsetSet('ttl', $ttl);
 
282
        return $this;
 
283
    }
 
284
 
 
285
    /**
 
286
     * PICS rating for the feed
 
287
     * Ignored if atom is used
 
288
     *
 
289
     * @param  string $rating
 
290
     * @return Zend_Feed_Builder_Header
 
291
     */
 
292
    public function setRating($rating)
 
293
    {
 
294
        $this->offsetSet('rating', $rating);
 
295
        return $this;
 
296
    }
 
297
 
 
298
    /**
 
299
     * Cloud to be notified of updates of the feed
 
300
     * Ignored if atom is used
 
301
     *
 
302
     * @param  string|Zend_Uri_Http $uri
 
303
     * @param  string               $procedure procedure to call, e.g. myCloud.rssPleaseNotify
 
304
     * @param  string               $protocol  protocol to use, e.g. soap or xml-rpc
 
305
     * @return Zend_Feed_Builder_Header
 
306
     * @throws Zend_Feed_Builder_Exception
 
307
     */
 
308
    public function setCloud($uri, $procedure, $protocol)
 
309
    {
 
310
        if (is_string($uri) && Zend_Uri_Http::check($uri)) {
 
311
            $uri = Zend_Uri::factory($uri);
 
312
        }
 
313
        if (!$uri instanceof Zend_Uri_Http) {
 
314
            /**
 
315
             * @see Zend_Feed_Builder_Exception
 
316
             */
 
317
            require_once 'Zend/Feed/Builder/Exception.php';
 
318
            throw new Zend_Feed_Builder_Exception('Passed parameter is not a valid HTTP URI');
 
319
        }
 
320
        if (!$uri->getPort()) {
 
321
            $uri->setPort(80);
 
322
        }
 
323
        $this->offsetSet('cloud', array('uri' => $uri,
 
324
                                        'procedure' => $procedure,
 
325
                                        'protocol' => $protocol));
 
326
        return $this;
 
327
    }
 
328
 
 
329
    /**
 
330
     * A text input box that can be displayed with the feed
 
331
     * Ignored if atom is used
 
332
     *
 
333
     * @param  string $title       the label of the Submit button in the text input area
 
334
     * @param  string $description explains the text input area
 
335
     * @param  string $name        the name of the text object in the text input area
 
336
     * @param  string $link        the URL of the CGI script that processes text input requests
 
337
     * @return Zend_Feed_Builder_Header
 
338
     */
 
339
    public function setTextInput($title, $description, $name, $link)
 
340
    {
 
341
        $this->offsetSet('textInput', array('title' => $title,
 
342
                                            'description' => $description,
 
343
                                            'name' => $name,
 
344
                                            'link' => $link));
 
345
        return $this;
 
346
    }
 
347
 
 
348
    /**
 
349
     * Hint telling aggregators which hours they can skip
 
350
     * Ignored if atom is used
 
351
     *
 
352
     * @param  array $hours list of hours in 24 format
 
353
     * @return Zend_Feed_Builder_Header
 
354
     * @throws Zend_Feed_Builder_Exception
 
355
     */
 
356
    public function setSkipHours(array $hours)
 
357
    {
 
358
        if (count($hours) > 24) {
 
359
            /**
 
360
             * @see Zend_Feed_Builder_Exception
 
361
             */
 
362
            require_once 'Zend/Feed/Builder/Exception.php';
 
363
            throw new Zend_Feed_Builder_Exception("you can not have more than 24 rows in the skipHours property");
 
364
        }
 
365
        foreach ($hours as $hour) {
 
366
            if ($hour < 0 || $hour > 23) {
 
367
                /**
 
368
                 * @see Zend_Feed_Builder_Exception
 
369
                 */
 
370
                require_once 'Zend/Feed/Builder/Exception.php';
 
371
                throw new Zend_Feed_Builder_Exception("$hour has te be between 0 and 23");
 
372
            }
 
373
        }
 
374
        $this->offsetSet('skipHours', $hours);
 
375
        return $this;
 
376
    }
 
377
 
 
378
    /**
 
379
     * Hint telling aggregators which days they can skip
 
380
     * Ignored if atom is used
 
381
     *
 
382
     * @param  array $days list of days to skip, e.g. Monday
 
383
     * @return Zend_Feed_Builder_Header
 
384
     * @throws Zend_Feed_Builder_Exception
 
385
     */
 
386
    public function setSkipDays(array $days)
 
387
    {
 
388
        if (count($days) > 7) {
 
389
            /**
 
390
             * @see Zend_Feed_Builder_Exception
 
391
             */
 
392
            require_once 'Zend/Feed/Builder/Exception.php';
 
393
            throw new Zend_Feed_Builder_Exception("you can not have more than 7 days in the skipDays property");
 
394
        }
 
395
        $valid = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday');
 
396
        foreach ($days as $day) {
 
397
            if (!in_array(strtolower($day), $valid)) {
 
398
                /**
 
399
                 * @see Zend_Feed_Builder_Exception
 
400
                 */
 
401
                require_once 'Zend/Feed/Builder/Exception.php';
 
402
                throw new Zend_Feed_Builder_Exception("$day is not a valid day");
 
403
            }
 
404
        }
 
405
        $this->offsetSet('skipDays', $days);
 
406
        return $this;
 
407
    }
 
408
 
 
409
    /**
 
410
     * Sets the iTunes rss extension
 
411
     *
 
412
     * @param  Zend_Feed_Builder_Header_Itunes $itunes
 
413
     * @return Zend_Feed_Builder_Header
 
414
     */
 
415
    public function setITunes(Zend_Feed_Builder_Header_Itunes $itunes)
 
416
    {
 
417
        $this->offsetSet('itunes', $itunes);
 
418
        return $this;
 
419
    }
 
420
}