af_psql_trgm: cleanup
This commit is contained in:
parent
a2c75257f1
commit
bed36cbf9f
|
@ -124,113 +124,117 @@ class Af_Psql_Trgm extends Plugin {
|
||||||
function hook_prefs_tab($args) {
|
function hook_prefs_tab($args) {
|
||||||
if ($args != "prefFeeds") return;
|
if ($args != "prefFeeds") return;
|
||||||
|
|
||||||
print "<div dojoType=\"dijit.layout.AccordionPane\"
|
$similarity = $this->host->get($this, "similarity", $this->default_similarity);
|
||||||
title=\"<i class='material-icons'>extension</i> ".__('Mark similar articles as read (af_psql_trgm)')."\">";
|
$min_title_length = $this->host->get($this, "min_title_length", $this->default_min_length);
|
||||||
|
$enable_globally = sql_bool_to_bool($this->host->get($this, "enable_globally"));
|
||||||
|
|
||||||
if (DB_TYPE != "pgsql") {
|
?>
|
||||||
print_error("Database type not supported.");
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$res = $this->pdo->query("select 'similarity'::regproc");
|
<div dojoType="dijit.layout.AccordionPane"
|
||||||
|
title="<i class='material-icons'>extension</i> <?= __('Mark similar articles as read (af_psql_trgm)') ?>">
|
||||||
|
|
||||||
if (!$res || !$res->fetch()) {
|
<?php
|
||||||
print_error("pg_trgm extension not found.");
|
if (DB_TYPE != "pgsql") {
|
||||||
}
|
print_error("Database type not supported.");
|
||||||
|
} else {
|
||||||
|
$res = $this->pdo->query("select 'similarity'::regproc");
|
||||||
|
|
||||||
$similarity = $this->host->get($this, "similarity", $this->default_similarity);
|
if (!$res || !$res->fetch()) {
|
||||||
$min_title_length = $this->host->get($this, "min_title_length", $this->default_min_length);
|
print_error("pg_trgm extension not found.");
|
||||||
$enable_globally = sql_bool_to_bool($this->host->get($this, "enable_globally"));
|
}
|
||||||
|
} ?>
|
||||||
|
|
||||||
print "<form dojoType=\"dijit.form.Form\">";
|
<form dojoType="dijit.form.Form">
|
||||||
|
|
||||||
print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
|
<?= \Controls\pluginhandler_tags($this, "save") ?>
|
||||||
evt.preventDefault();
|
|
||||||
if (this.validate()) {
|
<script type="dojo/method" event="onSubmit" args="evt">
|
||||||
console.log(dojo.objectToQuery(this.getValues()));
|
evt.preventDefault();
|
||||||
new Ajax.Request('backend.php', {
|
if (this.validate()) {
|
||||||
parameters: dojo.objectToQuery(this.getValues()),
|
Notify.progress('Saving data...', true);
|
||||||
onComplete: function(transport) {
|
xhrPost("backend.php", this.getValues(), (transport) => {
|
||||||
Notify.info(transport.responseText);
|
Notify.info(transport.responseText);
|
||||||
}
|
})
|
||||||
});
|
}
|
||||||
//this.reset();
|
</script>
|
||||||
}
|
|
||||||
</script>";
|
|
||||||
|
|
||||||
print \Controls\pluginhandler_tags($this, "save");
|
<?= format_notice("Enable for specific feeds in the feed editor.") ?>
|
||||||
|
|
||||||
print_notice("Enable for specific feeds in the feed editor.");
|
<fieldset>
|
||||||
|
<label><?= __("Minimum similarity:") ?></label>
|
||||||
|
<input dojoType="dijit.form.NumberSpinner"
|
||||||
|
placeholder="<?= $this->default_similarity ?>"
|
||||||
|
id='psql_trgm_similarity'
|
||||||
|
required="1"
|
||||||
|
name="similarity" value="<?= htmlspecialchars($similarity) ?>">
|
||||||
|
|
||||||
print "<fieldset>";
|
<div dojoType='dijit.Tooltip' connectId='psql_trgm_similarity' position='below'>
|
||||||
|
<?= __("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") ?>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
print "<label>" . __("Minimum similarity:") . "</label> ";
|
<fieldset>
|
||||||
print "<input dojoType=\"dijit.form.NumberSpinner\"
|
<label><?= __("Minimum title length:") ?></label>
|
||||||
placeholder=\"0.75\" id='psql_trgm_similarity'
|
<input dojoType="dijit.form.NumberSpinner"
|
||||||
required=\"1\" name=\"similarity\" value=\"$similarity\">";
|
placeholder="<?= $this->default_min_length ?>"
|
||||||
|
required="1"
|
||||||
|
name="min_title_length" value="<?= htmlspecialchars($min_title_length) ?>">
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
print "<div dojoType='dijit.Tooltip' connectId='psql_trgm_similarity' position='below'>" .
|
<fieldset>
|
||||||
__("PostgreSQL trigram extension returns string similarity as a floating point number (0-1). Setting it too low might produce false positives, zero disables checking.") .
|
<label class='checkbox'>
|
||||||
"</div>";
|
<?= \Controls\checkbox_tag("enable_globally", $enable_globally) ?>
|
||||||
|
<?= __("Enable for all feeds.") ?>
|
||||||
|
</label>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
print "</fieldset><fieldset>";
|
<hr/>
|
||||||
|
|
||||||
print "<label>" . __("Minimum title length:") . "</label> ";
|
<?= \Controls\submit_tag(__("Save")) ?>
|
||||||
print "<input dojoType=\"dijit.form.NumberSpinner\"
|
</form>
|
||||||
placeholder=\"32\"
|
|
||||||
required=\"1\" name=\"min_title_length\" value=\"$min_title_length\">";
|
|
||||||
|
|
||||||
print "</fieldset><fieldset>";
|
<?php
|
||||||
|
/* cleanup */
|
||||||
|
$enabled_feeds = $this->filter_unknown_feeds(
|
||||||
|
$this->get_stored_array("enabled_feeds"));
|
||||||
|
|
||||||
print "<label class='checkbox'>";
|
$this->host->set($this, "enabled_feeds", $enabled_feeds);
|
||||||
print \Controls\checkbox_tag("enable_globally", $enable_globally);
|
?>
|
||||||
print " " . __("Enable for all feeds:");
|
|
||||||
print "</label>";
|
|
||||||
|
|
||||||
print "</fieldset>";
|
<?php if (count($enabled_feeds) > 0) { ?>
|
||||||
|
<hr/>
|
||||||
|
<h3><?= __("Currently enabled for (click to edit):") ?></h3>
|
||||||
|
|
||||||
print "<hr/>";
|
<ul class="panel panel-scrollable list list-unstyled">
|
||||||
print \Controls\submit_tag(__("Save"));
|
<?php foreach ($enabled_feeds as $f) { ?>
|
||||||
print "</form>";
|
<li>
|
||||||
|
<i class='material-icons'>rss_feed</i>
|
||||||
/* cleanup */
|
<a href='#' onclick="CommonDialogs.editFeed(<?= $f ?>)">
|
||||||
$enabled_feeds = $this->filter_unknown_feeds(
|
<?= Feeds::_get_title($f) ?>
|
||||||
$this->get_stored_array("enabled_feeds"));
|
</a>
|
||||||
|
</li>
|
||||||
$this->host->set($this, "enabled_feeds", $enabled_feeds);
|
<?php } ?>
|
||||||
|
</ul>
|
||||||
if (count($enabled_feeds) > 0) {
|
<?php } ?>
|
||||||
print "<hr/>";
|
</div>
|
||||||
print "<h3>" . __("Currently enabled for (click to edit):") . "</h3>";
|
<?php
|
||||||
|
|
||||||
print "<ul class=\"panel panel-scrollable list list-unstyled\">";
|
|
||||||
foreach ($enabled_feeds as $f) {
|
|
||||||
print "<li>" .
|
|
||||||
"<i class='material-icons'>rss_feed</i> <a href='#'
|
|
||||||
onclick='CommonDialogs.editFeed($f)'>" .
|
|
||||||
Feeds::_get_title($f) . "</a></li>";
|
|
||||||
}
|
|
||||||
print "</ul>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</div>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hook_prefs_edit_feed($feed_id) {
|
function hook_prefs_edit_feed($feed_id) {
|
||||||
print "<header>".__("Similarity (af_psql_trgm)")."</header>";
|
$enabled_feeds = $this->get_stored_array("enabled_feeds");
|
||||||
print "<section>";
|
?>
|
||||||
|
<header><?= __("Similarity (af_psql_trgm)") ?></header>
|
||||||
|
|
||||||
$enabled_feeds = $this->get_stored_array("enabled_feeds");
|
<section>
|
||||||
$checked = in_array($feed_id, $enabled_feeds) ? "checked" : "";
|
<fieldset>
|
||||||
|
<label class="checkbox">
|
||||||
print "<fieldset>";
|
<?= \Controls\checkbox_tag("trgm_similarity_enabled", in_array($feed_id, $enabled_feeds)) ?>
|
||||||
|
<?= __('Mark similar articles as read') ?>
|
||||||
print "<label class='checkbox'><input dojoType='dijit.form.CheckBox' type='checkbox' id='trgm_similarity_enabled'
|
</label>
|
||||||
name='trgm_similarity_enabled' $checked> ".__('Mark similar articles as read')."</label>";
|
</fieldset>
|
||||||
|
</section>
|
||||||
print "</fieldset>";
|
</section>
|
||||||
|
<?php
|
||||||
print "</section>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hook_prefs_save_feed($feed_id) {
|
function hook_prefs_save_feed($feed_id) {
|
||||||
|
|
Loading…
Reference in New Issue