diff options
author | Daniel Stefan Haischt <dsh@pfsense.org> | 2007-10-14 06:13:04 +0000 |
---|---|---|
committer | Daniel Stefan Haischt <dsh@pfsense.org> | 2007-10-14 06:13:04 +0000 |
commit | ab3a9d33349c2f18a3e3727b26a682058d7735a7 (patch) | |
tree | a3228be17b5e5dd384000c7db1271c54a6365e46 /packages/dyntables/pkg | |
parent | 11bff113accc69c9c9cb8efee642c1378b936e29 (diff) | |
download | pfsense-packages-ab3a9d33349c2f18a3e3727b26a682058d7735a7.tar.gz pfsense-packages-ab3a9d33349c2f18a3e3727b26a682058d7735a7.tar.bz2 pfsense-packages-ab3a9d33349c2f18a3e3727b26a682058d7735a7.zip |
* added initial dynamic table prototype
Diffstat (limited to 'packages/dyntables/pkg')
-rw-r--r-- | packages/dyntables/pkg/dyntables.inc | 111 | ||||
-rw-r--r-- | packages/dyntables/pkg/dyntables.xml | 139 | ||||
-rw-r--r-- | packages/dyntables/pkg/dyntables_classdefs.inc | 146 |
3 files changed, 396 insertions, 0 deletions
diff --git a/packages/dyntables/pkg/dyntables.inc b/packages/dyntables/pkg/dyntables.inc new file mode 100644 index 00000000..853eea11 --- /dev/null +++ b/packages/dyntables/pkg/dyntables.inc @@ -0,0 +1,111 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + dyntables.inc + part of pfSense (http://www.pfSense.com) + Copyright (C) 2007 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +require_once("dyntables_classdefs.inc"); + +function syncPackageDyntables() { + +} + +function installPackageDyntables() { + +} + +function deinstallPackageDyntables() { + +} + +function checkForExtension($alertClass) { + if(! extension_loaded( 'json' )) { + if(! @dl( 'json.so' )) { + return openNoExtDialog($alertClass); + } + } +} + +/** + * openNoExtDialog() + * + * @param mixed $effectClass + * @return + */ +function openNoExtDialog($effectClass) { + $alertMessage = gettext("PHP extension json.so was not found or could not be loaded. Please check you PHP installation."); + $dialogScript = " + <script type='text/javascript'> + var anchor = document.getElementById('popupanchor'); + + function openNoExtDialog(html) { + var effect = new PopupEffect(html, {className: '${effectClass}'}); + Dialog.alert('${alertMessage}',{className:'alphacube', top:150, width:400, height:null, showEffect:effect.show.bind(effect), hideEffect:effect.hide.bind(effect)}); + } + + openNoExtDialog(anchor); + </script> + "; + + return $dialogScript; +} + +/** +* getWindowJSScriptRefs() +* +* @return an array of <script /> elements +*/ +function getWindowJSScriptRefs(){ + $result = array('<script type="text/javascript" src="/javascript/windows-js/javascript/window.js"></script>', + '<script type="text/javascript" src="/javascript/windows-js/javascript/window_effects.js"></script>', + '<script type="text/javascript" src="/javascript/windows-js/javascript/debug.js"></script>'); + + return $result; +} + +/** +* getWindowJSStyleRefs() +* +* @return an array of <style /> tags +*/ +function getWindowJSStyleRefs(){ + $result = array('<link href="/javascript/windows-js/themes/default.css" rel="stylesheet" type="text/css" />', + '<link href="/javascript/windows-js/themes/alert.css" rel="stylesheet" type="text/css" />', + '<link href="/javascript/windows-js/themes/alphacube.css" rel="stylesheet" type="text/css" />'); + + return $result; +} + +?>
\ No newline at end of file diff --git a/packages/dyntables/pkg/dyntables.xml b/packages/dyntables/pkg/dyntables.xml new file mode 100644 index 00000000..529e587e --- /dev/null +++ b/packages/dyntables/pkg/dyntables.xml @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "../../schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="../../xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ +/* $Id$ */ +/* ========================================================================== */ +/* + dyntables.xml + part of pfSense (http://www.pfSense.com) + Copyright (C) 2007 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + ]]> + </copyright> + <description> + This package adds dynamic reloading support of table data to + various pfSense web pages. Reloading table data is done using + Ajax. + </description> + <requirements> + This package is supposed to be run on RELENG based pfSense systems. + </requirements> + <faq>Currently there are no FAQ items provided.</faq> + <name>dyntables</name> + <version>1.0</version> + <title>System: Dynamic Tables</title> + <include_file>/usr/local/pkg/dyntables.inc</include_file> + <!-- Menu is where this packages menu will appear --> + <!-- + <menu> + <name>Menu Name</name> + <section>Menu Section</section> + <url>/phpfile.php</url> + </menu> + --> + <!-- + <service> + <name>yourservice</name> + <rcfile>/usr/local/etc/rc.d/yourservice.sh</rcfile> + </service> + --> + <tabs /> + <!-- + configpath gets expanded out automatically and config items + will be stored in that location + --> + <configpath>['installedpackages']['dyntables']['config']</configpath> + <!-- + | + | PHP files (user management) + | + --> + <additional_files_needed> + <prefix>/usr/local/www/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/dyntables/www/php/diag_dhcp_leases.php</item> + </additional_files_needed> + <!-- + | + | JavaScript files (*.js and *.inc.) + | + --> + <additional_files_needed> + <prefix>/usr/local/www/javascript</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/dyntables/www/js/dyntables.js</item> + </additional_files_needed> + <!-- + | + | Include files (class defs etc.) + | + --> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/dyntables/pkg/dyntables.inc</item> + </additional_files_needed> + <additional_files_needed> + <prefix>/usr/local/pkg/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/dyntables/pkg/dyntables_classdefs.inc</item> + </additional_files_needed> + <!-- + | + | Binary files + | + --> + <additional_files_needed> + <prefix>/usr/local/lib/php/extensions/no-debug-non-zts-20020429/</prefix> + <chmod>0755</chmod> + <item>http://www.pfsense.com/packages/config/dyntables/bin/json.so</item> + </additional_files_needed> + <!-- + fields gets invoked when the user adds or edits a item. The following items + will be parsed and rendered for the user as a gui with input, and selectboxes. + --> + <!-- + Arbitrary PHP Code, that gets executed if a certain event gets triggered. + --> + <custom_php_resync_config_command> + syncPackageDyntables(); + </custom_php_resync_config_command> + <custom_php_install_command> + installPackageDyntables(); + </custom_php_install_command> + <custom_php_deinstall_command> + deinstallPackageDyntables(); + </custom_php_deinstall_command> +</packagegui> diff --git a/packages/dyntables/pkg/dyntables_classdefs.inc b/packages/dyntables/pkg/dyntables_classdefs.inc new file mode 100644 index 00000000..696170d1 --- /dev/null +++ b/packages/dyntables/pkg/dyntables_classdefs.inc @@ -0,0 +1,146 @@ +<?php +/* $Id$ */ +/* ========================================================================== */ +/* + classdefs.inc + part of pfSense (http://www.pfSense.com) + Copyright (C) 2007 Daniel S. Haischt <me@daniel.stefan.haischt.name> + All rights reserved. + + Based on m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>. + All rights reserved. + */ +/* ========================================================================== */ +/* + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ +/* ========================================================================== */ + +if (! class_exists("Object")) { + class Object { + function Object() { + $args = func_get_args(); + if (method_exists($this, '__destruct')) { + register_shutdown_function(array(&$this, '__destruct')); + } + call_user_func_array(array(&$this, '__construct'), $args); + } + + function __construct() { + } + } +} + +class Column extends Object { + var $defaultClass = "listhdrr"; + var $class = null; + var $name = null; + var $sortID = null; + + function __construct($name) { + // Perform object initialization here. + parent::__construct(); + $this->name = $name; + } + + function setClass($class) { + $this->class = $class; + } + + function getClass() { + return $this->class; + } + + function setSortID($id) { + $this->sortID = $id; + } + + function getSortID() { + return $this->sortID; + } + + function toHTML() { + global $_GET; + + $classString = $this->class != null ? $this->class : $this->defaultClass; + $allString = isset($_GET['all']) ? ", {$_GET['all']}" : ""; + return "<td class='{$classString}'><a id='{$this->sortID}' href='#' onclick='sortTable(this{$allString});'>{$this->name}</a></td>"; + } +} + +class Table extends Object { + var $columns = null; + var $data = null; + + function __construct() { + // Perform object initialization here. + parent::__construct(); + $this->columns = array(); + $this->data = array(); + } + + function addColumn($column, $id = null, $class = null) { + $column = new Column($column); + + if ($id != null) { + $column->setSortID($id); + } + if ($class != null) { + $column->setClass($class); + } + + $this->columns[] = $column; + } + + function addDataSet($dataSet) { + if (is_array($dataSet)) { + if (count($dataSet) == count($this->columns)) { + $this->data[] = $dataSet; + } else { + trigger_error("Dataset does not match column size."); + } + } else { + trigger_error("Adding non arrays as datasets to a table is not supported."); + } + } + + function setData(&$data) { + $this->data = $data; + } + + function getData() { + return $this->data; + } + + function getColumnHTML() { + $htmlString = ""; + + foreach($this->columns as $column) { + $htmlString .= $column->toHtml(); + } + + return "<tr>{$htmlString}</tr>"; + } +} + +?>
\ No newline at end of file |