}
foreach ($available as $plugin) {
- $plugentry =& $globals->plugins->cacheGet($cache, $this->plug_barrel, $this->plug_page, $plugin);
+ $plugentry = $globals->plugins->cacheGet($cache, $this->plug_barrel, $this->plug_page, $plugin);
if (!is_array($plugentry) and $this->plug_page) {
$plugentry = $globals->plugins->cacheGet($cache, $this->plug_barrel, 0, $plugin);
if (is_array($plugentry))
}
// retrieve parameters from REQUEST
- foreach ($plug_h->params as $key => $val)
+ foreach ($plug_h->getParamNames() as $key)
{
if (isset($_REQUEST[$plug_h->name."_".$key])) {
- $plug_h->params[$key] = $_REQUEST[$plug_h->name."_".$key];
+ $plug_h->setParamValue($key, $_REQUEST[$plug_h->name."_".$key]);
}
}
{
return ($wperms != 'public');
}
-
+
+ /** Declare a plugin parameter.
+ */
+ function declareParam($key, $val)
+ {
+ $this->params[$key] = $val;
+ }
+
+
+ /** Return an array of parameter names.
+ */
+ function getParamNames()
+ {
+ return array_keys($this->params);
+ }
+
+
+ /** Return the value of a parameter of the plugin.
+ */
+ function getParamValue($key)
+ {
+ return isset($this->params[$key]) ? $this->params[$key] : '';
+ }
+
+
+ /** Set the value of a parameter of the plugin.
+ */
+ function setParamValue($key, $val)
+ {
+ if (isset($this->params[$key])) {
+ //echo "$this->name : Calling setParamValue($key, $val)<br/>\n";
+ $this->params[$key] = $val;
+ } else {
+ //echo "$this->name : skipping setParamValue($key, $val)<br/>\n";
+ }
+ }
+
+
/** Set plugin parameters.
*
* @param $params
*/
function setParams($params)
{
- $bits = explode("\0", $params);
+ $bits = explode("\0", $params);
foreach ($bits as $bit)
{
$frags = explode("=", $bit, 2);
$key = $frags[0];
- $val = isset($frags[1]) ? $frags[1] : '';
- if (isset($this->params[$key])) {
- $this->params[$key] = $val;
+ if (!empty($key))
+ {
+ $val = isset($frags[1]) ? $frags[1] : '';
+ $this->setParamValue($key, $val);
}
}
}
{
global $globals;
- //echo $this->name . " : deleteParams($barrel, $page)<br/>\n";
+ //echo $this->name . " : eraseParams($barrel, $page)<br/>\n";
$globals->db->query("delete from diogenes_plugin where plugin='{$this->name}' and barrel='$barrel' and page='$page'");
$this->active = 0;
unset($this->pos);
- foreach ($this->params as $key => $val)
+ foreach ($this->getParamNames() as $key)
{
- $this->params[$key] = '';
+ //echo "$this->name : erasing param<br/>\n";
+ $this->setParamValue($key, '');
}
}
$this->active = 1;
$params = '';
- foreach ($this->params as $key => $val)
- {
- //echo $this->name . " $key=$val<br/>";
+ foreach ($this->getParamNames() as $key)
+ {
+ $val = $this->getParamValue($key);
+ //echo "$this->name : $key = $val<br/>\n";
$params .= "$key=$val\0";
}
$globals->db->query("replace into diogenes_plugin set plugin='{$this->name}', barrel='$barrel', page='$page', pos='$pos', params='$params'");
/** Plugin description */
var $description = "This plugin allows you to insert a directory listing with icons and modification date. To make use of this plugin, insert <b>{FileList}</b> in your page where the file list should appear.";
- /** Plugin parameters */
- var $params = array('dirbase' => "", 'urlbase' => "", 'match' => "");
-
+
+ /** Constructor.
+ */
+ function FileList()
+ {
+ global $page;
+ $this->declareParam('dirbase', '');
+ $this->declareParam('urlbase', '');
+ $this->declareParam('match', '');
+ }
+
/** Prepare the output for a single file of the list.
*
{
global $page;
$bbarel = $page->barrel;
-
+
// process arguments
- $params = array();
- foreach($this->params as $key => $val) {
- $params[$key] = isset($args[$key]) ? $args[$key] : $this->params[$key];
+ $instance_vals = array();
+ foreach($this->getParamNames() as $key) {
+ $instance_vals[$key] = isset($args[$key]) ? $args[key] : $this->getParamValue($key);
}
- //print_r($params);
- if (empty($params['dirbase'])) {
- $params['dirbase'] = $bbarel->spool->spoolPath($page->curpage->props['PID']);
+ //print_r($instance_vals);
+ if (empty($instance_vals['dirbase'])) {
+ $instance_vals['dirbase'] = $bbarel->spool->spoolPath($page->curpage->props['PID']);
}
// process parameters
$output = '';
- $dir = $params['dirbase'];
+ $dir = $instance_vals['dirbase'];
if (is_dir($dir) && ($dh = opendir($dir))) {
$output .=
'<table class="light">
/* get the matching files */
while (($fname = readdir($dh)) !== false) {
if ( is_file("$dir/$fname")
- && preg_match('/^'.$params['match'].'/',$fname) )
+ && preg_match('/^'.$instance_vals['match'].'/',$fname) )
$filelist[] = $fname;
}
closedir($dh);
if (is_array($filelist)) {
rsort($filelist);
while(list ($key,$val) = each($filelist)) {
- $output .= $this->list_file("$dir/$val",$val,$params['urlbase'].$val);
+ $output .= $this->list_file("$dir/$val",$val,$instance_vals['urlbase'].$val);
}
} else {
$output .= '<tr><td colspan="4"><i>'.__("no files").'</i></td></tr>';
/** Plugin description */
var $description = "This plugin allows you to add entries to a page's <head> block.";
-
- /** Plugin parameters */
- var $params = array('contents' => '');
+
+
+ /** Constructor.
+ */
+ function HtmlHead()
+ {
+ $this->declareParam('contents', '');
+ }
+
/** Apply filtering to the input and return an output.
*
function filter($input)
{
global $page;
-
- if ($this->params['contents'])
+ $contents = $this->getParamValue('content');
+ if (!empty($contents))
{
- array_push($page->head, $this->params['contents']);
+ array_push($page->head, $contents);
}
return $input;
/** Plugin description */
var $description = "This plugin allows you to add an HTTP header to a page.";
- /** Plugin parameters */
- var $params = array('contents' => '');
+
+ /** Constructor.
+ */
+ function HttpHeader()
+ {
+ $this->declareParam('contents', '');
+ }
+
/** Apply filtering to the input and return an output.
*
*/
function filter($input)
{
- $header = $this->params['contents'];
-
+ $header = $this->getParamValue('contents');
if ($header)
{
header($header);
}
-
return $input;
}
/** Plugin description */
var $description = "This plugin allows you to mark external and secure (HTTPS) links in your pages.";
-
- /** Plugin parameters */
- var $params = array('main' => 1, 'sidebar' => 1);
+
+ /** Constructor.
+ */
+ function LinksMagic()
+ {
+ $this->declareParam('main', 1);
+ $this->declareParam('sidebar', 1);
+ }
+
+
/** Apply filtering to the input and return an output.
*
* @param $input
{
global $page;
- if ($this->params['sidebar'])
+ if ($this->getParamValue('sidebar'))
{
array_unshift($page->head, '<link rel="stylesheet" href="'.$page->url('links-sidebar.css').'" type="text/css" />');
}
- if ($this->params['main'])
+ if ($this->getParamValue('main'))
{
array_unshift($page->head, '<link rel="stylesheet" href="'.$page->url('links-main.css').'" type="text/css" />');
}
/** Plugin description */
var $description = "This plugin allows you to insert a form to send an e-mail to a fixed recipient. To make use of this plugin, insert <b>{MailForm}</b> in your page where the mail form should appear.";
- /** Plugin parameters */
- var $params = array('email' => '', 'title' => '', 'subject_tag' => '[web form] ');
+
+ /** Constructor.
+ */
+ function MailForm()
+ {
+ $this->declareParam('email', '');
+ $this->declareParam('title', '');
+ $this->declareParam('subject_tag', '[web form]');
+ }
+
/** Show an instance of the MailForm plugin.
*/
{
global $page;
- // get params
- $to_email = $this->params['email'];
- $form_title = $this->params['title'];
+ // get parameters
+ $to_email = $this->getParamValue('email');
+ $form_title = $this->getParamValue('title');
if (!isvalid_email($to_email)) {
return '<p>You must specify a valid e-mail in the "email" parameter to make use of the MailForm plugin.<p>';
$mymail = new HermesMailer();
$mymail->setFrom($from);
- $mymail->setSubject($this->params['subject_tag'].$subject);
+ $mymail->setSubject($this->getParamValue('subject_tag').$subject);
$mymail->addTo($to_email);
$mymail->setTxtBody($message);
$mymail->send();