2 /* Get the Compatibility info for phpwiki
3 http://pear.php.net/package/PHP_CompatInfo
6 * Copyright (C) 2004 Reini Urban <rurban@x-ray.at>
8 * This file is part of PhpWiki.
10 * PhpWiki is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * PhpWiki is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once 'PHP/CompatInfo.php';
27 function out_row($row, $header = false) {
28 if (empty($row)) return;
30 $tag = $header ? "th" : "td";
33 if (!empty($file) and substr($file,0,3) != '<b>' and $file != 'File') {
34 $row[0] = '<a href="'.$PHP_SELF.'?file='.urlencode($file).'">'.$file.'</a>';
36 foreach ($row as $r) {
37 echo "<$tag>", empty($r) ? ' ' : "$r", "</$tag>";
42 $info = new PHP_CompatInfo;
43 $dir = str_replace(array('\\','/'), '/', dirname(__FILE__));
44 $dir = preg_replace('/\/'.basename(dirname(__FILE__)).'$/', '', $dir);
45 $debug = !empty($_GET['debug']);
46 $detail = !empty($_GET['detail']);
48 $options = array('file_ext' => array('php'),
49 'ignore_files' => array(__FILE__),
50 'recurse_dir' => true,
51 'ignore_functions' => array(),
52 'debug' => $debug or $detail,
54 // var_dump($options);
56 $cols = array('File','Version','Extensions','Constants');
58 if (empty($_GET['file'])) {
60 echo "<h1>All Files</h1>\n";
61 echo " Show Details: <a href=\"",$_SERVER["SCRIPT_NAME"],"?detail=1\">YES</a>";
62 echo " <a href=\"",$_SERVER["SCRIPT_NAME"],"\">NO</a> <br>\n";
63 $r = $info->parseFolder($dir, $options);
65 $file = urldecode($_GET['file']);
66 echo "<h1>File $file</h1>\n";
67 echo " Show Details: <a href=\"",$_SERVER["SCRIPT_NAME"],"?file=$file&detail=1\">YES</a>";
68 echo " <a href=\"",$_SERVER["SCRIPT_NAME"],"?file=$file\">NO</a> <br>\n";
69 echo " => <a href=\"",$_SERVER["SCRIPT_NAME"],"\">Back to All Files</a><br>\n";
70 $r = $info->parseFile("$dir/$file", $options);
73 echo "<table border=\"1\">\n";
77 foreach ($r as $key => $info) {
79 if ($key == 'extensions')
80 out_row(array("<b>$key</b>", '', join(', ',$info), ''));
81 elseif ($key == 'constants')
82 out_row(array("<b>$key</b>", '', '', join(', ',$info)));
83 elseif ($key == 'version')
84 out_row(array("<b>$key</b>", $info, '', ''));
85 elseif ($key == 'ignored_files')
86 out_row(array("<b>$key</b>", join(',',$info), ''));
88 if (empty($_GET['file'])) {
89 $file = str_replace(array('\\','/'),'/',$key);
90 if (strlen($key) > strlen($dir))
91 $file = substr(str_replace($dir,'',$file),1);
92 if (!isset($info['extensions'][0])) {
95 $ext = array_shift($info['extensions']);
97 if (!isset($info['constants'][0])) {
100 $const = array_shift($info['constants']);
102 out_row(array($file, $info['version'], $ext, $const));
104 if (is_array($info['extensions'])
105 and sizeof($info['extensions']) >= sizeof($info['constants'])) {
106 foreach ($info['extensions'] as $i => $ext) {
107 if (isset($info['constants'][$i])) {
108 $const = $info['constants'][$i];
112 out_row(array('','', $ext, $const));
114 } elseif (is_array($info['constants'])) {
115 foreach ($info['constants'] as $i => $const) {
116 if (isset($info['extensions'][$i])) {
117 $ext = $info['extensions'][$i];
121 out_row(array('', '', $ext, $const));
125 if ($detail and is_array($info)) {
126 out_row(array('<b><i>DETAIL</i></b>','Version','Function','Extension'),1);
127 unset($info['version']);
128 unset($info['constants']);
129 unset($info['extensions']);
130 if (!empty($_GET['file'])) {
132 foreach ($info as $func) {
133 out_row(array('',$version,$func['function'],$func['extension']));
136 foreach ($info as $version => $functions) {
137 foreach ($functions as $func) {
138 out_row(array('',$version,$func['function'],$func['extension']));
157 // c-hanging-comment-ender-p: nil
158 // indent-tabs-mode: nil