]> git.wh0rd.org Git - tt-rss.git/commitdiff
support media:description for media: enclosures
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 5 Aug 2013 08:26:09 +0000 (12:26 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 5 Aug 2013 08:26:09 +0000 (12:26 +0400)
classes/feedenclosure.php
classes/feeditem/atom.php
classes/feeditem/rss.php
css/tt-rss.css
include/functions.php
include/rssfuncs.php

index d610dd7c8f551b04976e0d47ff88ae1eefde9636..b57100b0600bb35448694ac892f8e477ea25a541 100644 (file)
@@ -3,5 +3,6 @@ class FeedEnclosure {
        public $link;
        public $type;
        public $length;
+       public $title;
 }
 ?>
index b1251e6d315136cbe3079cb3dd6b1be4d6467fa1..b7a228aed406c88615fc13bbfd0ea1a2abd81f56 100644 (file)
@@ -146,6 +146,9 @@ class FeedItem_Atom extends FeedItem_Common {
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
 
+                       $desc = $this->xpath->query("media:description", $enclosure)->item(0);
+                       if ($desc) $enc->title = strip_tags($desc->nodeValue);
+
                        array_push($encs, $enc);
                }
 
index 095225a2a919fdd8498c5c63bf4be809fc0ff1a6..1f59f0612b104a7c589890e209860899af8641ee 100644 (file)
@@ -121,6 +121,9 @@ class FeedItem_RSS extends FeedItem_Common {
                        $enc->link = $enclosure->getAttribute("url");
                        $enc->length = $enclosure->getAttribute("length");
 
+                       $desc = $this->xpath->query("media:description", $enclosure)->item(0);
+                       if ($desc) $enc->title = strip_tags($desc->nodeValue);
+
                        array_push($encs, $enc);
                }
 
index 3392c3c7ae3035d452e6e93f98810fe86ca69ca9..9e500a759d468a64dcfc8eeab0790c51cac37d63 100644 (file)
@@ -1177,3 +1177,8 @@ span.highlight {
        background-color : #ffff00;
        color : #cc90cc;
 }
+
+div.enclosure_title {
+
+}
+
index 56361472ee5f4cc9b280fc6a5fce02932c89d7bf..6bc52e9d95db0cf1969daca91118580b8f7f8b53 100644 (file)
 
                                $url = $line["content_url"];
                                $ctype = $line["content_type"];
+                               $title = $line["title"];
 
                                if (!$ctype) $ctype = __("unknown type");
 
                                $entry["type"] = $ctype;
                                $entry["filename"] = $filename;
                                $entry["url"] = $url;
+                               $entry["title"] = $title;
 
                                array_push($entries, $entry);
                        }
                                                                        $rv .= "<p><a target=\"_blank\"
                                                                        href=\"".htmlspecialchars($entry["url"])."\"
                                                                        >" .htmlspecialchars($entry["url"]) . "</a></p>";
+                                                               }
 
+                                                               if ($entry['title']) {
+                                                                       $rv.= "<div class=\"enclosure_title\">${entry['title']}</div>";
                                                                }
                                                }
                                        }
                                "<option value=''>" . __('Attachments')."</option>";
 
                        foreach ($entries as $entry) {
-                               $rv .= "<option value=\"".htmlspecialchars($entry["url"])."\">" . htmlspecialchars($entry["filename"]) . "</option>";
+                               if ($entry["title"])
+                                       $title = "&mdash; " . truncate_string($entry["title"], 30);
+                               else
+                                       $title = "";
+
+                               $rv .= "<option value=\"".htmlspecialchars($entry["url"])."\">" . htmlspecialchars($entry["filename"]) . "$title</option>";
 
                        };
 
index 4b1b30c4bc48b9c6bca009ca177548e10bfd1526..dbe5c8bc91a1fa0ab87697d8f02908841134ef90 100644 (file)
                                if (is_array($encs)) {
                                        foreach ($encs as $e) {
                                                $e_item = array(
-                                                       $e->link, $e->type, $e->length);
+                                                       $e->link, $e->type, $e->length, $e->title);
                                                array_push($enclosures, $e_item);
                                        }
                                }
 
                                db_query("BEGIN");
 
+//                             debugging
+//                             db_query("DELETE FROM ttrss_enclosures WHERE post_id = '$entry_ref_id'");
+
                                foreach ($enclosures as $enc) {
                                        $enc_url = db_escape_string($enc[0]);
                                        $enc_type = db_escape_string($enc[1]);
                                        $enc_dur = db_escape_string($enc[2]);
+                                       $enc_title = db_escape_string($enc[3]);
 
                                        $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_dur', '$entry_ref_id')");
+                                                       ('$enc_url', '$enc_type', '$enc_title', '$enc_dur', '$entry_ref_id')");
                                        }
                                }