]> git.wh0rd.org - tt-rss.git/blobdiff - functions.php
code cleanup, test for db_escape() crazyness in DB sanity check
[tt-rss.git] / functions.php
index 5e0c05b1fa131d9e906c25fc68a39a16c5e11ee7..48d6e3a858adb4926c7d372781be8567c4dfce6e 100644 (file)
@@ -26,6 +26,7 @@
                                        "en_US" => "English",
                                        "fr_FR" => "Français",
                                        "hu_HU" => "Magyar (Hungarian)",
+                                       "it_IT" => "Italiano",
                                        "ja_JP" => "日本語 (Japanese)",
                                        "nb_NO" => "Norwegian bokmål",
                                        "ru_RU" => "Русский",
                                        }
 
                                        // <media:content>
-                                       // can there be many of those? -fox
+                                       // can there be many of those? yes -fox
 
                                        $m_ctr = $item['media']['content#'];
 
                                                        $item['media']['content@length']);
 
                                                array_push($enclosures, $e_item);
-                                       }
 
-                                       // FIXME: parse more of those, if needed.
+                                               for ($i = 0; $i <= $m_ctr; $i++ ) {
+
+                                                       if ($item["media"]["content#$i@url"]) {
+                                                               $e_item = array($item["media"]["content#$i@url"],
+                                                                       $item["media"]["content#$i@medium"],
+                                                                       $item["media"]["content#$i@length"]);
+                                                               array_push($enclosures, $e_item);
+                                                       }
+                                               }
+
+                                       }
                                }
 
                                # sanitize content
                        }
                }
 
+               if (db_escape_string("testTEST") != "testTEST") {
+                       $error_code = 12;
+               }
+
                error_reporting (DEFAULT_ERROR_LEVEL);
 
                if ($error_code != 0) {
 
                        $last_updated = htmlspecialchars($last_updated);
 
-                       $has_img = is_file(ICONS_DIR . "/$id.ico");
+                       $has_img = feed_has_icon($id);
 
                        $tmp_result = db_query($link,
                                "SELECT ttrss_feeds.id,COUNT(unread) AS unread
                                $tid = "headlineActionsBottom";
                        }
 
-                       print "<table class=\"$class\" id=\"$tid\"
+                       print "<nobr><table class=\"$class\" id=\"$tid\"
                                width=\"100%\" cellspacing=\"0\" cellpadding=\"0\"><tr>";
 
                        if ($rtl_content) {
                        print "</span>";
 
                        print "</td>";
-                       print "</tr></table>";
+                       print "</tr></table></nobr>";
 
                }
 
                        if ($zoom_mode) {
                                header("Content-Type: text/html");
                                print "<html><head>
+                                               <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
                                                <title>Tiny Tiny RSS - ".$line["title"]."</title>
                                                <link rel=\"stylesheet\" type=\"text/css\" href=\"tt-rss.css\">
                                        </head><body>";
                        if (!$zoom_mode) {
                                print "$tags_str 
                                        <a title=\"".__('Edit tags for this article')."\" 
-                                               href=\"javascript:editArticleTags($id, $feed_id)\">(+)</a>                              
-                                       <img src=\"images/art-zoom.png\" class='tagsPic' 
-                                               style=\"cursor : pointer\"
+                                       href=\"javascript:editArticleTags($id, $feed_id)\">(+)</a>";
+
+                               if (defined('_ENABLE_INLINE_VIEW')) {
+
+                                       print "<img src=\"images/art-inline.png\" class='tagsPic' 
+                                                       style=\"cursor : pointer\" style=\"cursor : pointer\"
+                                                       onclick=\"showOriginalArticleInline($id)\"
+                                                       alt='Inline' title='".__('Display original article content')."'>";
+
+                               }
+
+                               print "<img src=\"images/art-zoom.png\" class='tagsPic' 
+                                               style=\"cursor : pointer\" style=\"cursor : pointer\"
                                                onclick=\"zoomToArticle($id)\"
                                                alt='Zoom' title='".__('Show article summary in new window')."'>";
                        } else {
                                post_id = '$id' AND content_url != ''");
 
                        if (db_num_rows($result) > 0) {
-                               print "<div class=\"postEnclosures\">";
-
-                               if (db_num_rows($result) == 1) {
-                                       print __("Attachment:") . " ";
-                               } else {
-                                       print __("Attachments:") . " ";
-                               }
 
+                               $entries_html = array();
                                $entries = array();
 
                                while ($line = db_fetch_assoc($result)) {
                                        $entry .= "<a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
                                                $filename . " (" . $ctype . ")" . "</a>";
 
+                                       array_push($entries_html, $entry);
+
+                                       $entry = array();
+
+                                       $entry["type"] = $ctype;
+                                       $entry["filename"] = $filename;
+                                       $entry["url"] = $url;
+
                                        array_push($entries, $entry);
                                }
 
-                               print join(", ", $entries);
+                               if (!preg_match("/img/i", $line["content"]) &&
+                                       preg_match("/image/", $entries[0]["type"])) {
+
+                               }
+
+                               print "<div class=\"postEnclosures\">";
+
+                               if (!preg_match("/img/i", $line["content"])) {
+                                       foreach ($entries as $entry) {
+                                               if (preg_match("/image/", $entry["type"])) {
+                                                       print "<p><img 
+                                                               alt=\"".htmlspecialchars($entry["filename"])."\"
+                                                               src=\"" .htmlspecialchars($entry["url"]) . "\"></p>";
+                                               }
+                                       }
+                               }
+
+                               print "<div class=\"postEnclosures\">";
+
+                               if (db_num_rows($result) == 1) {
+                                       print __("Attachment:") . " ";
+                               } else {
+                                       print __("Attachments:") . " ";
+                               }
+
+                               print join(", ", $entries_html);
 
                                print "</div>";
                        }
                                        $entry_author = " - $entry_author";
                                }
 
-                               $has_feed_icon = is_file(ICONS_DIR . "/$feed_id.ico");
+                               $has_feed_icon = feed_has_icon($feed_id);
 
                                if ($has_feed_icon) {
                                        $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
 
                                                        $vf_catchup_link = "(<a onclick='javascript:catchupFeedInGroup($feed_id);' href='#'>mark as read</a>)";
 
-                                                       $has_feed_icon = is_file(ICONS_DIR . "/$feed_id.ico");
+                                                       $has_feed_icon = feed_has_icon($feed_id);
 
                                                        if ($has_feed_icon) {
                                                                $feed_icon_img = "<img class=\"tinyFeedIcon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">";
                                                post_id = '$id' AND content_url != ''");
 
                                        if (db_num_rows($e_result) > 0) {
-                               print "<div class=\"cdmEnclosures\">";
-
-                               if (db_num_rows($e_result) == 1) {
-                                       print __("Attachment:") . " ";
-                               } else {
-                                       print __("Attachments:") . " ";
-                               }
 
+                               $entries_html = array();
                                $entries = array();
 
                                while ($e_line = db_fetch_assoc($e_result)) {
                                        $entry .= "<a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
                                                $filename . " (" . $ctype . ")" . "</a>";
 
+                                       array_push($entries_html, $entry);
+
+                                       $entry = array();
+
+                                       $entry["type"] = $ctype;
+                                       $entry["filename"] = $filename;
+                                       $entry["url"] = $url;
+
                                        array_push($entries, $entry);
                                }
 
-                               print join(", ", $entries);
+                               if (!preg_match("/img/i", $line["content"])) {
+                                       foreach ($entries as $entry) {
+                                               if (preg_match("/image/", $entry["type"])) {
+                                                       print "<p><img 
+                                                               alt=\"".htmlspecialchars($entry["filename"])."\"
+                                                               src=\"" .htmlspecialchars($entry["url"]) . "\"></p>";
+                                               }
+                                       }
+                               }
+
+                               print "<div class=\"cdmEnclosures\">";
+
+                               if (db_num_rows($e_result) == 1) {
+                                       print __("Attachment:") . " ";
+                               } else {
+                                       print __("Attachments:") . " ";
+                               }
+
+                               print join(", ", $entries_html);
 
                                print "</div>";
                        }
 
+
                                        print "<br clear='both'>";
 //                                     print "</div>";
 
                        onclick=\"return addLabelExample()\"
                        value=\"".__("Add")."\">";
        }
+
+       function feed_has_icon($id) {
+               return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
+       }
+
+       function init_connection($link) {
+               if (DB_TYPE == "pgsql") {
+                       pg_query("set client_encoding = 'UTF-8'");
+                       pg_set_client_encoding("UNICODE");
+               } else {
+                       if (defined('MYSQL_CHARSET') && MYSQL_CHARSET) {
+                               db_query($link, "SET NAMES " . MYSQL_CHARSET);
+       //                      db_query($link, "SET CHARACTER SET " . MYSQL_CHARSET);
+                       }
+               }
+       }
 ?>