]>
git.wh0rd.org - tt-rss.git/blob - plugins/example/example.php
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.
16 function init($host) {
17 $this->link
= $host->get_link();
20 $host->add_hook($host::HOOK_PREFS_TAB
, $this);
24 $example_value = db_escape_string($_POST["example_value"]);
26 echo "Value set to $example_value (not really)";
29 function get_prefs_js() {
30 return file_get_contents(dirname(__FILE__
) . "/example.js");
33 function hook_prefs_tab($args) {
34 if ($args != "prefPrefs") return;
36 print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"".__("Example Pane")."\">";
38 print "<form dojoType=\"dijit.form.Form\">";
40 print "<script type=\"dojo/method\" event=\"onSubmit\" args=\"evt\">
42 if (this.validate()) {
43 console.log(dojo.objectToQuery(this.getValues()));
44 new Ajax.Request('backend.php', {
45 parameters: dojo.objectToQuery(this.getValues()),
46 onComplete: function(transport) {
47 notify_info(transport.responseText);
54 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
55 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"save\">";
56 print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"example\">";
58 print "<table width=\"100%\" class=\"prefPrefsList\">";
60 print "<tr><td width=\"40%\">".__("Sample value")."</td>";
61 print "<td class=\"prefValue\"><input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\" name=\"example_value\"></td></tr>";
65 print "<p><button dojoType=\"dijit.form.Button\" type=\"submit\">".
66 __("Set value")."</button>";