Skip to content

Commit

Permalink
Remove itemClass usage from most places
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Dec 9, 2011
1 parent efd35f2 commit a58f74f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion XML/Feed/Parser/Atom.php
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions XML/Feed/Parser/RSS09.php
Expand Up @@ -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());
}

/**
Expand Down
3 changes: 1 addition & 2 deletions XML/Feed/Parser/RSS1.php
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions XML/Feed/Parser/RSS11.php
Expand Up @@ -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');
Expand All @@ -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());

}

/**
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions XML/Feed/Parser/RSS2.php
Expand Up @@ -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');
Expand All @@ -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());
}

/**
Expand Down
2 changes: 2 additions & 0 deletions XML/Feed/Parser/Type.php
Expand Up @@ -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) {
Expand Down

0 comments on commit a58f74f

Please sign in to comment.