rssbuilder.class.php 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723
  1. <?php
  2. /**
  3. * @package RSSBuilder
  4. * @category FLP
  5. */
  6. /**
  7. * Abstract class for getting ini preferences
  8. *
  9. * Tested with WAMP (XP-SP1/1.3.27/4.0.12/4.3.2)
  10. * Last change: 2003-06-26
  11. *
  12. * @desc Abstract class for the RSS classes
  13. * @access protected
  14. * @author Michael Wimmer <flaimo 'at' gmx 'dot' net>
  15. * @copyright Michael Wimmer
  16. * @link http://www.flaimo.com/
  17. * @global array $GLOBALS['_TICKER_ini_settings']
  18. * @abstract
  19. * @package RSSBuilder
  20. * @category FLP
  21. * @version 1.002
  22. */
  23. class RSSBase {
  24. /*-----------------------*/
  25. /* C O N S T R U C T O R */
  26. /*-----------------------*/
  27. /**
  28. * Constructor
  29. *
  30. * @desc Constructor
  31. * @return void
  32. * @access private
  33. */
  34. function RSSBase() {
  35. } // end constructor
  36. } // end class RSSBase
  37. //---------------------------------------------------------------------------
  38. /**
  39. * Class for creating a RSS file
  40. *
  41. * Tested with WAMP (XP-SP1/1.3.27/4.0.12/4.3.2)
  42. * Last change: 2003-06-26
  43. *
  44. * @desc Class for creating a RSS file
  45. * @access public
  46. * @author Michael Wimmer <flaimo@gmx.net>
  47. * @copyright Michael Wimmer
  48. * @link http://www.flaimo.com/
  49. * @example rss_sample_script.php Sample script
  50. * @package RSSBuilder
  51. * @category FLP
  52. * @version 1.002
  53. */
  54. class RSSBuilder extends RSSBase {
  55. /*-------------------*/
  56. /* V A R I A B L E S */
  57. /*-------------------*/
  58. /**#@+
  59. * @access private
  60. * @var string
  61. */
  62. /**
  63. * encoding of the XML file
  64. *
  65. * @desc encoding of the XML file
  66. */
  67. var $encoding;
  68. /**
  69. * URL where the RSS document will be made available
  70. *
  71. * @desc URL where the RSS document will be made available
  72. */
  73. var $about;
  74. /**
  75. * title of the rss stream
  76. *
  77. * @desc title of the rss stream
  78. */
  79. var $title;
  80. /**
  81. * description of the rss stream
  82. *
  83. * @desc description of the rss stream
  84. */
  85. var $description;
  86. /**
  87. * publisher of the rss stream (person, an organization, or a service)
  88. *
  89. * @desc publisher of the rss stream
  90. */
  91. var $publisher;
  92. /**
  93. * creator of the rss stream (person, an organization, or a service)
  94. *
  95. * @desc creator of the rss stream
  96. */
  97. var $creator;
  98. /**
  99. * creation date of the file (format: 2003-05-29T00:03:07+0200)
  100. *
  101. * @desc creation date of the file (format: 2003-05-29T00:03:07+0200)
  102. */
  103. var $date;
  104. /**
  105. * iso format language
  106. *
  107. * @desc iso format language
  108. */
  109. var $language;
  110. /**
  111. * copyrights for the rss stream
  112. *
  113. * @desc copyrights for the rss stream
  114. */
  115. var $rights;
  116. /**
  117. * URL to an small image
  118. *
  119. * @desc URL to an small image
  120. */
  121. var $image_link;
  122. /**
  123. * spatial location, temporal period or jurisdiction
  124. *
  125. * spatial location (a place name or geographic coordinates), temporal
  126. * period (a period label, date, or date range) or jurisdiction (such as a
  127. * named administrative entity)
  128. *
  129. * @desc spatial location, temporal period or jurisdiction
  130. */
  131. var $coverage;
  132. /**
  133. * person, an organization, or a service
  134. *
  135. * @desc person, an organization, or a service
  136. */
  137. var $contributor;
  138. /**
  139. * 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly'
  140. *
  141. * @desc 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly'
  142. */
  143. var $period;
  144. /**
  145. * date (format: 2003-05-29T00:03:07+0200)
  146. *
  147. * Defines a base date to be used in concert with updatePeriod and
  148. * updateFrequency to calculate the publishing schedule.
  149. *
  150. * @desc base date to calculate from (format: 2003-05-29T00:03:07+0200)
  151. */
  152. var $base;
  153. /**
  154. * category (rss 2.0)
  155. *
  156. * @desc category (rss 2.0)
  157. * @since 1.001 - 2003-05-30
  158. */
  159. var $category;
  160. /**
  161. * compiled outputstring
  162. *
  163. * @desc compiled outputstring
  164. */
  165. var $output;
  166. /**#@-*/
  167. /**#@+
  168. * @access private
  169. */
  170. /**
  171. * every X hours/days/weeks/...
  172. *
  173. * @desc every X hours/days/weeks/...
  174. * @var int
  175. */
  176. var $frequency;
  177. /**
  178. * caching time in minutes (rss 2.0)
  179. *
  180. * @desc caching time in minutes (rss 2.0)
  181. * @var int
  182. * @since 1.001 - 2003-05-30
  183. */
  184. var $cache;
  185. /**
  186. * array wich all the rss items
  187. *
  188. * @desc array wich all the rss items
  189. * @var array
  190. */
  191. var $items = array();
  192. /**
  193. * use DC data
  194. *
  195. * @desc use DC data
  196. * @var boolean
  197. */
  198. var $use_dc_data = FALSE;
  199. /**
  200. * use SY data
  201. *
  202. * @desc use SY data
  203. * @var boolean
  204. */
  205. var $use_sy_data = FALSE;
  206. /**#@-*/
  207. /*-----------------------*/
  208. /* C O N S T R U C T O R */
  209. /*-----------------------*/
  210. /**#@+
  211. * @return void
  212. */
  213. /**
  214. * Constructor
  215. *
  216. * @desc Constructor
  217. * @param string $encoding encoding of the xml file
  218. * @param string $about URL where the RSS document will be made available
  219. * @param string $title
  220. * @param string $description
  221. * @param string $image_link URL
  222. * @uses setEncoding()
  223. * @uses setAbout()
  224. * @uses setTitle()
  225. * @uses setDescription()
  226. * @uses setImageLink()
  227. * @uses setCategory()
  228. * @uses etCache()
  229. * @access private
  230. */
  231. function RSSBuilder($encoding = '',
  232. $about = '',
  233. $title = '',
  234. $description = '',
  235. $image_link = '',
  236. $category = '',
  237. $cache = '') {
  238. $this->setEncoding($encoding);
  239. $this->setAbout($about);
  240. $this->setTitle($title);
  241. $this->setDescription($description);
  242. $this->setImageLink($image_link);
  243. $this->setCategory($category);
  244. $this->setCache($cache);
  245. } // end constructor
  246. /*-------------------*/
  247. /* F U N C T I O N S */
  248. /*-------------------*/
  249. /**
  250. * add additional DC data
  251. *
  252. * @desc add additional DC data
  253. * @param string $publisher person, an organization, or a service
  254. * @param string $creator person, an organization, or a service
  255. * @param string $date format: 2003-05-29T00:03:07+0200
  256. * @param string $language iso-format
  257. * @param string $rights copyright information
  258. * @param string $coverage spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity)
  259. * @param string $contributor person, an organization, or a service
  260. * @uses setPublisher()
  261. * @uses setCreator()
  262. * @uses setDate()
  263. * @uses setLanguage()
  264. * @uses setRights()
  265. * @uses setCoverage()
  266. * @uses setContributor()
  267. * @access public
  268. */
  269. function addDCdata($publisher = '',
  270. $creator = '',
  271. $date = '',
  272. $language = '',
  273. $rights = '',
  274. $coverage = '',
  275. $contributor = '') {
  276. $this->setPublisher($publisher);
  277. $this->setCreator($creator);
  278. $this->setDate($date);
  279. $this->setLanguage($language);
  280. $this->setRights($rights);
  281. $this->setCoverage($coverage);
  282. $this->setContributor($contributor);
  283. $this->use_dc_data = (boolean) TRUE;
  284. } // end function
  285. /**
  286. * add additional SY data
  287. *
  288. * @desc add additional DC data
  289. * @param string $period 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly'
  290. * @param int $frequency every x hours/days/weeks/...
  291. * @param string $base format: 2003-05-29T00:03:07+0200
  292. * @uses setPeriod()
  293. * @uses setFrequency()
  294. * @uses setBase()
  295. * @access public
  296. */
  297. function addSYdata($period = '', $frequency = '', $base = '') {
  298. $this->setPeriod($period);
  299. $this->setFrequency($frequency);
  300. $this->setBase($base);
  301. $this->use_sy_data = (boolean) TRUE;
  302. } // end function
  303. /**#@-*/
  304. /**#@+
  305. * @return void
  306. * @access private
  307. */
  308. /**
  309. * Sets $encoding variable
  310. *
  311. * @desc Sets $encoding variable
  312. * @param string $encoding encoding of the xml file
  313. * @see $encoding
  314. */
  315. function setEncoding($encoding = '') {
  316. if (!isset($this->encoding)) {
  317. $this->encoding = (string) ((strlen(trim($encoding)) > 0) ? trim($encoding) : 'UTF-8');
  318. } // end if
  319. } // end function
  320. /**
  321. * Sets $about variable
  322. *
  323. * @desc Sets $about variable
  324. * @param string $about
  325. * @see $about
  326. */
  327. function setAbout($about = '') {
  328. if (!isset($this->about) && strlen(trim($about)) > 0) {
  329. $this->about = (string) trim($about);
  330. } // end if
  331. } // end function
  332. /**
  333. * Sets $title variable
  334. *
  335. * @desc Sets $title variable
  336. * @param string $title
  337. * @see $title
  338. */
  339. function setTitle($title = '') {
  340. if (!isset($this->title) && strlen(trim($title)) > 0) {
  341. $this->title = (string) trim($title);
  342. } // end if
  343. } // end function
  344. /**
  345. * Sets $description variable
  346. *
  347. * @desc Sets $description variable
  348. * @param string $description
  349. * @see $description
  350. */
  351. function setDescription($description = '') {
  352. if (!isset($this->description) && strlen(trim($description)) > 0) {
  353. $this->description = (string) trim($description);
  354. } // end if
  355. } // end function
  356. /**
  357. * Sets $publisher variable
  358. *
  359. * @desc Sets $publisher variable
  360. * @param string $publisher
  361. * @see $publisher
  362. */
  363. function setPublisher($publisher = '') {
  364. if (!isset($this->publisher) && strlen(trim($publisher)) > 0) {
  365. $this->publisher = (string) trim($publisher);
  366. } // end if
  367. } // end function
  368. /**
  369. * Sets $creator variable
  370. *
  371. * @desc Sets $creator variable
  372. * @param string $creator
  373. * @see $creator
  374. */
  375. function setCreator($creator = '') {
  376. if (!isset($this->creator) && strlen(trim($creator)) > 0) {
  377. $this->creator = (string) trim($creator);
  378. } // end if
  379. } // end function
  380. /**
  381. * Sets $date variable
  382. *
  383. * @desc Sets $date variable
  384. * @param string $date format: 2003-05-29T00:03:07+0200
  385. * @see $date
  386. */
  387. function setDate($date = '') {
  388. if (!isset($this->date) && strlen(trim($date)) > 0) {
  389. $this->date = (string) trim($date);
  390. } // end if
  391. } // end function
  392. /**
  393. * Sets $language variable
  394. *
  395. * @desc Sets $language variable
  396. * @param string $language
  397. * @see $language
  398. * @uses isValidLanguageCode()
  399. */
  400. function setLanguage($language = '') {
  401. if (!isset($this->language) && $this->isValidLanguageCode($language) === TRUE) {
  402. $this->language = (string) trim($language);
  403. } // end if
  404. } // end function
  405. /**
  406. * Sets $rights variable
  407. *
  408. * @desc Sets $rights variable
  409. * @param string $rights
  410. * @see $rights
  411. */
  412. function setRights($rights = '') {
  413. if (!isset($this->rights) && strlen(trim($rights)) > 0) {
  414. $this->rights = (string) trim($rights);
  415. } // end if
  416. } // end function
  417. /**
  418. * Sets $coverage variable
  419. *
  420. * @desc Sets $coverage variable
  421. * @param string $coverage
  422. * @see $coverage
  423. */
  424. function setCoverage($coverage = '') {
  425. if (!isset($this->coverage) && strlen(trim($coverage)) > 0) {
  426. $this->coverage = (string) trim($coverage);
  427. } // end if
  428. } // end function
  429. /**
  430. * Sets $contributor variable
  431. *
  432. * @desc Sets $contributor variable
  433. * @param string $contributor
  434. * @see $contributor
  435. */
  436. function setContributor($contributor = '') {
  437. if (!isset($this->contributor) && strlen(trim($contributor)) > 0) {
  438. $this->contributor = (string) trim($contributor);
  439. } // end if
  440. } // end function
  441. /**
  442. * Sets $image_link variable
  443. *
  444. * @desc Sets $image_link variable
  445. * @param string $image_link
  446. * @see $image_link
  447. */
  448. function setImageLink($image_link = '') {
  449. if (!isset($this->image_link) && strlen(trim($image_link)) > 0) {
  450. $this->image_link = (string) trim($image_link);
  451. } // end if
  452. } // end function
  453. /**
  454. * Sets $period variable
  455. *
  456. * @desc Sets $period variable
  457. * @param string $period 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly'
  458. * @see $period
  459. */
  460. function setPeriod($period = '') {
  461. if (!isset($this->period) && strlen(trim($period)) > 0) {
  462. switch ($period) {
  463. case 'hourly':
  464. case 'daily':
  465. case 'weekly':
  466. case 'monthly':
  467. case 'yearly':
  468. $this->period = (string) trim($period);
  469. break;
  470. default:
  471. $this->period = (string) '';
  472. break;
  473. } // end switch
  474. } // end if
  475. } // end function
  476. /**
  477. * Sets $frequency variable
  478. *
  479. * @desc Sets $frequency variable
  480. * @param int $frequency
  481. * @see $frequency
  482. */
  483. function setFrequency($frequency = '') {
  484. if (!isset($this->frequency) && strlen(trim($frequency)) > 0) {
  485. $this->frequency = (int) $frequency;
  486. } // end if
  487. } // end function
  488. /**
  489. * Sets $base variable
  490. *
  491. * @desc Sets $base variable
  492. * @param string $base
  493. * @see $base
  494. */
  495. function setBase($base = '') {
  496. if (!isset($this->base) && strlen(trim($base)) > 0) {
  497. $this->base = (string) trim($base);
  498. } // end if
  499. } // end function
  500. /**
  501. * Sets $category variable
  502. *
  503. * @desc Sets $category variable
  504. * @param string $category
  505. * @see $category
  506. * @since 1.001 - 2003-05-30
  507. */
  508. function setCategory($category = '') {
  509. if (strlen(trim($category)) > 0) {
  510. $this->category = (string) trim($category);
  511. } // end if
  512. } // end function
  513. /**
  514. * Sets $cache variable
  515. *
  516. * @desc Sets $cache variable
  517. * @param int $cache
  518. * @see $cache
  519. * @since 1.001 - 2003-05-30
  520. */
  521. function setCache($cache = '') {
  522. if (strlen(trim($cache)) > 0) {
  523. $this->cache = (int) $cache;
  524. } // end if
  525. } // end function
  526. /**#@-*/
  527. /**#@+
  528. * @access public
  529. */
  530. /**
  531. * Checks if a given string is a valid iso-language-code
  532. *
  533. * @desc Checks if a given string is a valid iso-language-code
  534. * @param string $code String that should validated
  535. * @return boolean $isvalid If string is valid or not
  536. * @static
  537. */
  538. function isValidLanguageCode($code = '') {
  539. return (boolean) ((preg_match('(^([a-zA-Z]{2})$)',$code) > 0) ? TRUE : FALSE);
  540. } // end function
  541. /**
  542. * Returns $encoding variable
  543. *
  544. * @desc Returns $encoding variable
  545. * @return string $encoding
  546. * @see $image_link
  547. */
  548. function getEncoding() {
  549. return (string) $this->encoding;
  550. } // end function
  551. /**
  552. * Returns $about variable
  553. *
  554. * @desc Returns $about variable
  555. * @return string $about
  556. * @see $about
  557. */
  558. function getAbout() {
  559. return (string) $this->about;
  560. } // end function
  561. /**
  562. * Returns $title variable
  563. *
  564. * @desc Returns $title variable
  565. * @return string $title
  566. * @see $title
  567. */
  568. function getTitle() {
  569. return (string) $this->title;
  570. } // end function
  571. /**
  572. * Returns $description variable
  573. *
  574. * @desc Returns $description variable
  575. * @return string $description
  576. * @see $description
  577. */
  578. function getDescription() {
  579. return (string) $this->description;
  580. } // end function
  581. /**
  582. * Returns $publisher variable
  583. *
  584. * @desc Returns $publisher variable
  585. * @return string $publisher
  586. * @see $publisher
  587. */
  588. function getPublisher() {
  589. return (string) $this->publisher;
  590. } // end function
  591. /**
  592. * Returns $creator variable
  593. *
  594. * @desc Returns $creator variable
  595. * @return string $creator
  596. * @see $creator
  597. */
  598. function getCreator() {
  599. return (string) $this->creator;
  600. } // end function
  601. /**
  602. * Returns $date variable
  603. *
  604. * @desc Returns $date variable
  605. * @return string $date
  606. * @see $date
  607. */
  608. function getDate() {
  609. return (string) $this->date;
  610. } // end function
  611. /**
  612. * Returns $language variable
  613. *
  614. * @desc Returns $language variable
  615. * @return string $language
  616. * @see $language
  617. */
  618. function getLanguage() {
  619. return (string) $this->language;
  620. } // end function
  621. /**
  622. * Returns $rights variable
  623. *
  624. * @desc Returns $rights variable
  625. * @return string $rights
  626. * @see $rights
  627. */
  628. function getRights() {
  629. return (string) $this->rights;
  630. } // end function
  631. /**
  632. * Returns $coverage variable
  633. *
  634. * @desc Returns $coverage variable
  635. * @return string $coverage
  636. * @see $coverage
  637. */
  638. function getCoverage() {
  639. return (string) $this->coverage;
  640. } // end function
  641. /**
  642. * Returns $contributor variable
  643. *
  644. * @desc Returns $contributor variable
  645. * @return string $contributor
  646. * @see $contributor
  647. */
  648. function getContributor() {
  649. return (string) $this->contributor;
  650. } // end function
  651. /**
  652. * Returns $image_link variable
  653. *
  654. * @desc Returns $image_link variable
  655. * @return string $image_link
  656. * @see $image_link
  657. */
  658. function getImageLink() {
  659. return (string) $this->image_link;
  660. } // end function
  661. /**
  662. * Returns $period variable
  663. *
  664. * @desc Returns $period variable
  665. * @return string $period
  666. * @see $period
  667. */
  668. function getPeriod() {
  669. return (string) $this->period;
  670. } // end function
  671. /**
  672. * Returns $frequency variable
  673. *
  674. * @desc Returns $frequency variable
  675. * @return string $frequency
  676. * @see $frequency
  677. */
  678. function getFrequency() {
  679. return (int) $this->frequency;
  680. } // end function
  681. /**
  682. * Returns $base variable
  683. *
  684. * @desc Returns $base variable
  685. * @return string $base
  686. * @see $base
  687. */
  688. function getBase() {
  689. return (string) $this->base;
  690. } // end function
  691. /**
  692. * Returns $category variable
  693. *
  694. * @desc Returns $category variable
  695. * @return string $category
  696. * @see $category
  697. * @since 1.001 - 2003-05-30
  698. */
  699. function getCategory() {
  700. return (string) $this->category;
  701. } // end function
  702. /**
  703. * Returns $cache variable
  704. *
  705. * @desc Returns $cache variable
  706. * @return int $cache
  707. * @see $cache
  708. * @since 1.001 - 2003-05-30
  709. */
  710. function getCache() {
  711. return (int) $this->cache;
  712. } // end function
  713. /**
  714. * Adds another rss item to the object
  715. *
  716. * @desc Adds another rss item to the object
  717. * @param string $about URL
  718. * @param string $title
  719. * @param string $link URL
  720. * @param string $description (optional)
  721. * @param string $subject some sort of category (optional dc value - only shows up if DC data has been set before)
  722. * @param string $date format: 2003-05-29T00:03:07+0200 (optional dc value - only shows up if DC data has been set before)
  723. * @param string $author some sort of category author of item
  724. * @param string $comments url to comment page rss 2.0 value
  725. * @param string $image optional mod_im value for dispaying a different pic for every item
  726. * @return void
  727. * @see $items
  728. * @uses RSSItem
  729. */
  730. function addItem($about = '',
  731. $title = '',
  732. $link = '',
  733. $description = '',
  734. $subject = '',
  735. $date = '',
  736. $author = '',
  737. $comments = '',
  738. $image = '') {
  739. $item = new RSSItem($about,
  740. $title,
  741. $link,
  742. $description,
  743. $subject,
  744. $date,
  745. $author,
  746. $comments,
  747. $image);
  748. $this->items[] = $item;
  749. } // end function
  750. /**
  751. * Deletes a rss item from the array
  752. *
  753. * @desc Deletes a rss item from the array
  754. * @param int $id id of the element in the $items array
  755. * @return boolean true if item was deleted
  756. * @see $items
  757. */
  758. function deleteItem($id = -1) {
  759. if (array_key_exists($id, $this->items)) {
  760. unset($this->items[$id]);
  761. return (boolean) TRUE;
  762. } else {
  763. return (boolean) FALSE;
  764. } // end if
  765. } // end function
  766. /**
  767. * Returns an array with all the keys of the $items array
  768. *
  769. * @desc Returns an array with all the keys of the $items array
  770. * @return array array with all the keys of the $items array
  771. * @see $items
  772. */
  773. function getItemList() {
  774. return (array) array_keys($this->items);
  775. } // end function
  776. /**
  777. * Returns the $items array
  778. *
  779. * @desc Returns the $items array
  780. * @return array $items
  781. */
  782. function getItems() {
  783. return (array) $this->items;
  784. } // end function
  785. /**
  786. * Returns a single rss item by ID
  787. *
  788. * @desc Returns a single rss item by ID
  789. * @param int $id id of the element in the $items array
  790. * @return mixed RSSItem or FALSE
  791. * @see RSSItem
  792. */
  793. function getItem($id = -1) {
  794. if (array_key_exists($id, $this->items)) {
  795. return (object) $this->items[$id];
  796. } else {
  797. return (boolean) FALSE;
  798. } // end if
  799. } // end function
  800. /**#@-*/
  801. /**#@+
  802. * @return void
  803. * @access private
  804. */
  805. /**
  806. * creates the output based on the 0.91 rss version
  807. *
  808. * @desc creates the output based on the 0.91 rss version
  809. * @see $output
  810. */
  811. function createOutputV090() {
  812. // not implemented
  813. $this->createOutputV100();
  814. } // end function
  815. /**
  816. * creates the output based on the 0.91 rss version
  817. *
  818. * @desc creates the output based on the 0.91 rss version
  819. * @see $output
  820. * @since 1.001 - 2003-05-30
  821. */
  822. function createOutputV091() {
  823. $this->output = (string) '<!DOCTYPE rss SYSTEM "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n";
  824. $this->output .= (string) '<rss version="0.91">' . "\n";
  825. $this->output .= (string) '<channel>' . "\n";
  826. if (strlen($this->rights) > 0) {
  827. $this->output .= (string) '<copyright>' . $this->rights . '</copyright>' . "\n";
  828. } // end if
  829. if (strlen($this->date) > 0) {
  830. $this->output .= (string) '<pubDate>' .$this->date . '</pubDate>' . "\n";
  831. $this->output .= (string) '<lastBuildDate>' .$this->date . '</lastBuildDate>' . "\n";
  832. } // end if
  833. if (strlen($this->about) > 0) {
  834. $this->output .= (string) '<docs>' . $this->about . '</docs>' . "\n";
  835. } // end if
  836. if (strlen($this->description) > 0) {
  837. $this->output .= (string) '<description>' . $this->description . '</description>' . "\n";
  838. } // end if
  839. if (strlen($this->about) > 0) {
  840. $this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
  841. } // end if
  842. if (strlen($this->title) > 0) {
  843. $this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
  844. } // end if
  845. if (strlen($this->image_link) > 0) {
  846. $this->output .= (string) '<image>' . "\n";
  847. $this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
  848. $this->output .= (string) '<url>' . $this->image_link . '</url>' . "\n";
  849. $this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
  850. if (strlen($this->description) > 0) {
  851. $this->output .= (string) '<description>' . $this->description . '</description>' . "\n";
  852. } // end if
  853. $this->output .= (string) '</image>' . "\n";
  854. } // end if
  855. if (strlen($this->publisher) > 0) {
  856. $this->output .= (string) '<managingEditor>' . $this->publisher . '</managingEditor>' . "\n";
  857. } // end if
  858. if (strlen($this->creator) > 0) {
  859. $this->output .= (string) '<webMaster>' . $this->creator . '</webMaster>' . "\n";
  860. } // end if
  861. if (strlen($this->language) > 0) {
  862. $this->output .= (string) '<language>' . $this->language . '</language>' . "\n";
  863. } // end if
  864. if (count($this->getItemList()) > 0) {
  865. foreach ($this->getItemList() as $id) {
  866. $item =& $this->items[$id];
  867. if (strlen($item->getTitle()) > 0 && strlen($item->getLink()) > 0) {
  868. $this->output .= (string) '<item>' . "\n";
  869. $this->output .= (string) '<title>' . $item->getTitle() . '</title>' . "\n";
  870. $this->output .= (string) '<link>' . $item->getLink() . '</link>' . "\n";
  871. if (strlen($item->getDescription()) > 0) {
  872. $this->output .= (string) '<description>' . $item->getDescription() . '</description>' . "\n";
  873. } // end if
  874. $this->output .= (string) '</item>' . "\n";
  875. } // end if
  876. } // end foreach
  877. } // end if
  878. $this->output .= (string) '</channel>' . "\n";
  879. $this->output .= (string) '</rss>' . "\n";
  880. } // end function
  881. /**
  882. * creates the output based on the 1.0 rss version
  883. *
  884. * @desc creates the output based on the 1.0 rss version
  885. * @see $output
  886. */
  887. function createOutputV100() {
  888. $this->output = (string) '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:im="http://purl.org/rss/1.0/item-images/" ';
  889. if ($this->use_dc_data === TRUE) {
  890. $this->output .= (string) 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
  891. } // end if
  892. if ($this->use_sy_data === TRUE) {
  893. $this->output .= (string) 'xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" ';
  894. } // end if
  895. $this->output .= (string) 'xmlns="http://purl.org/rss/1.0/">' . "\n";
  896. if (strlen($this->about) > 0) {
  897. $this->output .= (string) '<channel rdf:about="' . $this->about . '">' . "\n";
  898. } else {
  899. $this->output .= (string) '<channel>' . "\n";
  900. } // end if
  901. if (strlen($this->title) > 0) {
  902. $this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
  903. } // end if
  904. if (strlen($this->about) > 0) {
  905. $this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
  906. } // end if
  907. if (strlen($this->description) > 0) {
  908. $this->output .= (string) '<description>' . $this->description . '</description>' . "\n";
  909. } // end if
  910. // additional dc data
  911. if (strlen($this->publisher) > 0) {
  912. $this->output .= (string) '<dc:publisher>' . $this->publisher . '</dc:publisher>' . "\n";
  913. } // end if
  914. if (strlen($this->creator) > 0) {
  915. $this->output .= (string) '<dc:creator>' . $this->creator . '</dc:creator>' . "\n";
  916. } // end if
  917. if (strlen($this->date) > 0) {
  918. $this->output .= (string) '<dc:date>' .$this->date . '</dc:date>' . "\n";
  919. } // end if
  920. if (strlen($this->language) > 0) {
  921. $this->output .= (string) '<dc:language>' . $this->language . '</dc:language>' . "\n";
  922. } // end if
  923. if (strlen($this->rights) > 0) {
  924. $this->output .= (string) '<dc:rights>' . $this->rights . '</dc:rights>' . "\n";
  925. } // end if
  926. if (strlen($this->coverage) > 0) {
  927. $this->output .= (string) '<dc:coverage>' . $this->coverage . '</dc:coverage>' . "\n";
  928. } // end if
  929. if (strlen($this->contributor) > 0) {
  930. $this->output .= (string) '<dc:contributor>' . $this->contributor . '</dc:contributor>' . "\n";
  931. } // end if
  932. // additional SY data
  933. if (strlen($this->period) > 0) {
  934. $this->output .= (string) '<sy:updatePeriod>' . $this->period . '</sy:updatePeriod>' . "\n";
  935. } // end if
  936. if (strlen($this->frequency) > 0) {
  937. $this->output .= (string) '<sy:updateFrequency>' . $this->frequency . '</sy:updateFrequency>' . "\n";
  938. } // end if
  939. if (strlen($this->base) > 0) {
  940. $this->output .= (string) '<sy:updateBase>' . $this->base . '</sy:updateBase>' . "\n";
  941. } // end if
  942. if (strlen($this->image_link) > 0) {
  943. $this->output .= (string) '<image rdf:about="' . $this->image_link . '">' . "\n";
  944. $this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
  945. $this->output .= (string) '<url>' . $this->image_link . '</url>' . "\n";
  946. $this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
  947. if (strlen($this->description) > 0) {
  948. $this->output .= (string) '<description>' . $this->description . '</description>' . "\n";
  949. } // end if
  950. $this->output .= (string) '</image>' . "\n";
  951. } // end if
  952. if (count($this->getItemList()) > 0) {
  953. $this->output .= (string) '<items><rdf:Seq>' . "\n";
  954. foreach ($this->getItemList() as $id) {
  955. $item =& $this->items[$id];
  956. if (strlen($item->getAbout()) > 0) {
  957. $this->output .= (string) ' <rdf:li resource="' . $item->getAbout() . '" />' . "\n";
  958. } // end if
  959. } // end foreach
  960. $this->output .= (string) '</rdf:Seq></items>' . "\n";
  961. } // end if
  962. $this->output .= (string) '</channel>' . "\n";
  963. if (count($this->getItemList()) > 0) {
  964. foreach ($this->getItemList() as $id) {
  965. $item =& $this->items[$id];
  966. if (strlen($item->getTitle()) > 0 && strlen($item->getLink()) > 0) {
  967. if (strlen($item->getAbout()) > 0) {
  968. $this->output .= (string) '<item rdf:about="' . $item->getAbout() . '">' . "\n";
  969. } else {
  970. $this->output .= (string) '<item>' . "\n";
  971. } // end if
  972. $this->output .= (string) '<title>' . $item->getTitle() . '</title>' . "\n";
  973. $this->output .= (string) '<link>' . $item->getLink() . '</link>' . "\n";
  974. if (strlen($item->getDescription()) > 0) {
  975. $this->output .= (string) '<description>' . $item->getDescription() . '</description>' . "\n";
  976. } // end if
  977. if ($this->use_dc_data === TRUE && strlen($item->getSubject()) > 0) {
  978. $this->output .= (string) '<dc:subject>' . $item->getSubject() . '</dc:subject>' . "\n";
  979. } // end if
  980. if ($this->use_dc_data === TRUE && strlen($item->getDate()) > 0) {
  981. $this->output .= (string) '<dc:date>' . $item->getDate() . '</dc:date>' . "\n";
  982. } // end if
  983. if (strlen($item->getImage()) > 0) {
  984. $this->output .= (string) '<im:image>' . $item->getImage() . '</im:image>' . "\n";
  985. } // end if
  986. $this->output .= (string) '</item>' . "\n";
  987. } // end if
  988. } // end foreach
  989. } // end if
  990. $this->output .= (string) '</rdf:RDF>';
  991. } // end function
  992. /**
  993. * creates the output based on the 2.0 rss draft
  994. *
  995. * @desc creates the output based on the 0.91 rss draft
  996. * @see $output
  997. * @since 1.001 - 2003-05-30
  998. */
  999. function createOutputV200() {
  1000. $this->output = (string) '<rss version="2.0" xmlns:im="http://purl.org/rss/1.0/item-images/" ';
  1001. if ($this->use_dc_data === TRUE) {
  1002. $this->output .= (string) 'xmlns:dc="http://purl.org/dc/elements/1.1/" ';
  1003. } // end if
  1004. if ($this->use_sy_data === TRUE) {
  1005. $this->output .= (string) 'xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" ';
  1006. } // end if
  1007. $this->output .= (string) '>' . "\n";
  1008. $this->output .= (string) '<channel>' . "\n";
  1009. if (strlen($this->rights) > 0) {
  1010. $this->output .= (string) '<copyright>' . $this->rights . '</copyright>' . "\n";
  1011. } // end if
  1012. if (strlen($this->date) > 0) {
  1013. $this->output .= (string) '<pubDate>' .$this->date . '</pubDate>' . "\n";
  1014. $this->output .= (string) '<lastBuildDate>' .$this->date . '</lastBuildDate>' . "\n";
  1015. } // end if
  1016. if (strlen($this->about) > 0) {
  1017. $this->output .= (string) '<docs>' . $this->about . '</docs>' . "\n";
  1018. } // end if
  1019. if (strlen($this->description) > 0) {
  1020. $this->output .= (string) '<description>' . $this->description . '</description>' . "\n";
  1021. } // end if
  1022. if (strlen($this->about) > 0) {
  1023. $this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
  1024. } // end if
  1025. if (strlen($this->title) > 0) {
  1026. $this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
  1027. } // end if
  1028. if (strlen($this->image_link) > 0) {
  1029. $this->output .= (string) '<image>' . "\n";
  1030. $this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
  1031. $this->output .= (string) '<url>' . $this->image_link . '</url>' . "\n";
  1032. $this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
  1033. if (strlen($this->description) > 0) {
  1034. $this->output .= (string) '<description>' . $this->description . '</description>' . "\n";
  1035. } // end if
  1036. $this->output .= (string) '</image>' . "\n";
  1037. } // end if
  1038. if (strlen($this->publisher) > 0) {
  1039. $this->output .= (string) '<managingEditor>' . $this->publisher . '</managingEditor>' . "\n";
  1040. } // end if
  1041. if (strlen($this->creator) > 0) {
  1042. $this->output .= (string) '<webMaster>' . $this->creator . '</webMaster>' . "\n";
  1043. $this->output .= (string) '<generator>' . $this->creator . '</generator>' . "\n";
  1044. } // end if
  1045. if (strlen($this->language) > 0) {
  1046. $this->output .= (string) '<language>' . $this->language . '</language>' . "\n";
  1047. } // end if
  1048. if (strlen($this->category) > 0) {
  1049. $this->output .= (string) '<category>' . $this->category . '</category>' . "\n";
  1050. } // end if
  1051. if (strlen($this->cache) > 0) {
  1052. $this->output .= (string) '<ttl>' . $this->cache . '</ttl>' . "\n";
  1053. } // end if
  1054. // additional dc data
  1055. if (strlen($this->publisher) > 0) {
  1056. $this->output .= (string) '<dc:publisher>' . $this->publisher . '</dc:publisher>' . "\n";
  1057. } // end if
  1058. if (strlen($this->creator) > 0) {
  1059. $this->output .= (string) '<dc:creator>' . $this->creator . '</dc:creator>' . "\n";
  1060. } // end if
  1061. if (strlen($this->date) > 0) {
  1062. $this->output .= (string) '<dc:date>' .$this->date . '</dc:date>' . "\n";
  1063. } // end if
  1064. if (strlen($this->language) > 0) {
  1065. $this->output .= (string) '<dc:language>' . $this->language . '</dc:language>' . "\n";
  1066. } // end if
  1067. if (strlen($this->rights) > 0) {
  1068. $this->output .= (string) '<dc:rights>' . $this->rights . '</dc:rights>' . "\n";
  1069. } // end if
  1070. if (strlen($this->coverage) > 0) {
  1071. $this->output .= (string) '<dc:coverage>' . $this->coverage . '</dc:coverage>' . "\n";
  1072. } // end if
  1073. if (strlen($this->contributor) > 0) {
  1074. $this->output .= (string) '<dc:contributor>' . $this->contributor . '</dc:contributor>' . "\n";
  1075. } // end if
  1076. // additional SY data
  1077. if (strlen($this->period) > 0) {
  1078. $this->output .= (string) '<sy:updatePeriod>' . $this->period . '</sy:updatePeriod>' . "\n";
  1079. } // end if
  1080. if (strlen($this->frequency) > 0) {
  1081. $this->output .= (string) '<sy:updateFrequency>' . $this->frequency . '</sy:updateFrequency>' . "\n";
  1082. } // end if
  1083. if (strlen($this->base) > 0) {
  1084. $this->output .= (string) '<sy:updateBase>' . $this->base . '</sy:updateBase>' . "\n";
  1085. } // end if
  1086. if (count($this->getItemList()) > 0) {
  1087. foreach ($this->getItemList() as $id) {
  1088. $item =& $this->items[$id];
  1089. if (strlen($item->getTitle()) > 0 && strlen($item->getLink()) > 0) {
  1090. $this->output .= (string) '<item>' . "\n";
  1091. $this->output .= (string) '<title>' . $item->getTitle() . '</title>' . "\n";
  1092. $this->output .= (string) '<link>' . $item->getLink() . '</link>' . "\n";
  1093. if (strlen($item->getDescription()) > 0) {
  1094. $this->output .= (string) '<description>' . $item->getDescription() . '</description>' . "\n";
  1095. } // end if
  1096. if ($this->use_dc_data === TRUE && strlen($item->getSubject()) > 0) {
  1097. $this->output .= (string) '<category>' . $item->getSubject() . '</category>' . "\n";
  1098. } // end if
  1099. if ($this->use_dc_data === TRUE && strlen($item->getDate()) > 0) {
  1100. $this->output .= (string) '<pubDate>' . $item->getDate() . '</pubDate>' . "\n";
  1101. } // end if
  1102. if (strlen($item->getAbout()) > 0) {
  1103. $this->output .= (string) '<guid>' . $item->getAbout() . '</guid>' . "\n";
  1104. } // end if
  1105. if (strlen($item->getAuthor()) > 0) {
  1106. $this->output .= (string) '<author>' . $item->getAuthor() . '</author>' . "\n";
  1107. } // end if
  1108. if (strlen($item->getComments()) > 0) {
  1109. $this->output .= (string) '<comments>' . $item->getComments() . '</comments>' . "\n";
  1110. } // end if
  1111. if (strlen($item->getImage()) > 0) {
  1112. $this->output .= (string) '<im:image>' . $item->getImage() . '</im:image>' . "\n";
  1113. } // end if
  1114. $this->output .= (string) '</item>' . "\n";
  1115. } // end if
  1116. } // end foreach
  1117. } // end if
  1118. $this->output .= (string) '</channel>' . "\n";
  1119. $this->output .= (string) '</rss>' . "\n";
  1120. } // end function
  1121. /**
  1122. * creates the output
  1123. *
  1124. * @desc creates the output
  1125. * @uses createOutputV090()
  1126. * @uses createOutputV091()
  1127. * @uses createOutputV200()
  1128. * @uses createOutputV100()
  1129. */
  1130. function createOutput($version = '') {
  1131. if (strlen(trim($version)) === 0) {
  1132. $version = (string) '1.0';
  1133. } // end if
  1134. switch ($version) {
  1135. case '0.9':
  1136. $this->createOutputV090();
  1137. break;
  1138. case '0.91':
  1139. $this->createOutputV091();
  1140. break;
  1141. case '2.00':
  1142. $this->createOutputV200();
  1143. break;
  1144. case '1.0':
  1145. default:
  1146. $this->createOutputV100();
  1147. break;
  1148. } // end switch
  1149. } // end function
  1150. /**#@-*/
  1151. /**#@+
  1152. * @return void
  1153. * @access public
  1154. * @uses createOutput()
  1155. */
  1156. /**
  1157. * echos the output
  1158. *
  1159. * use this function if you want to directly output the rss stream
  1160. *
  1161. * @desc echos the output
  1162. */
  1163. function outputRSS($version = '') {
  1164. if (!isset($this->output)) {
  1165. $this->createOutput($version);
  1166. } // end if
  1167. header ('content-type: text/xml');
  1168. header('Content-Disposition: inline; filename=rss_' . str_replace(' ','',$this->title) . '.xml');
  1169. $this->output = '<?xml version="1.0" encoding="' . $this->encoding . '"?>' . "\n" .
  1170. '<!-- RSS generated by phpcms.cn RSS Builder [' . date('Y-m-d H:i:s') .'] --> '. "\n" . $this->output;
  1171. echo $this->output;
  1172. } // end function
  1173. /**
  1174. * returns the output
  1175. *
  1176. * use this function if you want to have the output stream as a string (for example to write it in a cache file)
  1177. *
  1178. * @desc returns the output
  1179. */
  1180. function getRSSOutput($version = '') {
  1181. if (!isset($this->output)) {
  1182. $this->createOutput($version);
  1183. } // end if
  1184. return (string) '<?xml version="1.0" encoding="' . $this->encoding . '"?>' . "\n" .
  1185. '<!-- RSS generated by phpcms.cn RSS Builder [' . date('Y-m-d H:i:s') .'] --> ' . $this->output;
  1186. } // end function
  1187. /**#@-*/
  1188. } // end class RSSBuilder
  1189. //---------------------------------------------------------------------------
  1190. /**
  1191. * single rss item object
  1192. *
  1193. * Tested with WAMP (XP-SP1/1.3.27/4.0.12/4.3.2)
  1194. * Last change: 2003-06-26
  1195. *
  1196. * @desc single rss item object
  1197. * @access private
  1198. * @author Michael Wimmer <flaimo@gmx.net>
  1199. * @copyright Michael Wimmer
  1200. * @link http://www.flaimo.com/
  1201. * @package RSSBuilder
  1202. * @category FLP
  1203. * @version 1.002
  1204. */
  1205. class RSSItem extends RSSBase {
  1206. /*-------------------*/
  1207. /* V A R I A B L E S */
  1208. /*-------------------*/
  1209. /**#@+
  1210. * @access private
  1211. * @var string
  1212. */
  1213. /**
  1214. * URL
  1215. *
  1216. * @desc URL
  1217. */
  1218. var $about;
  1219. /**
  1220. * headline
  1221. *
  1222. * @desc headline
  1223. */
  1224. var $title;
  1225. /**
  1226. * URL to the full item
  1227. *
  1228. * @desc URL to the full item
  1229. */
  1230. var $link;
  1231. /**
  1232. * optional description
  1233. *
  1234. * @desc optional description
  1235. */
  1236. var $description;
  1237. /**
  1238. * optional subject (category)
  1239. *
  1240. * @desc optional subject (category)
  1241. */
  1242. var $subject;
  1243. /**
  1244. * optional date
  1245. *
  1246. * @desc optional date
  1247. */
  1248. var $date;
  1249. /**
  1250. * author of item
  1251. *
  1252. * @desc author of item
  1253. * @since 1.001 - 2003-05-30
  1254. */
  1255. var $author;
  1256. /**
  1257. * url to comments page (rss 2.0)
  1258. *
  1259. * @desc url to comments page (rss 2.0)
  1260. * @since 1.001 - 2003-05-30
  1261. */
  1262. var $comments;
  1263. /**
  1264. * imagelink for this item (mod_im only)
  1265. *
  1266. * @desc imagelink for this item (mod_im only)
  1267. * @since 1.002 - 2003-06-26
  1268. */
  1269. var $image;
  1270. /**#@-*/
  1271. /*-----------------------*/
  1272. /* C O N S T R U C T O R */
  1273. /*-----------------------*/
  1274. /**#@+
  1275. * @access private
  1276. * @return void
  1277. */
  1278. /**
  1279. * Constructor
  1280. *
  1281. * @desc Constructor
  1282. * @param string $about URL
  1283. * @param string $title
  1284. * @param string $link URL
  1285. * @param string $description (optional)
  1286. * @param string $subject some sort of category (optional)
  1287. * @param string $date format: 2003-05-29T00:03:07+0200 (optional)
  1288. * @param string $author some sort of category author of item
  1289. * @param string $comments url to comment page rss 2.0 value
  1290. * @param string $image optional mod_im value for dispaying a different pic for every item
  1291. * @uses setAbout()
  1292. * @uses setTitle()
  1293. * @uses setLink()
  1294. * @uses setDescription()
  1295. * @uses setSubject()
  1296. * @uses setDate()
  1297. * @uses setAuthor()
  1298. * @uses setComments()
  1299. * @uses setImage()
  1300. */
  1301. function RSSItem($about = '',
  1302. $title = '',
  1303. $link = '',
  1304. $description = '',
  1305. $subject = '',
  1306. $date = '',
  1307. $author = '',
  1308. $comments = '',
  1309. $image = '') {
  1310. $this->setAbout($about);
  1311. $this->setTitle($title);
  1312. $this->setLink($link);
  1313. $this->setDescription($description);
  1314. $this->setSubject($subject);
  1315. $this->setDate($date);
  1316. $this->setAuthor($author);
  1317. $this->setComments($comments);
  1318. $this->setImage($image);
  1319. } // end constructor
  1320. /**
  1321. * Sets $about variable
  1322. *
  1323. * @desc Sets $about variable
  1324. * @param string $about
  1325. * @see $about
  1326. */
  1327. function setAbout($about = '') {
  1328. if (!isset($this->about) && strlen(trim($about)) > 0) {
  1329. $this->about = (string) trim($about);
  1330. } // end if
  1331. } // end function
  1332. /**
  1333. * Sets $title variable
  1334. *
  1335. * @desc Sets $title variable
  1336. * @param string $title
  1337. * @see $title
  1338. */
  1339. function setTitle($title = '') {
  1340. if (!isset($this->title) && strlen(trim($title)) > 0) {
  1341. $this->title = (string) trim($title);
  1342. } // end if
  1343. } // end function
  1344. /**
  1345. * Sets $link variable
  1346. *
  1347. * @desc Sets $link variable
  1348. * @param string $link
  1349. * @see $link
  1350. */
  1351. function setLink($link = '') {
  1352. if (!isset($this->link) && strlen(trim($link)) > 0) {
  1353. $this->link = (string) trim($link);
  1354. } // end if
  1355. } // end function
  1356. /**
  1357. * Sets $description variable
  1358. *
  1359. * @desc Sets $description variable
  1360. * @param string $description
  1361. * @see $description
  1362. */
  1363. function setDescription($description = '') {
  1364. if (!isset($this->description) && strlen(trim($description)) > 0) {
  1365. $this->description = (string) trim($description);
  1366. } // end if
  1367. } // end function
  1368. /**
  1369. * Sets $subject variable
  1370. *
  1371. * @desc Sets $subject variable
  1372. * @param string $subject
  1373. * @see $subject
  1374. */
  1375. function setSubject($subject = '') {
  1376. if (!isset($this->subject) && strlen(trim($subject)) > 0) {
  1377. $this->subject = (string) trim($subject);
  1378. } // end if
  1379. } // end function
  1380. /**
  1381. * Sets $date variable
  1382. *
  1383. * @desc Sets $date variable
  1384. * @param string $date
  1385. * @see $date
  1386. */
  1387. function setDate($date = '') {
  1388. if (!isset($this->date) && strlen(trim($date)) > 0) {
  1389. $this->date = (string) trim($date);
  1390. } // end if
  1391. } // end function
  1392. /**
  1393. * Sets $author variable
  1394. *
  1395. * @desc Sets $author variable
  1396. * @param string $author
  1397. * @see $author
  1398. * @since 1.001 - 2003-05-30
  1399. */
  1400. function setAuthor($author = '') {
  1401. if (!isset($this->author) && strlen(trim($author)) > 0) {
  1402. $this->author = (string) trim($author);
  1403. } // end if
  1404. } // end function
  1405. /**
  1406. * Sets $comments variable
  1407. *
  1408. * @desc Sets $comments variable
  1409. * @param string $comments
  1410. * @see $comments
  1411. * @since 1.001 - 2003-05-30
  1412. */
  1413. function setComments($comments = '') {
  1414. if (!isset($this->comments) && strlen(trim($comments)) > 0) {
  1415. $this->comments = (string) trim($comments);
  1416. } // end if
  1417. } // end function
  1418. /**
  1419. * Sets $image variable
  1420. *
  1421. * @desc Sets $image variable
  1422. * @param string $image
  1423. * @see $image
  1424. * @since 1.002 - 2003-06-26
  1425. */
  1426. function setImage($image = '') {
  1427. if (!isset($this->image) && strlen(trim($image)) > 0) {
  1428. $this->image = (string) trim($image);
  1429. } // end if
  1430. } // end function
  1431. /**#@-*/
  1432. /**#@+
  1433. * @access public
  1434. */
  1435. /**
  1436. * Returns $about variable
  1437. *
  1438. * @desc Returns $about variable
  1439. * @return string $about
  1440. * @see $about
  1441. */
  1442. function getAbout() {
  1443. return (string) $this->about;
  1444. } // end function
  1445. /**
  1446. * Returns $title variable
  1447. *
  1448. * @desc Returns $title variable
  1449. * @return string $title
  1450. * @see $title
  1451. */
  1452. function getTitle() {
  1453. return (string) $this->title;
  1454. } // end function
  1455. /**
  1456. * Returns $link variable
  1457. *
  1458. * @desc Returns $link variable
  1459. * @return string $link
  1460. * @see $link
  1461. */
  1462. function getLink() {
  1463. return (string) $this->link;
  1464. } // end function
  1465. /**
  1466. * Returns $description variable
  1467. *
  1468. * @desc Returns $description variable
  1469. * @return string $description
  1470. * @see $description
  1471. */
  1472. function getDescription() {
  1473. return (string) $this->description;
  1474. } // end function
  1475. /**
  1476. * Returns $subject variable
  1477. *
  1478. * @desc Returns $subject variable
  1479. * @return string $subject
  1480. * @see $subject
  1481. */
  1482. function getSubject() {
  1483. return (string) $this->subject;
  1484. } // end function
  1485. /**
  1486. * Returns $date variable
  1487. *
  1488. * @desc Returns $date variable
  1489. * @return string $date
  1490. * @see $date
  1491. */
  1492. function getDate() {
  1493. return (string) $this->date;
  1494. } // end function
  1495. /**
  1496. * Returns $author variable
  1497. *
  1498. * @desc Returns $author variable
  1499. * @return string $author
  1500. * @see $author
  1501. * @since 1.001 - 2003-05-30
  1502. */
  1503. function getAuthor() {
  1504. return (string) $this->author;
  1505. } // end function
  1506. /**
  1507. * Returns $comments variable
  1508. *
  1509. * @desc Returns $comments variable
  1510. * @return string $comments
  1511. * @see $comments
  1512. * @since 1.001 - 2003-05-30
  1513. */
  1514. function getComments() {
  1515. return (string) $this->comments;
  1516. } // end function
  1517. /**
  1518. * Returns $image variable
  1519. *
  1520. * @desc Returns $image variable
  1521. * @return string $image
  1522. * @see $image
  1523. * @since 1.002 - 2003-06-26
  1524. */
  1525. function getImage() {
  1526. return (string) $this->image;
  1527. } // end function
  1528. /**#@-*/
  1529. } // end class RSSItem
  1530. ?>