]>
Commit | Line | Data |
---|---|---|
373266eb AD |
1 | <?php |
2 | function module_pref_instances($link) { | |
3 | ||
4 | $subop = $_REQUEST['subop']; | |
5 | ||
6 | if ($subop == "edit") { | |
7 | ||
9104a3e6 | 8 | $id = db_escape_string($_REQUEST["id"]); |
373266eb | 9 | |
9104a3e6 AD |
10 | $result = db_query($link, "SELECT * FROM ttrss_linked_instances WHERE |
11 | id = '$id'"); | |
12 | ||
13 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"$id\">"; | |
14 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">"; | |
15 | print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"editSave\">"; | |
16 | ||
17 | print "<div class=\"dlgSec\">".__("Instance")."</div>"; | |
18 | ||
19 | print "<div class=\"dlgSecCont\">"; | |
20 | ||
21 | /* URL */ | |
22 | ||
23 | $access_url = htmlspecialchars(db_fetch_result($result, 0, "access_url")); | |
24 | ||
25 | print __("URL:") . " "; | |
26 | ||
27 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" | |
28 | placeHolder=\"".__("Instance URL")."\" | |
29 | regExp='^(http|https)://.*' | |
30 | style=\"font-size : 16px; width: 20em\" name=\"access_url\" | |
31 | value=\"$access_url\">"; | |
32 | ||
33 | print "<hr/>"; | |
34 | ||
35 | $access_key = htmlspecialchars(db_fetch_result($result, 0, "access_key")); | |
36 | ||
37 | /* Access key */ | |
38 | ||
39 | print __("Access key:") . " "; | |
40 | ||
41 | print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" | |
42 | placeHolder=\"".__("Access key")."\" | |
43 | style=\"width: 20em\" name=\"access_key\" id=\"instance_edit_key\" | |
44 | value=\"$access_key\">"; | |
45 | ||
46 | print "</div>"; | |
47 | ||
48 | print "<div class=\"dlgButtons\"> | |
49 | <div style='float : left'> | |
50 | <button dojoType=\"dijit.form.Button\" | |
51 | onclick=\"return dijit.byId('instanceEditDlg').regenKey()\">". | |
52 | __('Generate new key')."</button> | |
53 | </div> | |
54 | <button dojoType=\"dijit.form.Button\" | |
55 | onclick=\"return dijit.byId('instanceEditDlg').execute()\">". | |
56 | __('Save')."</button> | |
57 | <button dojoType=\"dijit.form.Button\" | |
58 | onclick=\"return dijit.byId('instanceEditDlg').hide()\"\">". | |
59 | __('Cancel')."</button></div>"; | |
60 | ||
61 | return; | |
62 | } | |
63 | ||
64 | if ($subop == "editSave") { | |
65 | $id = db_escape_string($_REQUEST["id"]); | |
66 | $access_url = db_escape_string($_REQUEST["access_url"]); | |
67 | $access_key = db_escape_string($_REQUEST["access_key"]); | |
68 | ||
69 | db_query($link, "UPDATE ttrss_linked_instances SET | |
70 | access_key = '$access_key', access_url = '$access_url' | |
71 | WHERE id = '$id'"); | |
373266eb AD |
72 | |
73 | return; | |
74 | } | |
75 | ||
76 | print "<div id=\"pref-instance-wrap\" dojoType=\"dijit.layout.BorderContainer\" gutters=\"false\">"; | |
77 | print "<div id=\"pref-instance-header\" dojoType=\"dijit.layout.ContentPane\" region=\"top\">"; | |
78 | ||
79 | print "<div id=\"pref-instance-toolbar\" dojoType=\"dijit.Toolbar\">"; | |
80 | ||
81 | $sort = db_escape_string($_REQUEST["sort"]); | |
82 | ||
83 | if (!$sort || $sort == "undefined") { | |
84 | $sort = "access_url"; | |
85 | } | |
86 | ||
87 | print "<div dojoType=\"dijit.form.DropDownButton\">". | |
88 | "<span>" . __('Select')."</span>"; | |
89 | print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">"; | |
90 | print "<div onclick=\"selectTableRows('prefInstanceList', 'all')\" | |
91 | dojoType=\"dijit.MenuItem\">".__('All')."</div>"; | |
92 | print "<div onclick=\"selectTableRows('prefInstanceList', 'none')\" | |
93 | dojoType=\"dijit.MenuItem\">".__('None')."</div>"; | |
94 | print "</div></div>"; | |
95 | ||
96 | print "<button dojoType=\"dijit.form.Button\" onclick=\"addInstance()\">".__('Link instance')."</button>"; | |
97 | print "<button dojoType=\"dijit.form.Button\" onclick=\"editSelectedInstance()\">".__('Edit')."</button>"; | |
98 | print "<button dojoType=\"dijit.form.Button\" onclick=\"removeSelectedInstances()\">".__('Remove')."</button>"; | |
99 | ||
100 | print "</div>"; #toolbar | |
101 | ||
102 | $result = db_query($link, "SELECT * FROM ttrss_linked_instances | |
103 | ORDER BY $sort"); | |
104 | ||
105 | 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:"); | |
106 | ||
107 | print " <a href=\"#\" onclick=\"alert('".htmlspecialchars(get_self_url_prefix())."')\">(display url)</a>"; | |
108 | ||
109 | print "<p><table width='100%' id='prefInstanceList' class='prefInstanceList' cellspacing='0'>"; | |
110 | ||
111 | print "<tr class=\"title\"> | |
112 | <td align='center' width=\"5%\"> </td> | |
113 | <td width=''><a href=\"#\" onclick=\"updateInstanceList('access_url')\">".__('Instance URL')."</a></td> | |
114 | <td width='20%'><a href=\"#\" onclick=\"updateUsersList('last_connected')\">".__('Last connected')."</a></td> | |
115 | </tr>"; | |
116 | ||
117 | $lnum = 0; | |
118 | ||
119 | while ($line = db_fetch_assoc($result)) { | |
120 | $class = ($lnum % 2) ? "even" : "odd"; | |
121 | ||
122 | $id = $line['id']; | |
123 | $this_row_id = "id=\"LIRR-$id\""; | |
124 | ||
125 | $line["last_connected"] = make_local_datetime($link, $line["last_connected"], false); | |
126 | ||
127 | print "<tr class=\"$class\" $this_row_id>"; | |
128 | ||
129 | print "<td align='center'><input onclick='toggleSelectRow(this);' | |
130 | type=\"checkbox\" id=\"LICHK-$id\"></td>"; | |
131 | ||
132 | $onclick = "onclick='editInstance($id, event)' title='".__('Click to edit')."'"; | |
133 | ||
134 | print "<td $onclick>" . htmlspecialchars($line['access_url']) . "</td>"; | |
135 | print "<td $onclick>" . htmlspecialchars($line['last_connected']) . "</td>"; | |
136 | ||
137 | print "</tr>"; | |
138 | ||
139 | ++$lnum; | |
140 | } | |
141 | ||
142 | print "</table>"; | |
143 | ||
144 | print "</div>"; #pane | |
145 | print "</div>"; #container | |
146 | ||
147 | } | |
148 | ?> |