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