]> git.wh0rd.org - tt-rss.git/blobdiff - classes/dlg.php
tweak dialog topmost notices; add an explanation for the batch feed editor
[tt-rss.git] / classes / dlg.php
index b0cfe4451c3b95814fed49509d6f1c654129cc2d..0a5412fb539d348accd87eff2e70c2901caaf9da 100644 (file)
@@ -16,9 +16,29 @@ class Dlg extends Protected_Handler {
                print "</dlg>";
        }
 
+       function exportData() {
+
+               print "<p style='text-align : center' id='export_status_message'>You need to prepare exported data first by clicking the button below.</p>";
+
+               print "<div align='center'>";
+               print "<button dojoType=\"dijit.form.Button\"
+                       onclick=\"dijit.byId('dataExportDlg').prepare()\">".
+                       __('Prepare data')."</button>";
+
+               print "<button dojoType=\"dijit.form.Button\"
+                       onclick=\"dijit.byId('dataExportDlg').hide()\">".
+                       __('Close this window')."</button>";
+
+               print "</div>";
+
+
+       }
+
        function importOpml() {
                header("Content-Type: text/html"); # required for iframe
 
+               print __("If you have imported labels and/or filters, you might need to reload preferences to see your new data.") . "</p>";
+
                print "<div class=\"prefFeedOPMLHolder\">";
                $owner_uid = $_SESSION["uid"];
 
@@ -40,27 +60,15 @@ class Dlg extends Protected_Handler {
 
                /* Handle OPML import by DOMXML/DOMDocument */
 
-               if (function_exists('domxml_open_file')) {
-                       print "<ul class='nomarks'>";
-                       print "<li>".__("Importing using DOMXML.")."</li>";
-                       require_once "opml_domxml.php";
-                       opml_import_domxml($this->link, $owner_uid);
-                       print "</ul>";
-               } else if (PHP_VERSION >= 5) {
-                       print "<ul class='nomarks'>";
-                       print "<li>".__("Importing using DOMDocument.")."</li>";
-                       require_once "opml_domdoc.php";
-                       opml_import_domdoc($this->link, $owner_uid);
-                       print "</ul>";
-               } else {
-                       print_error(__("DOMXML extension is not found. It is required for PHP versions below 5."));
-               }
-
+               print "<ul class='nomarks'>";
+               require_once "opml.php";
+               opml_import_domdoc($this->link, $owner_uid);
+               print "</ul>";
                print "</div>";
 
                print "<div align='center'>";
                print "<button dojoType=\"dijit.form.Button\"
-                       onclick=\"dijit.byId('opmlImportDlg').hide()\">".
+                       onclick=\"dijit.byId('opmlImportDlg').execute()\">".
                        __('Close this window')."</button>";
                print "</div>";
 
@@ -72,12 +80,25 @@ class Dlg extends Protected_Handler {
        function editPrefProfiles() {
                print "<div dojoType=\"dijit.Toolbar\">";
 
+               print "<div dojoType=\"dijit.form.DropDownButton\">".
+                               "<span>" . __('Select')."</span>";
+               print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
+               print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
+                       dojoType=\"dijit.MenuItem\">".__('All')."</div>";
+               print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
+                       dojoType=\"dijit.MenuItem\">".__('None')."</div>";
+               print "</div></div>";
+
+               print "<div style=\"float : right\">";
+
                print "<input name=\"newprofile\" dojoType=\"dijit.form.ValidationTextBox\"
                                required=\"1\">
                        <button dojoType=\"dijit.form.Button\"
                        onclick=\"dijit.byId('profileEditDlg').addProfile()\">".
                                __('Create profile')."</button></div>";
 
+               print "</div>";
+
                $result = db_query($this->link, "SELECT title,id FROM ttrss_settings_profiles
                        WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
 
@@ -88,9 +109,10 @@ class Dlg extends Protected_Handler {
                print "<table width=\"100%\" class=\"prefFeedProfileList\"
                        cellspacing=\"0\" id=\"prefFeedProfileList\">";
 
-               print "<tr class=\"\" id=\"FCATR-0\">"; #odd
+               print "<tr class=\"placeholder\" id=\"FCATR-0\">"; #odd
 
                print "<td width='5%' align='center'><input
+                       id='FCATC-0'
                        onclick='toggleSelectRow2(this);'
                        dojoType=\"dijit.form.CheckBox\"
                        type=\"checkbox\"></td>";
@@ -115,12 +137,13 @@ class Dlg extends Protected_Handler {
                        $profile_id = $line["id"];
                        $this_row_id = "id=\"FCATR-$profile_id\"";
 
-                       print "<tr class=\"\" $this_row_id>";
+                       print "<tr class=\"placeholder\" $this_row_id>";
 
                        $edit_title = htmlspecialchars($line["title"]);
 
                        print "<td width='5%' align='center'><input
                                onclick='toggleSelectRow2(this);'
+                               id='FCATC-$profile_id'
                                dojoType=\"dijit.form.CheckBox\"
                                type=\"checkbox\"></td>";
 
@@ -276,12 +299,13 @@ class Dlg extends Protected_Handler {
                                " <input
                                        placeHolder=\"".__("Password")."\"
                                        dojoType=\"dijit.form.TextBox\" type='password'
-                                       style=\"width : 10em;\" name='pass'\">
+                                       style=\"width : 10em;\" name='pass'\">".
+                               " <p class='insensitive'>".__("OAuth will be used automatically for Twitter feeds.")."</p>
                        </div></div>";
 
 
                print "<div style=\"clear : both\">
-                       <input type=\"checkbox\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
+                       <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
                                        onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
                                <label for=\"feedDlg_loginCheck\">".
                                __('This feed requires authentication.')."</div>";
@@ -428,6 +452,7 @@ class Dlg extends Protected_Handler {
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"quiet\" value=\"1\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
 
                $result = db_query($this->link, "SELECT id,description
                        FROM ttrss_filter_types ORDER BY description");
@@ -472,8 +497,16 @@ class Dlg extends Protected_Handler {
                print "<hr/>";
 
                print __("in") . " ";
+
+               print "<span id='filterDlg_feeds'>";
                print_feed_select($this->link, "feed_id", $active_feed_id,
                        'dojoType="dijit.form.FilteringSelect"');
+               print "</span>";
+
+               print "<span id='filterDlg_cats' style='display : none'>";
+               print_feed_cat_select($this->link, "cat_id", $active_cat_id,
+                       'dojoType="dijit.form.FilteringSelect"');
+               print "</span>";
 
                print "</div>";
 
@@ -515,7 +548,11 @@ class Dlg extends Protected_Handler {
                                <label for=\"enabled\">".__('Enabled')."</label><hr/>";
 
                print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"inverse\" id=\"inverse\">
-                       <label for=\"inverse\">".__('Inverse match')."</label>";
+                       <label for=\"inverse\">".__('Inverse match')."</label><hr/>";
+
+               print "<input dojoType=\"dijit.form.CheckBox\" type=\"checkbox\" name=\"cat_filter\" id=\"cat_filter\" onchange=\"filterDlgCheckCat(this)\">
+                               <label for=\"cat_filter\">".__('Apply to category')."</label><hr/>";
+
 
                print "</div>";
 
@@ -553,7 +590,18 @@ class Dlg extends Protected_Handler {
                        GROUP BY ttrss_feeds.title, ttrss_feeds.id, ttrss_feeds.site_url, ttrss_feeds.feed_url
                        ORDER BY last_article");
 
-               print __("These feeds have not been updated with new content for 3 months (oldest first):");
+               print "<div class=\"dialogNotice\">" . __("These feeds have not been updated with new content for 3 months (oldest first):") . "</div>";
+
+               print "<div dojoType=\"dijit.Toolbar\">";
+               print "<div dojoType=\"dijit.form.DropDownButton\">".
+                               "<span>" . __('Select')."</span>";
+               print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
+               print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\"
+                       dojoType=\"dijit.MenuItem\">".__('All')."</div>";
+               print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\"
+                       dojoType=\"dijit.MenuItem\">".__('None')."</div>";
+               print "</div></div>";
+               print "</div>"; #toolbar
 
                print "<div class=\"inactiveFeedHolder\">";
 
@@ -567,13 +615,15 @@ class Dlg extends Protected_Handler {
                        $feed_id = $line["id"];
                        $this_row_id = "id=\"FUPDD-$feed_id\"";
 
-                       print "<tr class=\"\" $this_row_id>";
+                       # class needed for selectTableRows()
+                       print "<tr class=\"placeholder\" $this_row_id>";
 
                        $edit_title = htmlspecialchars($line["title"]);
 
+                       # id needed for selectTableRows()
                        print "<td width='5%' align='center'><input
                                onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
-                               type=\"checkbox\"></td>";
+                               type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>";
                        print "<td>";
 
                        print "<a class=\"visibleLink\" href=\"#\" ".
@@ -606,11 +656,22 @@ class Dlg extends Protected_Handler {
        }
 
        function feedsWithErrors() {
-               print __("These feeds have not been updated because of errors:");
+               print "<div class=\"dialogNotice\">" . __("These feeds have not been updated because of errors:") . "</div>";
 
                $result = db_query($this->link, "SELECT id,title,feed_url,last_error,site_url
                FROM ttrss_feeds WHERE last_error != '' AND owner_uid = ".$_SESSION["uid"]);
 
+               print "<div dojoType=\"dijit.Toolbar\">";
+               print "<div dojoType=\"dijit.form.DropDownButton\">".
+                               "<span>" . __('Select')."</span>";
+               print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
+               print "<div onclick=\"selectTableRows('prefErrorFeedList', 'all')\"
+                       dojoType=\"dijit.MenuItem\">".__('All')."</div>";
+               print "<div onclick=\"selectTableRows('prefErrorFeedList', 'none')\"
+                       dojoType=\"dijit.MenuItem\">".__('None')."</div>";
+               print "</div></div>";
+               print "</div>"; #toolbar
+
                print "<div class=\"inactiveFeedHolder\">";
 
                print "<table width=\"100%\" cellspacing=\"0\" id=\"prefErrorFeedList\">";
@@ -623,13 +684,15 @@ class Dlg extends Protected_Handler {
                        $feed_id = $line["id"];
                        $this_row_id = "id=\"FUPDD-$feed_id\"";
 
-                       print "<tr class=\"\" $this_row_id>";
+                       # class needed for selectTableRows()
+                       print "<tr class=\"placeholder\" $this_row_id>";
 
                        $edit_title = htmlspecialchars($line["title"]);
 
+                       # id needed for selectTableRows()
                        print "<td width='5%' align='center'><input
                                onclick='toggleSelectRow2(this);' dojoType=\"dijit.form.CheckBox\"
-                               type=\"checkbox\"></td>";
+                               type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>";
                        print "<td>";
 
                        print "<a class=\"visibleLink\" href=\"#\" ".
@@ -808,7 +871,7 @@ class Dlg extends Protected_Handler {
 
                $url_path = htmlspecialchars($this->params[2]) . "&key=" . $key;
 
-               print __("You can view this feed as RSS using the following URL:");
+               print "<div class=\"dialogNotice\">" .  __("You can view this feed as RSS using the following URL:") . "</div>";
 
                print "<div class=\"tagCloudContainer\">";
                print "<a id='gen_feed_url' href='$url_path' target='_blank'>$url_path</a>";
@@ -861,7 +924,9 @@ class Dlg extends Protected_Handler {
 
                $value = str_replace("<br/>", "\n", $value);
 
+               print "<div class=\"dialogNotice\">";
                print T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "tt-rss.css");
+               print "</div>";
 
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setpref\">";
@@ -933,5 +998,77 @@ class Dlg extends Protected_Handler {
                return;
        }
 
+       function dataImport() {
+               header("Content-Type: text/html"); # required for iframe
+
+               print "<div style='text-align : center'>";
+
+               if (is_file($_FILES['export_file']['tmp_name'])) {
+
+                       perform_data_import($this->link, $_FILES['export_file']['tmp_name'], $_SESSION['uid']);
+
+               } else {
+                       print "<p>" . T_sprintf("Could not upload file. You might need to adjust upload_max_filesize
+                               in PHP.ini (current value = %s)", ini_get("upload_max_filesize")) . " or use CLI import tool.</p>";
+
+               }
+
+               print "<button dojoType=\"dijit.form.Button\"
+                       onclick=\"dijit.byId('dataImportDlg').hide()\">".
+                       __('Close this window')."</button>";
+
+               print "</div>";
+
+       }
+
+       function batchSubscribe() {
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
+               print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"batchaddfeeds\">";
+
+               print "<table width='100%'><tr><td>
+                       ".__("Add one valid RSS feed per line (no feed detection is done)")."
+               </td><td align='right'>";
+               if (get_pref($this->link, 'ENABLE_FEED_CATS')) {
+                       print __('Place in category:') . " ";
+                       print_feed_cat_select($this->link, "cat", false, 'dojoType="dijit.form.Select"');
+               }
+               print "</td></tr><tr><td colspan='2'>";
+               print "<textarea
+                       style='font-size : 12px; width : 100%; height: 200px;'
+                       placeHolder=\"".__("Feeds to subscribe, One per line")."\"
+                       dojoType=\"dijit.form.SimpleTextarea\" required=\"1\" name=\"feeds\"></textarea>";
+
+               print "</td></tr><tr><td colspan='2'>";
+
+               print "<div id='feedDlg_loginContainer' style='display : none'>
+                               " .
+                               " <input dojoType=\"dijit.form.TextBox\" name='login'\"
+                                       placeHolder=\"".__("Login")."\"
+                                       style=\"width : 10em;\"> ".
+                               " <input
+                                       placeHolder=\"".__("Password")."\"
+                                       dojoType=\"dijit.form.TextBox\" type='password'
+                                       style=\"width : 10em;\" name='pass'\">".
+                               " <p class='insensitive'>".__("OAuth will be used automatically for Twitter feeds.")."</p>
+                               </div>";
+
+               print "</td></tr><tr><td colspan='2'>";
+
+               print "<div style=\"clear : both\">
+                       <input type=\"checkbox\" name=\"need_auth\" dojoType=\"dijit.form.CheckBox\" id=\"feedDlg_loginCheck\"
+                                       onclick='checkboxToggleElement(this, \"feedDlg_loginContainer\")'>
+                               <label for=\"feedDlg_loginCheck\">".
+                               __('Feeds require authentication.')."</div>";
+
+               print "</form>";
+
+               print "</td></tr></table>";
+
+               print "<div class=\"dlgButtons\">
+                       <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').execute()\">".__('Subscribe')."</button>
+                       <button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button>
+                       </div>";
+       }
+
 }
 ?>