]> git.wh0rd.org - tt-rss.git/blobdiff - include/functions.php
add a knob to disable reload on js change
[tt-rss.git] / include / functions.php
index c01e4100437886997ddd86423ff3c07f830cf1ff..9a3ea4315779360bd2404ba6a9e850c5021d7dc6 100644 (file)
         *                 5 - Couldn't download the URL content.
         */
        function subscribe_to_feed($link, $url, $cat_id = 0,
-                       $auth_login = '', $auth_pass = '', $need_auth = false) {
+                       $auth_login = '', $auth_pass = '') {
 
                global $fetch_last_error;
 
                $data['cdm_expanded'] = get_pref($link, 'CDM_EXPANDED');
 
                $data['dep_ts'] = calculate_dep_timestamp();
+               $data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE');
 
                if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
 
                $entries = $doc->getElementsByTagName("*");
 
                $allowed_elements = array('a', 'address', 'audio', 'article',
-                       'b', 'big', 'blockquote', 'body', 'br', 'cite',
+                       'b', 'big', 'blockquote', 'body', 'br', 'cite', 'center',
                        'code', 'dd', 'del', 'details', 'div', 'dl', 'font',
                        'dt', 'em', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
                        'header', 'html', 'i', 'img', 'ins', 'kbd',
                        }
 
                        if ($entry->hasAttributes()) {
-                               foreach (iterator_to_array($entry->attributes) as $attr) {
+                               $attrs_to_remove = array();
+
+                               foreach ($entry->attributes as $attr) {
 
                                        if (strpos($attr->nodeName, 'on') === 0) {
-                                               $entry->removeAttributeNode($attr);
+                                               array_push($attrs_to_remove, $attr);
                                        }
 
                                        if (in_array($attr->nodeName, $disallowed_attributes)) {
-                                               $entry->removeAttributeNode($attr);
+                                               array_push($attrs_to_remove, $attr);
                                        }
                                }
+
+                               foreach ($attrs_to_remove as $attr) {
+                                       $entry->removeAttributeNode($attr);
+                               }
                        }
                }
 
                                                <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>";
+                                       </head><body id=\"ttrssZoom\">";
                        }
 
                        $rv['content'] .= "<div class=\"postReply\" id=\"POST-$id\">";
 
                if ($zoom_mode) {
                        $rv['content'] .= "
-                               <div style=\"text-align : center\">
+                               <div class='footer'>
                                <button onclick=\"return window.close()\">".
                                        __("Close this window")."</button></div>";
                        $rv['content'] .= "</body></html>";
                return $max_ts;
        }
 
+       function T_js_decl($s1, $s2) {
+               if ($s1 && $s2) {
+                       $s1 = preg_replace("/\n/", "", $s1);
+                       $s2 = preg_replace("/\n/", "", $s2);
+
+                       $s1 = preg_replace("/\"/", "\\\"", $s1);
+                       $s2 = preg_replace("/\"/", "\\\"", $s2);
+
+                       return "T_messages[\"$s1\"] = \"$s2\";\n";
+               }
+       }
+
+       function init_js_translations() {
+
+       print 'var T_messages = new Object();
+
+               function __(msg) {
+                       if (T_messages[msg]) {
+                               return T_messages[msg];
+                       } else {
+                               return msg;
+                       }
+               }
+
+               function ngettext(msg1, msg2, n) {
+                       return (parseInt(n) > 1) ? msg2 : msg1;
+               }';
+
+               $l10n = _get_reader();
+
+               for ($i = 0; $i < $l10n->total; $i++) {
+                       $orig = $l10n->get_original_string($i);
+                       $translation = __($orig);
+
+                       print T_js_decl($orig, $translation);
+               }
+       }
+
 ?>