Subversion Repositories Sites.tela-botanica.org

Rev

Rev 609 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
420 florian 1
<?php
2
 
3
// Vérification de sécurité
4
if (!defined("WIKINI_VERSION"))
5
{
6
        die ("acc&egrave;s direct interdit");
7
}
8
 
9
 
10
// Meme nom : remplace
11
// _Meme nom : avant
12
// Meme nom : _apres
13
 
14
 
15
require_once('libs/class.plugins.php');
16
 
17
 
18
Class WikiTools extends Wiki {
19
	function Format($text, $formatter = "wakka") {
20
		return $this->IncludeBuffered($formatter.".php", "<i>Impossible de trouver le formateur \"$formatter\"</i>", compact("text"),$this->config['formatter_path']);
21
 
22
	}
23
 
24
	function IncludeBuffered($filename, $notfoundText = "", $vars = "", $path = "") {
25
		if ($path) $dirs = explode(":", $path);
26
		else $dirs = array("");
27
 
28
		$included['before']=array();
29
		$included['new']=array();
30
		$included['after']=array();
31
 
32
		foreach($dirs as $dir) {
33
			if ($dir) $dir .= "/";
34
			$fullfilename = $dir.$filename;
35
			if (strstr($filename,'page/')) {
36
				list($file,$extension) = explode("page/", $filename);
37
				$beforefullfilename = $dir.$file.'page/__'.$extension;
38
			}
39
			else {
40
				$beforefullfilename = $dir.'__'.$filename;
41
			}
42
 
43
 
44
			list($file,$extension) = explode(".", $filename);
45
			$afterfullfilename = $dir.$file.'__.'.$extension;
46
 
47
			if (file_exists($beforefullfilename)) {
48
				$included['before'][]=$beforefullfilename;
49
			}
50
 
51
			if (file_exists($fullfilename)) {
52
				$included['new'][]=$fullfilename;
53
			}
54
 
55
			if (file_exists($afterfullfilename)) {
56
				$included['after'][]=$afterfullfilename;
57
			}
58
		}
59
 
60
		$plugin_output_before='';
61
		$plugin_output_new='';
62
		$plugin_output_after='';
63
		$found=0;
64
 
65
		if (is_array($vars)) extract($vars);
66
 
67
		foreach ($included['before'] as $before) {
68
				$found=1;
69
				ob_start();
70
				include($before);
71
				$plugin_output_before.= ob_get_contents();
72
				ob_end_clean();
73
		}
74
		foreach ($included['new'] as $new) {
75
				$found=1;
76
				ob_start();
77
				require($new);
78
				$plugin_output_new = ob_get_contents();
79
				ob_end_clean();
80
				break;
81
		}
82
		foreach ($included['after'] as $after) {
83
				$found=1;
84
				ob_start();
85
				include($after);
86
				$plugin_output_after.= ob_get_contents();
87
				ob_end_clean();
88
		}
89
		if ($found) return $plugin_output_before.$plugin_output_new.$plugin_output_after;
90
		if ($notfoundText) return $notfoundText;
91
		else return false;
92
	}
93
 
94
}
95
 
96
$plugins_root = 'tools/';
97
 
98
$objPlugins = new plugins($plugins_root);
99
$objPlugins->getPlugins(true);
100
$plugins_list = $objPlugins->getPluginsList();
101
 
102
$wakkaConfig['formatter_path']='formatters';
103
$wikiClasses [] = 'WikiTools';
104
$wikiClassesContent [] = '';
105
 
106
foreach ($plugins_list as $k => $v) {
107
	if (file_exists($plugins_root.$k.'/wiki.php')) {
108
		include($plugins_root.$k.'/wiki.php');
109
	}
110
	if (file_exists($plugins_root.$k.'/actions')) {
111
		$wakkaConfig['action_path']=$plugins_root.$k.'/actions/'.':'.$wakkaConfig['action_path'];
112
	}
113
	if (file_exists($plugins_root.$k.'/handlers')) {
114
		$wakkaConfig['handler_path']=$plugins_root.$k.'/handlers/'.':'.$wakkaConfig['handler_path'];
115
	}
116
	if (file_exists($plugins_root.$k.'/formatters')) {
117
		$wakkaConfig['formatter_path']=$plugins_root.$k.'/formatters/'.':'.$wakkaConfig['formatter_path'];
118
	}
119
}
120
 
121
for ($iw=0;$iw<count($wikiClasses);$iw++) {
122
	if ($wikiClasses[$iw]!='WikiTools') {
123
		eval('Class '. $wikiClasses[$iw] .' extends '. $wikiClasses[$iw-1] . ' { '.$wikiClassesContent[$iw].' }; ');
124
	}
125
}
126
 
127
//$wiki  = new WikiTools($wakkaConfig);
128
eval ('$wiki  = new '.$wikiClasses[count($wikiClasses)-1]. '($wakkaConfig);');
129
 
130
?>