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);
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"]);
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"]);
$_SESSION = array();
}
- break;
+ break; // getprofiles
case "pubsub":
$mode = db_escape_string($_REQUEST['hub_mode']);
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.
--- /dev/null
+<?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%\"> </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
+
+ }
+?>
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);
} });
}
+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 {
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]);
+}
+
<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">
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;
}
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;
}
#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;
}