@@ -12,44 +12,41 @@ abstract class FeedCreator extends HtmlDescribable {
1212 /**
1313 * Mandatory attributes of a feed.
1414 */
15- var $ title , $ description , $ link ;
16- var $ format = 'BASE ' ;
15+ public $ title , $ description , $ link ;
16+ public $ format = 'BASE ' ;
1717
1818 /**
1919 * Optional attributes of a feed.
2020 */
21- var $ syndicationURL , $ image , $ language , $ copyright , $ pubDate , $ lastBuildDate , $ editor , $ editorEmail , $ webmaster , $ category , $ docs , $ ttl , $ rating , $ skipHours , $ skipDays ;
21+ public $ syndicationURL , $ image , $ language , $ copyright , $ pubDate , $ lastBuildDate , $ editor , $ editorEmail , $ webmaster , $ category , $ docs , $ ttl , $ rating , $ skipHours , $ skipDays ;
2222
2323 /**
2424 * The url of the external xsl stylesheet used to format the naked rss feed.
2525 * Ignored in the output when empty.
2626 */
27- var $ xslStyleSheet = "" ;
27+ public $ xslStyleSheet = "" ;
2828
2929
30- /**
31- * @access private
32- */
33- var $ items = Array ();
30+ /** @var FeedItem[] */
31+ public $ items = Array ();
3432
3533 /**
3634 * Generator string
37- *
3835 */
39- var $ generator = "info@mypapit.net " ;
36+ public $ generator = "info@mypapit.net " ;
4037
4138 /**
4239 * This feed's MIME content type.
4340 * @since 1.4
4441 * @access private
4542 */
46- var $ contentType = "application/xml " ;
43+ protected $ contentType = "application/xml " ;
4744
4845 /**
4946 * This feed's character encoding.
5047 * @since 1.6.1
5148 */
52- var $ encoding = "UTF-8 " ; //"ISO-8859-1";
49+ protected $ encoding = "UTF-8 " ; //"ISO-8859-1";
5350
5451 /**
5552 * Any additional elements to include as an associated array. All $key => $value pairs
@@ -59,19 +56,24 @@ abstract class FeedCreator extends HtmlDescribable {
5956 * if $value contains markup. This may be abused to embed tags not implemented by
6057 * the FeedCreator class used.
6158 */
62- var $ additionalElements = Array ();
59+ public $ additionalElements = Array ();
6360
6461 /**
6562 * Adds a FeedItem to the feed.
6663 *
67- * @param object FeedItem $item The FeedItem to add to the feed.
64+ * @param FeedItem $item The FeedItem to add to the feed.
6865 */
6966 public function addItem ($ item )
7067 {
7168 $ this ->items [] = $ item ;
7269 }
7370
74- function version ()
71+ /**
72+ * Get the version string for the generator
73+ *
74+ * @return string
75+ */
76+ public function version ()
7577 {
7678 return FEEDCREATOR_VERSION ." ( " .$ this ->generator .") " ;
7779 }
@@ -83,8 +85,8 @@ function version()
8385 * If the string is truncated, " ..." is appended.
8486 * If the string is already shorter than $length, it is returned unchanged.
8587 *
86- * @param string string A string to be truncated.
87- * @param int length the maximum length the string should be truncated to
88+ * @param string $ string A string to be truncated.
89+ * @param int $ length the maximum length the string should be truncated to
8890 * @return string the truncated string
8991 */
9092 public static function iTrunc ($ string , $ length ) {
@@ -119,18 +121,18 @@ public static function iTrunc($string, $length) {
119121 * The format of this comment seems to be recognized by
120122 * Syndic8.com.
121123 */
122- function _createGeneratorComment () {
124+ protected function _createGeneratorComment () {
123125 return "<!-- generator= \"" .FEEDCREATOR_VERSION ."\" --> \n" ;
124126 }
125127
126128 /**
127129 * Creates a string containing all additional elements specified in
128130 * $additionalElements.
129- * @param elements array an associative array containing key => value pairs
130- * @param indentString string a string that will be inserted before every generated line
131+ * @param array $elements an associative array containing key => value pairs
132+ * @param string $indentString a string that will be inserted before every generated line
131133 * @return string the XML tags corresponding to $additionalElements
132134 */
133- function _createAdditionalElements ($ elements , $ indentString ="" ) {
135+ protected function _createAdditionalElements ($ elements , $ indentString ="" ) {
134136 $ ae = "" ;
135137 if (is_array ($ elements )) {
136138 foreach ($ elements AS $ key => $ value ) {
@@ -140,7 +142,7 @@ function _createAdditionalElements($elements, $indentString="") {
140142 return $ ae ;
141143 }
142144
143- function _createStylesheetReferences () {
145+ protected function _createStylesheetReferences () {
144146 $ xml = "" ;
145147 if (!empty ($ this ->cssStyleSheet )) $ xml .= "<?xml-stylesheet href= \"" .$ this ->cssStyleSheet ."\" type= \"text/css \"?> \n" ;
146148 if (!empty ($ this ->xslStyleSheet )) $ xml .= "<?xml-stylesheet href= \"" .$ this ->xslStyleSheet ."\" type= \"text/xsl \"?> \n" ;
@@ -152,7 +154,7 @@ function _createStylesheetReferences() {
152154 *
153155 * @return string the feed's complete text
154156 */
155- abstract function createFeed ();
157+ abstract public function createFeed ();
156158
157159 /**
158160 * Generate a filename for the feed cache file. The result will be $_SERVER["PHP_SELF"] with the extension changed to .xml.
@@ -170,15 +172,18 @@ abstract function createFeed();
170172 * @since 1.4
171173 * @access private
172174 */
173- function _generateFilename () {
175+ protected function _generateFilename () {
174176 $ fileInfo = pathinfo ($ _SERVER ["PHP_SELF " ]);
175177 return substr ($ fileInfo ["basename " ],0 ,-(strlen ($ fileInfo ["extension " ])+1 )).".xml " ;
176178 }
177179
178180 /**
181+ * Send given file to Browser
182+ *
179183 * @since 1.4
184+ * @param string $filename
180185 */
181- private function _redirect ($ filename ) {
186+ protected function _redirect ($ filename ) {
182187 // attention, heavily-commented-out-area
183188
184189 // maybe use this in addition to file time checking
@@ -193,12 +198,12 @@ private function _redirect($filename) {
193198 //header("Location: ".$filename);
194199
195200 header ("Content-Type: " .$ this ->contentType ."; charset= " .$ this ->encoding ."; filename= " .basename ($ filename ));
196- if (preg_match (" /\.(kml|gpx)$/ " ,$ filename )) {
201+ if (preg_match (' /\.(kml|gpx)$/ ' ,$ filename )) {
197202 header ("Content-Disposition: attachment; filename= " .basename ($ filename ));
198203 } else {
199204 header ("Content-Disposition: inline; filename= " .basename ($ filename ));
200205 }
201- readfile ($ filename, " r " );
206+ readfile ($ filename );
202207 exit ();
203208 }
204209
@@ -209,10 +214,10 @@ private function _redirect($filename) {
209214 * before anything else, especially before you do the time consuming task to build the feed
210215 * (web fetching, for example).
211216 * @since 1.4
212- * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
213- * @param timeout int optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour)
217+ * @param string $filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
218+ * @param int $timeout optional the timeout in seconds before a cached version is refreshed (defaults to 3600 = 1 hour)
214219 */
215- function useCached ($ filename ="" , $ timeout =3600 ) {
220+ public function useCached ($ filename ="" , $ timeout =3600 ) {
216221 $ this ->_timeout = $ timeout ;
217222 if ($ filename =="" ) {
218223 $ filename = $ this ->_generateFilename ();
@@ -227,10 +232,10 @@ function useCached($filename="", $timeout=3600) {
227232 * header may be sent to redirect the user to the newly created file.
228233 * @since 1.4
229234 *
230- * @param filename string optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
231- * @param redirect boolean optional send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file.
235+ * @param string $filename optional the filename where a recent version of the feed is saved. If not specified, the filename is $_SERVER["PHP_SELF"] with the extension changed to .xml (see _generateFilename()).
236+ * @param bool $displayContents optional send an HTTP redirect header or not. If true, the user will be automatically redirected to the created file.
232237 */
233- function saveFeed ($ filename ="" , $ displayContents =true ) {
238+ public function saveFeed ($ filename ="" , $ displayContents =true ) {
234239 if ($ filename =="" ) {
235240 $ filename = $ this ->_generateFilename ();
236241 }
@@ -246,4 +251,3 @@ function saveFeed($filename="", $displayContents=true) {
246251 }
247252 }
248253}
249- ?>
0 commit comments