Commit b039286b authored by Darryl Hamilton's avatar Darryl Hamilton
Browse files

Patch from 1.0.3 to 1.0.4 (Bug #750815)



Change-Id: I0ecb1970326b48c48a53b71d3c1f238053d80b56
Signed-off-by: default avatarDarryl Hamilton <darrylh@catalyst.net.nz>
parent 6d51c6a2
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL
* @version CVS: $Id: Parser.php,v 1.24 2006/08/15 13:04:00 jystewart Exp $
* @version CVS: $Id: Parser.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -39,7 +39,7 @@ require_once 'XML/Feed/Parser/Exception.php';
* to the entire feed.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser implements Iterator
......@@ -86,13 +86,8 @@ class XML_Feed_Parser implements Iterator
*/
function __construct($feed, $strict = false, $suppressWarnings = false, $tidy = false)
{
$options = 0;
if ($suppressWarnings) {
$options |= LIBXML_NOWARNING;
$options |= LIBXML_NOERROR;
}
$this->model = new DOMDocument;
if (! $this->model->loadXML($feed, $options)) {
if (! $this->model->loadXML($feed)) {
if (extension_loaded('tidy') && $tidy) {
$tidy = new tidy;
$tidy->parseString($feed,
......
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: Atom.php,v 1.29 2008/03/30 22:00:36 jystewart Exp $
* @version CVS: $Id: Atom.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -30,7 +30,7 @@
* person - defaults to name, but parameter based access
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type
......@@ -39,7 +39,7 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type
* The URI of the RelaxNG schema used to (optionally) validate the feed
* @var string
*/
private $relax = 'atom.rnc';
protected $relax = 'atom.rng';
/**
* We're likely to use XPath, so let's keep it global
......@@ -117,7 +117,7 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type
$this->model = $model;
if ($strict) {
if (! $this->model->relaxNGValidateSource($this->relax)) {
if (! $this->relaxNGValidate()) {
throw new XML_Feed_Parser_Exception('Failed required validation');
}
}
......@@ -362,4 +362,4 @@ class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type
}
}
?>
\ No newline at end of file
?>
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: AtomElement.php,v 1.19 2007/03/26 12:43:11 jystewart Exp $
* @version CVS: $Id: AtomElement.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -26,7 +26,7 @@
* XML_Feed_Parser_Atom with which it shares many methods.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_AtomElement extends XML_Feed_Parser_Atom
......
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL
* @version CVS: $Id: Exception.php,v 1.3 2005/11/07 01:52:35 jystewart Exp $
* @version CVS: $Id: Exception.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -31,7 +31,7 @@ require_once 'PEAR/Exception.php';
* to help with identification of the source of exceptions.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_Exception extends PEAR_Exception
......
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS09.php,v 1.5 2006/07/26 21:18:46 jystewart Exp $
* @version CVS: $Id: RSS09.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -25,7 +25,7 @@
* This class handles RSS0.9 feeds.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
* @todo Find a Relax NG URI we can use
*/
......@@ -35,7 +35,7 @@ class XML_Feed_Parser_RSS09 extends XML_Feed_Parser_Type
* The URI of the RelaxNG schema used to (optionally) validate the feed
* @var string
*/
private $relax = '';
protected $relax = '';
/**
* We're likely to use XPath, so let's keep it global
......@@ -209,6 +209,13 @@ class XML_Feed_Parser_RSS09 extends XML_Feed_Parser_Type
$link = $links->item($offset);
return $this->addBase($link->nodeValue, $link);
}
/**
* Not implemented - no available validation.
*/
public function relaxNGValidate() {
return true;
}
}
?>
\ No newline at end of file
?>
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS09Element.php,v 1.4 2006/06/30 17:41:56 jystewart Exp $
* @version CVS: $Id: RSS09Element.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -26,7 +26,7 @@
* XML_Feed_Parser_RSS09 with which it shares many methods.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_RSS09Element extends XML_Feed_Parser_RSS09
......
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS1.php,v 1.10 2006/07/27 13:52:05 jystewart Exp $
* @version CVS: $Id: RSS1.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -25,7 +25,7 @@
* This class handles RSS1.0 feeds.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
* @todo Find a Relax NG URI we can use
*/
......@@ -35,7 +35,7 @@ class XML_Feed_Parser_RSS1 extends XML_Feed_Parser_Type
* The URI of the RelaxNG schema used to (optionally) validate the feed
* @var string
*/
private $relax = 'rss10.rnc';
protected $relax = 'rss10.rng';
/**
* We're likely to use XPath, so let's keep it global
......@@ -121,9 +121,7 @@ class XML_Feed_Parser_RSS1 extends XML_Feed_Parser_Type
{
$this->model = $model;
if ($strict) {
$validate = $this->model->relaxNGValidate(self::getSchemaDir .
DIRECTORY_SEPARATOR . $this->relax);
if (! $validate) {
if (! $this->relaxNGValidate()) {
throw new XML_Feed_Parser_Exception('Failed required validation');
}
}
......@@ -274,4 +272,4 @@ class XML_Feed_Parser_RSS1 extends XML_Feed_Parser_Type
}
}
?>
\ No newline at end of file
?>
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS11.php,v 1.6 2006/07/27 13:52:05 jystewart Exp $
* @version CVS: $Id: RSS11.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -26,7 +26,7 @@
* http://inamidst.com/rss1.1/
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
* @todo Support for RDF:List
* @todo Ensure xml:lang is accessible to users
......@@ -37,7 +37,7 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type
* The URI of the RelaxNG schema used to (optionally) validate the feed
* @var string
*/
private $relax = 'rss11.rnc';
protected $relax = 'rss11.rng';
/**
* We're likely to use XPath, so let's keep it global
......@@ -123,9 +123,7 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type
$this->model = $model;
if ($strict) {
$validate = $this->model->relaxNGValidate(self::getSchemaDir .
DIRECTORY_SEPARATOR . $this->relax);
if (! $validate) {
if (! $this->relaxNGValidate()) {
throw new XML_Feed_Parser_Exception('Failed required validation');
}
}
......@@ -273,4 +271,4 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type
}
}
?>
\ No newline at end of file
?>
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS11Element.php,v 1.4 2006/06/30 17:41:56 jystewart Exp $
* @version CVS: $Id: RSS11Element.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -26,7 +26,7 @@
* XML_Feed_Parser_RSS11 with which it shares many methods.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_RSS11Element extends XML_Feed_Parser_RSS11
......@@ -65,7 +65,7 @@ class XML_Feed_Parser_RSS11Element extends XML_Feed_Parser_RSS11
protected $compatMap = array(
'content' => array('content'),
'updated' => array('lastBuildDate'),
'published' => array('pubdate'),
'published' => array('date'),
'subtitle' => array('description'),
'updated' => array('date'),
'author' => array('creator'),
......@@ -148,4 +148,4 @@ class XML_Feed_Parser_RSS11Element extends XML_Feed_Parser_RSS11
}
}
?>
\ No newline at end of file
?>
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS1Element.php,v 1.6 2006/06/30 17:41:56 jystewart Exp $
* @version CVS: $Id: RSS1Element.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -26,7 +26,7 @@
* XML_Feed_Parser_RSS1 with which it shares many methods.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_RSS1Element extends XML_Feed_Parser_RSS1
......@@ -65,7 +65,7 @@ class XML_Feed_Parser_RSS1Element extends XML_Feed_Parser_RSS1
protected $compatMap = array(
'content' => array('content'),
'updated' => array('lastBuildDate'),
'published' => array('pubdate'),
'published' => array('date'),
'subtitle' => array('description'),
'updated' => array('date'),
'author' => array('creator'),
......@@ -113,4 +113,4 @@ class XML_Feed_Parser_RSS1Element extends XML_Feed_Parser_RSS1
}
}
?>
\ No newline at end of file
?>
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS2.php,v 1.12 2008/03/08 18:16:45 jystewart Exp $
* @version CVS: $Id: RSS2.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -25,7 +25,7 @@
* This class handles RSS2 feeds.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type
......@@ -34,7 +34,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type
* The URI of the RelaxNG schema used to (optionally) validate the feed
* @var string
*/
private $relax = 'rss20.rnc';
protected $relax = 'rss20.rng';
/**
* We're likely to use XPath, so let's keep it global
......@@ -116,7 +116,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type
$this->model = $model;
if ($strict) {
if (! $this->model->relaxNGValidate($this->relax)) {
if (! $this->relaxNGValidate()) {
throw new XML_Feed_Parser_Exception('Failed required validation');
}
}
......@@ -321,8 +321,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type
*/
function getLink($offset, $attribute = 'href', $params = array())
{
$xPath = new DOMXPath($this->model);
$links = $xPath->query('//link');
$links = $this->model->getElementsByTagName('link');
if ($links->length <= $offset) {
return false;
......@@ -332,4 +331,4 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type
}
}
?>
\ No newline at end of file
?>
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: RSS2Element.php,v 1.11 2006/07/26 21:18:47 jystewart Exp $
* @version CVS: $Id: RSS2Element.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -26,7 +26,7 @@
* called by XML_Feed_Parser_RSS2 with which it shares many methods.
*
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
* @package XML_Feed_Parser
*/
class XML_Feed_Parser_RSS2Element extends XML_Feed_Parser_RSS2
......
......@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL 2.1
* @version CVS: $Id: Type.php,v 1.25 2008/03/08 18:39:09 jystewart Exp $
* @version CVS: $Id: Type.php 304308 2010-10-11 12:05:50Z clockwerx $
* @link http://pear.php.net/package/XML_Feed_Parser/
*/
......@@ -27,7 +27,7 @@
*
* @package XML_Feed_Parser
* @author James Stewart <james@jystewart.net>
* @version Release: 1.0.3
* @version Release: @package_version@
*/
abstract class XML_Feed_Parser_Type
{
......@@ -462,6 +462,14 @@ abstract class XML_Feed_Parser_Type
$config = new PEAR_Config;
return $config->get('data_dir') . '/XML_Feed_Parser/schemas';
}
public function relaxNGValidate() {
$dir = self::getSchemaDir();
$path = $dir . '/' . $this->relax;
return $this->model->relaxNGValidate($path);
}
}
?>
\ No newline at end of file
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment