]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/CompatInfo.php
Allow bold, italics or underlined for numbers
[SourceForge/phpwiki.git] / tests / CompatInfo.php
1 <?php
2 /* Get the Compatibility info for phpwiki
3    http://pear.php.net/package/PHP_CompatInfo
4 */
5 /*
6  * Copyright (C) 2004 Reini Urban <rurban@x-ray.at>
7  *
8  * This file is part of PhpWiki.
9  *
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.
14  *
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.
19  *
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.
23  */
24
25 require_once 'PHP/CompatInfo.php';
26
27 function out_row($row, $header = false) {
28     if (empty($row)) return;
29     echo "<tr>";
30     $tag = $header ? "th" : "td";
31     // link to file?
32     $file = $row[0];
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>';
35     }
36     foreach ($row as $r) {
37         echo "<$tag>", empty($r) ? '&nbsp;' : "$r", "</$tag>";
38     }
39     echo "</tr>\n";
40 }
41
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']);
47 // echo $dir;
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,
53                  );
54 // var_dump($options);
55 set_time_limit(240);
56 $cols = array('File','Version','Extensions','Constants');
57
58 if (empty($_GET['file'])) {
59     $file = false;
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);
64 } else {
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 " =&gt; <a href=\"",$_SERVER["SCRIPT_NAME"],"\">Back to All Files</a><br>\n";
70     $r = $info->parseFile("$dir/$file", $options);
71 }
72
73 echo "<table border=\"1\">\n";
74
75 out_row($cols,1);
76
77 foreach ($r as $key => $info) {
78
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), ''));
87     else{
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])) {
93                 $ext = '';
94             } else {
95                 $ext = array_shift($info['extensions']);
96             }
97             if (!isset($info['constants'][0])) {
98                 $const = '';
99             } else {
100                 $const = array_shift($info['constants']);
101             }
102             out_row(array($file, $info['version'], $ext, $const));
103
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];
109                     } else {
110                         $const = '';
111                     }
112                     out_row(array('','', $ext, $const));
113                 }
114             } elseif (is_array($info['constants'])) {
115                 foreach ($info['constants'] as $i => $const) {
116                     if (isset($info['extensions'][$i])) {
117                         $ext = $info['extensions'][$i];
118                     } else {
119                         $ext = '';
120                     }
121                     out_row(array('', '', $ext, $const));
122                 }
123             }
124         }
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'])) {
131                 $version = $key;
132                 foreach ($info as $func) {
133                     out_row(array('',$version,$func['function'],$func['extension']));
134                 }
135             } else {
136                 foreach ($info as $version => $functions) {
137                     foreach ($functions as $func) {
138                         out_row(array('',$version,$func['function'],$func['extension']));
139                     }
140                 }
141             }
142         }
143     }
144 }
145 echo "</table>\n";
146
147 if ($debug) {
148     echo "<pre>\n";
149     var_dump ($r);
150     echo "</pre>\n";
151 }
152
153 // Local Variables:
154 // mode: php
155 // tab-width: 8
156 // c-basic-offset: 4
157 // c-hanging-comment-ender-p: nil
158 // indent-tabs-mode: nil
159 // End: