]>
git.wh0rd.org - tt-rss.git/blob - plugins/example/example.php
e49ee5f27e14afcbf2cb41175d11974cb2a56c28
2 class Example
extends Plugin
{
4 // Demonstrates how to add a separate panel to the preferences screen and inject Javascript/save data using Dojo forms.
9 function __construct($host) {
10 $this->link
= $host->get_link();
13 $host->add_hook($host::HOOK_PREFS_TAB
, $this);
17 $example_value = db_escape_string($_POST["example_value"]);
19 echo "Value set to $example_value (not really)";
22 function get_prefs_js() {
23 return file_get_contents(dirname(__FILE__
) . "/example.js");
26 function hook_prefs_tab($args) {
27 if ($args != "prefPrefs") return;
29 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__("Example Pane")."\">";
31 print "<form dojoType=\"dijit.form.Form\">";
33 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
35 if (this.validate()) {
36 console.log(dojo.objectToQuery(this.getValues()));
37 new Ajax.Request('backend.php', {
38 parameters: dojo.objectToQuery(this.getValues()),
39 onComplete: function(transport) {
40 notify_info(transport.responseText);
47 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
48 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">";
49 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"example\">";
51 print "<table width=\"100%\" class=\"prefPrefsList\">";
53 print "<tr><td width=\"40%\">".__("Sample value")."</td>";
54 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"example_value\"></td></tr>";
58 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
59 __("Set value")."</button>";