replace a few more controls to new style

master
Andrew Dolgov 2 years ago
parent bf88c64d1e
commit f58c49beaa
  1. 2
      classes/pref/feeds.php
  2. 105
      classes/pref/filters.php
  3. 10
      plugins/af_proxy_http/init.php
  4. 8
      plugins/af_psql_trgm/init.php
  5. 16
      plugins/af_readability/init.php
  6. 15
      plugins/af_redditimgur/init.php

@ -1325,7 +1325,7 @@ class Pref_Feeds extends Handler_Protected {
</button>
<label class='checkbox'>
<?php print_checkbox("include_settings", true, "1", "") ?>
<?= \Controls\checkbox_tag("include_settings", true, "1") ?>
<?= __("Include settings") ?>
</label>
</form>

@ -818,7 +818,7 @@ class Pref_Filters extends Handler_Protected {
print "<fieldset>";
print "<span id='filterDlg_feeds'>";
print_feed_multi_select("feed_id",
$this->feed_multi_select("feed_id",
$feed_id,
'style="width : 500px; height : 300px" dojoType="dijit.form.MultiSelect"');
print "</span>";
@ -1070,4 +1070,107 @@ class Pref_Filters extends Handler_Protected {
$this->pdo->commit();
}
private function feed_multi_select($id, $default_ids = [],
$attributes = "", $include_all_feeds = true,
$root_id = null, $nest_level = 0) {
$pdo = Db::pdo();
// print_r(in_array("CAT:6",$default_ids));
if (!$root_id) {
print "<select multiple=\true\" id=\"$id\" name=\"$id\" $attributes>";
if ($include_all_feeds) {
$is_selected = (in_array("0", $default_ids)) ? "selected=\"1\"" : "";
print "<option $is_selected value=\"0\">".__('All feeds')."</option>";
}
}
if (get_pref('ENABLE_FEED_CATS')) {
if (!$root_id) $root_id = null;
$sth = $pdo->prepare("SELECT id,title,
(SELECT COUNT(id) FROM ttrss_feed_categories AS c2 WHERE
c2.parent_cat = ttrss_feed_categories.id) AS num_children
FROM ttrss_feed_categories
WHERE owner_uid = :uid AND
(parent_cat = :root_id OR (:root_id IS NULL AND parent_cat IS NULL)) ORDER BY title");
$sth->execute([":uid" => $_SESSION['uid'], ":root_id" => $root_id]);
while ($line = $sth->fetch()) {
for ($i = 0; $i < $nest_level; $i++)
$line["title"] = "" . $line["title"];
$is_selected = in_array("CAT:".$line["id"], $default_ids) ? "selected=\"1\"" : "";
printf("<option $is_selected value='CAT:%d'>%s</option>",
$line["id"], htmlspecialchars($line["title"]));
if ($line["num_children"] > 0)
$this->feed_multi_select($id, $default_ids, $attributes,
$include_all_feeds, $line["id"], $nest_level+1);
$f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
WHERE cat_id = ? AND owner_uid = ? ORDER BY title");
$f_sth->execute([$line['id'], $_SESSION['uid']]);
while ($fline = $f_sth->fetch()) {
$is_selected = (in_array($fline["id"], $default_ids)) ? "selected=\"1\"" : "";
$fline["title"] = "" . $fline["title"];
for ($i = 0; $i < $nest_level; $i++)
$fline["title"] = "" . $fline["title"];
printf("<option $is_selected value='%d'>%s</option>",
$fline["id"], htmlspecialchars($fline["title"]));
}
}
if (!$root_id) {
$is_selected = in_array("CAT:0", $default_ids) ? "selected=\"1\"" : "";
printf("<option $is_selected value='CAT:0'>%s</option>",
__("Uncategorized"));
$f_sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
WHERE cat_id IS NULL AND owner_uid = ? ORDER BY title");
$f_sth->execute([$_SESSION['uid']]);
while ($fline = $f_sth->fetch()) {
$is_selected = in_array($fline["id"], $default_ids) ? "selected=\"1\"" : "";
$fline["title"] = "" . $fline["title"];
for ($i = 0; $i < $nest_level; $i++)
$fline["title"] = "" . $fline["title"];
printf("<option $is_selected value='%d'>%s</option>",
$fline["id"], htmlspecialchars($fline["title"]));
}
}
} else {
$sth = $pdo->prepare("SELECT id,title FROM ttrss_feeds
WHERE owner_uid = ? ORDER BY title");
$sth->execute([$_SESSION['uid']]);
while ($line = $sth->fetch()) {
$is_selected = (in_array($line["id"], $default_ids)) ? "selected=\"1\"" : "";
printf("<option $is_selected value='%d'>%s</option>",
$line["id"], htmlspecialchars($line["title"]));
}
}
if (!$root_id) {
print "</select>";
}
}
}

@ -222,11 +222,13 @@ class Af_Proxy_Http extends Plugin {
print \Controls\hidden_tag("method", "save");
print \Controls\hidden_tag("plugin", "af_proxy_http");
$proxy_all = $this->host->get($this, "proxy_all");
print_checkbox("proxy_all", $proxy_all);
$proxy_all = sql_bool_to_bool($this->host->get($this, "proxy_all"));
print \Controls\checkbox_tag("proxy_all", $proxy_all);
print "&nbsp;<label for=\"proxy_all\">" . __("Enable proxy for all remote images.") . "</label><br/>";
print "<p>"; print_button("submit", __("Save"));
print "<hr/>";
print \Controls\submit_tag(__("Save"));
print "</form>";
@ -234,7 +236,7 @@ class Af_Proxy_Http extends Plugin {
}
function save() {
$proxy_all = checkbox_to_sql_bool($_POST["proxy_all"]);
$proxy_all = checkbox_to_sql_bool($_POST["proxy_all"] ?? "");
$this->host->set($this, "proxy_all", $proxy_all);

@ -139,7 +139,7 @@ class Af_Psql_Trgm extends Plugin {
$similarity = $this->host->get($this, "similarity", $this->default_similarity);
$min_title_length = $this->host->get($this, "min_title_length", $this->default_min_length);
$enable_globally = $this->host->get($this, "enable_globally");
$enable_globally = sql_bool_to_bool($this->host->get($this, "enable_globally"));
print "<form dojoType=\"dijit.form.Form\">";
@ -186,13 +186,14 @@ class Af_Psql_Trgm extends Plugin {
print "</fieldset><fieldset>";
print "<label class='checkbox'>";
print_checkbox("enable_globally", $enable_globally);
print \Controls\checkbox_tag("enable_globally", $enable_globally);
print " " . __("Enable for all feeds:");
print "</label>";
print "</fieldset>";
print_button("submit", __("Save"), "class='alt-primary'");
print "<hr/>";
print \Controls\submit_tag(__("Save"));
print "</form>";
/* cleanup */
@ -202,6 +203,7 @@ class Af_Psql_Trgm extends Plugin {
$this->host->set($this, "enabled_feeds", $enabled_feeds);
if (count($enabled_feeds) > 0) {
print "<hr/>";
print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
print "<ul class=\"panel panel-scrollable list list-unstyled\">";

@ -18,7 +18,7 @@ class Af_Readability extends Plugin {
}
function save() {
$enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"]);
$enable_share_anything = checkbox_to_sql_bool($_POST["enable_share_anything"] ?? "");
$this->host->set($this, "enable_share_anything", $enable_share_anything);
@ -29,11 +29,6 @@ class Af_Readability extends Plugin {
{
$this->host = $host;
if (version_compare(PHP_VERSION, '7.0.0', '<')) {
user_error("af_readability requires PHP 7.0", E_USER_WARNING);
return;
}
$host->add_hook($host::HOOK_ARTICLE_FILTER, $this);
$host->add_hook($host::HOOK_PREFS_TAB, $this);
$host->add_hook($host::HOOK_PREFS_EDIT_FEED, $this);
@ -91,16 +86,18 @@ class Af_Readability extends Plugin {
print \Controls\hidden_tag("method", "save");
print \Controls\hidden_tag("plugin", "af_readability");
$enable_share_anything = $this->host->get($this, "enable_share_anything");
$enable_share_anything = sql_bool_to_bool($this->host->get($this, "enable_share_anything"));
print "<fieldset>";
print "<label class='checkbox'> ";
print_checkbox("enable_share_anything", $enable_share_anything);
print \Controls\checkbox_tag("enable_share_anything", $enable_share_anything);
print " " . __("Provide full-text services to core code (bookmarklets) and other plugins");
print "</label>";
print "</fieldset>";
print_button("submit", __("Save"), "class='alt-primary'");
print "<hr/>";
print \Controls\submit_tag(__("Save"));
print "</form>";
/* cleanup */
@ -114,6 +111,7 @@ class Af_Readability extends Plugin {
$this->host->set($this, "append_feeds", $append_feeds);
if (count($enabled_feeds) > 0) {
print "<hr/>";
print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
print "<ul class='panel panel-scrollable list list-unstyled'>";

@ -64,32 +64,33 @@ class Af_RedditImgur extends Plugin {
print "<fieldset class='narrow'>";
print "<label class='checkbox'>";
print_checkbox("enable_readability", $enable_readability);
print \Controls\checkbox_tag("enable_readability", $enable_readability);
print " " . __("Extract missing content using Readability (requires af_readability)") . "</label>";
print "</fieldset>";
print "<fieldset class='narrow'>";
print "<label class='checkbox'>";
print_checkbox("enable_content_dupcheck", $enable_content_dupcheck);
print \Controls\checkbox_tag("enable_content_dupcheck", $enable_content_dupcheck);
print " " . __("Enable additional duplicate checking") . "</label>";
print "</fieldset>";
print "<fieldset class='narrow'>";
print "<label class='checkbox'>";
print_checkbox("reddit_to_teddit", $reddit_to_teddit);
print \Controls\checkbox_tag("reddit_to_teddit", $reddit_to_teddit);
print " " . T_sprintf("Rewrite Reddit URLs to %s",
"<a target=\"_blank\" href=\"https://teddit.net/about\">Teddit</a>") . "</label>";
print_button("submit", __("Save"), 'class="alt-primary"');
print "<hr/>";
print \Controls\submit_tag(__("Save"));
print "</form>";
print "</div>";
}
function save() {
$enable_readability = checkbox_to_sql_bool($_POST["enable_readability"]);
$enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"]);
$reddit_to_teddit = checkbox_to_sql_bool($_POST["reddit_to_teddit"]);
$enable_readability = checkbox_to_sql_bool($_POST["enable_readability"] ?? "");
$enable_content_dupcheck = checkbox_to_sql_bool($_POST["enable_content_dupcheck"] ?? "");
$reddit_to_teddit = checkbox_to_sql_bool($_POST["reddit_to_teddit"] ?? "");
$this->host->set($this, "enable_readability", $enable_readability, false);
$this->host->set($this, "reddit_to_teddit", $reddit_to_teddit, false);

Loading…
Cancel
Save