diff options
author | Fernando Lemos <fernandotcl@pfsense.org> | 2006-08-02 19:24:37 +0000 |
---|---|---|
committer | Fernando Lemos <fernandotcl@pfsense.org> | 2006-08-02 19:24:37 +0000 |
commit | fe0ca0756af0ae0ccf08b5b5215026e385f243e5 (patch) | |
tree | 74b9f41e3f7a6bfa71bace245af4fc69affd75dc | |
parent | b281e3f765f49ea1afb0db5ece2b8aa3c288b246 (diff) | |
download | pfsense-packages-fe0ca0756af0ae0ccf08b5b5215026e385f243e5.tar.gz pfsense-packages-fe0ca0756af0ae0ccf08b5b5215026e385f243e5.tar.bz2 pfsense-packages-fe0ca0756af0ae0ccf08b5b5215026e385f243e5.zip |
Sample cg2 files, used as reference for the implementation. Feel free to send me suggestions. Those are also not complete yet.
-rw-r--r-- | packages/cg2/sample/sample.inc | 30 | ||||
-rw-r--r-- | packages/cg2/sample/sample.xml | 17 | ||||
-rw-r--r-- | packages/cg2/sample/sample_ui.xml | 130 | ||||
-rw-r--r-- | packages/cg2/sample/sample_ui2.xml | 28 |
4 files changed, 205 insertions, 0 deletions
diff --git a/packages/cg2/sample/sample.inc b/packages/cg2/sample/sample.inc new file mode 100644 index 00000000..9f53c8de --- /dev/null +++ b/packages/cg2/sample/sample.inc @@ -0,0 +1,30 @@ +<?php +var_dump('BEING INCLUDED'); + +function sample_on_load_event(&$widgets) +{ + /* Called when the form is just loaded. You receive the array widgets as + * argument, and can modify it to alter the behavior of the form. */ + var_dump('BEING LOADED'); + //$widget =& $widgets[2]; + $widget =& get_widget($widgets, 'mytextarea'); + $widget->value='This example shows how to change the text inside a text box from within the include file, when the form is loaded.'; +} + +function sample_on_sync_event() +{ + /* This is called when the form is posted. You generally want to sync the + * configurations in the XML file to settings in files spread across the file + * system or maybe restart a service here. */ + var_dump('BEING SYNCED'); +} + +function sample_on_submit_event() +{ + /* This allows you to perform an action when an specific submit button is + * clicked. This should only be used when you have more than one submit + * button in the same form. Otherwise, <on_load_event> performs better and + * is cleaner. */ + var_dump('BEING SUBMITTED'); +} +?> diff --git a/packages/cg2/sample/sample.xml b/packages/cg2/sample/sample.xml new file mode 100644 index 00000000..980d4f8e --- /dev/null +++ b/packages/cg2/sample/sample.xml @@ -0,0 +1,17 @@ +<coregui_master> +<version>2.0</version> + +<title>A fancy example</title> + +<!--<include>sample.inc</include>--> +<!--<tabs_callback>sample_generate_tabs</tabscallback>--> +<tab> + <label>My fancy tab</label> + <interface>sample_ui.xml</interface> +</tab> +<tab> + <label>Another fancy tab</label> + <interface>sample_ui2.xml</interface> +</tab> + +</coregui_master> diff --git a/packages/cg2/sample/sample_ui.xml b/packages/cg2/sample/sample_ui.xml new file mode 100644 index 00000000..65d9ebdf --- /dev/null +++ b/packages/cg2/sample/sample_ui.xml @@ -0,0 +1,130 @@ +<coregui_interface> +<version>2.0</version> +<config>sample</config> + +<include>sample.inc</include> +<!--<include>sample2.inc</include>--> +<include_javascript>sample.js</include_javascript> + +<element> + <type>form</type> + <on_load_event>sample_on_load_event</on_load_event> + <on_sync_event>sample_on_sync_event</on_sync_event> + <widget> + <type>header</type> + <label>Headers are useful to separate stuff...</label> + </widget> + <widget> + <type>textbox</type> + <name>mytextbox</name> + <label>My fancy textbox</label> + <description>This is a textbox</description> + <value>Welcome to the world of coregui 2.0</value> + <required/> + </widget> + <widget> + <type>textarea</type> + <name>mytextarea</name> + <label>My fancy textarea</label> + <description>Just testing descriptions...</description> + <value>This widget can not be edited!</value> + <read_only/> + </widget> + <widget> + <type>checkbox</type> + <name>mycheckbox</name> + <label>A sample checkbox</label> + <caption>Check this nice checkbox</caption> + <description>Now checkboxes can have a caption as well.</description> + <on_check_javascript>alert('hey, this is only meant for quick and dirty stuff, do NOT implement anything longer than 2 or 3 commands here! Btw, i was clicked.');</on_check_javascript> + </widget> + <widget> + <type>submit</type> + <name>mysubmit</name> + <caption>Send something</caption> + <on_submit_event>sample_on_submit_event</on_submit_event> + <group_start/> + </widget> + <widget> + <type>button</type> + <name>mybutton</name> + <caption>Cancel something</caption> + <description>The description for the last element in a group is the description that matters.</description> + <on_click_javascript>alert('Hi, don\'t abuse me, use include_javascript instead!');</on_click_javascript> + <group_end/> + </widget> + <widget> + <type>textbox</type> + <name>dummydummy</name> + <label>Just some dummy text</label> + <do_not_display/> + </widget> + <widget> + <type>checkbox</type> + <name>anothercheckbox</name> + <label>Another checkbox</label> + <caption>Enable</caption> + <description>Another checkbox, this time after a group, and disabled.</description> + <disabled/> + </widget> +</element> + +<element> + <type>table</type> + <buttons>move,edit,delete,add</buttons> + <apply>Those stupid rules have been updated. Click this button to apply thechanges.</apply> + <on_sync_event>sample_on_sync_event</on_sync_event> + <widget> + <type>checkbox</type> + <name>dummycheckbox</name> + <label>Dummy checkbox</label> + </widget> + <widget> + <type>port</type> + <name>dummyport</name> + <label>Port</label> + <description>Enter a port here.</description> + <value>3128</value> + <required/> + </widget> + <widget> + <type>textbox</type> + <name>dummysetting</name> + <label>Dummy setting</label> + <description>This dummy setting will not show up in the table.</description> + <not_in_table/> + </widget> + <widget> + <type>textarea</type> + <name>longfield</name> + <label>Very long field</label> + <description>Very very very very very long field.</description> + <highlighted/> + </widget> +</element> + +<element> + <type>form</type> + <widget> + <type>header</type> + <label>...such as two different forms</label> + </widget> + <widget> + <type>button</type> + <name>mybutton</name> + <label>A simple button</label> + <caption>Another silly button</caption> + </widget> +</element> + +<element> + <type>table</type> + <widget> + <label>Silly test</label> + </widget> + <widget> + <label>Another field</label> + </widget> +</element> + +</coregui_interface> diff --git a/packages/cg2/sample/sample_ui2.xml b/packages/cg2/sample/sample_ui2.xml new file mode 100644 index 00000000..27c8cf6e --- /dev/null +++ b/packages/cg2/sample/sample_ui2.xml @@ -0,0 +1,28 @@ +<coregui_interface> +<version>2.0</version> +<config>sample2</config> + +<element> + <type>form</type> + <widget> + <type>textbox</type> + <name>mytextbox</name> + <label>My fancy textbox</label> + <value>Welcome to the world of coregui 2.0</value> + <required/> + </widget> + <widget> + <type>textarea</type> + <name>mytextarea</name> + <label>My fancy textarea</label> + <value>This widget will be encoded to the config</value> + <encode/> + </widget> + <widget> + <type>submit</type> + <name>mysubmit</name> + <caption>Submit this now</caption> + </widget> +</element> + +</coregui_interface> |