2 /* Get the Compatibility info for phpwiki
3 http://pear.php.net/package/PHP_CompatInfo
8 * Copyright (C) 2004 Reini Urban <rurban@x-ray.at>
10 * This file is part of PhpWiki.
12 * PhpWiki is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * PhpWiki is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with PhpWiki; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 require_once 'PHP/CompatInfo.php';
29 function out_row($row, $header = false) {
30 if (empty($row)) return;
32 $tag = $header ? "th" : "td";
35 if (!empty($file) and substr($file,0,3) != '<b>' and $file != 'File') {
36 $row[0] = '<a href="'.$PHP_SELF.'?file='.urlencode($file).'">'.$file.'</a>';
38 foreach ($row as $r) {
39 echo "<$tag>", empty($r) ? ' ' : "$r", "</$tag>";
44 $info = new PHP_CompatInfo;
45 $dir = str_replace(array('\\','/'), '/', dirname(__FILE__));
46 $dir = preg_replace('/\/'.basename(dirname(__FILE__)).'$/', '', $dir);
47 $debug = !empty($_GET['debug']);
48 $detail = !empty($_GET['detail']);
50 $options = array('file_ext' => array('php'),
51 'ignore_files' => array(__FILE__),
52 'recurse_dir' => true,
53 'ignore_functions' => array(),
54 'debug' => $debug or $detail,
56 // var_dump($options);
58 $cols = array('File','Version','Extensions','Constants');
60 if (empty($_GET['file'])) {
62 echo "<h1>All Files</h1>\n";
63 echo " Show Details: <a href=\"",$_SERVER["SCRIPT_NAME"],"?detail=1\">YES</a>";
64 echo " <a href=\"",$_SERVER["SCRIPT_NAME"],"\">NO</a> <br>\n";
65 $r = $info->parseFolder($dir, $options);
67 $file = urldecode($_GET['file']);
68 echo "<h1>File $file</h1>\n";
69 echo " Show Details: <a href=\"",$_SERVER["SCRIPT_NAME"],"?file=$file&detail=1\">YES</a>";
70 echo " <a href=\"",$_SERVER["SCRIPT_NAME"],"?file=$file\">NO</a> <br>\n";
71 echo " => <a href=\"",$_SERVER["SCRIPT_NAME"],"\">Back to All Files</a><br>\n";
72 $r = $info->parseFile("$dir/$file", $options);
75 echo "<table border=\"1\">\n";
79 foreach ($r as $key => $info) {
81 if ($key == 'extensions')
82 out_row(array("<b>$key</b>", '', join(', ',$info), ''));
83 elseif ($key == 'constants')
84 out_row(array("<b>$key</b>", '', '', join(', ',$info)));
85 elseif ($key == 'version')
86 out_row(array("<b>$key</b>", $info, '', ''));
87 elseif ($key == 'ignored_files')
88 out_row(array("<b>$key</b>", join(',',$info), ''));
90 if (empty($_GET['file'])) {
91 $file = str_replace(array('\\','/'),'/',$key);
92 if (strlen($key) > strlen($dir))
93 $file = substr(str_replace($dir,'',$file),1);
94 if (!isset($info['extensions'][0])) {
97 $ext = array_shift($info['extensions']);
99 if (!isset($info['constants'][0])) {
102 $const = array_shift($info['constants']);
104 out_row(array($file, $info['version'], $ext, $const));
106 if (is_array($info['extensions'])
107 and sizeof($info['extensions']) >= sizeof($info['constants'])) {
108 foreach ($info['extensions'] as $i => $ext) {
109 if (isset($info['constants'][$i])) {
110 $const = $info['constants'][$i];
114 out_row(array('','', $ext, $const));
116 } elseif (is_array($info['constants'])) {
117 foreach ($info['constants'] as $i => $const) {
118 if (isset($info['extensions'][$i])) {
119 $ext = $info['extensions'][$i];
123 out_row(array('', '', $ext, $const));
127 if ($detail and is_array($info)) {
128 out_row(array('<b><i>DETAIL</i></b>','Version','Function','Extension'),1);
129 unset($info['version']);
130 unset($info['constants']);
131 unset($info['extensions']);
132 if (!empty($_GET['file'])) {
134 foreach ($info as $func) {
135 out_row(array('',$version,$func['function'],$func['extension']));
138 foreach ($info as $version => $functions) {
139 foreach ($functions as $func) {
140 out_row(array('',$version,$func['function'],$func['extension']));
159 // c-hanging-comment-ender-p: nil
160 // indent-tabs-mode: nil