]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement instances tab
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 20 Apr 2011 08:11:24 +0000 (12:11 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 20 Apr 2011 09:13:29 +0000 (13:13 +0400)
backend.php
modules/pref-instances.php [new file with mode: 0644]
prefs.js
prefs.php
tt-rss.css

index fdaf2c4668b8973c520d14dcae485194aa7c80e4..e63d5abd705bc5f791652751fd8b0c02b41c97be 100644 (file)
        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.
diff --git a/modules/pref-instances.php b/modules/pref-instances.php
new file mode 100644 (file)
index 0000000..0671944
--- /dev/null
@@ -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
+
+       }
+?>
index d22686cee4ec831c234e6eae69db62bd799e312e..f0a9de5dbaf47dca8d72a5cbb3607fb98cfdc677 100644 (file)
--- 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]);
+}
+
index 5b70b2cad214f0eb0a445746ee7d7e6226e7d5be..11dab397706556c25bc75bbaa2b59c69e62a5450 100644 (file)
--- a/prefs.php
+++ b/prefs.php
        <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">
index 816832040ffd174b5b7af71ca398039b616fa87a..28c9e9a1dea24348c125efde4c074164ae83f008 100644 (file)
@@ -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;
 }