From 373266eb0394cd879e74db009e1629828a47eb33 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 20 Apr 2011 12:11:24 +0400 Subject: [PATCH] implement instances tab --- backend.php | 14 ++++-- modules/pref-instances.php | 86 ++++++++++++++++++++++++++++++++++ prefs.js | 94 ++++++++++++++++++++++++++++++++++++++ prefs.php | 4 ++ tt-rss.css | 17 +++++-- 5 files changed, 207 insertions(+), 8 deletions(-) create mode 100644 modules/pref-instances.php diff --git a/backend.php b/backend.php index fdaf2c46..e63d5abd 100644 --- a/backend.php +++ b/backend.php @@ -121,6 +121,7 @@ require_once "modules/pref-filters.php"; require_once "modules/pref-labels.php"; require_once "modules/pref-users.php"; + require_once "modules/pref-instances.php"; $error = sanity_check($link); @@ -435,6 +436,10 @@ module_pref_feed_browser($link); break; // pref-feed-browser + case "pref-instances": + module_pref_instances($link); + break; // pref-instances + case "rss": $feed = db_escape_string($_REQUEST["id"]); $key = db_escape_string($_REQUEST["key"]); @@ -504,6 +509,7 @@ header("Content-type: text/html"); print __("Loading, please wait...") . " " . ""; + break; // loading case "getProfiles": $login = db_escape_string($_REQUEST["login"]); @@ -528,7 +534,7 @@ $_SESSION = array(); } - break; + break; // getprofiles case "pubsub": $mode = db_escape_string($_REQUEST['hub_mode']); @@ -570,17 +576,17 @@ header('HTTP/1.0 404 Not Found'); } - break; + break; // pubsub case "logout": logout_user(); header("Location: tt-rss.php"); - break; + break; // logout default: header("Content-Type: text/plain"); print json_encode(array("error" => array("code" => 7))); - break; + break; // fallback } // Select action according to $op value. // We close the connection to database. diff --git a/modules/pref-instances.php b/modules/pref-instances.php new file mode 100644 index 00000000..0671944d --- /dev/null +++ b/modules/pref-instances.php @@ -0,0 +1,86 @@ +"; + print "
"; + + print "
"; + + $sort = db_escape_string($_REQUEST["sort"]); + + if (!$sort || $sort == "undefined") { + $sort = "access_url"; + } + + print "
". + "" . __('Select').""; + print "
"; + print "
".__('All')."
"; + print "
".__('None')."
"; + print "
"; + + print ""; + print ""; + print ""; + + print "
"; #toolbar + + $result = db_query($link, "SELECT * FROM ttrss_linked_instances + ORDER BY $sort"); + + print "

" . __("You can connect other instances of Tiny Tiny RSS to this one to share Popular feeds. Link to this instance of Tiny Tiny RSS by using this URL:"); + + print " (display url)"; + + print "

"; + + print " + + + + "; + + $lnum = 0; + + while ($line = db_fetch_assoc($result)) { + $class = ($lnum % 2) ? "even" : "odd"; + + $id = $line['id']; + $this_row_id = "id=\"LIRR-$id\""; + + $line["last_connected"] = make_local_datetime($link, $line["last_connected"], false); + + print ""; + + print ""; + + $onclick = "onclick='editInstance($id, event)' title='".__('Click to edit')."'"; + + print ""; + print ""; + + print ""; + + ++$lnum; + } + + print "
 ".__('Instance URL')."".__('Last connected')."
" . htmlspecialchars($line['access_url']) . "" . htmlspecialchars($line['last_connected']) . "
"; + + print "

"; #pane + print ""; #container + + } +?> diff --git a/prefs.js b/prefs.js index d22686ce..f0a9de5d 100644 --- a/prefs.js +++ b/prefs.js @@ -5,6 +5,16 @@ var hotkey_prefix_pressed = false; var seq = ""; +function instancelist_callback2(transport) { + try { + dijit.byId('instanceConfigTab').attr('content', transport.responseText); + selectTab("instanceConfig", true); + notify(""); + } catch (e) { + exception_error("instancelist_callback2", e); + } +} + function feedlist_callback2(transport) { try { dijit.byId('feedConfigTab').attr('content', transport.responseText); @@ -61,6 +71,14 @@ function updateFeedList(sort_key) { } }); } +function updateInstanceList(sort_key) { + new Ajax.Request("backend.php", { + parameters: "?op=pref-instances&sort=" + param_escape(sort_key), + onComplete: function(transport) { + instancelist_callback2(transport); + } }); +} + function updateUsersList(sort_key) { try { @@ -1755,3 +1773,79 @@ function insertSSLserial(value) { exception_error("insertSSLcerial", e); } } + +function getSelectedInstances() { + return getSelectedTableRowIds("prefInstanceList"); +} + +function addInstance() { + try { + alert("TODO: function not implemented."); + + + } catch (e) { + exception_error("addInstance", e); + } +} + +function editInstance(id, event) { + try { + if (!event || !event.ctrlKey) { + + selectTableRows('prefInstanceList', 'none'); + selectTableRowById('LIRR-'+id, 'LICHK-'+id, true); + + var query = "backend.php?op=pref-instances&subop=edit&id=" + + param_escape(id); + + if (dijit.byId("instanceEditDlg")) + dijit.byId("instanceEditDlg").destroyRecursive(); + + dialog = new dijit.Dialog({ + id: "instanceEditDlg", + title: __("Edit Instance"), + style: "width: 600px", + href: query, + }); + + dialog.show(); + + } else if (event.ctrlKey) { + var cb = $('LICHK-' + id); + cb.checked = !cb.checked; + toggleSelectRow(cb); + } + + + } catch (e) { + exception_error("editInstance", e); + } +} + +function removeSelectedInstances() { + try { + alert("TODO: function not implemented."); + + } catch (e) { + exception_error("removeInstance", e); + } +} + +function editSelectedInstance() { + var rows = getSelectedInstances(); + + if (rows.length == 0) { + alert(__("No instances are selected.")); + return; + } + + if (rows.length > 1) { + alert(__("Please select only one instance.")); + return; + } + + notify(""); + + editInstance(rows[0]); +} + diff --git a/prefs.php b/prefs.php index 5b70b2ca..11dab397 100644 --- a/prefs.php +++ b/prefs.php @@ -103,7 +103,11 @@
+
+