|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
function print_select($id, $default, $values, $attributes = "", $name = "") |
|
4
|
|
|
{ |
|
5
|
|
|
if (!$name) { |
|
6
|
|
|
$name = $id; |
|
7
|
|
|
} |
|
8
|
|
|
|
|
9
|
|
|
print "<select name=\"$name\" id=\"$id\" $attributes>"; |
|
10
|
|
|
foreach ($values as $v) { |
|
11
|
|
|
if ($v == $default) { |
|
12
|
|
|
$sel = "selected=\"1\""; |
|
13
|
|
|
} else { |
|
14
|
|
|
$sel = ""; |
|
15
|
|
|
} |
|
16
|
|
|
$v = trim($v); |
|
17
|
|
|
print "<option value=\"$v\" $sel>$v</option>"; |
|
18
|
|
|
} |
|
19
|
|
|
print "</select>"; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
function print_select_hash($id, $default, $values, $attributes = "", $name = "") |
|
23
|
|
|
{ |
|
24
|
|
|
if (!$name) { |
|
25
|
|
|
$name = $id; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
print "<select name=\"$name\" id='$id' $attributes>"; |
|
29
|
|
|
foreach (array_keys($values) as $v) { |
|
30
|
|
|
if ($v == $default) { |
|
31
|
|
|
$sel = 'selected="selected"'; |
|
32
|
|
|
} else { |
|
33
|
|
|
$sel = ""; |
|
34
|
|
|
} |
|
35
|
|
|
$v = trim($v); |
|
36
|
|
|
print "<option $sel value=\"$v\">".$values[$v]."</option>"; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
print "</select>"; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
function print_hidden($name, $value) |
|
43
|
|
|
{ |
|
44
|
|
|
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"$name\" value=\"$value\">"; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
function print_checkbox($id, $checked, $value = "", $attributes = "") |
|
48
|
|
|
{ |
|
49
|
|
|
$checked_str = $checked ? "checked" : ""; |
|
50
|
|
|
$value_str = $value ? "value=\"$value\"" : ""; |
|
51
|
|
|
print "<input dojoType=\"dijit.form.CheckBox\" id=\"$id\" $value_str $checked_str $attributes name=\"$id\">"; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
function print_button($type, $value, $attributes = "") |
|
55
|
|
|
{ |
|
56
|
|
|
print "<p><button dojoType=\"dijit.form.Button\" $attributes type=\"$type\">$value</button>"; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
function print_radio($id, $default, $true_is, $values, $attributes = "") |
|
60
|
|
|
{ |
|
61
|
|
|
foreach ($values as $v) { |
|
62
|
|
|
|
|
63
|
|
|
if ($v == $default) { |
|
64
|
|
|
$sel = "checked"; |
|
65
|
|
|
} else { |
|
66
|
|
|
$sel = ""; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
if ($v == $true_is) { |
|
70
|
|
|
$sel .= " value=\"1\""; |
|
71
|
|
|
} else { |
|
72
|
|
|
$sel .= " value=\"0\""; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
print "<input class=\"noborder\" dojoType=\"dijit.form.RadioButton\" |
|
76
|
|
|
type=\"radio\" $sel $attributes name=\"$id\"> $v "; |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
function print_feed_multi_select($id, $default_ids = [], $attributes = "", $include_all_feeds = true, $root_id = null, $nest_level = 0) |
|
82
|
|
|
{ |
|
83
|
|
|
$pdo = DB::pdo(); |
|
84
|
|
|
print_r(in_array("CAT:6", $default_ids)); |
|
85
|
|
|
if (!$root_id) { |
|
86
|
|
|
print "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>"; |
|
87
|
|
|
if ($include_all_feeds) { |
|
88
|
|
|
$is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : ""; |
|
89
|
|
|
print "<option $is_selected value=\"0\">".__('All feeds')."</option>"; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
if (get_pref('ENABLE_FEED_CATS')) { |
|
93
|
|
|
if (!$root_id) { |
|
94
|
|
|
$root_id = null; |
|
95
|
|
|
} |
|
96
|
|
|
$sth = $pdo->prepare("SELECT id,title, |
|
97
|
|
|
(SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
|
98
|
|
|
c2.parent_cat = ttrss_feed_categories.id) AS num_children |
|
99
|
|
|
FROM ttrss_feed_categories |
|
100
|
|
|
WHERE owner_uid = :uid AND |
|
101
|
|
|
(parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title"); |
|
102
|
|
|
$sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); |
|
103
|
|
|
while ($line = $sth->fetch()) { |
|
104
|
|
|
for ($i = 0; $i < $nest_level; $i++) { |
|
105
|
|
|
$line["title"] = " - ".$line["title"]; |
|
106
|
|
|
} |
|
107
|
|
|
$is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : ""; |
|
108
|
|
|
printf("<option $is_selected value='CAT:%d'>%s</option>", |
|
109
|
|
|
$line["id"], htmlspecialchars($line["title"])); |
|
110
|
|
|
|
|
111
|
|
|
if ($line["num_children"] > 0) { |
|
112
|
|
|
print_feed_multi_select($id, $default_ids, $attributes, $include_all_feeds, $line["id"], $nest_level + 1); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
$f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds WHERE cat_id = ? AND owner_uid = ? ORDER BY title"); |
|
116
|
|
|
$f_sth->execute([$line['id'], $_SESSION['uid']]); |
|
117
|
|
|
while ($fline = $f_sth->fetch()) { |
|
118
|
|
|
$is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : ""; |
|
119
|
|
|
$fline["title"] = " + ".$fline["title"]; |
|
120
|
|
|
for ($i = 0; $i < $nest_level; $i++) { |
|
121
|
|
|
$fline["title"] = " - ".$fline["title"]; |
|
122
|
|
|
} |
|
123
|
|
|
printf("<option $is_selected value='%d'>%s</option>", $fline["id"], htmlspecialchars($fline["title"])); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
if (!$root_id) { |
|
128
|
|
|
$is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : ""; |
|
129
|
|
|
|
|
130
|
|
|
printf("<option $is_selected value='CAT:0'>%s</option>", |
|
131
|
|
|
__("Uncategorized")); |
|
132
|
|
|
|
|
133
|
|
|
$f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
134
|
|
|
WHERE cat_id IS NULL AND owner_uid = ? ORDER BY title"); |
|
135
|
|
|
$f_sth->execute([$_SESSION['uid']]); |
|
136
|
|
|
|
|
137
|
|
|
while ($fline = $f_sth->fetch()) { |
|
138
|
|
|
$is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : ""; |
|
139
|
|
|
|
|
140
|
|
|
$fline["title"] = " + ".$fline["title"]; |
|
141
|
|
|
|
|
142
|
|
|
for ($i = 0; $i < $nest_level; $i++) { |
|
143
|
|
|
$fline["title"] = " - ".$fline["title"]; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
printf("<option $is_selected value='%d'>%s</option>", |
|
147
|
|
|
$fline["id"], htmlspecialchars($fline["title"])); |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
} else { |
|
152
|
|
|
$sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds |
|
153
|
|
|
WHERE owner_uid = ? ORDER BY title"); |
|
154
|
|
|
$sth->execute([$_SESSION['uid']]); |
|
155
|
|
|
|
|
156
|
|
|
while ($line = $sth->fetch()) { |
|
157
|
|
|
|
|
158
|
|
|
$is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : ""; |
|
159
|
|
|
|
|
160
|
|
|
printf("<option $is_selected value='%d'>%s</option>", |
|
161
|
|
|
$line["id"], htmlspecialchars($line["title"])); |
|
162
|
|
|
} |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
if (!$root_id) { |
|
166
|
|
|
print "</select>"; |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
function print_feed_cat_select($id, $default_id, $attributes, $include_all_cats = true, $root_id = null, $nest_level = 0) |
|
171
|
|
|
{ |
|
172
|
|
|
if (!$root_id) { |
|
173
|
|
|
print "<select id=\"$id\" name=\"$id\" default=\"$default_id\" $attributes>"; |
|
174
|
|
|
} |
|
175
|
|
|
$pdo = DB::pdo(); |
|
176
|
|
|
if (!$root_id) { |
|
177
|
|
|
$root_id = null; |
|
178
|
|
|
} |
|
179
|
|
|
$sth = $pdo->prepare("SELECT id,title, |
|
180
|
|
|
(SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE |
|
181
|
|
|
c2.parent_cat = ttrss_feed_categories.id) AS num_children |
|
182
|
|
|
FROM ttrss_feed_categories |
|
183
|
|
|
WHERE owner_uid = :uid AND |
|
184
|
|
|
(parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title"); |
|
185
|
|
|
$sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]); |
|
186
|
|
|
|
|
187
|
|
|
$found = 0; |
|
188
|
|
|
|
|
189
|
|
|
while ($line = $sth->fetch()) { |
|
190
|
|
|
++$found; |
|
191
|
|
|
|
|
192
|
|
|
if ($line["id"] == $default_id) { |
|
193
|
|
|
$is_selected = "selected=\"1\""; |
|
194
|
|
|
} else { |
|
195
|
|
|
$is_selected = ""; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
for ($i = 0; $i < $nest_level; $i++) { |
|
199
|
|
|
$line["title"] = " - ".$line["title"]; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
if ($line["title"]) { |
|
203
|
|
|
printf("<option $is_selected value='%d'>%s</option>", |
|
204
|
|
|
$line["id"], htmlspecialchars($line["title"])); |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
if ($line["num_children"] > 0) { |
|
208
|
|
|
print_feed_cat_select($id, $default_id, $attributes, |
|
209
|
|
|
$include_all_cats, $line["id"], $nest_level + 1); |
|
210
|
|
|
} |
|
211
|
|
|
} |
|
212
|
|
|
|
|
213
|
|
|
if (!$root_id) { |
|
214
|
|
|
if ($include_all_cats) { |
|
215
|
|
|
if ($found > 0) { |
|
216
|
|
|
print "<option disabled=\"1\">--------</option>"; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
if ($default_id == 0) { |
|
220
|
|
|
$is_selected = "selected=\"1\""; |
|
221
|
|
|
} else { |
|
222
|
|
|
$is_selected = ""; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
print "<option $is_selected value=\"0\">".__('Uncategorized')."</option>"; |
|
226
|
|
|
} |
|
227
|
|
|
print "</select>"; |
|
228
|
|
|
} |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* @deprecated Use Twig filter cssTag |
|
233
|
|
|
*/ |
|
234
|
|
|
function stylesheet_tag($filename, $id = false) |
|
|
|
|
|
|
235
|
|
|
{ |
|
236
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
237
|
|
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* @deprecated Use Twig filter jsTag |
|
241
|
|
|
*/ |
|
242
|
|
|
function javascript_tag($filename) |
|
|
|
|
|
|
243
|
|
|
{ |
|
244
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @deprecated Use twig function warningMessage |
|
249
|
|
|
*/ |
|
250
|
|
|
function format_warning() |
|
251
|
|
|
{ |
|
252
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @deprecated Use twig function noticeMessage |
|
257
|
|
|
*/ |
|
258
|
|
|
function format_notice() |
|
259
|
|
|
{ |
|
260
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @deprecated Use twig function errorMessage |
|
265
|
|
|
*/ |
|
266
|
|
|
function format_error() |
|
267
|
|
|
{ |
|
268
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* @deprecated Use twig function noticeMessage |
|
273
|
|
|
*/ |
|
274
|
|
|
function print_notice() |
|
275
|
|
|
{ |
|
276
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
/** |
|
280
|
|
|
* @deprecated Use twig function warningMessage |
|
281
|
|
|
*/ |
|
282
|
|
|
function print_warning() |
|
283
|
|
|
{ |
|
284
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
/** |
|
288
|
|
|
* @deprecated Use twig function errorMessage |
|
289
|
|
|
*/ |
|
290
|
|
|
function print_error() |
|
291
|
|
|
{ |
|
292
|
|
|
user_error(__FUNCTION__.' is deprecated', E_USER_DEPRECATED); |
|
293
|
|
|
} |
|
294
|
|
|
|
|
295
|
|
|
function format_inline_player($url, $ctype) |
|
296
|
|
|
{ |
|
297
|
|
|
$entry = ""; |
|
298
|
|
|
$url = htmlspecialchars($url); |
|
299
|
|
|
if (strpos($ctype, "audio/") === 0) { |
|
300
|
|
|
$entry .= "<div class='inline-player'>"; |
|
301
|
|
|
if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false || |
|
302
|
|
|
$_SESSION["hasMp3"])) { |
|
303
|
|
|
$entry .= "<audio preload=\"none\" controls><source type=\"$ctype\" src=\"$url\"/></audio> "; |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
if ($entry) { |
|
307
|
|
|
$entry .= "<a target=\"_blank\" rel=\"noopener noreferrer\"href=\"$url\">".basename($url)."</a>"; |
|
308
|
|
|
} |
|
309
|
|
|
$entry .= "</div>"; |
|
310
|
|
|
return $entry; |
|
311
|
|
|
} |
|
312
|
|
|
return ""; |
|
313
|
|
|
} |
|
314
|
|
|
|
|
315
|
|
|
function print_label_select($name, $value, $attributes = "") |
|
316
|
|
|
{ |
|
317
|
|
|
$pdo = Db::pdo(); |
|
318
|
|
|
$sth = $pdo->prepare("SELECT caption FROM ttrss_labels2 WHERE owner_uid = ? ORDER BY caption"); |
|
319
|
|
|
$sth->execute([$_SESSION['uid']]); |
|
320
|
|
|
print "<select default=\"$value\" name=\"".htmlspecialchars($name)."\" $attributes>"; |
|
321
|
|
|
while ($line = $sth->fetch()) { |
|
322
|
|
|
$issel = ($line["caption"] == $value) ? "selected=\"1\"" : ""; |
|
323
|
|
|
print "<option value=\"".htmlspecialchars($line["caption"])."\"$issel>".htmlspecialchars($line["caption"])."</option>"; |
|
324
|
|
|
|
|
325
|
|
|
} |
|
326
|
|
|
print "</select>"; |
|
327
|
|
|
} |
|
328
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.