2 /* Get the Compatibility info for phpwiki
3 http://pear.php.net/package/PHP_CompatInfo
5 $Id: CompatInfo.php,v 1.2 2004-08-24 00:27:29 rurban Exp $
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
28 require_once 'PHP/CompatInfo.php';
30 function out_row($row, $header = false) {
31 if (empty($row)) return;
33 $tag = $header ? "th" : "td";
36 if (!empty($file) and substr($file,0,3) != '<b>' and $file != 'File') {
37 $row[0] = '<a href="'.$PHP_SELF.'?file='.urlencode($file).'">'.$file.'</a>';
39 foreach ($row as $r) {
40 echo "<$tag>", empty($r) ? ' ' : "$r", "</$tag>";
45 $info = new PHP_CompatInfo;
46 $dir = str_replace(array('\\','/'), '/', dirname(__FILE__));
47 $dir = preg_replace('/\/'.basename(dirname(__FILE__)).'$/', '', $dir);
48 $debug = !empty($_GET['debug']);
49 $detail = !empty($_GET['detail']);
51 $options = array('file_ext' => array('php'),
52 'ignore_files' => array(__FILE__),
53 'recurse_dir' => true,
54 'ignore_functions' => array(),
55 'debug' => $debug or $detail,
57 // var_dump($options);
59 $cols = array('File','Version','Extensions','Constants');
61 if (empty($_GET['file'])) {
63 echo "<h1>All Files</h1>\n";
64 echo " Show Details: <a href=\"",$_SERVER["SCRIPT_NAME"],"?detail=1\">YES</a>";
65 echo " <a href=\"",$_SERVER["SCRIPT_NAME"],"\">NO</a> <br>\n";
66 $r = $info->parseFolder($dir, $options);
68 $file = urldecode($_GET['file']);
69 echo "<h1>File $file</h1>\n";
70 echo " Show Details: <a href=\"",$_SERVER["SCRIPT_NAME"],"?file=$file&detail=1\">YES</a>";
71 echo " <a href=\"",$_SERVER["SCRIPT_NAME"],"?file=$file\">NO</a> <br>\n";
72 echo " => <a href=\"",$_SERVER["SCRIPT_NAME"],"\">Back to All Files</a><br>\n";
73 $r = $info->parseFile("$dir/$file", $options);
76 echo "<table border=\"1\">\n";
80 foreach ($r as $key => $info) {
82 if ($key == 'extensions')
83 out_row(array("<b>$key</b>", '', join(',',$info), ''));
84 elseif ($key == 'constants')
85 out_row(array("<b>$key</b>", '', '', join(',',$info)));
86 elseif ($key == 'version')
87 out_row(array("<b>$key</b>", $info, '', ''));
88 elseif ($key == 'ignored_files')
89 out_row(array("<b>$key</b>", join(',',$info), ''));
91 if (empty($_GET['file'])) {
92 $file = str_replace(array('\\','/'),'/',$key);
93 if (strlen($key) > strlen($dir))
94 $file = substr(str_replace($dir,'',$file),1);
95 if (!isset($info['extensions'][0])) {
98 $ext = array_shift($info['extensions']);
100 if (!isset($info['constants'][0])) {
103 $const = array_shift($info['constants']);
105 out_row(array($file, $info['version'], $ext, $const));
107 if (is_array($info['extensions'])
108 and sizeof($info['extensions']) >= sizeof($info['constants'])) {
109 foreach ($info['extensions'] as $i => $ext) {
110 if (isset($info['constants'][$i])) {
111 $const = $info['constants'][$i];
115 out_row(array('','', $ext, $const));
117 } elseif (is_array($info['constants'])) {
118 foreach ($info['constants'] as $i => $const) {
119 if (isset($info['extensions'][$i])) {
120 $ext = $info['extensions'][$i];
124 out_row(array('', '', $ext, $const));
128 if ($detail and is_array($info)) {
129 out_row(array('<b><i>DETAIL</i></b>','Version','Function','Extension'),1);
130 unset($info['version']);
131 unset($info['constants']);
132 unset($info['extensions']);
133 if (!empty($_GET['file'])) {
135 foreach ($info as $func) {
136 out_row(array('',$version,$func['function'],$func['extension']));
139 foreach ($info as $version => $functions) {
140 foreach ($functions as $func) {
141 out_row(array('',$version,$func['function'],$func['extension']));
156 // $Log: not supported by cvs2svn $
157 // Revision 1.1 2004/08/24 00:21:57 rurban
158 // Print the PHP compatibility info for phpwiki.
159 // per file and per project,
160 // (which function is dependend on which php version?)
163 // (c-file-style: "gnu")
168 // c-hanging-comment-ender-p: nil
169 // indent-tabs-mode: nil