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)
\n"; $this->params[$key] = $val; } else { //echo "$this->name : skipping setParamValue($key, $val)
\n"; } } /** Set plugin parameters. * * @param $params */ function setParams($params) { $bits = explode("\0", $params); foreach ($bits as $bit) { $frags = explode("=", $bit, 2); $key = $frags[0]; if (!empty($key)) { $val = isset($frags[1]) ? $frags[1] : ''; $this->setParamValue($key, $val); } } } /** Erase parameters from database. * * @param $barrel * @param $page */ function eraseParams($barrel = '', $page = 0) { global $globals; //echo $this->name . " : eraseParams($barrel, $page)
\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->getParamNames() as $key) { //echo "$this->name : erasing param
\n"; $this->setParamValue($key, ''); } } /** Store parameters to database. * * @param $barrel * @param $page * @param $pos */ function writeParams($barrel = '', $page = 0, $pos = 0) { global $globals; $this->pos = $pos; $this->active = 1; $params = ''; foreach ($this->getParamNames() as $key) { $val = $this->getParamValue($key); //echo "$this->name : $key = $val
\n"; $params .= "$key=$val\0"; } $globals->db->query("replace into diogenes_plugin set plugin='{$this->name}', barrel='$barrel', page='$page', pos='$pos', params='$params'"); } /** Dump parameters to a table. */ function dump() { $plugentr = array(); // copy over properties $props = array('active', 'name', 'params', 'description', 'version', 'type', 'pos'); foreach ($props as $prop) { if (isset($this->$prop)) { $plugentr[$prop] = stripslashes_recurse($this->$prop); } } return $plugentr; } } ?>