From 2b2aaeca01f8c7ab2faea3170793854679885246 Mon Sep 17 00:00:00 2001
From: Alex Barth <alex_b@53995.no-reply.drupal.org>
Date: Mon, 25 Jan 2010 20:03:05 +0000
Subject: [PATCH] #686462: Move FeedsEnclosure class to FeedsParser.inc.

---
 feeds.plugins.inc                  |  2 +-
 plugins/FeedsParser.inc            | 61 ++++++++++++++++++++++++++++++
 plugins/FeedsSyndicationParser.inc | 61 ------------------------------
 3 files changed, 62 insertions(+), 62 deletions(-)

diff --git a/feeds.plugins.inc b/feeds.plugins.inc
index 0bc096d2..e1e7e497 100644
--- a/feeds.plugins.inc
+++ b/feeds.plugins.inc
@@ -113,7 +113,7 @@ function _feeds_feeds_plugins() {
       'description' => 'Parse RSS and Atom feeds.',
       'help' => 'Use <a href="http://simplepie.org">SimplePie</a> to parse XML feeds in RSS 1, RSS 2 and Atom format.',
       'handler' => array(
-        'parent' => 'FeedsSyndicationParser',
+        'parent' => 'FeedsParser',
         'class' => 'FeedsSimplePieParser',
         'file' => 'FeedsSimplePieParser.inc',
         'path' => $path,
diff --git a/plugins/FeedsParser.inc b/plugins/FeedsParser.inc
index 3068c4ed..3f5cae00 100644
--- a/plugins/FeedsParser.inc
+++ b/plugins/FeedsParser.inc
@@ -97,6 +97,67 @@ class FeedsElement {
   }
 }
 
+/**
+ * Enclosure element, can be part of the result array.
+ */
+class FeedsEnclosure extends FeedsElement {
+  protected $mime_type;
+  protected $file;
+
+  /**
+   * Constructor, requires MIME type.
+   */
+  public function __construct($value, $mime_type) {
+    parent::__construct($value);
+    $this->mime_type = $mime_type;
+  }
+
+  /**
+   * @return
+   *   MIME type of return value of getValue().
+   */
+  public function getMIMEType() {
+    return $this->mime_type;
+  }
+
+  /**
+   * @return
+   *   The content of the referenced resource.
+   */
+  public function getContent() {
+    feeds_include_library('http_request.inc', 'http_request');
+    $result = http_request_get($this->getValue());
+    if ($result->code != 200) {
+      throw new Exception(t('Download of @url failed with code !code.', array('@url' => $this->getValue(), '!code' => $result->code)));
+    }
+    return $result->data;
+  }
+
+  /**
+   * @return
+   *   The file path to the downloaded resource referenced by the enclosure.
+   *   Downloads resource if not downloaded yet.
+   *
+   * @todo Get file extension from mime_type.
+   * @todo This is not concurrency safe.
+   */
+  public function getFile() {
+    if(!isset($this->file)) {
+      $dest = file_destination(file_directory_temp() .'/'. get_class($this) .'-'. basename($this->getValue()), FILE_EXISTS_RENAME);
+      if (ini_get('allow_url_fopen')) {
+        $this->file = copy($this->getValue(), $dest) ? $dest : 0;
+      }
+      else {
+        $this->file = file_save_data($this->getContent(), $dest);
+      }
+      if ($this->file === 0) {
+        throw new Exception(t('Cannot write content to %dest', array('%dest' => $dest)));
+      }
+    }
+    return $this->file;
+  }
+}
+
 /**
  * Defines a date element of a parsed result (including ranges, repeat).
  */
diff --git a/plugins/FeedsSyndicationParser.inc b/plugins/FeedsSyndicationParser.inc
index 08473e83..1561bce2 100644
--- a/plugins/FeedsSyndicationParser.inc
+++ b/plugins/FeedsSyndicationParser.inc
@@ -1,67 +1,6 @@
 <?php
 // $Id$
 
-/**
- * Enclosure element, can be part of the result array.
- */
-class FeedsEnclosure extends FeedsElement {
-  protected $mime_type;
-  protected $file;
-
-  /**
-   * Constructor, requires MIME type.
-   */
-  public function __construct($value, $mime_type) {
-    parent::__construct($value);
-    $this->mime_type = $mime_type;
-  }
-
-  /**
-   * @return
-   *   MIME type of return value of getValue().
-   */
-  public function getMIMEType() {
-    return $this->mime_type;
-  }
-
-  /**
-   * @return
-   *   The content of the referenced resource.
-   */
-  public function getContent() {
-    feeds_include_library('http_request.inc', 'http_request');
-    $result = http_request_get($this->getValue());
-    if ($result->code != 200) {
-      throw new Exception(t('Download of @url failed with code !code.', array('@url' => $this->getValue(), '!code' => $result->code)));
-    }
-    return $result->data;
-  }
-
-  /**
-   * @return
-   *   The file path to the downloaded resource referenced by the enclosure.
-   *   Downloads resource if not downloaded yet.
-   *
-   * @todo Get file extension from mime_type.
-   * @todo This is not concurrency safe.
-   */
-  public function getFile() {
-    if(!isset($this->file)) {
-      $dest = file_destination(file_directory_temp() .'/'. get_class($this) .'-'. basename($this->getValue()), FILE_EXISTS_RENAME);
-      if (ini_get('allow_url_fopen')) {
-        $this->file = copy($this->getValue(), $dest) ? $dest : 0;
-      }
-      else {
-        $this->file = file_save_data($this->getContent(), $dest);
-      }
-      if ($this->file === 0) {
-        throw new Exception(t('Cannot write content to %dest', array('%dest' => $dest)));
-      }
-    }
-    return $this->file;
-  }
-}
-
 /**
  * Class definition for Common Syndication Parser.
  *
-- 
GitLab