]> git.wh0rd.org Git - tt-rss.git/commitdiff
Store size of enclosure to database
authorFelix Eckhofer <felix@eckhofer.com>
Tue, 15 Jul 2014 13:32:28 +0000 (15:32 +0200)
committerFelix Eckhofer <felix@eckhofer.com>
Tue, 15 Jul 2014 14:23:46 +0000 (16:23 +0200)
classes/feedenclosure.php
classes/feeditem/atom.php
classes/feeditem/rss.php
include/rssfuncs.php

index b57100b0600bb35448694ac892f8e477ea25a541..64f1a0616aa89df2ececa1fb8dbe8c485a1d8aa2 100644 (file)
@@ -4,5 +4,7 @@ class FeedEnclosure {
        public $type;
        public $length;
        public $title;
+       public $height;
+       public $width;
 }
 ?>
index 48e3aa567173e7067f89d88002a7d429a3e37034..dfac7149f6cb4981cd6d768dd36e3600b80dd438 100644 (file)
@@ -145,6 +145,8 @@ class FeedItem_Atom extends FeedItem_Common {
                        $enc->type = $enclosure->getAttribute("type");
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        $desc = $this->xpath->query("media:description", $enclosure)->item(0);
                        if ($desc) $enc->title = strip_tags($desc->nodeValue);
@@ -164,6 +166,8 @@ class FeedItem_Atom extends FeedItem_Common {
                                $enc->type = $content->getAttribute("type");
                                $enc->link = $content->getAttribute("url");
                                $enc->length = $content->getAttribute("length");
+                               $enc->height = $content->getAttribute("height");
+                               $enc->width = $content->getAttribute("width");
 
                                $desc = $this->xpath->query("media:description", $content)->item(0);
                                if ($desc) {
@@ -184,6 +188,8 @@ class FeedItem_Atom extends FeedItem_Common {
 
                        $enc->type = "image/generic";
                        $enc->link = $enclosure->getAttribute("url");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        array_push($encs, $enc);
                }
index bf08a1dfefe747a47c1192613d45cbd22eae0998..c9a7467cda6581b6d00ec788c08a64d5c7d6345e 100644 (file)
@@ -113,6 +113,8 @@ class FeedItem_RSS extends FeedItem_Common {
                        $enc->type = $enclosure->getAttribute("type");
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        array_push($encs, $enc);
                }
@@ -125,6 +127,8 @@ class FeedItem_RSS extends FeedItem_Common {
                        $enc->type = $enclosure->getAttribute("type");
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        $desc = $this->xpath->query("media:description", $enclosure)->item(0);
                        if ($desc) $enc->title = strip_tags($desc->nodeValue);
@@ -144,6 +148,8 @@ class FeedItem_RSS extends FeedItem_Common {
                                $enc->type = $content->getAttribute("type");
                                $enc->link = $content->getAttribute("url");
                                $enc->length = $content->getAttribute("length");
+                               $enc->height = $content->getAttribute("height");
+                               $enc->width = $content->getAttribute("width");
 
                                $desc = $this->xpath->query("media:description", $content)->item(0);
                                if ($desc) {
@@ -164,6 +170,8 @@ class FeedItem_RSS extends FeedItem_Common {
 
                        $enc->type = "image/generic";
                        $enc->link = $enclosure->getAttribute("url");
+                       $enc->height = $enclosure->getAttribute("height");
+                       $enc->width = $enclosure->getAttribute("width");
 
                        array_push($encs, $enc);
                }
index 60cb3b2d24a007cbbee15612736f1f54a5dcdf82..cdc490cb09d9f0440455884c29252d5bf7d14d08 100644 (file)
                                if (is_array($encs)) {
                                        foreach ($encs as $e) {
                                                $e_item = array(
-                                                       $e->link, $e->type, $e->length, $e->title);
+                                                       $e->link, $e->type, $e->length, $e->title, $e->width, $e->height);
                                                array_push($enclosures, $e_item);
                                        }
                                }
                                        $enc_type = db_escape_string($enc[1]);
                                        $enc_dur = db_escape_string($enc[2]);
                                        $enc_title = db_escape_string($enc[3]);
+                                       $enc_width = intval($enc[4]);
+                                       $enc_height = intval($enc[5]);
 
                                        $result = db_query("SELECT id FROM ttrss_enclosures
                                                WHERE content_url = '$enc_url' AND post_id = '$entry_ref_id'");
 
                                        if (db_num_rows($result) == 0) {
                                                db_query("INSERT INTO ttrss_enclosures
-                                                       (content_url, content_type, title, duration, post_id) VALUES
-                                                       ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id')");
+                                                       (content_url, content_type, title, duration, post_id, width, height) VALUES
+                                                       ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id', $enc_width, $enc_height)");
                                        }
                                }