Permalink
Browse files

Remove itemClass usage from most places

  • Loading branch information...
1 parent efd35f2 commit a58f74f3b9350d2a546e09a324203246c436ea47 @CloCkWeRX CloCkWeRX committed Dec 9, 2011
@@ -150,7 +150,8 @@ function getEntryById($id)
if ($entries->length > 0) {
$xmlBase = $entries->item(0)->baseURI;
/** @todo Avoid instantiating classes we can't keep track of */
- $entry = new $this->itemClass($entries->item(0), $this, $xmlBase);
+ $entry = new XML_Feed_Parser_AtomElement($entries->item(0), $this, $xmlBase);
+ $entry->setSanitizer($this->getSanitizer());
if (in_array('evaluate', get_class_methods($this->xpath))) {
$offset = $this->xpath->evaluate("count(preceding-sibling::atom:entry)", $entries->item(0));
@@ -105,13 +105,12 @@ class XML_Feed_Parser_RSS09 extends XML_Feed_Parser_Type
function __construct(DOMDocument $model, $strict = false)
{
$this->model = $model;
-
+ $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
$this->xpath = new DOMXPath($model);
foreach ($this->namespaces as $key => $value) {
$this->xpath->registerNamespace($key, $value);
}
$this->numberEntries = $this->count('item');
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
}
/**
@@ -155,8 +155,7 @@ function getEntryById($id)
$entries = $this->xpath->query("//rss:item[@rdf:about='$id']");
if ($entries->length > 0) {
- $classname = $this->itemClass;
- $entry = new $classname($entries->item(0), $this);
+ $entry = new XML_Feed_Parser_RSS1Element($entries->item(0), $this);
if (in_array('evaluate', get_class_methods($this->xpath))) {
$offset = $this->xpath->evaluate("count(preceding-sibling::rss:item)", $entries->item(0));
$this->entries[$offset] = $entry;
@@ -121,7 +121,7 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type
function __construct(DOMDocument $model, $strict = false)
{
$this->model = $model;
-
+ $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
if ($strict) {
if (! $this->relaxNGValidate()) {
throw new XML_Feed_Parser_Exception('Failed required validation');
@@ -133,7 +133,7 @@ function __construct(DOMDocument $model, $strict = false)
$this->xpath->registerNamespace($key, $value);
}
$this->numberEntries = $this->count('item');
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
+
}
/**
@@ -156,8 +156,7 @@ function getEntryById($id)
$entries = $this->xpath->query("//rss:item[@rdf:about='$id']");
if ($entries->length > 0) {
- $classname = $this->itemClass;
- $entry = new $classname($entries->item(0), $this);
+ $entry = new XML_Feed_Parser_RSS1Element($entries->item(0), $this);
return $entry;
}
return false;
@@ -114,7 +114,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type
function __construct(DOMDocument $model, $strict = false)
{
$this->model = $model;
-
+ $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
if ($strict) {
if (! $this->relaxNGValidate()) {
throw new XML_Feed_Parser_Exception('Failed required validation');
@@ -126,7 +126,6 @@ function __construct(DOMDocument $model, $strict = false)
$this->xpath->registerNamespace($key, $value);
}
$this->numberEntries = $this->count('item');
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
}
/**
@@ -210,6 +210,8 @@ function getEntryByOffset($offset)
$entries = $this->model->getElementsByTagName($this->itemElement);
if ($entries->length > $offset) {
$xmlBase = $entries->item($offset)->baseURI;
+ /** @todo Remove this behaviour - each driver should control this better */
+ /** @todo Try to avoid new here */
$this->entries[$offset] = new $this->itemClass(
$entries->item($offset), $this, $xmlBase);
if ($id = $this->entries[$offset]->id) {

0 comments on commit a58f74f

Please sign in to comment.