Skel.php

00001 <?php
00002 /*
00003  * Copyright (C) 2003-2004 Polytechnique.org
00004  * http://opensource.polytechnique.org/
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 // dependency on PEAR
00022 require_once 'System.php';
00023 
00028 function stripslashes_recurse($value)
00029 {
00030    $value = is_array($value) ?
00031                array_map('stripslashes_recurse', $value) :
00032                stripslashes($value);
00033    return $value;
00034 }
00035 
00036 
00039 class Diogenes_Plugin_Skel {
00041   var $type;
00042   
00044   var $params = array();
00045   
00047   var $name = "Plugin_Skel";
00048   
00050   var $description = "Plugin skeleton";
00051   
00053   var $version = "0.1";
00054 
00056   var $pos;
00057   
00059   var $active = 0;
00060   
00061   
00066   function allow_wperms($wperms) 
00067   {
00068     return ($wperms != 'public');
00069   }
00070    
00071 
00076   function setParams($params)
00077   {
00078     $bits = explode("\0", $params);      
00079     foreach ($bits as $bit)
00080     {
00081       $frags = explode("=", $bit, 2);
00082       $key = $frags[0];
00083       $val = isset($frags[1]) ? $frags[1] : '';
00084       if (isset($this->params[$key])) {
00085         $this->params[$key] = $val;
00086       }
00087     }
00088   }
00089   
00090   
00096   function eraseParams($barrel = '', $page = 0)
00097   {
00098     global $globals;
00099     
00100     //echo $this->name . " : deleteParams($barrel, $page)<br/>\n";
00101     $globals->db->query("delete from diogenes_plugin where plugin='{$this->name}' and barrel='$barrel' and page='$page'");
00102     
00103     $this->active = 0;
00104     unset($this->pos);
00105     foreach ($this->params as $key => $val)
00106     {
00107       $this->params[$key] = '';
00108     }
00109   }
00110    
00111     
00118   function writeParams($barrel = '', $page = 0, $pos = 0)
00119   {
00120     global $globals;
00121 
00122     $this->pos = $pos;
00123     $this->active = 1;
00124     
00125     $params = '';
00126     foreach ($this->params as $key => $val)
00127     { 
00128       //echo $this->name . " $key=$val<br/>";
00129       $params .= "$key=$val\0";     
00130     }        
00131     $globals->db->query("replace into diogenes_plugin set plugin='{$this->name}', barrel='$barrel', page='$page', pos='$pos', params='$params'");
00132   }
00133   
00134   
00137   function dump()
00138   {
00139     $plugentr = array();
00140 
00141     // copy over properties
00142     $props = array('active', 'name', 'params', 'description', 'version', 'type', 'pos');
00143     foreach ($props as $prop)
00144     {
00145       if (isset($this->$prop))
00146       {
00147         $plugentr[$prop] =  stripslashes_recurse($this->$prop);
00148       }
00149     }    
00150     return $plugentr;
00151   }
00152   
00153 }
00154   
00155 ?>

Generated on Fri Jan 11 01:20:08 2008 for Diogenes by  doxygen 1.5.1