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

📄 xml_domit_rss_shared.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 3 页
字号:
					if ($rssText != '') $this->cache->save($rssText, $url);	            	return $rssText;	        	}	    	}	    	else {				$this->cache->useHTTPClient($this->doUseHTTPClient);	        	return $this->cache->getData($url);	    	}		}		else {			return $this->getTextFromFile($url);		}	} //getDataFromCache	/**	* Parses the RSS data provided	* @param string The the RSS data	* @return boolean True if parsing is successful	*/	function parseRSSData($rssText) {	    if ($rssText != '') {			return $this->fromString($rssText);		}		else {			return false;		}	} //parseRSSData	/**	* Reads in RSS text from a file and parses it	* @param string The file path	* @return boolean True if parsing is successful	*/	function &fromFile($filename) {		$success = $this->node->loadXML($filename, false);		return $success;	} //fromFile	/**	* Reads in RSS text from a string and parses it	* @param string The RSS text	* @return boolean True if parsing is successful	*/	function &fromString($rssText) {		$success = $this->node->parseXML($rssText, false);		return $success;	} //fromString	/**	* Establishes a connection, given an url	* @param string The url of the data	*/	function establishConnection($url) {		require_once(DOMIT_RSS_INCLUDE_PATH . 'php_http_client_generic.php');		$host = php_http_connection::formatHost($url);		$host = substr($host, 0, strpos($host, '/'));		$this->setConnection($host, '/', 80, $this->rssTimeout);	} //establishConnection	/**	* Get text from an url or file	* @param string The url or file path	* @return string The text contained in the url or file, or an empty string	*/	function getTextFromFile($filename) {		$fileContents = '';		if ($this->doUseHTTPClient) {			$this->establishConnection($filename);			$response =& $this->httpConnection->get($filename);			if ($response != null) {				$fileContents = $response->getResponse();			}		}		else {			if (function_exists('file_get_contents')) {				$fileContents = @file_get_contents($filename);			}			else {				require_once(DOMIT_RSS_INCLUDE_PATH . 'php_file_utilities.php');				$fileContents =& php_file_utilities::getDataFromFile($filename, 'r');			}			if ($fileContents == '') {				$this->establishConnection($filename);				$response =& $this->httpConnection->get($filename);				if ($response != null) {					$fileContents = $response->getResponse();				}			}		}		return $fileContents;	} //getTextFromFile	/**	* Gets a reference to the underlying DOM document	* @return Object A reference to the underlying DOM document	*/	function &getDocument() {		return $this->node;	} //getDocument	/**	* Gets a reference to the root DOM element	* @return Object A reference to the root DOM element	*/	function &getNode() {		return $this->node->documentElement;	} //getNode	/**	* Forces channel elements that are external to a channel to be referenced as subelements of that channel	*/	function handleChannelElementsEmbedded() {		if (count($this->domit_rss_items) > 0) {			foreach ($this->domit_rss_channels as $key => $value) {				$this->domit_rss_channels[$key]->domit_rss_items =& $this->domit_rss_items;				if (count($this->DOMIT_RSS_indexer) > 0) {					foreach ($this->DOMIT_RSS_indexer as $ikey => $ivalue) {						if ($ikey != DOMIT_RSS_ARRAY_CHANNELS) {							$this->domit_rss_channels[$key]->DOMIT_RSS_indexer[$ikey] =& $this->DOMIT_RSS_indexer[$ikey];							unset($this->DOMIT_RSS_indexer[$ikey]);						}					}				}			}		}	} //handleChannelElementsEmbedded	/**	* Returns the version of RSS used to format the data	* @return string The version of RSS used to format the data	*/	function getRSSVersion() {		$version = $this->node->documentElement->getAttribute(DOMIT_RSS_ATTR_VERSION);		if ($version == '') {			$xmlns = $this->node->documentElement->getAttribute('xmlns');			$total = strlen($xmlns);			if (substr($xmlns, $total) == '/') {			    $total--;			}			for ($i = ($total - 1); $i > -1; $i--) {			    $currentChar = substr($xmlns, $i);			    if ($currentChar == '/') {			        break;			    }			    else {			        $version = $currentChar . $version;			    }			}		}		return $version;	} //getRSSVersion	/**	* Returns the number of channels in the document	* @return int The number of channels in the document	*/	function getChannelCount() {		return count($this->domit_rss_channels);	} //getChannelCount()	/**	* Returns a reference to the channel located at the specified index	* @return Object A reference to the channel located at the specified index	*/	function &getChannel($index) {		return $this->domit_rss_channels[$index];	} //getChannel} //xml_domit_rss_base_document/*** Represents a simple RSS element, without attributes and only a single child text node** @package domit-rss* @subpackage domit-rss-main* @author John Heinstein <johnkarl@nbnet.nb.ca>*/class xml_domit_rss_simpleelement extends xml_domit_rss_elementindexer {	/**	* Constructor	* @param Object A DOM node containing element data	*/	function xml_domit_rss_simpleelement(&$element) {		$this->node =& $element;	} //xml_domit_rss_simpleelement	/**	* Gets the text of the element	* @return string The element text	*/	function getElementText() {	    $element =& $this->node;	    $result = '';    	$total = $element->childCount;		for ($i = 0; $i < $total; $i++) {			$currNode =& $element->childNodes[$i];			if ($currNode->nodeType == DOMIT_CDATA_SECTION_NODE) {				$result .= $currNode->nodeValue;			}			else {				$result .= $currNode->toString();			}	    }        return $result;	} //getElementText} //xml_domit_rss_simpleelement/*** @global object Reference to custom error handler for DOMIT RSS Exception class*/$GLOBALS['DOMIT_RSS_Exception_errorHandler'] = null;/*** @global int Error mode; specifies whether to die on error or simply return*///$GLOBALS['DOMIT_RSS_Exception_mode'] = DOMIT_RSS_ONERROR_RETURN;// fixes bug identified here: sarahk.pcpropertymanager.com/blog/using-domit-rss/225/$GLOBALS['DOMIT_RSS_Exception_mode'] = 1;/*** @global string Log file for errors*/$GLOBALS['DOMIT_RSS_Exception_log'] = null;/*** A DOMIT! RSS exception handling class** @package domit-rss* @author John Heinstein <johnkarl@nbnet.nb.ca>*/class xml_domit_rss_exception {	/**	* Raises the specified exception	* @param int The error number	* @param string A string explanation of the error	*/	function raiseException($errorNum, $errorString) {		if ($GLOBALS['DOMIT_RSS_Exception_errorHandler'] != null) {			call_user_func($GLOBALS['DOMIT_RSS_Exception_errorHandler'], $errorNum, $errorString);		}		else {			$errorMessageText = $errorNum  . ' ' . $errorString;			$errorMessage = 'Error: ' . $errorMessageText;			if ((!isset($GLOBALS['DOMIT_RSS_ERROR_FORMATTING_HTML'])) ||				($GLOBALS['DOMIT_RSS_ERROR_FORMATTING_HTML'] == true)) {					$errorMessage = "<p><pre>" . $errorMessage . "</pre></p>";			}			//log error to file			if ((isset($GLOBALS['DOMIT_RSS_Exception_log'])) &&				($GLOBALS['DOMIT_RSS_Exception_log'] != null)) {					require_once(DOMIT_RSS_INCLUDE_PATH . 'php_file_utilities.php');					$logItem = "\n" . date('Y-m-d H:i:s') . 'DOMIT! RSS Error ' . $errorMessageText;					php_file_utilities::putDataToFile($GLOBALS['DOMIT_RSS_Exception_log'], $logItem, 'a');			}			switch ($GLOBALS['DOMIT_RSS_Exception_mode']) {				case DOMIT_RSS_ONERROR_CONTINUE:					return;					break;				case DOMIT_RSS_ONERROR_DIE:					die($errorMessage);					break;			}		}	} //raiseException	/**	* custom handler for DOM RSS errors	* @param object A reference to the custom error handler	*/	function setErrorHandler($method) {		$GLOBALS['DOMIT_RSS_Exception_errorHandler'] =& $method;		require_once(DOMIT_RSS_INCLUDE_PATH . 'php_http_exceptions.php');		$GLOBALS['HTTP_Exception_errorHandler'] =& $method;		require_once(DOMIT_RSS_INCLUDE_PATH . 'xml_domit_shared.php');		$GLOBALS['HTTP_Exception_errorHandler'] =& $method;	} //setErrorHandler	/**	* Set error mode	* @param int The DOMIT RSS error mode	*/	function setErrorMode($mode) {		$GLOBALS['DOMIT_RSS_Exception_mode'] = $mode;		require_once(DOMIT_RSS_INCLUDE_PATH . 'php_http_exceptions.php');		require_once(DOMIT_RSS_INCLUDE_PATH . 'xml_domit_shared.php');		if ($mode == DOMIT_RSS_ONERROR_CONTINUE) {			$GLOBALS['HTTP_Exception_mode'] = HTTP_ONERROR_CONTINUE;			$GLOBALS['DOMIT_DOMException_mode'] = DOMIT_ONERROR_CONTINUE;		}		else {			$GLOBALS['HTTP_Exception_mode'] = HTTP_ONERROR_DIE;			$GLOBALS['DOMIT_DOMException_mode'] = DOMIT_ONERROR_DIE;		}	} //setErrorMode	/**	* Set error mode	* @param boolean True if errors should be logged	* @param string Absolute or relative path to log file	*/	function setErrorLog($doLogErrors, $logfile) {		require_once(DOMIT_RSS_INCLUDE_PATH . 'php_http_exceptions.php');		if ($doLogErrors) {			$GLOBALS['DOMIT_RSS_Exception_log'] = $logfile;			$GLOBALS['HTTP_Exception_log'] = $logfile;			$GLOBALS['DOMIT_Exception_log'] = $logfile;		}		else {			$GLOBALS['DOMIT_RSS_Exception_log'] = null;			$GLOBALS['HTTP_Exception_log'] = null;			$GLOBALS['DOMIT_Exception_log'] = null;		}	} //setErrorLog} //xml_domit_rss_exception?>

⌨️ 快捷键说明

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