Filter.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 'Plugin/Skel.php';
00023 
00026 class Diogenes_Plugin_Filter extends Diogenes_Plugin_Skel
00027 {
00029   var $name = "Plugin_Filter";
00030   
00032   var $description = "Filter plugin skeleton";
00033   
00035   var $version = "0.1";
00036 
00038   var $type = "filter";  
00039   
00040   
00048   function filter($input)
00049   {
00050     global $page;
00051     $name = $this->name;
00052     
00053     $mask = "/(\{$name(\s+[^\}]*)?\})/";
00054     $bits = preg_split($mask, $input, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
00055     $output = "";    
00056     while($bit = array_shift($bits)) {
00057       $matches = array();
00058       if (preg_match($mask, $bit, $matches)) {
00059         if ($matches[2]) 
00060         {  
00061           $argstr = array_shift($bits);
00062         } else {
00063           $argstr = "";
00064         }
00065         $argbits = preg_split("/\s/", trim($argstr));
00066         $args = array();
00067         foreach($argbits as $argbit)
00068         {
00069           if (preg_match('/([a-zA-Z]+)=([\'"])(.*)\2$/', $argbit, $matches)) {
00070             $args[$matches[1]] = $matches[3];
00071           }
00072         }
00073         $output .= $this->show($args);        
00074       } else {
00075         $output .= $bit;
00076       }
00077     }
00078     return $output;
00079   }
00080   
00081   
00085   function show()
00086   {
00087     return '';
00088   }
00089   
00090   
00091 }
00092   
00093 ?>

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