Cheetah
ChRSS.php
Go to the documentation of this file.
1 <?php
2 
8 class ChRSS
9 {
10  var $sXmlText;
11 
12  //mandatory
13  var $title;
14  var $link;
16 
17  //optional
18  var $language;
22  var $pubDate;
24  var $category;
26  var $docs;
27  var $cloud;
28  var $ttl;
29  var $image;
30  var $rating;
33  var $skipDays;
34 
35  //array with items
36  var $items;
37 
38  function __construct( $url )
39  {
40  $this -> items = array();
41 
42  if( $url and $this -> sXmlText = ch_file_get_contents( $url ) )
43  $this -> _doFillFromText();
44  else
45  return null;
46  }
47 
48  function _doFillFromText()
49  {
50  $vals = $ind = array();
51 
52  $xml_parser = xml_parser_create( 'UTF-8' );
53 
54  xml_parser_set_option ( $xml_parser, XML_OPTION_CASE_FOLDING, 0 );
55  xml_parser_set_option ( $xml_parser, XML_OPTION_SKIP_WHITE, 1 );
56  xml_parser_set_option ( $xml_parser, XML_OPTION_TARGET_ENCODING, 'UTF-8' );
57 
58  xml_parse_into_struct( $xml_parser, $this -> sXmlText, $vals, $ind );
59 
60  xml_parser_free( $xml_parser );
61 
62  $this -> sXmlText = '';
63 
64  //mandatory
65  $this -> title = $vals[ $ind['title'][0] ]['value'];
66  $this -> link = $vals[ $ind['link'][0] ]['value'];
67  $this -> description = $vals[ $ind['description'][0] ]['value'];
68 
69  //optional
70  if( $ind['language'] and $vals[ $ind['language'][0] ]['level'] == 3 )
71  $this -> language = $vals[ $ind['language'][0] ]['value'];
72 
73  if( $ind['copyright'] and $vals[ $ind['copyright'][0] ]['level'] == 3 )
74  $this -> copyright = $vals[ $ind['copyright'][0] ]['value'];
75 
76  if( $ind['managingEditor'] and $vals[ $ind['managingEditor'][0] ]['level'] == 3 )
77  $this -> managingEditor = $vals[ $ind['managingEditor'][0] ]['value'];
78 
79  if( $ind['webMaster'] and $vals[ $ind['webMaster'][0] ]['level'] == 3 )
80  $this -> webMaster = $vals[ $ind['webMaster'][0] ]['value'];
81 
82  if( $ind['lastBuildDate'] and $vals[ $ind['lastBuildDate'][0] ]['level'] == 3 )
83  $this -> lastBuildDate = $vals[ $ind['lastBuildDate'][0] ]['value'];
84 
85  if( $ind['generator'] and $vals[ $ind['generator'][0] ]['level'] == 3 )
86  $this -> generator = $vals[ $ind['generator'][0] ]['value'];
87 
88  if( $ind['docs'] and $vals[ $ind['docs'][0] ]['level'] == 3 )
89  $this -> docs = $vals[ $ind['docs'][0] ]['value'];
90 
91  if( $ind['cloud'] and $vals[ $ind['cloud'][0] ]['level'] == 3 )
92  $this -> cloud = $vals[ $ind['cloud'][0] ]['value'];
93 
94  if( $ind['ttl'] and $vals[ $ind['ttl'][0] ]['level'] == 3 )
95  $this -> ttl = $vals[ $ind['ttl'][0] ]['value'];
96 
97  if( $ind['image'] and $vals[ $ind['image'][0] ]['level'] == 3 )
98  $this -> image = $vals[ $ind['image'][0] ]['value'];
99 
100  if( $ind['rating'] and $vals[ $ind['rating'][0] ]['level'] == 3 )
101  $this -> rating = $vals[ $ind['rating'][0] ]['value'];
102 
103  if( $ind['textInput'] and $vals[ $ind['textInput'][0] ]['level'] == 3 )
104  $this -> textInput = $vals[ $ind['textInput'][0] ]['value'];
105 
106  if( $ind['skipHours'] and $vals[ $ind['skipHours'][0] ]['level'] == 3 )
107  $this -> skipHours = $vals[ $ind['skipHours'][0] ]['value'];
108 
109  if( $ind['skipDays'] and $vals[ $ind['skipDays'][0] ]['level'] == 3 )
110  $this -> skipDays = $vals[ $ind['skipDays'][0] ]['value'];
111 
112  if( $ind['pubDate'] and $vals[ $ind['pubDate'][0] ]['level'] == 3 )
113  $this -> pubDate = $vals[ $ind['pubDate'][0] ]['value'];
114 
115  if( $ind['category'] and $vals[ $ind['category'][0] ]['level'] == 3 )
116  $this -> category = $vals[ $ind['category'][0] ]['value'];
117 
118  //get cheetah version
119  if( $ind['cheetah'] and $vals[ $ind['cheetah'][0] ]['level'] == 3 )
120  $this -> dolVersion = $vals[ $ind['cheetah'][0] ]['value'];
121 
122  //items
123  if ($ind && $ind['item'])
124  foreach( $ind['item'] as $itemInd ) {
125  if( $vals[ $itemInd ]['type'] == 'close' )
126  continue;
127 
128  $aItem = array();
129  $aItem['category'] = array();
130 
131  while( $vals[ ++$itemInd ]['level'] == 4 ) {
132  if( $vals[ $itemInd ]['tag'] == 'category' )
133  $aItem['category'][] = $vals[ $itemInd ];
134  else
135  $aItem[ $vals[ $itemInd ]['tag'] ] = $vals[ $itemInd ];
136  }
137  $this -> items[] = new ChRSSItem( $aItem );
138  }
139  }
140 }
141 
143 {
144  var $title;
145  var $link;
147  var $author;
150  var $pubDate;
151 
152  var $guid;
154 
155  var $source;
157 
162 
163  function __construct( $aItem )
164  {
165  $this -> title = $aItem['title']['value'];
166  $this -> link = $aItem['link']['value'];
167  $this -> description = $aItem['description']['value'];
168  $this -> author = $aItem['author']['value'];
169  $this -> comments = $aItem['comments']['value'];
170  $this -> pubDate = $aItem['pubDate']['value'];
171 
172  $this -> source = $aItem['source']['value'];
173  $this -> source_url = $aItem['source']['attributes']['url'];
174 
175  $this -> enclosure = $aItem['enclosure']['value'];
176  $this -> enclosure_url = $aItem['enclosure']['attributes']['url'];
177  $this -> enclosure_length = $aItem['enclosure']['attributes']['length'];
178  $this -> enclosure_type = $aItem['enclosure']['attributes']['type'];
179 
180  $this -> guid = $aItem['guid']['value'];
181 
182  if( $aItem['guid']['attributes']['isPermaLink'] == 'false' )
183  $this -> guid_isPermaLink = false;
184  else
185  $this -> guid_isPermaLink = true; //default value is true
186 
187  $this -> category = array(); // (title => url)
188  foreach( $aItem['category'] as $category ) {
189  $this -> category[ $category['value'] ] = $category['attributes']['url'] ;
190  }
191  }
192 }
ChRSS\$ttl
$ttl
Definition: ChRSS.php:28
ChRSS\$pubDate
$pubDate
Definition: ChRSS.php:22
ChRSS\$skipDays
$skipDays
Definition: ChRSS.php:33
ChRSS\$items
$items
Definition: ChRSS.php:36
ChRSS\$image
$image
Definition: ChRSS.php:29
ChRSSItem\$enclosure_url
$enclosure_url
Definition: ChRSS.php:159
ChRSS\$language
$language
Definition: ChRSS.php:18
ChRSSItem\$author
$author
Definition: ChRSS.php:147
ChRSS\$skipHours
$skipHours
Definition: ChRSS.php:32
php
ChRSSItem\$category
$category
Definition: ChRSS.php:148
ChRSSItem
Definition: ChRSS.php:143
ChRSS\$category
$category
Definition: ChRSS.php:24
ChRSSItem\$description
$description
Definition: ChRSS.php:146
$url
URI MungeSecretKey $url
Definition: URI.MungeSecretKey.txt:14
ChRSSItem\$link
$link
Definition: ChRSS.php:145
ChRSS\$rating
$rating
Definition: ChRSS.php:30
ChRSSItem\$source_url
$source_url
Definition: ChRSS.php:156
and
and
Definition: license.txt:18
ChRSS\$docs
$docs
Definition: ChRSS.php:26
ChRSS\$link
$link
Definition: ChRSS.php:14
ChRSSItem\$comments
$comments
Definition: ChRSS.php:149
ChRSS\_doFillFromText
_doFillFromText()
Definition: ChRSS.php:48
ChRSS\$textInput
$textInput
Definition: ChRSS.php:31
ChRSS\$generator
$generator
Definition: ChRSS.php:25
ChRSSItem\$enclosure
$enclosure
Definition: ChRSS.php:158
ch_file_get_contents
ch_file_get_contents($sFileUrl, $aParams=array(), $sMethod='get', $aHeaders=array(), &$sHttpCode=null)
Definition: utils.inc.php:1357
ChRSS\$sXmlText
$sXmlText
Definition: ChRSS.php:10
ChRSSItem\$title
$title
Definition: ChRSS.php:144
ChRSSItem\$enclosure_length
$enclosure_length
Definition: ChRSS.php:160
ChRSSItem\__construct
__construct( $aItem)
Definition: ChRSS.php:163
ChRSS\$cloud
$cloud
Definition: ChRSS.php:27
ChRSS
Definition: ChRSS.php:9
ChRSSItem\$enclosure_type
$enclosure_type
Definition: ChRSS.php:161
ChRSS\$lastBuildDate
$lastBuildDate
Definition: ChRSS.php:23
ChRSS\$title
$title
Definition: ChRSS.php:13
ChRSSItem\$source
$source
Definition: ChRSS.php:155
ChRSS\__construct
__construct( $url)
Definition: ChRSS.php:38
ChRSS\$copyright
$copyright
Definition: ChRSS.php:19
image
License THE YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS Definitions Adaptation means a work based upon the or upon the Work and other pre existing such as a derivative arrangement of music or other alterations of a literary or artistic or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be or adapted including in any form recognizably derived from the except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License For the avoidance of where the Work is a musical performance or the synchronization of the Work in timed relation with a moving image("synching") will be considered an Adaptation for the purpose of this License. 2. "Collection" means a collection of literary or artistic works
ChRSS\$description
$description
Definition: ChRSS.php:15
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChRSS\$webMaster
$webMaster
Definition: ChRSS.php:21
ChRSSItem\$guid_isPermaLink
$guid_isPermaLink
Definition: ChRSS.php:153
ChRSS\$managingEditor
$managingEditor
Definition: ChRSS.php:20
ChRSSItem\$pubDate
$pubDate
Definition: ChRSS.php:150
ChRSSItem\$guid
$guid
Definition: ChRSS.php:152