summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-04-20 12:11:24 +0400
committerAndrew Dolgov <[email protected]>2011-04-20 13:13:29 +0400
commit373266eb0394cd879e74db009e1629828a47eb33 (patch)
tree0feedb2bdd68e3496e58058bfd990f0db0ffdbcf
parentafb875ccd704dec355b73eecb2ded23f047414d8 (diff)
implement instances tab
-rw-r--r--backend.php14
-rw-r--r--modules/pref-instances.php86
-rw-r--r--prefs.js94
-rw-r--r--prefs.php4
-rw-r--r--tt-rss.css17
5 files changed, 207 insertions, 8 deletions
diff --git a/backend.php b/backend.php
index fdaf2c466..e63d5abd7 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...") . " " .
"<img src='images/indicator_tiny.gif'>";
+ 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 000000000..0671944d3
--- /dev/null
+++ b/modules/pref-instances.php
@@ -0,0 +1,86 @@
+<?php
+ function module_pref_instances($link) {
+
+ $subop = $_REQUEST['subop'];
+
+ if ($subop == "edit") {
+
+ print "TODO: function not implemented.";
+
+
+ return;
+ }
+
+ print "<div id=\"pref-instance-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">";
+ print "<div id=\"pref-instance-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">";
+
+ print "<div id=\"pref-instance-toolbar\" dojoType=\"dijit.Toolbar\">";
+
+ $sort = db_escape_string($_REQUEST["sort"]);
+
+ if (!$sort || $sort == "undefined") {
+ $sort = "access_url";
+ }
+
+ print "<div dojoType=\"dijit.form.DropDownButton\">".
+ "<span>" . __('Select')."</span>";
+ print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
+ print "<div onclick=\"selectTableRows('prefInstanceList', 'all')\"
+ dojoType=\"dijit.MenuItem\">".__('All')."</div>";
+ print "<div onclick=\"selectTableRows('prefInstanceList', 'none')\"
+ dojoType=\"dijit.MenuItem\">".__('None')."</div>";
+ print "</div></div>";
+
+ print "<button dojoType=\"dijit.form.Button\" onclick=\"addInstance()\">".__('Link instance')."</button>";
+ print "<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedInstance()\">".__('Edit')."</button>";
+ print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedInstances()\">".__('Remove')."</button>";
+
+ print "</div>"; #toolbar
+
+ $result = db_query($link, "SELECT * FROM ttrss_linked_instances
+ ORDER BY $sort");
+
+ print "<p class=\"insensitive\" style='margin-left : 1em;'>" . __("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 " <a href=\"#\" onclick=\"alert('".htmlspecialchars(get_self_url_prefix())."')\">(display url)</a>";
+
+ print "<p><table width='100%' id='prefInstanceList' class='prefInstanceList' cellspacing='0'>";
+
+ print "<tr class=\"title\">
+ <td align='center' width=\"5%\">&nbsp;</td>
+ <td width=''><a href=\"#\" onclick=\"updateInstanceList('access_url')\">".__('Instance URL')."</a></td>
+ <td width='20%'><a href=\"#\" onclick=\"updateUsersList('last_connected')\">".__('Last connected')."</a></td>
+ </tr>";
+
+ $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 "<tr class=\"$class\" $this_row_id>";
+
+ print "<td align='center'><input onclick='toggleSelectRow(this);'
+ type=\"checkbox\" id=\"LICHK-$id\"></td>";
+
+ $onclick = "onclick='editInstance($id, event)' title='".__('Click to edit')."'";
+
+ print "<td $onclick>" . htmlspecialchars($line['access_url']) . "</td>";
+ print "<td $onclick>" . htmlspecialchars($line['last_connected']) . "</td>";
+
+ print "</tr>";
+
+ ++$lnum;
+ }
+
+ print "</table>";
+
+ print "</div>"; #pane
+ print "</div>"; #container
+
+ }
+?>
diff --git a/prefs.js b/prefs.js
index d22686cee..f0a9de5db 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 5b70b2cad..11dab3977 100644
--- a/prefs.php
+++ b/prefs.php
@@ -103,7 +103,11 @@
<div id="userConfigTab" dojoType="dijit.layout.ContentPane"
href="backend.php?op=pref-users"
title="<?php echo __('Users') ?>"></div>
+ <div id="instanceConfigTab" dojoType="dijit.layout.ContentPane"
+ href="backend.php?op=pref-instances"
+ title="<?php echo __('Linked') ?>"></div>
<?php } ?>
+
</div>
<div id="footer" dojoType="dijit.layout.ContentPane" region="bottom">
diff --git a/tt-rss.css b/tt-rss.css
index 816832040..28c9e9a1d 100644
--- a/tt-rss.css
+++ b/tt-rss.css
@@ -350,7 +350,11 @@ table.prefUserList tr.oddSelected,
table.prefFeedList tr.even,
table.prefFeedList tr.odd,
table.prefFeedList tr.evenSelected,
-table.prefFeedList tr.oddSelected
+table.prefFeedList tr.oddSelected,
+table.prefInstanceList tr.even,
+table.prefInstanceList tr.odd,
+table.prefInstanceList tr.evenSelected,
+table.prefInstanceList tr.oddSelected
{
cursor : pointer;
}
@@ -370,7 +374,11 @@ table.prefUserList tr.oddSelected:hover td,
table.prefFeedList tr.even:hover td,
table.prefFeedList tr.odd:hover td,
table.prefFeedList tr.evenSelected:hover td,
-table.prefFeedList tr.oddSelected:hover td
+table.prefFeedList tr.oddSelected:hover td,
+table.prefInstanceList tr.even:hover td,
+table.prefInstanceList tr.odd:hover td,
+table.prefInstanceList tr.evenSelected:hover td,
+table.prefInstanceList tr.oddSelected:hover td
{
color : #88b0f0;
}
@@ -1472,13 +1480,14 @@ div#pref-tabs .dijitContentPane h3 {
#pref-filter-wrap, #pref-filter-header, #pref-filter-content,
#pref-label-wrap, #pref-label-header, #pref-label-content,
-#pref-user-wrap, #pref-user-header, #pref-user-content {
+#pref-user-wrap, #pref-user-header, #pref-user-content,
+#pref-instance-wrap, #pref-instance-header, #pref-instance-content {
margin : 0px;
padding : 0px;
border-width : 0px;
}
-#userConfigTab, #labelConfigTab, #filterConfigTab, #pref-feeds-feeds {
+#userConfigTab, #labelConfigTab, #filterConfigTab, #pref-feeds-feeds, #instanceConfigTab {
padding : 0px;
}