⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xml_domit_rss_shared.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/*** @package domit-rss* @version 0.51* @copyright (C) 2004 John Heinstein. All rights reserved* @license http://www.gnu.org/copyleft/lesser.html LGPL License* @author John Heinstein <johnkarl@nbnet.nb.ca>* @link http://www.engageinteractive.com/domitrss/ DOMIT! RSS Home Page* DOMIT! RSS is Free Software**//** channel constant */define('DOMIT_RSS_ELEMENT_CHANNEL', 'channel');/** item constant */define('DOMIT_RSS_ELEMENT_ITEM', 'item');/** title constant */define('DOMIT_RSS_ELEMENT_TITLE', 'title');/** link constant */define('DOMIT_RSS_ELEMENT_LINK', 'link');/** description constant */define('DOMIT_RSS_ELEMENT_DESCRIPTION', 'description');/** version constant */define('DOMIT_RSS_ATTR_VERSION', 'version');/** name of array containing list of existing RSS items */define('DOMIT_RSS_ARRAY_ITEMS', 'item'); //formerly named 'domit_rss_items'/** name of array containing list of existing RSS channels */define('DOMIT_RSS_ARRAY_CHANNELS', 'channel'); //formerly named 'domit_rss_channels'/** name of array containing list of existing RSS categories */define('DOMIT_RSS_ARRAY_CATEGORIES', 'category'); //formerly named 'domit_rss_categories'/** DOMIT RSS error, attempt to call an abstract method */define('DOMIT_RSS_ABSTRACT_METHOD_INVOCATION_ERR', 101);/** DOMIT RSS error, specified element not present */define('DOMIT_RSS_ELEMENT_NOT_FOUND_ERR', 102);/** DOMIT RSS error, specified attribute not present */define('DOMIT_RSS_ATTR_NOT_FOUND_ERR', 103);/** DOMIT RSS error, parsing failed */define('DOMIT_RSS_PARSING_ERR', 104);//DOMIT! RSS Error Modes/** continue on error  */define('DOMIT_RSS_ONERROR_CONTINUE', 1);/** die on error  */define('DOMIT_RSS_ONERROR_DIE', 2);/** die on error  */define('DOMIT_RSS_ONERROR_RETURN', 3);/*** The base class of all DOMIT! RSS objects** @package domit-rss* @author John Heinstein <johnkarl@nbnet.nb.ca>*/class xml_domit_rss_base {    /** @var Object The underlying DOMIT! node of the element */	var $node = null;	/** @var array A list of valid RSS defined child elements */	var $rssDefinedElements = array();	/**	* Retrieves the underlying DOMIT node	* @return Object The underlying DOMIT node	*/	function getNode() {	    return $this->node;	} //getNode	/**	* Retrieves the text of the named attribute, checking first if the attribute exists	* @param string The attribute name	* @return string The attribute value, or an empty string	*/	function getAttribute($attr) {		if ($this->node->hasAttribute($attr)) {			return $this->node->getAttribute($attr);		}		return "";	} //getAttribute	/**	* Checks whether the named attribute exists	* @param string The attribute name	* @return boolean True if the attribute exists	*/	function hasAttribute($attr) {	    return (($this->node->nodeType == DOMIT_ELEMENT_NODE) && $this->node->hasAttribute($attr));	} //hasAttribute	/**	* Tests whether the named element is predefined by the RSS spec	* @param string The element name	* @return boolean True if the element is predefined by the RSS spec	*/	function isRSSDefined($elementName) {	    $isDefined = false;	    foreach ($this->rssDefinedElements as $key => $value) {	        if ($elementName == $value) {	            $isDefined = true;	            break;	        }	    }	    return $isDefined;	} //isRSSDefined	/**	* Tests whether the named element has a single child text node	* @param string The element name	* @return boolean True if the named element has a single child text node	*/	function isSimpleRSSElement($elementName) {	    $elementName = strtolower($elementName);		if (isset($this->DOMIT_RSS_indexer[$elementName])) {	    	return (get_class($this->getElement($elementName)) == 'xml_domit_rss_simpleelement');		}		else {		    return false;		}	} //isSimpleRSSElement	/**	* Generates a string representation of the node and its children	* @param boolean True if HTML readable output is desired	* @param boolean True if illegal xml characters in text nodes and attributes should be converted to entities	* @return string The string representation	*/    function get($htmlSafe = false, $subEntities = false) {	    return $this->node->toString($htmlSafe, $subEntities);	} //toString    /**	* Generates a normalized (formatted for readability) representation of the node and its children	* @param boolean True if HTML readable output is desired	* @param boolean True if illegal xml characters in text nodes and attributes should be converted to entities	* @return string The formatted string representation	*/	function toNormalizedString($htmlSafe = false, $subEntities = false) {	    return $this->node->toNormalizedString($htmlSafe, $subEntities);	} //toNormalizedString} //xml_domit_rss_base/*** Represents a collection of custom RSS elements, e.g. a set of dc:creator entries** @package domit-rss* @subpackage domit-rss-main* @author John Heinstein <johnkarl@nbnet.nb.ca>*/class xml_domit_rss_collection extends xml_domit_rss_elementindexer {    /** @var array An array holding the collection of custom elements */	var $elements = array();	/** @var int The number of custom elements in the collection */	var $elementCount = 0;	/**	* Adds a custom RSS element (DOM node) to the collection	* @param Object A DOM node representing a custom RSS element	*/	function addElement(&$node) {		$this->elements[] =& $node;		$this->elementCount++;	} //addElement	/**	* Retrieves the element at the specified index	* @param int The index of the requested custom RSS element	* @return Object The DOMIT node representing the requested element	*/	function &getElementAt($index) {		return $this->elements[$index];	} //getElementAt	/**	* Retrieves the element at the specified index (alias for getElementAt)	* @param int The index of the requested custom RSS element	* @return Object The DOMIT node representing the requested element	*/	function &getElement($index) {		return $this->getElementAt($index);	} //getElement	/**	* Returns the number of elements in the collection	* @return int The number of members in the collection	*/	function getElementCount() {	    return $this->elementCount;	} //getElementCount	/**	* Gets a text representation of the collection (applies the toString method to each member and concatenates)	* @return string The element text	*/	function getElementText() {		$total = $this->getElementCount();  		$result = '';        for ($i = 0; $i < $total; $i++) {            $result .= $currElement->toString();        }        return $result;	} //getElementText} //xml_domit_rss_collection/*** Provides indexing functionality to RSS classes** @package domit-rss* @author John Heinstein <johnkarl@nbnet.nb.ca>*/class xml_domit_rss_elementindexer extends xml_domit_rss_base {	/** @var Array Name based index to RSS elements */	var $DOMIT_RSS_indexer = array();	/** @var Array Numerical index to RSS elements; for optimization purposes, only set if requested by getElementAt */	var $DOMIT_RSS_numericalIndexer;	/**	* Performs generic initialization of elements	*/	function _init(){		$total = $this->node->childCount;		for($i = 0; $i < $total; $i++) {			$currNode =& $this->node->childNodes[$i];			//$this->DOMIT_RSS_indexer[$currNode->nodeName] =& $currNode;			$this->addIndexedElement($currNode);		}	} //_init	/**	* Adds a custom element (one not defined by the RSS specs, e..g., dc:creator) to the indexer	* @param Object A DOMIT! node representing the custom element	*/	function addIndexedElement(&$node) {	    $tagName = strtolower($node->nodeName);	    if (isset($this->DOMIT_RSS_indexer[$tagName])) {	        if (strtolower(get_class($this->DOMIT_RSS_indexer[$tagName])) == 'domit_element') {	        	$collection = new xml_domit_rss_collection();	        	$collection->addElement($this->DOMIT_RSS_indexer[$tagName]);	        	$collection->addElement($node);	        	$this->DOMIT_RSS_indexer[$tagName] =& $collection;	        }	        else {				//Don't think I need this case???	            //$this->DOMIT_RSS_indexer[$tagName]->addElement($node);	        }	    }	    else {	        $this->DOMIT_RSS_indexer[$tagName] =& $node;	    }	} //addIndexedElement	/**	* Indicates whether the requested element is actually a collection of elements of the same type	* @param string The name of the requested element	* @return boolean True if a collection of elements exists	*/	function isCollection($elementName) {	    $elementName = strtolower($elementName);		if (isset($this->DOMIT_RSS_indexer[$elementName])) {			return (get_class($this->DOMIT_RSS_indexer[$elementName]) == 'xml_domit_rss_collection');		}		else {			return false;		}	} //isCollection	/**	* Indicates whether the requested element is a DOMIT! node	* @param string The name of the requested element	* @return boolean True if the requested element is a DOMIT! node	*/	function isNode($elementName) {	    $elementName = strtolower($elementName);		if (isset($this->DOMIT_RSS_indexer[$elementName])) {			return (strtolower(get_class($this->DOMIT_RSS_indexer[$elementName])) == 'domit_element');		}		else {			return false;		}	} //isNode	/**	* Indicates whether the requested element is a DOMIT! node (alias for isNode)	* @param string The name of the requested element	* @return boolean True if the requested element is a DOMIT! node	*/	function isCustomRSSElement($elementName) {	    return isNode($elementName);	} //isCustomRSSElement	/**	* Gets a named list of existing elements as a child of the current element	* @return array A named list of existing elements	*/	function getElementList() {		return array_keys($this->DOMIT_RSS_indexer);	} //getElementList	/**	* Indicates whether a particular element exists	* @param string The name of the requested element	* @return boolean True if an element with the specified name exists	*/	function hasElement($elementName) {		return isset($this->DOMIT_RSS_indexer[strtolower($elementName)]);	} //hasElement	/**	* Gets a reference to an element with the specified name	* @param string The name of the requested element	* @return mixed A reference to an element with the specified name, or the text of the element if it is a text node	*/	function &getElement($elementName) {		$elementName = strtolower($elementName);		if (isset($this->DOMIT_RSS_indexer[$elementName])) {			return $this->DOMIT_RSS_indexer[$elementName];		}		else {			xml_domit_rss_exception::raiseException(DOMIT_RSS_ELEMENT_NOT_FOUND_ERR,					'Element ' . $elementName . ' not present.');		}	} //getElement	/**	* Gets a reference to an element at the specified index	* @param int The index of the requested element	* @return mixed A reference to an element at the specified index, or the text of the element if it is a text node	*/	function &getElementAt($index) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -