]> git.wh0rd.org - tt-rss.git/blobdiff - modules/pref-feeds.php
rework OPML import process
[tt-rss.git] / modules / pref-feeds.php
index d0bc194a46064914df9e21d00c48ab921d0ee176..859b11ee948715a87a9195931c42aa00cc753c07 100644 (file)
@@ -2,7 +2,7 @@
 
        function batch_edit_cbox($elem, $label = false) {
                print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
-                       onchange=\"batchFeedsToggleField(this, '$elem', '$label')\">";
+                       onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">";
        }
 
        function module_pref_feeds($link) {
                if ($subop == "editfeeds") {
 
                        $feed_ids = db_escape_string($_REQUEST["ids"]);
-                       
-                       header("Content-Type: text/xml");
-                       print "<dlg id=\"$subop\">";
-                       print "<title>".__('Multiple Feed Editor')."</title>";
-                       print "<content><![CDATA[";
-
-                       print "<form id=\"batch_edit_feed_form\" onsubmit=\"return false\">";   
 
-                       print "<input type=\"hidden\" name=\"ids\" value=\"$feed_ids\">";
-                       print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
-                       print "<input type=\"hidden\" name=\"subop\" value=\"batchEditSave\">";
+                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"ids\" value=\"$feed_ids\">";
+                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-feeds\">";
+                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"batchEditSave\">";
 
                        print "<div class=\"dlgSec\">".__("Feed")."</div>";
                        print "<div class=\"dlgSecCont\">";
 
                        /* Title */
 
-                       print "<input disabled style=\"font-size : 16px\" size=\"35\" onkeypress=\"return filterCR(event, feedEditSave)\"
-                                           name=\"title\" value=\"$title\">";
+                       print "<input dojoType=\"dijit.form.ValidationTextBox\" 
+                               disabled=\"1\" style=\"font-size : 16px; width : 20em;\" required=\"1\"
+                               name=\"title\" value=\"$title\">";
 
                        batch_edit_cbox("title");
 
                        print "<br/>";
 
                        print __('URL:') . " ";
-                       print "<input disabled size=\"40\" onkeypress=\"return filterCR(event, feedEditSave)\"
+                       print "<input dojoType=\"dijit.form.ValidationTextBox\" disabled=\"1\"
+                               required=\"1\" regExp='^(http|https)://.*' style=\"width : 20em\"
                                name=\"feed_url\" value=\"$feed_url\">";
 
                        batch_edit_cbox("feed_url");
 
                                print __('Place in category:') . " ";
 
-                               print_feed_cat_select($link, "cat_id", $cat_id, "disabled");
+                               print_feed_cat_select($link, "cat_id", $cat_id, 
+                                       'disabled="1" dojoType="dijit.form.Select"');
 
                                batch_edit_cbox("cat_id");
 
                        /* Update Interval */
 
                        print_select_hash("update_interval", $update_interval, $update_intervals, 
-                               "disabled");
+                               'disabled="1" dojoType="dijit.form.Select"');
 
                        batch_edit_cbox("update_interval");
 
 
                        print " " . __('using') . " ";
                        print_select_hash("update_method", $update_method, $update_methods, 
-                               "disabled");                    
+                               'disabled="1" dojoType="dijit.form.Select"');                   
                        batch_edit_cbox("update_method");
 
                        /* Purge intl */
 
-                       if (FORCE_ARTICLE_PURGE != 0) {
+                       if (FORCE_ARTICLE_PURGE == 0) {
 
                                print "<br/>";
 
                                print __('Article purging:') . " ";
 
                                print_select_hash("purge_interval", $purge_interval, $purge_intervals,
-                                       "disabled");
+                                       'disabled="1" dojoType="dijit.form.Select"');
 
                                batch_edit_cbox("purge_interval");
                        }
                        print "<div class=\"dlgSec\">".__("Authentication")."</div>";
                        print "<div class=\"dlgSecCont\">";
 
-                       print __('Login:') . " ";
-                       print "<input disabled size=\"15\" onkeypress=\"return filterCR(event, feedEditSave)\"
+                       print "<input dojoType=\"dijit.form.TextBox\" 
+                               placeHolder=\"".__("Login")."\" disabled=\"1\"
                                name=\"auth_login\" value=\"$auth_login\">";
 
                        batch_edit_cbox("auth_login");
 
-                       print " " . __("Password:") . " ";
-
-                       print "<input disabled size=\"15\" type=\"password\" name=\"auth_pass\" 
-                               onkeypress=\"return filterCR(event, feedEditSave)\"
+                       print "<br/><input dojoType=\"dijit.form.TextBox\" type=\"password\" name=\"auth_pass\" 
+                               placeHolder=\"".__("Password")."\" disabled=\"1\"
                                value=\"$auth_pass\">";
 
                        batch_edit_cbox("auth_pass");
                        print "<div class=\"dlgSec\">".__("Options")."</div>";
                        print "<div class=\"dlgSecCont\">";
 
-                       print "<div style=\"line-height : 100%\">";
-
-                       print "<input disabled type=\"checkbox\" name=\"private\" id=\"private\" 
-                               $checked>&nbsp;<label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>";
+                       print "<input disabled=\"1\" type=\"checkbox\" name=\"private\" id=\"private\" 
+                               dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"private_l\" class='insensitive' for=\"private\">".__('Hide from Popular feeds')."</label>";
 
                        print "&nbsp;"; batch_edit_cbox("private", "private_l");
 
-                       print "<br/><input disabled type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
-                               $checked>&nbsp;<label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
+                       print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
+                               dojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"rtl_content_l\" for=\"rtl_content\">".__('Right-to-left content')."</label>";
 
                        print "&nbsp;"; batch_edit_cbox("rtl_content", "rtl_content_l");
 
-                       print "<br/><input disabled type=\"checkbox\" id=\"include_in_digest\" 
+                       print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"include_in_digest\" 
                                name=\"include_in_digest\" 
-                               $checked>&nbsp;<label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
+                               dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"include_in_digest_l\" class='insensitive' for=\"include_in_digest\">".__('Include in e-mail digest')."</label>";
 
                        print "&nbsp;"; batch_edit_cbox("include_in_digest", "include_in_digest_l");
 
-                       print "<br/><input disabled type=\"checkbox\" id=\"always_display_enclosures\" 
+                       print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"always_display_enclosures\" 
                                name=\"always_display_enclosures\" 
-                               $checked>&nbsp;<label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
+                               dojoType=\"dijit.form.CheckBox\">&nbsp;<label id=\"always_display_enclosures_l\" class='insensitive' for=\"always_display_enclosures\">".__('Always display image attachments')."</label>";
 
                        print "&nbsp;"; batch_edit_cbox("always_display_enclosures", "always_display_enclosures_l");
 
-                       print "<br/><input disabled type=\"checkbox\" id=\"cache_images\" 
+                       print "<br/><input disabled=\"1\" type=\"checkbox\" id=\"cache_images\" 
                                name=\"cache_images\" 
-                               $checked>&nbsp;<label class='insensitive' id=\"cache_images_l\" 
+                               dojoType=\"dijit.form.CheckBox\">&nbsp;<label class='insensitive' id=\"cache_images_l\" 
                                        for=\"cache_images\">".
                                __('Cache images locally')."</label>";
 
 
-                       if (SIMPLEPIE_CACHE_IMAGES) {
-                               print "&nbsp;"; batch_edit_cbox("cache_images", "cache_images_l");
-                       }
+                       print "&nbsp;"; batch_edit_cbox("cache_images", "cache_images_l");
 
-                       print "</div>";
                        print "</div>";
 
-                       print "</form>";
-
                        print "<div class='dlgButtons'>
-                               <input type=\"submit\" class=\"button\" 
-                               onclick=\"return feedsEditSave()\" value=\"".__('Save')."\">
-                               <input type='submit' class='button'                     
-                               onclick=\"return closeInfoBox()\" value=\"".__('Cancel')."\">
+                               <button dojoType=\"dijit.form.Button\" 
+                                       onclick=\"return dijit.byId('feedEditDlg').execute()\">".
+                                       __('Save')."</button>
+                               <button dojoType=\"dijit.form.Button\"
+                               onclick=\"return dijit.byId('feedEditDlg').hide()\">".
+                                       __('Cancel')."</button>
                                </div>";
-
-                       print "]]></content></dlg>";
-
+               
                        return;
                }
 
 
                                db_query($link, "COMMIT");
                        }
-
+                       return;
                }
 
                if ($subop == "remove") {
 
                        }
 
-                       header("Content-Type: text/xml");
-                       print "<dlg id=\"$subop\">";
-                       print "<title>".__('Category editor')."</title>";
-                       print "<content><![CDATA[";
-
                        if ($action == "add") {
 
                                $feed_cat = db_escape_string(trim($_REQUEST["cat"]));
                        }
 
                        print "<div dojoType=\"dijit.Toolbar\">
-                               <input id=\"fadd_cat\" 
-                                       onkeypress=\"return filterCR(event, addFeedCat)\"
-                                       size=\"40\">
-                                       <button onclick=\"addFeedCat()\">".
-                                       __('Create category')."</button></div>";
+                               <input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"newcat\">
+                                       <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').addCategory()\">".
+                                               __('Create category')."</button></div>";
        
                        $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
                                WHERE owner_uid = ".$_SESSION["uid"]."
 
                        if (db_num_rows($result) != 0) {
 
-#                              print   __('Select:')." 
-#                                      <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'all')\">".__('All')."</a>,
-#                                      <a href=\"#\" onclick=\"selectTableRows('prefFeedCatList', 'none')\">".__('None')."</a>";
-#
                                print "<div class=\"prefFeedCatHolder\">";
 
-                               print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
+#                              print "<form id=\"feed_cat_edit_form\" onsubmit=\"return false\">";
 
                                print "<table width=\"100%\" class=\"prefFeedCatList\" 
                                        cellspacing=\"0\" id=\"prefFeedCatList\">";
                
                                        print "<td width='5%' align='center'><input 
                                                onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\" 
-                                               type=\"checkbox\" id=\"FCCHK-$cat_id\"></td>";
+                                               type=\"checkbox\"></td>";
        
                                        print "<td>";
                                        
                                                                        cid: this.srcNodeRef.getAttribute('cat-id')},
                                                                        load: function(response) {
                                                                                elem.attr('value', response);
+                                                                               updateFeedList();
                                                                }
                                                        });     
                                                </script>
        
                                print "</table>";
 
-                               print "</form>";
+#                              print "</form>";
 
                                print "</div>";
 
 
                        print "<div class='dlgButtons'>
                                <div style='float : left'>
-                               <button onclick=\"return removeSelectedFeedCats()\">".
-                               __('Remove')."</button>
+                               <button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').removeSelected()\">".
+                               __('Remove selected categories')."</button>
                                </div>";
 
-                       print "<button onclick=\"selectTab('feedConfig')\">".
+                       print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('feedCatEditDlg').hide()\">".
                                __('Close this window')."</button></div>";
 
-                       print "]]></content></dlg>";
-
                        return;
 
                }
                if ($quiet) return;
 
                print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">";
-               print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">";
+               print "<div id=\"pref-feeds-feeds\" dojoType=\"dijit.layout.AccordionPane\" title=\"".__('Feeds')."\">";
 
                $result = db_query($link, "SELECT COUNT(id) AS num_errors
                        FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
 
                print "<div dojoType=\"dijit.Toolbar\">";
 
-               /* 
-               print "<div style='float : right'> 
-                       <input id=\"feed_search\" size=\"20\" type=\"search\"
-                               onfocus=\"disableHotkeys();\" 
-                               onblur=\"enableHotkeys();\"
-                               onchange=\"updateFeedList()\" value=\"$feed_search\">
-                       <button onclick=\"updateFeedList()\">".
-                               __('Search')."</button>
-                               </div>"; */
-
                print "<div dojoType=\"dijit.form.DropDownButton\">".
                                "<span>" . __('Select')."</span>";
                print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
 
                print "</p>";
 
-               print "<iframe name=\"upload_iframe\"
+               print "<iframe id=\"upload_iframe\" 
+                       name=\"upload_iframe\" onload=\"opmlImportComplete(this)\"
                        style=\"width: 400px; height: 100px; display: none;\"></iframe>";
 
-               print "<div style='float : left'>";
                print "<form style='display : block' target=\"upload_iframe\"
                        enctype=\"multipart/form-data\" method=\"POST\" 
                                action=\"backend.php\">
                        <input id=\"opml_file\" name=\"opml_file\" type=\"file\">&nbsp;
                        <input type=\"hidden\" name=\"op\" value=\"dlg\">
                        <input type=\"hidden\" name=\"id\" value=\"importOpml\">
-                       <button onclick=\"return opmlImport();\"
+                       <button dojoType=\"dijit.form.Button\" onclick=\"return opmlImport();\"
                                type=\"submit\">".__('Import')."</button>
+                       <button dojoType=\"dijit.form.Button\" onclick=\"gotoExportOpml()\">".__('Export OPML')."</button>
                        </form>";
-               print "</div>&nbsp;";
-
-               print "<button onclick=\"gotoExportOpml()\">".__('Export OPML')."</button>";
 
                print "<p>".__('Your OPML can be published publicly and can be subscribed by anyone who knows the URL below.');
 
                print "<div class=\"insensitive\">" . __("Note: Published OPML does not include your Tiny Tiny RSS settings, feeds that require authentication or feeds hidden from Popular feeds.") .                  "</div>" . "</p>";
 
-               print "<button onclick=\"return displayDlg('pubOPMLUrl')\">".
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('pubOPMLUrl')\">".
                        __('Display URL')."</button> ";
 
 
 
                $bm_url = htmlspecialchars("javascript:{if(confirm('$confirm_str'.replace('%s',window.location.href)))window.location.href='$bm_subscribe_url'+window.location.href}");
 
-               print "<a href=\"$bm_url\" class='visibleLink'>" . __('Subscribe in Tiny Tiny RSS'). "</a>";
+               print "<a href=\"$bm_url\" class='bookmarklet'>" . __('Subscribe in Tiny Tiny RSS'). "</a>";
 
                print "</div>"; #pane
 
                $rss_url = '-2::' . htmlspecialchars(get_self_url_prefix() . 
                                "/backend.php?op=rss&id=-2&view-mode=all_articles");;
 
-               print "<button onclick=\"return displayDlg('generatedFeed', '$rss_url')\">".
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"return displayDlg('generatedFeed', '$rss_url')\">".
                        __('Display URL')."</button> ";
                
-               print "<button onclick=\"return clearFeedAccessKeys()\">".
+               print "<button dojoType=\"dijit.form.Button\" onclick=\"return clearFeedAccessKeys()\">".
                        __('Clear all generated URLs')."</button> ";
 
                print "</div>"; #pane