]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/CompatInfo.php
extra_empty_lines
[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    $Id$
6 */
7 /*
8  * Copyright (C) 2004 Reini Urban <rurban@x-ray.at>
9  *
10  * This file is part of PhpWiki.
11  *
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.
16  *
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.
21  *
22  * You should have received a copy of the GNU General Public License along
23  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25  */
26
27 require_once 'PHP/CompatInfo.php';
28
29 function out_row($row, $header = false) {
30     if (empty($row)) return;
31     echo "<tr>";
32     $tag = $header ? "th" : "td";
33     // link to file?
34     $file = $row[0];
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>';
37     }
38     foreach ($row as $r) {
39         echo "<$tag>", empty($r) ? '&nbsp;' : "$r", "</$tag>";
40     }
41     echo "</tr>\n";
42 }
43
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']);
49 // echo $dir;
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,
55                  );
56 // var_dump($options);
57 set_time_limit(240);
58 $cols = array('File','Version','Extensions','Constants');
59
60 if (empty($_GET['file'])) {
61     $file = false;
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);
66 } else {
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 " =&gt; <a href=\"",$_SERVER["SCRIPT_NAME"],"\">Back to All Files</a><br>\n";
72     $r = $info->parseFile("$dir/$file", $options);
73 }
74
75 echo "<table border=\"1\">\n";
76
77 out_row($cols,1);
78
79 foreach ($r as $key => $info) {
80
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), ''));
89     else{
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])) {
95                 $ext = '';
96             } else {
97                 $ext = array_shift($info['extensions']);
98             }
99             if (!isset($info['constants'][0])) {
100                 $const = '';
101             } else {
102                 $const = array_shift($info['constants']);
103             }
104             out_row(array($file, $info['version'], $ext, $const));
105
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];
111                     } else {
112                         $const = '';
113                     }
114                     out_row(array('','', $ext, $const));
115                 }
116             } elseif (is_array($info['constants'])) {
117                 foreach ($info['constants'] as $i => $const) {
118                     if (isset($info['extensions'][$i])) {
119                         $ext = $info['extensions'][$i];
120                     } else {
121                         $ext = '';
122                     }
123                     out_row(array('', '', $ext, $const));
124                 }
125             }
126         }
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'])) {
133                 $version = $key;
134                 foreach ($info as $func) {
135                     out_row(array('',$version,$func['function'],$func['extension']));
136                 }
137             } else {
138                 foreach ($info as $version => $functions) {
139                     foreach ($functions as $func) {
140                         out_row(array('',$version,$func['function'],$func['extension']));
141                     }
142                 }
143             }
144         }
145     }
146 }
147 echo "</table>\n";
148
149 if ($debug) {
150     echo "<pre>\n";
151     var_dump ($r);
152     echo "</pre>\n";
153 }
154
155 // Local Variables:
156 // mode: php
157 // tab-width: 8
158 // c-basic-offset: 4
159 // c-hanging-comment-ender-p: nil
160 // indent-tabs-mode: nil
161 // End:
162 ?>