093000d5bacd22f63108d1eb81679e94eb385d24
3 * Copyright (C) 2003-2004 Polytechnique.org
4 * http://opensource.polytechnique.org/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 require_once 'System.php';
24 /** Recursive stripslashes.
28 function stripslashes_recurse($value)
30 $value = is_array($value) ?
31 array_map('stripslashes_recurse', $value) :
37 /** This class describes a Diogenes plugin.
39 class Diogenes_Plugin_Skel
{
40 /** Plugin type (object, filter) */
43 /** Array of plugin parameters */
44 var $params = array();
47 var $name = "Plugin_Skel";
49 /** Plugin description */
50 var $description = "Plugin skeleton";
55 /** Position of the plugin */
58 /** Is the plugin active ? */
62 /** Is the plugin allowed with respect to a given write permission on a page ?
66 function allow_wperms($wperms)
68 return ($wperms != 'public');
72 /** Set plugin parameters.
76 function setParams($params)
78 $bits = explode("\0", $params);
79 foreach ($bits as $bit)
81 $frags = explode("=", $bit, 2);
83 $val = isset($frags[1]) ?
$frags[1] : '';
84 if (isset($this->params
[$key])) {
85 $this->params
[$key] = $val;
91 /** Erase parameters from database.
96 function eraseParams($barrel = '', $page = 0)
100 //echo $this->name . " : deleteParams($barrel, $page)<br/>\n";
101 $globals->db
->query("delete from diogenes_plugin where plugin='{$this->name}' and barrel='$barrel' and page='$page'");
105 foreach ($this->params
as $key => $val)
107 $this->params
[$key] = '';
112 /** Store parameters to database.
118 function writeParams($barrel = '', $page = 0, $pos = 0)
126 foreach ($this->params
as $key => $val)
128 //echo $this->name . " $key=$val<br/>";
129 $params .= "$key=$val\0";
131 $globals->db
->query("replace into diogenes_plugin set plugin='{$this->name}', barrel='$barrel', page='$page', pos='$pos', params='$params'");
135 /** Dump parameters to a table.
141 // copy over properties
142 $props = array('active', 'name', 'params', 'description', 'version', 'type', 'pos');
143 foreach ($props as $prop)
145 if (isset($this->$prop))
147 $plugentr[$prop] = stripslashes_recurse($this->$prop);