📄 rss.class.php
字号:
$this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
} // end if
if (strlen($this->title) > 0) {
$this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
} // end if
if (strlen($this->image_link) > 0) {
$this->output .= (string) '<image>' . "\n";
$this->output .= (string) '<title>' . $this->title . '</title>' . "\n";
$this->output .= (string) '<url>' . $this->image_link . '</url>' . "\n";
$this->output .= (string) '<link>' . $this->about . '</link>' . "\n";
if (strlen($this->description) > 0) {
$this->output .= (string) '<description>' . $this->description . '</description>' . "\n";
} // end if
$this->output .= (string) '</image>' . "\n";
} // end if
if (strlen($this->publisher) > 0) {
$this->output .= (string) '<managingEditor>' . $this->publisher . '</managingEditor>' . "\n";
} // end if
if (strlen($this->creator) > 0) {
$this->output .= (string) '<webMaster>' . $this->creator . '</webMaster>' . "\n";
$this->output .= (string) '<generator>' . $this->creator . '</generator>' . "\n";
} // end if
if (strlen($this->language) > 0) {
$this->output .= (string) '<language>' . $this->language . '</language>' . "\n";
} // end if
if (strlen($this->category) > 0) {
$this->output .= (string) '<category>' . $this->category . '</category>' . "\n";
} // end if
if (strlen($this->cache) > 0) {
$this->output .= (string) '<ttl>' . $this->cache . '</ttl>' . "\n";
} // end if
// additional dc data
if (strlen($this->publisher) > 0) {
$this->output .= (string) '<dc:publisher>' . $this->publisher . '</dc:publisher>' . "\n";
} // end if
if (strlen($this->creator) > 0) {
$this->output .= (string) '<dc:creator>' . $this->creator . '</dc:creator>' . "\n";
} // end if
if (strlen($this->date) > 0) {
$this->output .= (string) '<dc:date>' .$this->date . '</dc:date>' . "\n";
} // end if
if (strlen($this->language) > 0) {
$this->output .= (string) '<dc:language>' . $this->language . '</dc:language>' . "\n";
} // end if
if (strlen($this->rights) > 0) {
$this->output .= (string) '<dc:rights>' . $this->rights . '</dc:rights>' . "\n";
} // end if
if (strlen($this->coverage) > 0) {
$this->output .= (string) '<dc:coverage>' . $this->coverage . '</dc:coverage>' . "\n";
} // end if
if (strlen($this->contributor) > 0) {
$this->output .= (string) '<dc:contributor>' . $this->contributor . '</dc:contributor>' . "\n";
} // end if
// additional SY data
if (strlen($this->period) > 0) {
$this->output .= (string) '<sy:updatePeriod>' . $this->period . '</sy:updatePeriod>' . "\n";
} // end if
if (strlen($this->frequency) > 0) {
$this->output .= (string) '<sy:updateFrequency>' . $this->frequency . '</sy:updateFrequency>' . "\n";
} // end if
if (strlen($this->base) > 0) {
$this->output .= (string) '<sy:updateBase>' . $this->base . '</sy:updateBase>' . "\n";
} // end if
if (count($this->getItemList()) > 0) {
foreach ($this->getItemList() as $id) {
$item =& $this->items[$id];
if (strlen($item->getTitle()) > 0 && strlen($item->getLink()) > 0) {
$this->output .= (string) '<item>' . "\n";
$this->output .= (string) '<title>' . $item->getTitle() . '</title>' . "\n";
$this->output .= (string) '<link>' . $item->getLink() . '</link>' . "\n";
if (strlen($item->getDescription()) > 0) {
$this->output .= (string) '<description>' . $item->getDescription() . '</description>' . "\n";
} // end if
if ($this->use_dc_data === TRUE && strlen($item->getSubject()) > 0) {
$this->output .= (string) '<category>' . $item->getSubject() . '</category>' . "\n";
} // end if
if ($this->use_dc_data === TRUE && strlen($item->getDate()) > 0) {
$this->output .= (string) '<pubDate>' . $item->getDate() . '</pubDate>' . "\n";
} // end if
if (strlen($item->getAbout()) > 0) {
$this->output .= (string) '<guid>' . $item->getAbout() . '</guid>' . "\n";
} // end if
if (strlen($item->getAuthor()) > 0) {
$this->output .= (string) '<author>' . $item->getAuthor() . '</author>' . "\n";
} // end if
if (strlen($item->getComments()) > 0) {
$this->output .= (string) '<comments>' . $item->getComments() . '</comments>' . "\n";
} // end if
if (strlen($item->getImage()) > 0) {
$this->output .= (string) '<im:image>' . $item->getImage() . '</im:image>' . "\n";
} // end if
$this->output .= (string) '</item>' . "\n";
} // end if
} // end foreach
} // end if
$this->output .= (string) '</channel>' . "\n";
$this->output .= (string) '</rss>' . "\n";
} // end function
/**
* creates the output
*
* @desc creates the output
* @uses createOutputV090()
* @uses createOutputV091()
* @uses createOutputV200()
* @uses createOutputV100()
*/
function createOutput($version = '') {
if (strlen(trim($version)) === 0) {
$version = (string) '1.0';
} // end if
switch ($version) {
case '0.9':
$this->createOutputV090();
break;
case '0.91':
$this->createOutputV091();
break;
case '2.00':
$this->createOutputV200();
break;
case '1.0':
default:
$this->createOutputV100();
break;
} // end switch
} // end function
/**#@-*/
/**#@+
* @return void
* @access public
* @uses createOutput()
*/
/**
* echos the output
*
* use this function if you want to directly output the rss stream
*
* @desc echos the output
*/
function outputRSS($version = '') {
if (!isset($this->output)) {
$this->createOutput($version);
} // end if
header ('content-type: text/xml');
header('Content-Disposition: inline; filename=rss_' . str_replace(' ','',$this->title) . '.xml');
$this->output = '<?xml version="1.0" encoding="' . $this->encoding . '"?>' . "\n" .
'<!-- RSS generated by Flaimo.com RSS Builder [' . date('Y-m-d H:i:s') .'] --> ' . $this->output;
echo $this->output;
} // end function
/**
* returns the output
*
* use this function if you want to have the output stream as a string (for example to write it in a cache file)
*
* @desc returns the output
*/
function getRSSOutput($version = '') {
if (!isset($this->output)) {
$this->createOutput($version);
} // end if
return (string) '<?xml version="1.0" encoding="' . $this->encoding . '"?>' . "\n" .
'<!-- RSS generated by Flaimo.com RSS Builder [' . date('Y-m-d H:i:s') .'] --> ' . $this->output;
} // end function
/**#@-*/
} // end class RSSBuilder
//---------------------------------------------------------------------------
/**
* single rss item object
*
* Tested with WAMP (XP-SP1/1.3.27/4.0.12/4.3.2)
* Last change: 2003-06-26
*
* @desc single rss item object
* @access private
* @author Michael Wimmer <flaimo@gmx.net>
* @copyright Michael Wimmer
* @link http://www.flaimo.com/
* @package RSSBuilder
* @category FLP
* @version 1.002
*/
class RSSItem extends RSSBase {
/*-------------------*/
/* V A R I A B L E S */
/*-------------------*/
/**#@+
* @access private
* @var string
*/
/**
* URL
*
* @desc URL
*/
var $about;
/**
* headline
*
* @desc headline
*/
var $title;
/**
* URL to the full item
*
* @desc URL to the full item
*/
var $link;
/**
* optional description
*
* @desc optional description
*/
var $description;
/**
* optional subject (category)
*
* @desc optional subject (category)
*/
var $subject;
/**
* optional date
*
* @desc optional date
*/
var $date;
/**
* author of item
*
* @desc author of item
* @since 1.001 - 2003-05-30
*/
var $author;
/**
* url to comments page (rss 2.0)
*
* @desc url to comments page (rss 2.0)
* @since 1.001 - 2003-05-30
*/
var $comments;
/**
* imagelink for this item (mod_im only)
*
* @desc imagelink for this item (mod_im only)
* @since 1.002 - 2003-06-26
*/
var $image;
/**#@-*/
/*-----------------------*/
/* C O N S T R U C T O R */
/*-----------------------*/
/**#@+
* @access private
* @return void
*/
/**
* Constructor
*
* @desc Constructor
* @param string $about URL
* @param string $title
* @param string $link URL
* @param string $description (optional)
* @param string $subject some sort of category (optional)
* @param string $date format: 2003-05-29T00:03:07+0200 (optional)
* @param string $author some sort of category author of item
* @param string $comments url to comment page rss 2.0 value
* @param string $image optional mod_im value for dispaying a different pic for every item
* @uses setAbout()
* @uses setTitle()
* @uses setLink()
* @uses setDescription()
* @uses setSubject()
* @uses setDate()
* @uses setAuthor()
* @uses setComments()
* @uses setImage()
*/
function RSSItem($about = '',
$title = '',
$link = '',
$description = '',
$subject = '',
$date = '',
$author = '',
$comments = '',
$image = '') {
$this->setAbout($about);
$this->setTitle($title);
$this->setLink($link);
$this->setDescription($description);
$this->setSubject($subject);
$this->setDate($date);
$this->setAuthor($author);
$this->setComments($comments);
$this->setImage($image);
} // end constructor
/**
* Sets $about variable
*
* @desc Sets $about variable
* @param string $about
* @see $about
*/
function setAbout($about = '') {
if (!isset($this->about) && strlen(trim($about)) > 0) {
$this->about = (string) trim($about);
} // end if
} // end function
/**
* Sets $title variable
*
* @desc Sets $title variable
* @param string $title
* @see $title
*/
function setTitle($title = '') {
if (!isset($this->title) && strlen(trim($title)) > 0) {
$this->title = (string) trim($title);
} // end if
} // end function
/**
* Sets $link variable
*
* @desc Sets $link variable
* @param string $link
* @see $link
*/
function setLink($link = '') {
if (!isset($this->link) && strlen(trim($link)) > 0) {
$this->link = (string) trim($link);
} // end if
} // end function
/**
* Sets $description variable
*
* @desc Sets $description variable
* @param string $description
* @see $description
*/
function setDescription($description = '') {
if (!isset($this->description) && strlen(trim($description)) > 0) {
$this->description = (string) trim($description);
} // end if
} // end function
/**
* Sets $subject variable
*
* @desc Sets $subject variable
* @param string $subject
* @see $subject
*/
function setSubject($subject = '') {
if (!isset($this->subject) && strlen(trim($subject)) > 0) {
$this->subject = (string) trim($subject);
} // end if
} // end function
/**
* Sets $date variable
*
* @desc Sets $date variable
* @param string $date
* @see $date
*/
function setDate($date = '') {
if (!isset($this->date) && strlen(trim($date)) > 0) {
$this->date = (string) trim($date);
} // end if
} // end function
/**
* Sets $author variable
*
* @desc Sets $author variable
* @param string $author
* @see $author
* @since 1.001 - 2003-05-30
*/
function setAuthor($author = '') {
if (!isset($this->author) && strlen(trim($author)) > 0) {
$this->author = (string) trim($author);
} // end if
} // end function
/**
* Sets $comments variable
*
* @desc Sets $comments variable
* @param string $comments
* @see $comments
* @since 1.001 - 2003-05-30
*/
function setComments($comments = '') {
if (!isset($this->comments) && strlen(trim($comments)) > 0) {
$this->comments = (string) trim($comments);
} // end if
} // end function
/**
* Sets $image variable
*
* @desc Sets $image variable
* @param string $image
* @see $image
* @since 1.002 - 2003-06-26
*/
function setImage($image = '') {
if (!isset($this->image) && strlen(trim($image)) > 0) {
$this->image = (string) trim($image);
} // end if
} // end function
/**#@-*/
/**#@+
* @access public
*/
/**
* Returns $about variable
*
* @desc Returns $about variable
* @return string $about
* @see $about
*/
function getAbout() {
return (string) $this->about;
} // end function
/**
* Returns $title variable
*
* @desc Returns $title variable
* @return string $title
* @see $title
*/
function getTitle() {
return (string) $this->title;
} // end function
/**
* Returns $link variable
*
* @desc Returns $link variable
* @return string $link
* @see $link
*/
function getLink() {
return (string) $this->link;
} // end function
/**
* Returns $description variable
*
* @desc Returns $description variable
* @return string $description
* @see $description
*/
function getDescription() {
return (string) $this->description;
} // end function
/**
* Returns $subject variable
*
* @desc Returns $subject variable
* @return string $subject
* @see $subject
*/
function getSubject() {
return (string) $this->subject;
} // end function
/**
* Returns $date variable
*
* @desc Returns $date variable
* @return string $date
* @see $date
*/
function getDate() {
return (string) $this->date;
} // end function
/**
* Returns $author variable
*
* @desc Returns $author variable
* @return string $author
* @see $author
* @since 1.001 - 2003-05-30
*/
function getAuthor() {
return (string) $this->author;
} // end function
/**
* Returns $comments variable
*
* @desc Returns $comments variable
* @return string $comments
* @see $comments
* @since 1.001 - 2003-05-30
*/
function getComments() {
return (string) $this->comments;
} // end function
/**
* Returns $image variable
*
* @desc Returns $image variable
* @return string $image
* @see $image
* @since 1.002 - 2003-06-26
*/
function getImage() {
return (string) $this->image;
} // end function
/**#@-*/
} // end class RSSItem
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -