summaryrefslogtreecommitdiff
path: root/plugins/af_readability/init.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/af_readability/init.php')
-rwxr-xr-xplugins/af_readability/init.php166
1 files changed, 77 insertions, 89 deletions
diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php
index a76c98380..be9220cda 100755
--- a/plugins/af_readability/init.php
+++ b/plugins/af_readability/init.php
@@ -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);
@@ -60,99 +55,92 @@ class Af_Readability extends Plugin {
function hook_prefs_tab($args) {
if ($args != "prefFeeds") return;
- print "<div dojoType='dijit.layout.AccordionPane'
- title=\"<i class='material-icons'>extension</i> ".__('Readability settings (af_readability)')."\">";
+ $enable_share_anything = sql_bool_to_bool($this->host->get($this, "enable_share_anything"));
- if (version_compare(PHP_VERSION, '7.0.0', '<')) {
- print_error("This plugin requires PHP 7.0.");
- } else {
+ ?>
+ <div dojoType='dijit.layout.AccordionPane'
+ title="<i class='material-icons'>extension</i> <?= __('Readability settings (af_readability)') ?>">
- print "<h2>" . __("Global settings") . "</h2>";
+ <?= format_notice("Enable for specific feeds in the feed editor.") ?>
- print_notice("Enable for specific feeds in the feed editor.");
+ <form dojoType='dijit.form.Form'>
- print "<form dojoType='dijit.form.Form'>";
+ <?= \Controls\pluginhandler_tags($this, "save") ?>
- print "<script type='dojo/method' event='onSubmit' args='evt'>
- evt.preventDefault();
- if (this.validate()) {
- console.log(dojo.objectToQuery(this.getValues()));
- new Ajax.Request('backend.php', {
- parameters: dojo.objectToQuery(this.getValues()),
- onComplete: function(transport) {
- Notify.info(transport.responseText);
+ <script type="dojo/method" event="onSubmit" args="evt">
+ evt.preventDefault();
+ if (this.validate()) {
+ Notify.progress('Saving data...', true);
+ xhr.post("backend.php", this.getValues(), (reply) => {
+ Notify.info(reply);
+ })
}
- });
- //this.reset();
- }
- </script>";
-
- print_hidden("op", "pluginhandler");
- print_hidden("method", "save");
- print_hidden("plugin", "af_readability");
-
- $enable_share_anything = $this->host->get($this, "enable_share_anything");
-
- print "<fieldset>";
- print "<label class='checkbox'> ";
- print_checkbox("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 "</form>";
-
- /* cleanup */
- $enabled_feeds = $this->filter_unknown_feeds(
- $this->get_stored_array("enabled_feeds"));
-
- $append_feeds = $this->filter_unknown_feeds(
- $this->get_stored_array("append_feeds"));
-
- $this->host->set($this, "enabled_feeds", $enabled_feeds);
- $this->host->set($this, "append_feeds", $append_feeds);
-
- if (count($enabled_feeds) > 0) {
- print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
-
- print "<ul class='panel panel-scrollable list list-unstyled'>";
- foreach ($enabled_feeds as $f) {
- $is_append = in_array($f, $append_feeds);
-
- print "<li><i class='material-icons'>rss_feed</i> <a href='#'
- onclick='CommonDialogs.editFeed($f)'>".
- Feeds::getFeedTitle($f) . " " . ($is_append ? __("(append)") : "") . "</a></li>";
- }
- print "</ul>";
- }
-
- }
-
- print "</div>";
+ </script>
+
+ <fieldset>
+ <label class='checkbox'>
+ <?= \Controls\checkbox_tag("enable_share_anything", $enable_share_anything) ?>
+ <?= __("Provide full-text services to core code (bookmarklets) and other plugins") ?>
+ </label>
+ </fieldset>
+
+ <hr/>
+
+ <?= \Controls\submit_tag(__("Save")) ?>
+ </form>
+
+ <?php
+ /* cleanup */
+ $enabled_feeds = $this->filter_unknown_feeds(
+ $this->get_stored_array("enabled_feeds"));
+
+ $append_feeds = $this->filter_unknown_feeds(
+ $this->get_stored_array("append_feeds"));
+
+ $this->host->set($this, "enabled_feeds", $enabled_feeds);
+ $this->host->set($this, "append_feeds", $append_feeds);
+ ?>
+
+ <?php if (count($enabled_feeds) > 0) { ?>
+ <hr/>
+ <h3><?= __("Currently enabled for (click to edit):") ?></h3>
+
+ <ul class='panel panel-scrollable list list-unstyled'>
+ <?php foreach ($enabled_feeds as $f) { ?>
+ <li>
+ <i class='material-icons'>rss_feed</i>
+ <a href='#' onclick="CommonDialogs.editFeed(<?= $f ?>)">
+ <?= Feeds::_get_title($f) . " " . (in_array($f, $append_feeds) ? __("(append)") : "") ?>
+ </a>
+ </li>
+ <?php } ?>
+ </ul>
+ <?php } ?>
+ </div>
+ <?php
}
function hook_prefs_edit_feed($feed_id) {
- print "<header>".__("Readability")."</header>";
- print "<section>";
-
$enabled_feeds = $this->get_stored_array("enabled_feeds");
$append_feeds = $this->get_stored_array("append_feeds");
-
- $enable_checked = in_array($feed_id, $enabled_feeds) ? "checked" : "";
- $append_checked = in_array($feed_id, $append_feeds) ? "checked" : "";
-
- print "<fieldset>";
-
- print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='af_readability_enabled'
- name='af_readability_enabled' $enable_checked>&nbsp;".__('Inline article content')."</label>";
-
- print "</fieldset><fieldset>";
-
- print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='af_readability_append'
- name='af_readability_append' $append_checked>&nbsp;".__('Append to summary, instead of replacing it')."</label>";
-
- print "</section>";
+ ?>
+
+ <header><?= __("Readability") ?></header>
+ <section>
+ <fieldset>
+ <label class='checkbox'>
+ <?= \Controls\checkbox_tag("af_readability_enabled", in_array($feed_id, $enabled_feeds)) ?>
+ <?= __('Inline article content') ?>
+ </label>
+ </fieldset>
+ <fieldset>
+ <label class='checkbox'>
+ <?= \Controls\checkbox_tag("af_readability_append", in_array($feed_id, $append_feeds)) ?>
+ <?= __('Append to summary, instead of replacing it') ?>
+ </label>
+ </fieldset>
+ </section>
+ <?php
}
function hook_prefs_save_feed($feed_id) {
@@ -333,7 +321,7 @@ class Af_Readability extends Plugin {
}
function embed() {
- $article_id = (int) $_REQUEST["param"];
+ $article_id = (int) $_REQUEST["id"];
$sth = $this->pdo->prepare("SELECT link FROM ttrss_entries WHERE id = ?");
$sth->execute([$article_id]);