| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 require_once 'interface.RSS.inc.php'; 3 require_once 'class.RSSBase.inc.php'; 4 /** 5 * Class for creating an RSS-feed 6 * @author Michael Wimmer <flaimo@gmail.com> 7 * @category flaimo-php 8 * @copyright Copyright © 2002-2008, Michael Wimmer 9 * @license GNU General Public License v3 10 * @link http://code.google.com/p/flaimo-php/ 11 * @package RSS 12 * @version 2.2.1 13 */ 14 class RSSBuilder extends RSSBase { 15 16 protected $rss_data = array(); 17 protected $dc_data = array(); 18 protected $sy_data = array(); 19 protected $rss_itemlist; 20 protected $filename; 21 22 protected $versions = array('0.91' => '091', '1.0' => '100', '2.0' => '200'); 23 protected $version_objects = array(); 24 25 function __construct($encoding = 'ISO-8859-1', 26 $about = '', 27 $title = '', 28 $description = '', 29 $image_link = '', 30 $category = '', 31 $cache = 60) { 32 parent::setVar($encoding, 'rss_data["encoding"]', 'string'); 33 parent::setVar($about, 'rss_data["about"]', 'string'); 34 parent::setVar($title, 'rss_data["title"]', 'string'); 35 parent::setVar($description, 'rss_data["description"]', 'string'); 36 parent::setVar($image_link, 'rss_data["image_link"]', 'string'); 37 parent::setVar($category, 'rss_data["category"]', 'string'); 38 parent::setVar($cache, 'rss_data["cache"]', 'int'); 39 $this->rss_itemlist = new RSSItemList(); 40 $this->filename = 'rss_' . str_replace(' ','_', $this->getTitle()) . '.xml'; 41 } // end constructor 42 43 public function addRSSItem($about = '', 44 $title = '', 45 $link = '', 46 $description = '', 47 $subject = '', 48 $date = 0, 49 $author = '', 50 $comments = '', 51 $image = '') { 52 $this->rss_itemlist->addRSSItem(new RSSItem($about, $title, $link, 53 $description, $subject, $date, $author, 54 $comments, $image)); 55 } // end function 56 57 public function addDCdata($publisher = '', 58 $creator = '', 59 $date = 0, 60 $language = 'en', 61 $rights = '', 62 $coverage = '', 63 $contributor = '') { 64 parent::setVar($publisher, 'dc_data["publisher"]', 'string'); 65 parent::setVar($creator, 'dc_data["creator"]', 'string'); 66 parent::setVar($date, 'dc_data["date"]', 'int'); 67 68 if (preg_match('(^([a-zA-Z]{2})$)',$language) > 0) { 69 parent::setVar($language, 'dc_data["language"]', 'string'); 70 } // end if 71 72 parent::setVar($rights, 'dc_data["rights"]', 'string'); 73 parent::setVar($coverage, 'dc_data["coverage"]', 'string'); 74 parent::setVar($contributor, 'dc_data["contributor"]', 'string'); 75 } // end function 76 77 public function addSYdata($period = 'daily', 78 $frequency = 1, 79 $base = 0) { 80 81 $periods = array('hourly','daily','weekly','monthly','yearly'); 82 if (in_array($period, $periods)) { 83 parent::setVar($period, 'sy_data["period"]', 'string'); 84 } // end if 85 86 parent::setVar($frequency, 'sy_data["frequency"]', 'int'); 87 parent::setVar($base, 'sy_data["base"]', 'int'); 88 } // end function 89 90 public function getEncoding() { 91 return parent::getVar('rss_data["encoding"]'); 92 } // end function 93 94 public function getAbout() { 95 return parent::getVar('rss_data["about"]'); 96 } // end function 97 98 public function getTitle() { 99 return parent::getVar('rss_data["title"]'); 100 } // end function 101 102 public function getDescription() { 103 return parent::getVar('rss_data["description"]'); 104 } // end function 105 106 public function getImageLink() { 107 return parent::getVar('rss_data["image_link"]'); 108 } // end function 109 110 public function getCategory() { 111 return parent::getVar('rss_data["category"]'); 112 } // end function 113 114 public function getCache() { 115 return parent::getVar('rss_data["cache"]'); 116 } // end function 117 118 119 public function getRSSItemList() { 120 return parent::getVar('rss_itemlist'); 121 } // end function 122 123 124 public function getDCPublisher() { 125 return parent::getVar('dc_data["publisher"]'); 126 } // end function 127 128 public function getDCCreator() { 129 return parent::getVar('dc_data["creator"]'); 130 } // end function 131 132 public function getDCDate() { 133 return parent::getVar('dc_data["date"]'); 134 } // end function 135 136 public function getDCLanguage() { 137 return parent::getVar('dc_data["language"]'); 138 } // end function 139 140 public function getDCRights() { 141 return parent::getVar('dc_data["rights"]'); 142 } // end function 143 144 public function getDCCoverage() { 145 return parent::getVar('dc_data["coverage"]'); 146 } // end function 147 148 public function getDCContributor() { 149 return parent::getVar('dc_data["contributor"]'); 150 } // end function 151 152 153 public function getSYPeriod() { 154 return parent::getVar('sy_data["period"]'); 155 } // end function 156 157 public function getSYFrequency() { 158 return parent::getVar('sy_data["frequency"]'); 159 } // end function 160 161 public function getSYBase() { 162 return parent::getVar('sy_data["base"]'); 163 } // end function 164 165 public function getFilename() { 166 return parent::getVar('filename'); 167 } // end function 168 169 protected function setVersionObject($version = '0.91') { 170 if (array_key_exists($version, $this->versions)) { 171 $classname = 'RSS_V_' . $this->versions[$version]; 172 $this->version_objects[$version] = new $classname($this); 173 } // end if 174 } // end function 175 176 protected function prepareRSSRequest($version = '0.91') { 177 $this->filename = $this->versions[$version] . '_' . $this->filename; 178 if (!isset($this->version_objects[$version])) { 179 $this->setVersionObject($version); 180 } // end if 181 } // end function 182 183 public function getRSSOutput($version = '0.91') { 184 $this->prepareRSSRequest($version); 185 return $this->version_objects[$version]->getRSSOutput(); 186 } // end function 187 188 public function saveRSS($version = '0.91', $path = '') { 189 $this->prepareRSSRequest($version); 190 return $this->version_objects[$version]->saveRSS($path); 191 } // end function 192 193 public function outputRSS($version = '0.91') { 194 $this->prepareRSSRequest($version); 195 return $this->version_objects[$version]->outputRSS(); 196 } // end function 197 } // end class 198 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |