summaryrefslogtreecommitdiff
path: root/framework/Xml/TRssFeedDocument.php
blob: e4c441abcb0c40604ba333a9eabc732355bdeb99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
<?php
/**
 * TRssFeedDocument, TRssFeedItem, TRssFeedTextInput, TRssFeedCloud class file
 * 
 * @author Knut Urdalen <knut.urdalen@gmail.com>
 * @link http://www.pradosoft.com
 * @copyright Copyright &copy; 2006 PradoSoft
 * @license http://www.pradosoft.com/license/
 * @package System.Xml
 */

Prado::using('System.Xml.TFeedDocument');

/**
 * TRssFeedDocument class
 * 
 * TRssFeedDocument represents an RSS feed. RSS is a family of web feed formats, specified in XML and 
 * used for Web syndication. RSS is used by (among other things) news websites, weblogs and 
 * podcasting.
 *
 * @author Knut Urdalen <knut.urdalen@gmail.com>
 * @package System.Xml
 * @since 3.1
 */
class TRssFeedDocument extends TFeedDocument {
  
  private $_rss; // reference to rss node
  private $_channel; // reference to channel node

  /**
   * Constructor
   */
  public function __construct($encoding = null) {
    parent::__construct($encoding);

    $this->formatOutput = true;

    $this->_rss = $this->createElement('rss');
    $this->_rss->setAttribute('version', '0.91');
    $this->appendChild($this->_rss);

    $this->_channel = $this->createElement('channel');
    $this->_rss->appendChild($this->_channel);
  }

  public function init() {
    
  }

  /**
   * @return RSS version
   */
  public function getVersion() {
    return $this->_rss->getAttribute('version');
  }

  /**
   * @param string $version RSS version
   */
  public function setVersion($version) {
    if($version == '0.91' or $version == '0.92' or $version == '2.0') {
      $this->_rss->setAttribute('version', $version);
    } else {
      throw new TInvalidDataTypeException('rssfeed_version_invalid', $version);
    }
  }

  /**
   * @return string The name of the channel.
   */
  public function getTitle() {
    return $this->get('title');
  }

  /**
   * The name of the channel. It's how people refer to your service. If you have an HTML 
   * website that contains the same information as your RSS file, the title of your channel 
   * should be the same as the title of your website.
   *
   * @param string $title The name of the channel.
   */
  public function setTitle($title) {
    $this->set('title', $title);
  }

  /**
   * @return string The URL to the HTML website corresponding to the channel.
   */
  public function getLink() {
    return $this->get('link');
  }

  /**
   * The URL to the HTML website corresponding to the channel.
   *
   * @param string $link The URL to the HTML website corresponding to the channel.
   */
  public function setLink($link) {
    $this->set('link', $link);
  }

  /**
   * @return string Phrase or sentence describing the channel.
   */
  public function getDescription() {
    return $this->get('description');
  }

  /**
   * @param string $description Phrase or sentence describing the channel.
   */
  public function setDescription($description) {
    $this->set('description', $description);
  }

  /**
   * @return string The language the channel is written in.
   */
  public function getLanguage() {
    return $this->get('language');
  }

  /**
   * The language the channel is written in. This allows aggregators to group all Italian 
   * language sites, for example, on a single page. A list of allowable values for this 
   * element, as provided by Netscape, is {@link http://www.rssboard.org/rss-language-codes here}. 
   * You may also use {@link http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes values defined} 
   * by the W3C.
   */
  public function setLanguage($language) {
    $this->set('language', $language);
  }

  /**
   * @return string Copyright notice for content in the channel.
   */
  public function getCopyright() {
    return $this->get('copyright');
  }
  
  /**
   * @param string Copyright notice for content in the channel.
   */
  public function setCopyright($copyright) {
    $this->set('copyright', $copyright);
  }

  /**
   * @return string Email address for person responsible for editorial content.
   */
  public function getManagingEditor() {
    return $this->get('managingEditor');
  }
  
  /**
   * @param string Email address for person responsible for editorial content.
   */
  public function setManagingEditor($managingEditor) {
    $this->set('managingEditor', $managingEditor);
  }

  /**
   * @return string Email address for person responsible for technical issues relating to channel.
   */
  public function getWebMaster() {
    return $this->get('webMaster');
  }
  
  /**
   * @param string Email address for person responsible for technical issues relating to channel.
   */
  public function setWebMaster($webMaster) {
    $this->set('webMaster', $webMaster);
  }

  /**
   * @return string The {@link http://www.w3.org/PICS/ PICS} rating for the channel.
   */
  public function getRating() {
    return $this->get('rating');
  }
  
  /**
   * @param string The {@link http://www.w3.org/PICS/ PICS} rating for the channel.
   */
  public function setRating($rating) {
    $this->set('rating', $rating);
  }

  /**
   * @return string Publication date
   */
  public function getPublicationDate() {
    return $this->get('pubDate');
  }

  /**
   * The publication date for the content in the channel. For example, the New York Times 
   * publishes on a daily basis, the publication date flips once every 24 hours. That's when 
   * the pubDate of the channel changes. All date-times in RSS conform to the Date and Time 
   * Specification of {@link http://asg.web.cmu.edu/rfc/rfc822.html RFC 822}, with the exception 
   * that the year may be expressed with two characters or four characters (four preferred).
   *
   * @param string $pubDate Publication date
   */
  public function setPublicationDate($pubDate) {
    $this->set('pubDate', $pubDate);
  }

  /**
   * @return The last time the channel was modified.
   */
  public function getLastBuildDate() {
    return $this->get('lastBuildDate');
  }

  /**
   * @param string $date The last time the channel was modified (RFC 822).
   */
  public function setLastBuildDate($date) {
    return $this->set('lastBuildDate', $date);
  }

  /**
   * @return An URL that references a description of the channel.
   */
  public function getDocumentation() {
    return $this->get('docs');
  }
  
  /**
   * A URL that points to the documentation for the format used in the RSS file. It's probably 
   * a pointer to this page. It's for people who might stumble across an RSS file on a Web 
   * server 25 years from now and wonder what it is.
   * 
   * @param string $documentation An URL that references a description of the channel.
   */
  public function setDocumentation($documentation) {
    $this->set('docs', $documentation);
  }

  /**
   * @return array The days of the week, spelled out in English.
   */
  public function getSkipDays() {
    $skipDays = $this->_channel->getElementsByTagName('skipDays')->item(0);
    $return = array();
    if($skipDays instanceof DOMElement) {
      $days = $skipDays->getElementsByTagName('day');
      foreach($days as $day) {
        $return[] = $day->nodeValue;
      }
    }
    return $return;
  }

  /**
   * @param array $days The days of the week, spelled out in English.
   */
  public function setSkipDays($days) {

    $skipDays = $this->createElement('skipDays');
    foreach($days as $day) { // Append day
      $day = $this->createElement('day', $day);
      $skipDays->appendChild($day);
    }
    
    // Add skipDays
    $node = $this->_channel->getElementsByTagName('skipDays')->item(0);
    if($node instanceof DOMElement) {
      $this->_channel->replaceChild($skipDays, $node);
    } else {
      $this->_channel->appendChild($skipDays);
    }
  }

  /**
   * @return array
   */
  public function getSkipHours() {
    $skipHours = $this->_channel->getElementsByTagName('skipHours')->item(0);
    $return = array();
    if($skipHours instanceof DOMElement) {
      $hours = $skipHours->getElementsByTagName('hour');
      foreach($hours as $hour) {
        $return[] = (int)$hour->nodeValue;
      }
    }
    return $return;    
  }

  /**
   * A list of hour's indicating the hours in the day, GMT, when the channel is unlikely to 
   * be updated. If not set, the channel is assumed to be updated hourly.
   *
   * @param array $hours
   */
  public function setSkipHours($hours) {
    
    $skipHours = $this->createElement('skipHours');
    foreach($hours as $hour) { // Append hour
      $hour = $this->createElement('hour', $hour);
      $skipHours->appendChild($hour);
    }
    
    // Add skipHours
    $node = $this->_channel->getElementsByTagName('skipHours')->item(0);
    if($node instanceof DOMElement) {
      $this->_channel->replaceChild($skipHours, $node);
    } else {
      $this->_channel->appendChild($skipHours);
    }    
  }

  /**
   *
   *
   * @param TRssFeedItem $item 
   */
  public function addItem(TRssFeedItem $item) {

    //if($this->_version == '0.91' and count($this->getItems()) <= 15) {

      $fragment = $this->createDocumentFragment();
      if($fragment->appendXML($item->toString())) {
	$this->_channel->appendChild($fragment);
      } else {
	// TODO
      }
    /*} else {
      throw new TInvalidOperationException('');
    }*/
  }

  /**
   *
   *
   * @param TRssFeedImage $image The feed accompanying icon.
   */
  public function setImage(TRssFeedImage $image) {
    $fragment = $this->createDocumentFragment();
    $fragment->appendXML($image->toString());
    $node = $this->_channel->getElementsByTagName($name)->item(0);
    if($node instanceof DOMElement) {
      $this->_channel->replaceChild($fragment, $node);
    } else {
      $this->_channel->appendChild($fragment);
    }
  }

  /**
   *
   *
   * @param TRssFeedTextInput $textInput A small text box and a Submit button to associate with a CGI application.
   */
  public function setTextInput(TRssFeedTextInput $textInput) {
    $fragment = $this->createDocumentFragment();
    $fragment->appendXML($textInput->toString());
    $node = $this->_channel->getElementsByTagName($name)->item(0);
    if($node instanceof DOMElement) {
      $this->_channel->replaceChild($fragment, $node);
    } else {
      $this->_channel->appendChild($fragment);
    }
  }

  /**
   *
   * @param TRssFeedCloud $cloud
   * @since RSS 0.92
   */
  public function setCloud(TRssFeedCloud $cloud) {
    // TODO: RSS >= 0.92
    $fragment = $this->createDocumentFragment();
    $fragment->appendXML($cloud->toString());
    $node = $this->_channel->getElementsByTagName($name)->item(0);
    if($node instanceof DOMElement) {
      $this->_channel->replaceChild($fragment, $node);
    } else {
      $this->_channel->appendChild($fragment);
    }

  }
  
  /**
   * @return array A list of TRssItem's
   */
  public function getItems() {
    $return = array();
    $elements = $this->getElementsByTagName('item');
    
    $items = new TRssFeedItemList();
    
    /*foreach($items as $item) {
      $return[] = 
    }*/
    return $return;
  }

  /**
   * @return string Category path seperated with forward slash.
   */
  public function getCategory() {
    return $this->get('category');
  }

  /**
   * Specify one or more categories that the channel belongs to.
   *
   * @param string $category Category path seperated with forward slash.
   * @param string $domain Domain name which the category applies to.
   * @since RSS 2.0
   */ 
  public function setCategory($category, $domain) {
    $newNode = $this->createElement('category', $category);
    $newNode->setAttribute('domain', $domain);
    $node = $this->_channel->getElementsByTagName($category)->item(0); 
    if($node instanceof DOMElement) {
      $this->_channel->replaceChild($newNode, $node);
    } else {
      $this->_channel->appendChild($newNode);
    }
  }
  
  /**
   * @return string A string indicating the program used to generate the channel.
   */
  public function getGenerator() {
    return $this->get('generator');
  }

  /**
   * @param string $generator A string indicating the program used to generate the channel.
   * @since RSS 2.0
   */
  public function setGenerator($generator) {
    if($this->getVersion() >= '2.0') {
      $this->set('generator', $generator);
    } else {
      throw new TInvalidDataTypeException('rssfeed_generator_unsupported');
    }
  }

  /**
   * ttl stands for time to live. It's a number of minutes that indicates how long a 
   * channel can be cached before refreshing from the source.
   *
   * @param int Number of minutes that channel can be cached.
   * @since RSS 2.0
   */
  public function setTimeToLive($ttl) {
    
  }

  /**
   * Help getter
   */
  private function get($name) {
    return $this->getElementsByTagName($name)->item(0)->nodeValue;
  }

  /**
   * Helpt setter
   */
  private function set($name, $value) {
    $newNode = $this->createElement($name, $value);
    $node = $this->_channel->getElementsByTagName($name)->item(0); 
    if($node instanceof DOMElement) {
      $this->_channel->replaceChild($newNode, $node);
    } else {
      $this->_channel->appendChild($newNode);
    }
  }

  /**
   *
   * @return string Feed as XML
   */
  public function getFeedContent() {
    return $this->saveXML();
  }
}

/**
 * TRssFeedItem class
 * 
 * An item may represent a "story" -- much like a story in a newspaper or magazine; if so its 
 * description is a synopsis of the story, and the link points to the full story. An item may 
 * also be complete in itself, if so, the description contains the text (entity-encoded HTML 
 * is allowed), and the link and title may be omitted. All elements of an item are optional, 
 * however at least one of title or description must be present. 
 *
 * @author Knut Urdalen <knut.urdalen@gmail.com>
 * @package System.Xml
 * @since 3.1
 */
class TRssFeedItem extends TFeedItem {

  
  public function __construct() {
    parent::__construct('item');
  }

  /**
   * @return string The title of the item.
   */
  public function getTitle() {
    return $this->get('title');
  }

  /**
   * @param string $title The title of the item.
   */
  public function setTitle($title) {    
    $this->set('title', $title);
  }  

  /**
   * @return string The URL of the item.
   */
  public function getLink() {
    return $this->get('link');
  }

  /**
   * @param string $link The URL of the item.
   */
  public function setLink($link) {
    $this->set('link', $link);
  }

  /**
   * @return string The item synopsis.
   */
  public function getDescription() {
    return $this->get('description');
  }

  /**
   * @param string $description The item synopsis.
   */
  public function setDescription($description) {
    $this->set('description', $description);
  }

  
  /**
   * The RSS channel that the item came from. The purpose of this property is to propagate 
   * credit for links, to publicize the sources of news items. It can be used in the Post 
   * command of an aggregator. It should be generated automatically when forwarding an item 
   * from an aggregator to a weblog authoring tool.
   *
   * @param string $source Name of source
   * @param string $url Link back to source
   * @since RSS 0.92
   */
  public function setSource($source, $url) {
    $source = $this->getElementsByTagName('source');
    if($source instanceof TXmlElement) {
      $source->setValue($source);
      $source->setAttribute('url', $url);
    } else {
      $source = new TXmlElement('source');
      $source->setValue($source);
      $source->setAttribute('url', $url);
      $this->getElements()->add($source);
    }
  }

  /**
   * Describes a media object that is attached to the item.
   * 
   * @param string $url Where the enclosure is located.
   * @param int $length Size in bytes.
   * @param string $type  MIME type
   * @since RSS 0.92
   */
  public function setEnclosure($url, $length, $type) {
    $enclosure = $this->getElementsByTagName('enclosure');
    if($enclosure instanceof TXmlElement) {
      $enclosure->setAttribute('url', $url);
      $enclosure->setAttribute('length', $length);
      $enclosure->setAttribute('type', $type);
    } else {
      $enclosure = new TXmlElement('enclosure');
      $enclosure->setAttribute('url', $url);
      $enclosure->setAttribute('length', $length);
      $enclosure->setAttribute('type', $type);
      $this->getElements()->add($enclosure);
    }
  }

  /**
   * Includes the item in one or more categories.
   * 
   * @param string $category A forward-slash-separated string that identifies a hierarchic location in the indicated taxonomy.
   * @param string $domain 
   * @since RSS 0.92
   */
  public function setCategory($category, $domain) {
    $element = $this->getElementsByTagName('category');
    if($element instanceof TXmlElement) {
      $element->setValue($category);
      $element->setAttribute('domain', $domain);
    } else {
      $element = new TXmlElement('category');
      $element->setValue($category);
      $element->setAttribute('domain', $domain);
      $this->getElements()->insertAt(count($this->getElements()), $element);
    }
  }

  /**
   * @param string $comments URL of a page for comments relating to the item.
   * @since RSS 2.0
   */
  public function setComments($comments) {
    $this->set('comments', $comments);
  }

  /**
   * @param string $author Email address of the author of the item.
   * @since RSS 2.0
   */
  public function setAuthor($author) {
    $this->set('author', $author);
  }

  /**
   * @param string $pubDate Indicates when the item was published.
   * @since RSS 2.0
   */
  public function setPublicationDate($pubDate) {
    $this->set('pubDate', $pubDate);
  }

  /**
   * guid stands for globally unique identifier. It's a string that uniquely identifies the 
   * item. When present, an aggregator may choose to use this string to determine if an item 
   * is new.
   *
   * @param string $guid A string that uniquely identifies the item.
   * @param bool $isPermaLink If its value is false, the guid may not be assumed to be a url, or a url to anything in particular.
   * @since RSS 2.0
   */
  public function setGuid($guid, $isPermaLink = true) {
    
  }
}

/**
 * TRssFeedItemList class
 *
 * @author Knut Urdalen <knut.urdalen@gmail.com>
 * @package System.Xml
 * @since 3.1
 */
class TRssFeedItemList extends TList {
  

  /*public function insertAt($index, TRssFeedItem $item) {
    
  }

  public function removeAt($index) {
    
  }*/

}

/**
 * TRssFeedImage class
 *
 * Specifies a GIF, JPEG or PNG image that can be displayed with the channel.
 *
 * @author Knut Urdalen <knut.urdalen@gmail.com>
 * @package System.Xml
 * @since 3.1
 */
class TRssFeedImage extends TFeedElement {

  public function __construct() {
    parent::__construct('image');
  }

  /**
   * @return string Title of the image.
   */
  public function getTitle() {
    return $this->get('title');
  }

  /**
   * Title describes the image, it's used in the ALT attribute of the HTML <img> tag when the 
   * channel is rendered in HTML.
   *
   * @param string $title Title of the image.
   */
  public function setTitle($title) {
    $this->set('title', $title);
  }

  /**
   * @return string URL of a GIF, JPEG or PNG image that represents the channel.
   */
  public function getUrl() {
    return $this->get('url');
  }

  /**
   * @param string $url URL of a GIF, JPEG or PNG image that represents the channel.
   */
  public function setUrl($url) {
    $this->set('url', $url);
  }

  /**
   * @return string The URL that a user is expected to click on.
   */
  public function getLink() {
    return $this->get('link');
  }

  /**
   * The URL that a user is expected to click on, as opposed to a {@link TRssFeedImage::setUrl} 
   * that is for loading a resource, such as an image.
   *
   * The link must start with either "http://" or "ftp://". All other urls are considered 
   * invalid.
   * 
   * @param string $link The URL that a user is expected to click on.
   */
  public function setLink($link) {
    if(substr($link, 0, 7) == 'http://' or substr($link, 0, 6) == 'ftp://') {
      $this->set('link', $link);
    } else {
      throw new TInvalidDataValueException('rssfeedimage_link_invalid');
    }
  }

  /**
   * @return int Width of the image in pixels.
   */
  public function getWidth() {
    return $this->get('width');
  }

  /**
   * The value must be between 1 and 144. If ommitted, the default value is 88.
   * 
   * @param int Width of the image in pixels.
   */
  public function setWidth($width) {
    if($width >= 1 and $width <= 144) {
      $this->set('width', $width);
    } else {
      throw new TInvalidDataValueException('rssfeedimage_width_invalid', 1, 144);
    }
  }

  /**
   * @return int Height of the image in pixels.
   */
  public function getHeight() {
    return $this->get('height');
  }

  /**
   * The value must be between 1 and 400. If ommitted, the default value is 31.
   *
   * @param int $height Height of the image in pixels.
   */
  public function setHeight($height) {
    if($height >= 1 and $height <= 400) {
      $this->set('height', $height);
    } else {
      throw new TInvalidDataValueException('rssfeedimage_height_invalid', 1, 400);
    }
  }
  
  /**
   * @return string A plain text description of the image.
   */
  public function getDescription() {
    return $this->get('description');
  }

  /**
   * @param string $description A plain text description of the image.
   */
  public function setDescription($description) {
    $this->set('description', $description);
  }

}

/**
 * TRssFeedTextInput class
 *
 * The purpose of the textinput element is something of a mystery. You can use it to specify 
 * a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.
 *
 * @author Knut Urdalen <knut.urdalen@gmail.com>
 * @package System.Xml
 * @since 3.1 
 */
class TRssFeedTextInput extends TFeedElement {
  
  public function __construct() {
    parent::__construct('textinput');
  }
  
  /**
   * @return string The label of the Submit button in the text input area.
   */
  public function getTitle() {
    return $this->get('title');
  }
  
  /**
   * @param string $title The label of the Submit button in the text input area.
   */
  public function setTitle($title) {
    $this->set('title', $title);
  }

  /**
   * @return string Explains the text input area.
   */
  public function getDescription() {
    return $this->get('description');
  }

  /**
   * @param string $description Explains the text input area.
   */
  public function setDescription($description) {
    $this->set('description', $description);
  }

  /**
   * @return string The name of the text object in the text input area.
   */
  public function getName() {
    return $this->get('name');
  }

  /**
   * @param string $name The name of the text object in the text input area.
   */
  public function setName($name) {
    $this->set('name', $name);
  }

  /**
   * @return string The URL of the script that processes text input requests.
   */
  public function getLink() {
    return $this->get('link');
  }

  /**
   * @param string $link The URL of the script that processes text input requests.
   */
  public function setLink($link) {
    $this->set('link', $link);
  }
}


/**
 * TRssFeedCloud class
 *
 * It specifies a web service that supports the rssCloud interface which can be 
 * implemented in HTTP-POST, XML-RPC or SOAP 1.1.
 *
 * Its purpose is to allow processes to register with a cloud to be notified of 
 * updates to the channel, implementing a lightweight publish-subscribe protocol 
 * for RSS feeds.
 *
 * @author Knut Urdalen <knut.urdalen@gmail.com>
 * @package System.Xml
 * @since 3.1
 * @link http://www.rssboard.org/rsscloud-interface RssCloud API
 */
class TRssFeedCloud extends TFeedElement {

  const PROTOCOL_HTTP_POST = 'HTTP-POST';
  const PROTOCOL_XML_RPC = 'XML-RPC';
  const PROTOCOL_SOAP = 'SOAP';

  public function __construct() {
    parent::__construct('cloud');
  }

  public function getDomain() {
    return $this->get('domain');
  }

  public function setDomain($domain) {
    $this->set('domain', $domain);
  }

  public function getPort() {
    return $this->get('port');
  }
  
  public function setPort($port) {
    $this->set('port', $port);
  }

  public function getPath() {
    return $this->get('path');
  }

  public function setPath($path) {
    $this->set('path', $path);
  }

  public function getRegisterProcedure() {
    return $this->get('registerProcedure');
  }

  public function setRegisterProcedure($registerProcedure) {
    $this->set('registerProcedure', $registerProcedure);
  }

  public function getProtocol() {
    return $this->get('protocol');
  }

  public function setProtocol($protocol) {
    if(strcasecmp($protocol, self::PROTOCOL_HTTP_POST) or
       strcasecmp($protocol, self::PROTOCOL_XML_RPC) or
       strcasecmp($protocol, self::PROTOCOL_SOAP)) {
      $this->set('protocol', $protocol);
    } else {
      throw new TInvalidDataTypeException('rssfeedcloud_protocol_invalid', $protocol);
    }
  }

  protected function get($name) {
    return $this->getAttribute($name)->nodeValue;
  }

  protected function set($name, $value) {
    $this->setAttribute($name, $value);
  }

}

?>