]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions2.php
force ngettext() count argument type to string
[tt-rss.git] / include / functions2.php
index 1c2ffb9369329532ad8c0571fd98e039f9f6f5f4..28477a0cfd0c7447f5a0237eae0d5fca6f2d7eaf 100644 (file)
@@ -89,6 +89,7 @@
                                "feed_edit" => __("Edit feed"),
                                "feed_catchup" => __("Mark as read"),
                                "feed_reverse" => __("Reverse headlines"),
+                               "feed_toggle_vgroup" => __("Toggle headline grouping"),
                                "feed_debug_update" => __("Debug feed update"),
                                "feed_debug_viewfeed" => __("Debug viewfeed()"),
                                "catchup_all" => __("Mark all feeds as read"),
                                "f e" => "feed_edit",
                                "f q" => "feed_catchup",
                                "f x" => "feed_reverse",
+                               "f g" => "feed_toggle_vgroup",
                                "f *d" => "feed_debug_update",
                                "f *g" => "feed_debug_viewfeed",
                                "f *c" => "toggle_combined_mode",
 
                $res = $doc->saveHTML();
 
-               return $res;
+               /* strip everything outside of <body>...</body> */
+
+               $res_frag = array();
+               if (preg_match('/<body>(.*)<\/body>/is', $res, $res_frag)) {
+                       return $res_frag[1];
+               } else {
+                       return $res;
+               }
        }
 
        function strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes) {
                                                array_push($attrs_to_remove, $attr);
                                        }
 
+                                       if ($attr->nodeName == 'href' && stripos($attr->value, 'javascript:') === 0) {
+                                               array_push($attrs_to_remove, $attr);
+                                       }
+
                                        if (in_array($attr->nodeName, $disallowed_attributes)) {
                                                array_push($attrs_to_remove, $attr);
                                        }
                                $line = $p->hook_render_article($line);
                        }
 
-                       $num_comments = $line["num_comments"];
+                       $num_comments = (int) $line["num_comments"];
                        $entry_comments = "";
 
                        if ($num_comments > 0) {
                        }
 
                        if ($zoom_mode) {
-                               $feed_title = "<a href=\"".htmlspecialchars($line["site_url"]).
-                                       "\" target=\"_blank\">".
-                                       htmlspecialchars($line["feed_title"])."</a>";
+                               $feed_title = htmlspecialchars($line["feed_title"]);
 
                                $rv['content'] .= "<div class=\"postFeedTitle\">$feed_title</div>";
 
                        $url .= '/';
                }
 
+               //convert IDNA hostname to punycode if possible
+               if (function_exists("idn_to_ascii")) {
+                       $parts = parse_url($url);
+                       if (mb_detect_encoding($parts['host']) != 'ASCII')
+                       {
+                               $parts['host'] = idn_to_ascii($parts['host']);
+                               $url = build_url($parts);
+                       }
+               }
+
                if ($url != "http:///")
                        return $url;
                else
 
                                if (!$ctype) $ctype = __("unknown type");
 
-                               $filename = substr($url, strrpos($url, "/")+1);
+                               //$filename = substr($url, strrpos($url, "/")+1);
+                               $filename = basename($url);
 
                                $player = format_inline_player($url, $ctype);
 
 
                        foreach ($entries as $entry) {
                                if ($entry["title"])
-                                       $title = "&mdash; " . truncate_string($entry["title"], 30);
+                                       $title = " &mdash; " . truncate_string($entry["title"], 30);
                                else
                                        $title = "";
 
+                               if ($entry["filename"])
+                                       $filename = truncate_middle(htmlspecialchars($entry["filename"]), 60);
+                               else
+                                       $filename = "";
+
                                $rv .= "<div onclick='window.open(\"".htmlspecialchars($entry["url"])."\")'
-                                       dojoType=\"dijit.MenuItem\">".htmlspecialchars($entry["filename"])."$title</div>";
+                                       dojoType=\"dijit.MenuItem\">".$filename . $title."</div>";
 
                        };
 
 
                return $tmp;
        }
+
+       function get_upload_error_message($code) {
+
+               $errors = array(
+                       0 => __('There is no error, the file uploaded with success'),
+                       1 => __('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
+                       2 => __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
+                       3 => __('The uploaded file was only partially uploaded'),
+                       4 => __('No file was uploaded'),
+                       6 => __('Missing a temporary folder'),
+                       7 => __('Failed to write file to disk.'),
+                       8 => __('A PHP extension stopped the file upload.'),
+               );
+
+               return $errors[$code];
+       }
 ?>