Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Remove itemClass usage from most places

  • Loading branch information...
commit a58f74f3b9350d2a546e09a324203246c436ea47 1 parent efd35f2
Daniel O'Connor CloCkWeRX authored
3  XML/Feed/Parser/Atom.php
@@ -150,7 +150,8 @@ function getEntryById($id)
150 150 if ($entries->length > 0) {
151 151 $xmlBase = $entries->item(0)->baseURI;
152 152 /** @todo Avoid instantiating classes we can't keep track of */
153   - $entry = new $this->itemClass($entries->item(0), $this, $xmlBase);
  153 + $entry = new XML_Feed_Parser_AtomElement($entries->item(0), $this, $xmlBase);
  154 + $entry->setSanitizer($this->getSanitizer());
154 155
155 156 if (in_array('evaluate', get_class_methods($this->xpath))) {
156 157 $offset = $this->xpath->evaluate("count(preceding-sibling::atom:entry)", $entries->item(0));
3  XML/Feed/Parser/RSS09.php
@@ -105,13 +105,12 @@ class XML_Feed_Parser_RSS09 extends XML_Feed_Parser_Type
105 105 function __construct(DOMDocument $model, $strict = false)
106 106 {
107 107 $this->model = $model;
108   -
  108 + $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
109 109 $this->xpath = new DOMXPath($model);
110 110 foreach ($this->namespaces as $key => $value) {
111 111 $this->xpath->registerNamespace($key, $value);
112 112 }
113 113 $this->numberEntries = $this->count('item');
114   - $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
115 114 }
116 115
117 116 /**
3  XML/Feed/Parser/RSS1.php
@@ -155,8 +155,7 @@ function getEntryById($id)
155 155
156 156 $entries = $this->xpath->query("//rss:item[@rdf:about='$id']");
157 157 if ($entries->length > 0) {
158   - $classname = $this->itemClass;
159   - $entry = new $classname($entries->item(0), $this);
  158 + $entry = new XML_Feed_Parser_RSS1Element($entries->item(0), $this);
160 159 if (in_array('evaluate', get_class_methods($this->xpath))) {
161 160 $offset = $this->xpath->evaluate("count(preceding-sibling::rss:item)", $entries->item(0));
162 161 $this->entries[$offset] = $entry;
7 XML/Feed/Parser/RSS11.php
@@ -121,7 +121,7 @@ class XML_Feed_Parser_RSS11 extends XML_Feed_Parser_Type
121 121 function __construct(DOMDocument $model, $strict = false)
122 122 {
123 123 $this->model = $model;
124   -
  124 + $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
125 125 if ($strict) {
126 126 if (! $this->relaxNGValidate()) {
127 127 throw new XML_Feed_Parser_Exception('Failed required validation');
@@ -133,7 +133,7 @@ function __construct(DOMDocument $model, $strict = false)
133 133 $this->xpath->registerNamespace($key, $value);
134 134 }
135 135 $this->numberEntries = $this->count('item');
136   - $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
  136 +
137 137 }
138 138
139 139 /**
@@ -156,8 +156,7 @@ function getEntryById($id)
156 156
157 157 $entries = $this->xpath->query("//rss:item[@rdf:about='$id']");
158 158 if ($entries->length > 0) {
159   - $classname = $this->itemClass;
160   - $entry = new $classname($entries->item(0), $this);
  159 + $entry = new XML_Feed_Parser_RSS1Element($entries->item(0), $this);
161 160 return $entry;
162 161 }
163 162 return false;
3  XML/Feed/Parser/RSS2.php
@@ -114,7 +114,7 @@ class XML_Feed_Parser_RSS2 extends XML_Feed_Parser_Type
114 114 function __construct(DOMDocument $model, $strict = false)
115 115 {
116 116 $this->model = $model;
117   -
  117 + $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
118 118 if ($strict) {
119 119 if (! $this->relaxNGValidate()) {
120 120 throw new XML_Feed_Parser_Exception('Failed required validation');
@@ -126,7 +126,6 @@ function __construct(DOMDocument $model, $strict = false)
126 126 $this->xpath->registerNamespace($key, $value);
127 127 }
128 128 $this->numberEntries = $this->count('item');
129   - $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
130 129 }
131 130
132 131 /**
2  XML/Feed/Parser/Type.php
@@ -210,6 +210,8 @@ function getEntryByOffset($offset)
210 210 $entries = $this->model->getElementsByTagName($this->itemElement);
211 211 if ($entries->length > $offset) {
212 212 $xmlBase = $entries->item($offset)->baseURI;
  213 + /** @todo Remove this behaviour - each driver should control this better */
  214 + /** @todo Try to avoid new here */
213 215 $this->entries[$offset] = new $this->itemClass(
214 216 $entries->item($offset), $this, $xmlBase);
215 217 if ($id = $this->entries[$offset]->id) {

0 comments on commit a58f74f

Please sign in to comment.
Something went wrong with that request. Please try again.