root/trunk/lib/SGL/FilterChain.php

Revision 3125, 1.2 kB (checked in by demian, 3 weeks ago)

bugfix to trunk merge -3

Line 
1 <?php
2 class SGL_FilterChain
3 {
4     var $aFilters;
5
6     function SGL_FilterChain($aFilters)
7     {
8         $this->aFilters = array_map('trim', $aFilters);
9     }
10
11     function doFilter(&$input, &$output)
12     {
13         $this->loadFilters();
14
15         $filters = '';
16         $closeParens = '';
17
18         $code = '$process = ';
19         foreach ($this->aFilters as $filter) {
20             $filters .= "new $filter(\n";
21             $closeParens .= ')';
22         }
23         $code = $filters . $closeParens;
24         eval("\$process = $code;");
25
26         $process->process($input, $output);
27     }
28
29     function loadFilters()
30     {
31         //  allow libs to come from custom path or seagull/lib/SGL/Task
32         $ok = ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR
33             . SGL_LIB_DIR);
34         if (!$ok) {
35             SGL::displayStaticPage('You need to be able to run ini_set(), sometimes '.
36             'this is not available in safe_mode or in earlier versions of PHP');
37         }
38
39         foreach ($this->aFilters as $filter) {
40             if (!class_exists($filter)) {
41                 $path = trim(preg_replace('/_/', '/', $filter)) . '.php';
42                 require_once $path;
43             }
44         }
45     }
46 }
47 ?>
Note: See TracBrowser for help on using the browser.