summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Barth2010-10-25 23:59:31 (GMT)
committer Alex Barth2010-10-25 23:59:31 (GMT)
commit0932c95986f83a29afa3c7258ca6db9b2d9cf278 (patch)
tree52b2d23ef3c691d773c94745be1ce47245d20235
parent12ba86a0115c5524e32522d0c4e39f10527a9832 (diff)
#912630 twistor, alex_b: FeedsParserResult: make items accessible for modification.
-rw-r--r--CHANGELOG.txt2
-rw-r--r--feeds.api.php2
-rw-r--r--feeds.module2
-rw-r--r--plugins/FeedsOPMLParser.inc2
-rw-r--r--plugins/FeedsParser.inc80
-rw-r--r--plugins/FeedsSimplePieParser.inc8
-rw-r--r--plugins/FeedsSitemapParser.inc2
-rw-r--r--plugins/FeedsSyndicationParser.inc8
8 files changed, 19 insertions, 87 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 989c560..f2fb7a6 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -3,6 +3,8 @@
Feeds 7.x 2.0 XXXXXXXXXXXXXXXXXXX
---------------------------------
+- #912630 twistor, alex_b: FeedsParserResult: make items accessible for
+ modification.
- #933306 alex_b: Fix Feeds creates subscriptions for not existing importers.
- #946822 twistor: FeedsSitemapParser broken: Serialization of
'SimpleXMLElement' is not allowed.
diff --git a/feeds.api.php b/feeds.api.php
index 44578b4..e203147 100644
--- a/feeds.api.php
+++ b/feeds.api.php
@@ -96,7 +96,7 @@ function hook_feeds_plugins() {
*/
function hook_feeds_after_parse(FeedsSource $source, FeedsParserResult $result) {
// For example, set title of imported content:
- $result->setTitle('Import number ' . my_module_import_id());
+ $result->title = 'Import number ' . my_module_import_id();
}
/**
diff --git a/feeds.module b/feeds.module
index 697e4fa..7df0e3d 100644
--- a/feeds.module
+++ b/feeds.module
@@ -424,7 +424,7 @@ function feeds_node_validate($node, $form, &$form_state) {
if (trim($node->title) == '') {
try {
$source->addConfig($last_feeds);
- if (!$last_title = $source->preview()->getTitle()) {
+ if (!$last_title = $source->preview()->title) {
throw new Exception();
}
}
diff --git a/plugins/FeedsOPMLParser.inc b/plugins/FeedsOPMLParser.inc
index db473ba..9adc59f 100644
--- a/plugins/FeedsOPMLParser.inc
+++ b/plugins/FeedsOPMLParser.inc
@@ -18,7 +18,7 @@ class FeedsOPMLParser extends FeedsParser {
feeds_include_library('opml_parser.inc', 'opml_parser');
$opml = opml_parser_parse($fetcher_result->getRaw());
$result = new FeedsParserResult($opml['items']);
- $result->setTitle($opml['title']);
+ $result->title = $opml['title'];
return $result;
}
diff --git a/plugins/FeedsParser.inc b/plugins/FeedsParser.inc
index 79c9baa..b7e0897 100644
--- a/plugins/FeedsParser.inc
+++ b/plugins/FeedsParser.inc
@@ -5,11 +5,11 @@
* A result of a parsing stage.
*/
class FeedsParserResult extends FeedsResult {
- protected $title;
- protected $description;
- protected $link;
- protected $items;
- protected $current_item;
+ public $title;
+ public $description;
+ public $link;
+ public $items;
+ public $current_item;
/**
* Constructor.
@@ -22,31 +22,6 @@ class FeedsParserResult extends FeedsResult {
}
/**
- * @return
- * A string that is the feed's title.
- */
- public function getTitle() {
- return $this->title;
- }
-
- /**
- * @return
- * A string that is the feed's description.
- */
- public function getDescription() {
- return $this->description;
- }
-
- /**
- * @return
- * A string that is the link to the feed's site (not the actual URL of the
- * feed). Falls back to URL if not available.
- */
- public function getLink() {
- return $this->link;
- }
-
- /**
* @todo Move to a nextItem() based approach, not consuming the item array.
* Can only be done once we don't cache the entire batch object between page
* loads for batching anymore.
@@ -67,51 +42,6 @@ class FeedsParserResult extends FeedsResult {
public function currentItem() {
return empty($this->current_item) ? NULL : $this->current_item;
}
-
- /**
- * Set title.
- */
- public function setTitle($title) {
- $this->title = $title;
- }
-
- /**
- * Set description.
- */
- public function setDescription($description) {
- $this->description = $description;
- }
-
- /**
- * Set link.
- */
- public function setLink($link) {
- $this->link = $link;
- }
-
- /**
- * Set items.
- *
- * @param $items
- * An array of the items in the feed. Cannot be NULL.
- */
- public function setItems($items) {
- $this->items = $items;
- }
-
- /**
- * Add an item.
- */
- public function addItem($item) {
- $this->items[] = $item;
- }
-
- /**
- * Get number of items.
- */
- public function getItemCount() {
- return count($this->items);
- }
}
/**
diff --git a/plugins/FeedsSimplePieParser.inc b/plugins/FeedsSimplePieParser.inc
index c3e1c5a..197fe28 100644
--- a/plugins/FeedsSimplePieParser.inc
+++ b/plugins/FeedsSimplePieParser.inc
@@ -75,9 +75,9 @@ class FeedsSimplePieParser extends FeedsParser {
// Construct the standard form of the parsed feed
$result = new FeedsParserResult();
- $result->setTitle(html_entity_decode(($title = $parser->get_title()) ? $title : $this->createTitle($parser->get_description())));
- $result->setDescription($parser->get_description());
- $result->setLink(html_entity_decode($parser->get_link()));
+ $result->title = html_entity_decode(($title = $parser->get_title()) ? $title : $this->createTitle($parser->get_description()));
+ $result->description = $parser->get_description();
+ $result->link = html_entity_decode($parser->get_link());
$items_num = $parser->get_item_quantity();
for ($i = 0; $i < $items_num; $i++) {
@@ -137,7 +137,7 @@ class FeedsSimplePieParser extends FeedsParser {
$this->parseExtensions($item, $simplepie_item);
$item['raw'] = $simplepie_item->data;
- $result->addItem($item);
+ $result->items[] = $item;
}
// Release parser.
unset($parser);
diff --git a/plugins/FeedsSitemapParser.inc b/plugins/FeedsSitemapParser.inc
index f569911..329a86b 100644
--- a/plugins/FeedsSitemapParser.inc
+++ b/plugins/FeedsSitemapParser.inc
@@ -26,7 +26,7 @@ class FeedsSitemapParser extends FeedsParser {
if ($url->priority) {
$item['priority'] = (string) $url->priority;
}
- $result->addItem($item);
+ $result->items[] = $item;
}
date_default_timezone_set($tz);
return $result;
diff --git a/plugins/FeedsSyndicationParser.inc b/plugins/FeedsSyndicationParser.inc
index aabcd32..80c7dff 100644
--- a/plugins/FeedsSyndicationParser.inc
+++ b/plugins/FeedsSyndicationParser.inc
@@ -15,9 +15,9 @@ class FeedsSyndicationParser extends FeedsParser {
feeds_include_library('common_syndication_parser.inc', 'common_syndication_parser');
$feed = common_syndication_parser_parse($fetcher_result->getRaw());
$result = new FeedsParserResult();
- $result->setTitle($feed['title']);
- $result->setDescription($feed['description']);
- $result->setLink($feed['link']);
+ $result->title = $feed['title'];
+ $result->description = $feed['description'];
+ $result->link = $feed['link'];
if (is_array($feed['items'])) {
foreach ($feed['items'] as $item) {
if (isset($item['geolocations'])) {
@@ -25,7 +25,7 @@ class FeedsSyndicationParser extends FeedsParser {
$item['geolocations'][$k] = new FeedsGeoTermElement($v);
}
}
- $result->addItem($item);
+ $result->items[] = $item;
}
}
return $result;