| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* This was all in {@link phpdoc.inc}, and now encapsulates the complexity
|
|
|
4 |
*
|
|
|
5 |
* phpDocumentor :: automatic documentation generator
|
|
|
6 |
*
|
|
|
7 |
* PHP versions 4 and 5
|
|
|
8 |
*
|
|
|
9 |
* Copyright (c) 2002-2006 Gregory Beaver
|
|
|
10 |
*
|
|
|
11 |
* LICENSE:
|
|
|
12 |
*
|
|
|
13 |
* This library is free software; you can redistribute it
|
|
|
14 |
* and/or modify it under the terms of the GNU Lesser General
|
|
|
15 |
* Public License as published by the Free Software Foundation;
|
|
|
16 |
* either version 2.1 of the License, or (at your option) any
|
|
|
17 |
* later version.
|
|
|
18 |
*
|
|
|
19 |
* This library is distributed in the hope that it will be useful,
|
|
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
22 |
* Lesser General Public License for more details.
|
|
|
23 |
*
|
|
|
24 |
* You should have received a copy of the GNU Lesser General Public
|
|
|
25 |
* License along with this library; if not, write to the Free Software
|
|
|
26 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
27 |
*
|
|
|
28 |
* @package phpDocumentor
|
|
|
29 |
* @author Gregory Beaver <cellog@php.net>
|
|
|
30 |
* @copyright 2002-2006 Gregory Beaver
|
|
|
31 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
|
|
32 |
* @version CVS: $Id: Setup.inc.php 258122 2008-04-22 15:48:55Z ashnazg $
|
|
|
33 |
* @link http://www.phpdoc.org
|
|
|
34 |
* @link http://pear.php.net/PhpDocumentor
|
|
|
35 |
* @since 1.2
|
|
|
36 |
*/
|
|
|
37 |
error_reporting(E_ALL);
|
|
|
38 |
|
|
|
39 |
/** ensure top-level PhpDocumentor dir is in include path */
|
|
|
40 |
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));
|
|
|
41 |
|
|
|
42 |
/** common settings */
|
|
|
43 |
include_once("phpDocumentor/common.inc.php");
|
|
|
44 |
|
|
|
45 |
include_once("phpDocumentor/Io.inc");
|
|
|
46 |
include_once("phpDocumentor/Publisher.inc");
|
|
|
47 |
include_once("phpDocumentor/Classes.inc");
|
|
|
48 |
include_once("phpDocumentor/ProceduralPages.inc");
|
|
|
49 |
include_once("phpDocumentor/IntermediateParser.inc");
|
|
|
50 |
include_once("phpDocumentor/WordParser.inc");
|
|
|
51 |
include_once("phpDocumentor/EventStack.inc");
|
|
|
52 |
include_once("phpDocumentor/ParserData.inc");
|
|
|
53 |
include_once("phpDocumentor/InlineTags.inc");
|
|
|
54 |
include_once("phpDocumentor/DocBlockTags.inc");
|
|
|
55 |
include_once("phpDocumentor/DescHTML.inc");
|
|
|
56 |
include_once("phpDocumentor/ParserDocBlock.inc");
|
|
|
57 |
include_once("phpDocumentor/ParserElements.inc");
|
|
|
58 |
include_once("phpDocumentor/Parser.inc");
|
|
|
59 |
include_once("phpDocumentor/phpDocumentorTWordParser.inc");
|
|
|
60 |
include_once("phpDocumentor/phpDocumentorTParser.inc");
|
|
|
61 |
include_once("phpDocumentor/HighlightParser.inc");
|
|
|
62 |
include_once("phpDocumentor/TutorialHighlightParser.inc");
|
|
|
63 |
include_once("phpDocumentor/ParserDescCleanup.inc");
|
|
|
64 |
include_once("phpDocumentor/PackagePageElements.inc");
|
|
|
65 |
include_once("phpDocumentor/XMLpackagePageParser.inc");
|
|
|
66 |
include_once("phpDocumentor/LinkClasses.inc");
|
|
|
67 |
include_once("phpDocumentor/Converter.inc");
|
|
|
68 |
include_once("phpDocumentor/Errors.inc");
|
|
|
69 |
if (isset($_GET))
|
|
|
70 |
{
|
|
|
71 |
/**
|
|
|
72 |
* $interface is either 'web' or is not set at all
|
|
|
73 |
* @global array $interface
|
|
|
74 |
*/
|
|
|
75 |
if (isset($_GET['interface'])) $interface = $_GET['interface'];
|
|
|
76 |
/**
|
|
|
77 |
* $_phpDocumentor_setting is either the value from the web interface, or is set up by {@link Io::parseArgv()}
|
|
|
78 |
* @global array $_phpDocumentor_setting
|
|
|
79 |
*/
|
|
|
80 |
if (isset($_GET['setting'])) $_phpDocumentor_setting = $_GET['setting'];
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
/**
|
|
|
84 |
* default package name, set using -dn --defaultpackagename
|
|
|
85 |
* @global string $GLOBALS['phpDocumentor_DefaultPackageName']
|
|
|
86 |
* @name $phpDocumentor_DefaultPackageName
|
|
|
87 |
*/
|
|
|
88 |
$GLOBALS['phpDocumentor_DefaultPackageName'] = 'default';
|
|
|
89 |
|
|
|
90 |
/**
|
|
|
91 |
* default package name, set using -dn --defaultcategoryname
|
|
|
92 |
* @global string $GLOBALS['phpDocumentor_DefaultCategoryName']
|
|
|
93 |
* @name $phpDocumentor_DefaultCategoryName
|
|
|
94 |
*/
|
|
|
95 |
$GLOBALS['phpDocumentor_DefaultCategoryName'] = 'default';
|
|
|
96 |
|
|
|
97 |
/**
|
|
|
98 |
* @package phpDocumentor
|
|
|
99 |
*/
|
|
|
100 |
class phpDocumentor_setup
|
|
|
101 |
{
|
|
|
102 |
/**
|
|
|
103 |
* The main parser
|
|
|
104 |
* @var Parser|phpDocumentorTParser
|
|
|
105 |
*/
|
|
|
106 |
var $parse;
|
|
|
107 |
/**
|
|
|
108 |
* Used to parse command-line options
|
|
|
109 |
* @var Io
|
|
|
110 |
*/
|
|
|
111 |
var $setup;
|
|
|
112 |
/**
|
|
|
113 |
* Used to organize output from the Parser before Conversion
|
|
|
114 |
* @var phpDocumentor_IntermediateParser
|
|
|
115 |
*/
|
|
|
116 |
var $render = false;
|
|
|
117 |
/**
|
|
|
118 |
* Packages to create documentation for
|
|
|
119 |
* @var string
|
|
|
120 |
*/
|
|
|
121 |
var $packages = false;
|
|
|
122 |
/**
|
|
|
123 |
* contents of --filename commandline
|
|
|
124 |
* @tutorial phpDocumentor.howto.pkg#using.command-line.filename
|
|
|
125 |
* @var string
|
|
|
126 |
*/
|
|
|
127 |
var $files = '';
|
|
|
128 |
/**
|
|
|
129 |
* contents of --directory commandline
|
|
|
130 |
* @tutorial phpDocumentor.howto.pkg#using.command-line.directory
|
|
|
131 |
* @var string
|
|
|
132 |
*/
|
|
|
133 |
var $dirs = '';
|
|
|
134 |
/**
|
|
|
135 |
* contents of --hidden commandline
|
|
|
136 |
* @tutorial phpDocumentor.howto.pkg#using.command-line.hidden
|
|
|
137 |
* @var boolean
|
|
|
138 |
*/
|
|
|
139 |
var $hidden = false;
|
|
|
140 |
/**
|
|
|
141 |
* time that parsing was started, used for informative timing of output
|
|
|
142 |
* @access private
|
|
|
143 |
*/
|
|
|
144 |
var $parse_start_time;
|
|
|
145 |
/**
|
|
|
146 |
* contents of --ignore commandline
|
|
|
147 |
* @tutorial phpDocumentor.howto.pkg#using.command-line.ignore
|
|
|
148 |
* @var string
|
|
|
149 |
*/
|
|
|
150 |
var $ignore_files = array();
|
|
|
151 |
/**
|
|
|
152 |
* contents of --ignoresymlinks commandline
|
|
|
153 |
* @var boolean
|
|
|
154 |
*/
|
|
|
155 |
var $ignoresymlinks = false;
|
|
|
156 |
|
|
|
157 |
/**
|
|
|
158 |
* Checks PHP version, makes sure it is 4.2.0+, and chooses the
|
|
|
159 |
* phpDocumentorTParser if version is 4.3.0+
|
|
|
160 |
* @uses parseIni()
|
|
|
161 |
*/
|
|
|
162 |
function phpDocumentor_setup()
|
|
|
163 |
{
|
|
|
164 |
global $_phpDocumentor_cvsphpfile_exts, $_phpDocumentor_setting;
|
|
|
165 |
if (!function_exists('is_a'))
|
|
|
166 |
{
|
|
|
167 |
print "phpDocumentor requires PHP version 4.2.0 or greater to function";
|
|
|
168 |
exit;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
$this->setup = new Io;
|
|
|
172 |
if (!isset($interface) && !isset($_GET['interface']) && !isset($_phpDocumentor_setting))
|
|
|
173 |
{
|
|
|
174 |
// Parse the argv settings
|
|
|
175 |
$_phpDocumentor_setting = $this->setup->parseArgv();
|
|
|
176 |
}
|
|
|
177 |
if (isset($_phpDocumentor_setting['useconfig']) &&
|
|
|
178 |
!empty($_phpDocumentor_setting['useconfig'])) {
|
|
|
179 |
$this->readConfigFile($_phpDocumentor_setting['useconfig']);
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
// set runtime to a large value since this can take quite a while
|
|
|
183 |
// we can only set_time_limit when not in safe_mode bug #912064
|
|
|
184 |
if (!ini_get('safe_mode'))
|
|
|
185 |
{
|
|
|
186 |
set_time_limit(0); // unlimited runtime
|
|
|
187 |
} else
|
|
|
188 |
{
|
|
|
189 |
phpDocumentor_out("time_limit cannot be set since your in safe_mode, please edit time_limit in your php.ini to allow enough time for phpDocumentor to run");
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
$phpver = phpversion();
|
|
|
193 |
$phpdocver = PHPDOCUMENTOR_VER;
|
|
|
194 |
if (isset($_GET['interface'])) {
|
|
|
195 |
$phpver = "<b>$phpver</b>";
|
|
|
196 |
$phpdocver = "<b>$phpdocver</b>";
|
|
|
197 |
}
|
|
|
198 |
phpDocumentor_out("PHP Version $phpver\n");
|
|
|
199 |
phpDocumentor_out("phpDocumentor version $phpdocver\n\n");
|
|
|
200 |
|
|
|
201 |
$this->parseIni();
|
|
|
202 |
$this->setMemoryLimit();
|
|
|
203 |
|
|
|
204 |
/*
|
|
|
205 |
* NOTE:
|
|
|
206 |
* It is possible for the tokenizer extension to be loaded,
|
|
|
207 |
* but actually be broken in the OS, and therefore not working...
|
|
|
208 |
* the conditional below will NOT recognize this scenario.
|
|
|
209 |
* You can separately run the {@link tokenizer_test.php} to
|
|
|
210 |
* verify that the tokenizer library is working correctly
|
|
|
211 |
* from the OS perspective.
|
|
|
212 |
*/
|
|
|
213 |
if (tokenizer_ext) {
|
|
|
214 |
phpDocumentor_out("using tokenizer Parser\n");
|
|
|
215 |
$this->parse = new phpDocumentorTParser;
|
|
|
216 |
} else {
|
|
|
217 |
phpDocumentor_out("No Tokenizer support detected, so using default (slower) Parser..." . PHP_EOL);
|
|
|
218 |
|
|
|
219 |
if (version_compare(phpversion(), '4.3.0', '<')) {
|
|
|
220 |
phpDocumentor_out(" for faster parsing, recompile PHP with --enable-tokenizer." . PHP_EOL );
|
|
|
221 |
} else {
|
|
|
222 |
phpDocumentor_out(" for faster parsing, recompile PHP without --disable-tokenizer." . PHP_EOL );
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
$this->parse = new Parser;
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
/**
|
|
|
230 |
* Get phpDocumentor settings from a user configuration file
|
|
|
231 |
* @param string user configuration file
|
|
|
232 |
*/
|
|
|
233 |
function readConfigFile($file)
|
|
|
234 |
{
|
|
|
235 |
global $_phpDocumentor_setting, $_phpDocumentor_options;
|
|
|
236 |
// security
|
|
|
237 |
$file = str_replace(array('..','.ini','\\'),array('','','/'),$file);
|
|
|
238 |
if (is_file($file . '.ini'))
|
|
|
239 |
{
|
|
|
240 |
$_phpDocumentor_setting = phpDocumentor_parse_ini_file($file.'.ini');
|
|
|
241 |
} else
|
|
|
242 |
{
|
|
|
243 |
if ('/var/www/pear' != '@'.'DATA-DIR@')
|
|
|
244 |
{
|
|
|
245 |
$configdir = str_replace('\\','/', '/var/www/pear/PhpDocumentor') . PATH_DELIMITER . 'user' . PATH_DELIMITER;
|
|
|
246 |
} else {
|
|
|
247 |
$configdir = str_replace('\\','/',$GLOBALS['_phpDocumentor_install_dir']) . PATH_DELIMITER . 'user' . PATH_DELIMITER;
|
|
|
248 |
}
|
|
|
249 |
if (isset($_phpDocumentor_options['userdir'])) $configdir = $_phpDocumentor_options['userdir'];
|
|
|
250 |
if (substr($configdir,-1) != '/')
|
|
|
251 |
{
|
|
|
252 |
$configdir .= '/';
|
|
|
253 |
}
|
|
|
254 |
$_phpDocumentor_setting = phpDocumentor_parse_ini_file( $configdir . $file . '.ini');
|
|
|
255 |
if (empty($_phpDocumentor_setting['defaultpackagename']))
|
|
|
256 |
{
|
|
|
257 |
$_phpDocumentor_setting['defaultpackagename'] = 'default';
|
|
|
258 |
}
|
|
|
259 |
}
|
|
|
260 |
// don't want a loop condition!
|
|
|
261 |
unset($_phpDocumentor_setting['useconfig']);
|
|
|
262 |
}
|
|
|
263 |
|
|
|
264 |
/**
|
|
|
265 |
* Get phpDocumentor settings from command-line or web interface
|
|
|
266 |
*/
|
|
|
267 |
function readCommandLineSettings()
|
|
|
268 |
{
|
|
|
269 |
global $_phpDocumentor_setting,$interface,$_phpDocumentor_RIC_files;
|
|
|
270 |
// subscribe $render class to $parse class events
|
|
|
271 |
if (!isset($_phpDocumentor_setting['junk'])) $_phpDocumentor_setting['junk'] = '';
|
|
|
272 |
if (!isset($_phpDocumentor_setting['title'])) $_phpDocumentor_setting['title'] = 'Generated Documentation';
|
|
|
273 |
$temp_title = $_phpDocumentor_setting['title'];
|
|
|
274 |
$this->render = new phpDocumentor_IntermediateParser($temp_title);
|
|
|
275 |
if (isset($_phpDocumentor_setting['help']) || $_phpDocumentor_setting['junk'] == "-h" || $_phpDocumentor_setting['junk'] == "--help")
|
|
|
276 |
{
|
|
|
277 |
echo $this->setup->displayHelpMsg();
|
|
|
278 |
die();
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
// set to parse hidden files
|
|
|
282 |
$this->hidden = (isset($_phpDocumentor_setting['hidden'])) ? decideOnOrOff($_phpDocumentor_setting['hidden']) : false;
|
|
|
283 |
|
|
|
284 |
// set to parse through symlinks
|
|
|
285 |
$this->ignoresymlinks = (isset($_phpDocumentor_setting['ignoresymlinks'])) ? decideOnOrOff($_phpDocumentor_setting['ignoresymlinks']) : false;
|
|
|
286 |
|
|
|
287 |
// set to parse elements marked private with @access private
|
|
|
288 |
$this->render->setParsePrivate((isset($_phpDocumentor_setting['parseprivate'])) ? decideOnOrOff($_phpDocumentor_setting['parseprivate']) : false);
|
|
|
289 |
|
|
|
290 |
// set to print warnings when undocumented elements are spotted
|
|
|
291 |
$this->render->setUndocumentedElementWarningsMode((isset($_phpDocumentor_setting['undocumentedelements'])) ? decideOnOrOff($_phpDocumentor_setting['undocumentedelements']) : false);
|
|
|
292 |
|
|
|
293 |
if (isset($_phpDocumentor_setting['ignoretags']))
|
|
|
294 |
{
|
|
|
295 |
$ignoretags = explode(',', $_phpDocumentor_setting['ignoretags']);
|
|
|
296 |
$ignoretags = array_map('trim', $ignoretags);
|
|
|
297 |
$tags = array();
|
|
|
298 |
foreach($ignoretags as $tag)
|
|
|
299 |
{
|
|
|
300 |
if (!in_array($tag,array('@global', '@access', '@package', '@ignore', '@name', '@param', '@return', '@staticvar', '@var')))
|
|
|
301 |
$tags[] = $tag;
|
|
|
302 |
}
|
|
|
303 |
$_phpDocumentor_setting['ignoretags'] = $tags;
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
if (isset($_phpDocumentor_setting['readmeinstallchangelog']))
|
|
|
307 |
{
|
|
|
308 |
$_phpDocumentor_setting['readmeinstallchangelog'] = explode(',',str_replace(' ','',$_phpDocumentor_setting['readmeinstallchangelog']));
|
|
|
309 |
$rics = array();
|
|
|
310 |
foreach($_phpDocumentor_setting['readmeinstallchangelog'] as $ric)
|
|
|
311 |
{
|
|
|
312 |
$rics[] = strtoupper(trim($ric));
|
|
|
313 |
}
|
|
|
314 |
$_phpDocumentor_RIC_files = $rics;
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
if (isset($_phpDocumentor_setting['javadocdesc']) && $_phpDocumentor_setting['javadocdesc'] == 'on')
|
|
|
318 |
{
|
|
|
319 |
$this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock';
|
|
|
320 |
}
|
|
|
321 |
if (tokenizer_ext)
|
|
|
322 |
{
|
|
|
323 |
if (isset($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
|
|
|
324 |
{
|
|
|
325 |
$_phpDocumentor_setting['sourcecode'] = true;
|
|
|
326 |
} else
|
|
|
327 |
{
|
|
|
328 |
$_phpDocumentor_setting['sourcecode'] = false;
|
|
|
329 |
}
|
|
|
330 |
} else
|
|
|
331 |
{
|
|
|
332 |
if (isset($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
|
|
|
333 |
{
|
|
|
334 |
addWarning(PDERROR_SOURCECODE_IGNORED);
|
|
|
335 |
}
|
|
|
336 |
$_phpDocumentor_setting['sourcecode'] = false;
|
|
|
337 |
}
|
|
|
338 |
if (isset($_phpDocumentor_setting['converterparams']))
|
|
|
339 |
{
|
|
|
340 |
$_phpDocumentor_setting['converterparams'] = explode($_phpDocumentor_setting['converterparams']);
|
|
|
341 |
foreach($_phpDocumentor_setting['converterparams'] as $i => $p)
|
|
|
342 |
{
|
|
|
343 |
$_phpDocumentor_setting['converterparams'][$i] = trim($p);
|
|
|
344 |
}
|
|
|
345 |
}
|
|
|
346 |
if (isset($_phpDocumentor_setting['customtags']) && !empty($_phpDocumentor_setting['customtags']))
|
|
|
347 |
{
|
|
|
348 |
$c = explode(',',$_phpDocumentor_setting['customtags']);
|
|
|
349 |
for($i=0;$i<count($c); $i++)
|
|
|
350 |
{
|
|
|
351 |
$GLOBALS['_phpDocumentor_tags_allowed'][] = trim($c[$i]);
|
|
|
352 |
}
|
|
|
353 |
}
|
|
|
354 |
if (isset($_phpDocumentor_setting['pear']))
|
|
|
355 |
{
|
|
|
356 |
if ($_phpDocumentor_setting['pear'] === 'off') $_phpDocumentor_setting['pear'] = false;
|
|
|
357 |
if ($_phpDocumentor_setting['pear'] === 'on') $_phpDocumentor_setting['pear'] = true;
|
|
|
358 |
}
|
|
|
359 |
if (!isset($_phpDocumentor_setting['pear'])) $_phpDocumentor_setting['pear'] = false;
|
|
|
360 |
// set to change the default package name from "default" to whatever you want
|
|
|
361 |
if (isset($_phpDocumentor_setting['defaultpackagename']))
|
|
|
362 |
{
|
|
|
363 |
$GLOBALS['phpDocumentor_DefaultPackageName'] = trim($_phpDocumentor_setting['defaultpackagename']);
|
|
|
364 |
}
|
|
|
365 |
// set to change the default category name from "default" to whatever you want
|
|
|
366 |
if (isset($_phpDocumentor_setting['defaultcategoryname']))
|
|
|
367 |
{
|
|
|
368 |
$GLOBALS['phpDocumentor_DefaultCategoryName'] = trim($_phpDocumentor_setting['defaultcategoryname']);
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
// set the mode (quiet or verbose)
|
|
|
372 |
$this->render->setQuietMode((isset($_phpDocumentor_setting['quiet'])) ? decideOnOrOff($_phpDocumentor_setting['quiet']) : false);
|
|
|
373 |
|
|
|
374 |
// Setup the different classes
|
|
|
375 |
if (isset($_phpDocumentor_setting['templatebase']))
|
|
|
376 |
{
|
|
|
377 |
$this->render->setTemplateBase(trim($_phpDocumentor_setting['templatebase']));
|
|
|
378 |
}
|
|
|
379 |
if (isset($_phpDocumentor_setting['target']) && !empty($_phpDocumentor_setting['target']))
|
|
|
380 |
{
|
|
|
381 |
$this->render->setTargetDir(trim($_phpDocumentor_setting['target']));
|
|
|
382 |
}
|
|
|
383 |
else
|
|
|
384 |
{
|
|
|
385 |
echo "a target directory must be specified\n try phpdoc -h\n";
|
|
|
386 |
die();
|
|
|
387 |
}
|
|
|
388 |
if (!empty($_phpDocumentor_setting['packageoutput']))
|
|
|
389 |
{
|
|
|
390 |
$this->packages = explode(",",trim($_phpDocumentor_setting['packageoutput']));
|
|
|
391 |
foreach($this->packages as $p => $v)
|
|
|
392 |
{
|
|
|
393 |
$this->packages[$p] = trim($v);
|
|
|
394 |
}
|
|
|
395 |
}
|
|
|
396 |
if (!empty($_phpDocumentor_setting['filename'])) {
|
|
|
397 |
$this->files = trim($_phpDocumentor_setting['filename']);
|
|
|
398 |
}
|
|
|
399 |
if (!empty($_phpDocumentor_setting['directory'])) {
|
|
|
400 |
$this->dirs = trim($_phpDocumentor_setting['directory']);
|
|
|
401 |
}
|
|
|
402 |
}
|
|
|
403 |
|
|
|
404 |
function checkIgnoreTag($tagname, $inline = false)
|
|
|
405 |
{
|
|
|
406 |
global $_phpDocumentor_setting;
|
|
|
407 |
$tagname = '@'.$tagname;
|
|
|
408 |
if (!isset($_phpDocumentor_setting['ignoretags'])) return false;
|
|
|
409 |
if ($inline) $tagname = '{'.$tagname.'}';
|
|
|
410 |
return in_array($tagname, $_phpDocumentor_setting['ignoretags']);
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
/**
|
|
|
414 |
* Allow a memory_limit setting in phpDocumentor.ini to override php.ini or default memory limit
|
|
|
415 |
* @todo recognize "K" and "G" in memory_limit settings, rather than just "M"
|
|
|
416 |
*/
|
|
|
417 |
function setMemoryLimit() {
|
|
|
418 |
global $_phpDocumentor_options;
|
|
|
419 |
$DEFAULT_MEMORY_SIZE_MINIMUM = 256;
|
|
|
420 |
|
|
|
421 |
// PhpDoc memory_limit from phpDocumentor.ini overrides all other considerations
|
|
|
422 |
if (isset($_phpDocumentor_options['memory_limit'])) {
|
|
|
423 |
$phpdoc_ini_setting = str_replace('M', '', $_phpDocumentor_options['memory_limit']);
|
|
|
424 |
|
|
|
425 |
// allow phpdoc.ini to DISABLE the setting via "= -1"
|
|
|
426 |
if ($phpdoc_ini_setting == -1)
|
|
|
427 |
{
|
|
|
428 |
$memory_setting_to_use = $phpdoc_ini_setting;
|
|
|
429 |
$max_mem_log_message = "setting disabled by phpDocumentor.ini...\n";
|
|
|
430 |
}
|
|
|
431 |
else
|
|
|
432 |
{
|
|
|
433 |
$memory_setting_to_use = $phpdoc_ini_setting . "M";
|
|
|
434 |
$max_mem_log_message = "set at " . $memory_setting_to_use . " by phpDocumentor.ini...\n";
|
|
|
435 |
}
|
|
|
436 |
} else {
|
|
|
437 |
$php_ini_setting = str_replace('M', '', ini_get('memory_limit'));
|
|
|
438 |
|
|
|
439 |
// allow php.ini to DISABLE the setting via "= -1"
|
|
|
440 |
if ($php_ini_setting == -1)
|
|
|
441 |
{
|
|
|
442 |
// allow it to remain disabled
|
|
|
443 |
$memory_setting_to_use = $php_ini_setting;
|
|
|
444 |
$max_mem_log_message = "setting disabled by php.ini...\n";
|
|
|
445 |
}
|
|
|
446 |
else
|
|
|
447 |
{
|
|
|
448 |
// memory_limit from php.ini must be at least the default minimum
|
|
|
449 |
$memory_setting_to_use = ($php_ini_setting > $DEFAULT_MEMORY_SIZE_MINIMUM) ? $php_ini_setting . "M" : $DEFAULT_MEMORY_SIZE_MINIMUM . "M";
|
|
|
450 |
$max_mem_log_message = "set at " . $memory_setting_to_use . " after considering php.ini...\n";
|
|
|
451 |
}
|
|
|
452 |
}
|
|
|
453 |
if (ini_set("memory_limit", $memory_setting_to_use))
|
|
|
454 |
{
|
|
|
455 |
// PHP had to have been compiled with "--enable-memory-limit" to allow setting the value explicitly
|
|
|
456 |
phpDocumentor_out("Maximum memory usage " . $max_mem_log_message);
|
|
|
457 |
}
|
|
|
458 |
else
|
|
|
459 |
{
|
|
|
460 |
// PHP must not have been compiled with "--enable-memory-limit", so we cannot modify it...
|
|
|
461 |
// no need to notify user of this unless they tried using memory_limit in their phpDocumentor.ini...
|
|
|
462 |
if (isset($phpdoc_ini_setting))
|
|
|
463 |
{
|
|
|
464 |
phpDocumentor_out("Unable to alter memory_limit via your phpDocumentor.ini... perhaps PHP wasn't compiled with \"--enable-memory-limit\"?\n");
|
|
|
465 |
}
|
|
|
466 |
}
|
|
|
467 |
}
|
|
|
468 |
|
|
|
469 |
function setJavadocDesc()
|
|
|
470 |
{
|
|
|
471 |
$this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock';
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
function setParsePrivate($flag = true)
|
|
|
475 |
{
|
|
|
476 |
$this->render->setParsePrivate($flag);
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
function setQuietMode($flag = true)
|
|
|
480 |
{
|
|
|
481 |
$this->render->setQuietMode($flag);
|
|
|
482 |
}
|
|
|
483 |
|
|
|
484 |
function setUndocumentedElementWarnings($flag = true)
|
|
|
485 |
{
|
|
|
486 |
$this->render->setUndocumentedElementWarnings($flag);
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
function setTargetDir($target)
|
|
|
490 |
{
|
|
|
491 |
$this->render->setTargetDir($target);
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
function setTemplateBase($dir)
|
|
|
495 |
{
|
|
|
496 |
$this->render->setTemplateBase($dir);
|
|
|
497 |
}
|
|
|
498 |
|
|
|
499 |
function setPackageOutput($po)
|
|
|
500 |
{
|
|
|
501 |
$this->packages = explode(",",$po);
|
|
|
502 |
array_map('trim', $this->packages);
|
|
|
503 |
}
|
|
|
504 |
|
|
|
505 |
function setTitle($ti)
|
|
|
506 |
{
|
|
|
507 |
$this->render = new phpDocumentor_IntermediateParser($ti);
|
|
|
508 |
}
|
|
|
509 |
|
|
|
510 |
function setFilesToParse($files)
|
|
|
511 |
{
|
|
|
512 |
$this->files = $files;
|
|
|
513 |
}
|
|
|
514 |
|
|
|
515 |
function setDirectoriesToParse($dirs)
|
|
|
516 |
{
|
|
|
517 |
$this->dirs = $dirs;
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
function parseHiddenFiles($flag = true)
|
|
|
521 |
{
|
|
|
522 |
$this->hidden = $flag;
|
|
|
523 |
}
|
|
|
524 |
|
|
|
525 |
function setIgnore($ig)
|
|
|
526 |
{
|
|
|
527 |
if (strstr($ig,","))
|
|
|
528 |
{
|
|
|
529 |
$this->ignore_files = explode(",",$ig);
|
|
|
530 |
} else {
|
|
|
531 |
if (!empty($ig))
|
|
|
532 |
$this->ignore_files = array($ig);
|
|
|
533 |
}
|
|
|
534 |
$this->ignore_files = array_map('trim', $this->ignore_files);
|
|
|
535 |
}
|
|
|
536 |
|
|
|
537 |
function createDocs($title = false)
|
|
|
538 |
{
|
|
|
539 |
$this->parse_start_time = time();
|
|
|
540 |
global $_phpDocumentor_setting;
|
|
|
541 |
if (!$this->render)
|
|
|
542 |
{
|
|
|
543 |
$this->render = new phpDocumentor_IntermediateParser($title);
|
|
|
544 |
}
|
|
|
545 |
// setup ignore list
|
|
|
546 |
$this->ignore_files =array();
|
|
|
547 |
if(isset($_phpDocumentor_setting['ignore']))
|
|
|
548 |
{
|
|
|
549 |
$this->setIgnore($_phpDocumentor_setting['ignore']);
|
|
|
550 |
}
|
|
|
551 |
$this->parse->subscribe("*",$this->render);
|
|
|
552 |
// parse the directory
|
|
|
553 |
if (!empty($this->files))
|
|
|
554 |
{
|
|
|
555 |
$files = explode(",",$this->files);
|
|
|
556 |
foreach($files as $file)
|
|
|
557 |
{
|
|
|
558 |
$file = trim($file);
|
|
|
559 |
$test = $this->setup->getAllFiles($file);
|
|
|
560 |
if ($test)
|
|
|
561 |
{
|
|
|
562 |
foreach($test as $file)
|
|
|
563 |
{
|
|
|
564 |
$file = trim($file);
|
|
|
565 |
$dir = realpath(dirname($file));
|
|
|
566 |
$dir = strtr($dir, "\\", "/");
|
|
|
567 |
$dir = str_replace('//','/',$dir);
|
|
|
568 |
// strip trailing directory seperator
|
|
|
569 |
if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
|
|
|
570 |
{
|
|
|
571 |
$dir = substr($dir,0,-1);
|
|
|
572 |
}
|
|
|
573 |
$file = strtr(realpath($file), "\\", "/");
|
|
|
574 |
$file = str_replace('//','/',$file);
|
|
|
575 |
|
|
|
576 |
if (!$this->setup->checkIgnore(basename($file),dirname($file),$this->ignore_files,true,$this->ignoresymlinks))
|
|
|
577 |
{
|
|
|
578 |
$filelist[] = str_replace('\\','/',$file);
|
|
|
579 |
} else {
|
|
|
580 |
phpDocumentor_out("File $file Ignored\n");
|
|
|
581 |
flush();
|
|
|
582 |
}
|
|
|
583 |
}
|
|
|
584 |
} else
|
|
|
585 |
{
|
|
|
586 |
$dir = dirname(realpath($file));
|
|
|
587 |
$dir = strtr($dir, "\\", "/");
|
|
|
588 |
$dir = str_replace('//','/',$dir);
|
|
|
589 |
// strip trailing directory seperator
|
|
|
590 |
if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
|
|
|
591 |
{
|
|
|
592 |
$dir = substr($dir,0,-1);
|
|
|
593 |
}
|
|
|
594 |
$base = count(explode("/",$dir));
|
|
|
595 |
$file = strtr(realpath($file), "\\", "/");
|
|
|
596 |
$file = str_replace('//','/',$file);
|
|
|
597 |
flush();
|
|
|
598 |
|
|
|
599 |
if (!$this->setup->checkIgnore(basename($file),dirname($file),$this->ignore_files,true,$this->ignoresymlinks))
|
|
|
600 |
{
|
|
|
601 |
$filelist[] = str_replace('\\','/',$file);
|
|
|
602 |
} else {
|
|
|
603 |
phpDocumentor_out("File $file Ignored\n");
|
|
|
604 |
flush();
|
|
|
605 |
}
|
|
|
606 |
}
|
|
|
607 |
}
|
|
|
608 |
}
|
|
|
609 |
if (!empty($this->dirs))
|
|
|
610 |
{
|
|
|
611 |
$dirs = explode(",",$this->dirs);
|
|
|
612 |
foreach($dirs as $dir)
|
|
|
613 |
{
|
|
|
614 |
$olddir = $dir;
|
|
|
615 |
$dir = realpath($dir);
|
|
|
616 |
if (!$dir) {
|
|
|
617 |
phpDocumentor_out('ERROR: "' . $olddir . '" does not exist, skipping');
|
|
|
618 |
continue;
|
|
|
619 |
}
|
|
|
620 |
$dir = trim($dir);
|
|
|
621 |
$dir = strtr($dir, "\\", "/");
|
|
|
622 |
$dir = str_replace('//','/',$dir);
|
|
|
623 |
// strip trailing directory seperator
|
|
|
624 |
if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
|
|
|
625 |
{
|
|
|
626 |
$dir = substr($dir,0,-1);
|
|
|
627 |
}
|
|
|
628 |
$files = $this->setup->dirList($dir,$this->hidden,$this->ignoresymlinks);
|
|
|
629 |
if (is_array($files))
|
|
|
630 |
{
|
|
|
631 |
foreach($files as $file)
|
|
|
632 |
{
|
|
|
633 |
$file = strtr($file, '\\', '/');
|
|
|
634 |
// file's subpath, relative to $dir
|
|
|
635 |
$file_subpath = str_replace('\\', '/', realpath(dirname($file)));
|
|
|
636 |
$file_subpath = preg_replace('[\\/]', DIRECTORY_SEPARATOR, $file_subpath);
|
|
|
637 |
$file_subpath = preg_replace('~^' . preg_quote($dir, '~') . '~', '', $file_subpath);
|
|
|
638 |
|
|
|
639 |
if (!$this->setup->checkIgnore(basename($file), $file_subpath, $this->ignore_files,true,$this->ignoresymlinks))
|
|
|
640 |
{
|
|
|
641 |
$filelist[] = $file;
|
|
|
642 |
} else {
|
|
|
643 |
phpDocumentor_out("File $file Ignored\n");
|
|
|
644 |
flush();
|
|
|
645 |
}
|
|
|
646 |
}
|
|
|
647 |
}
|
|
|
648 |
}
|
|
|
649 |
}
|
|
|
650 |
if (isset($filelist))
|
|
|
651 |
{
|
|
|
652 |
if (PHPDOCUMENTOR_WINDOWS)
|
|
|
653 |
{
|
|
|
654 |
// case insensitive array_unique
|
|
|
655 |
usort($filelist,'strnatcasecmp');
|
|
|
656 |
reset($filelist);
|
|
|
657 |
|
|
|
658 |
$newarray = array();
|
|
|
659 |
$i = 0;
|
|
|
660 |
|
|
|
661 |
$element = current($filelist);
|
|
|
662 |
for ($n=0;$n<sizeof($filelist);$n++)
|
|
|
663 |
{
|
|
|
664 |
if (strtolower(next($filelist)) != strtolower($element))
|
|
|
665 |
{
|
|
|
666 |
$newarray[$i] = $element;
|
|
|
667 |
$element = current($filelist);
|
|
|
668 |
$i++;
|
|
|
669 |
}
|
|
|
670 |
}
|
|
|
671 |
$filelist = $newarray;
|
|
|
672 |
} else $filelist = array_unique($filelist);
|
|
|
673 |
|
|
|
674 |
$base = count(explode("/",$source_base = $this->setup->getBase($filelist)));
|
|
|
675 |
define("PHPDOCUMENTOR_BASE",$source_base);
|
|
|
676 |
list($filelist,$ric) = $this->setup->getReadmeInstallChangelog($source_base, $filelist);
|
|
|
677 |
phpDocumentor_out("\n\nGrabbing README/INSTALL/CHANGELOG\n");
|
|
|
678 |
flush();
|
|
|
679 |
foreach($ric as $file)
|
|
|
680 |
{
|
|
|
681 |
phpDocumentor_out(basename($file).'...');
|
|
|
682 |
flush();
|
|
|
683 |
$fp = fopen($file,'r');
|
|
|
684 |
$contents = fread($fp,filesize($file));
|
|
|
685 |
$this->render->HandleEvent(PHPDOCUMENTOR_EVENT_README_INSTALL_CHANGELOG, array(basename($file),$contents));
|
|
|
686 |
fclose($fp);
|
|
|
687 |
}
|
|
|
688 |
phpDocumentor_out("\ndone\n");
|
|
|
689 |
flush();
|
|
|
690 |
list($filelist,$tutorials) = $this->setup->getTutorials($filelist);
|
|
|
691 |
phpDocumentor_out("\n\nTutorial/Extended Documentation Parsing Stage\n\n");
|
|
|
692 |
flush();
|
|
|
693 |
if (count($tutorials))
|
|
|
694 |
{
|
|
|
695 |
$tuteparser = new XMLPackagePageParser;
|
|
|
696 |
$tuteparser->subscribe('*',$this->render);
|
|
|
697 |
foreach($tutorials as $tutorial)
|
|
|
698 |
{
|
|
|
699 |
switch($tutorial['tutetype'])
|
|
|
700 |
{
|
|
|
701 |
case 'pkg' :
|
|
|
702 |
case 'cls' :
|
|
|
703 |
case 'proc' :
|
|
|
704 |
switch($tutorial['tutetype'])
|
|
|
705 |
{
|
|
|
706 |
case 'pkg' :
|
|
|
707 |
$ptext = 'Package-level Docs ';
|
|
|
708 |
if (!empty($tutorial['subpackage']))
|
|
|
709 |
$ptext = 'Sub-Package Docs ';
|
|
|
710 |
break;
|
|
|
711 |
case 'cls' :
|
|
|
712 |
$ptext = 'Class-level Docs ';
|
|
|
713 |
break;
|
|
|
714 |
case 'proc' :
|
|
|
715 |
$ptext = 'Procedural-level Docs ';
|
|
|
716 |
break;
|
|
|
717 |
}
|
|
|
718 |
$fp = @fopen($tutorial['path'],"r");
|
|
|
719 |
if ($fp)
|
|
|
720 |
{
|
|
|
721 |
$ret = fread($fp,filesize($tutorial['path']));
|
|
|
722 |
// fix 1151650
|
|
|
723 |
if (stristr($ret, "utf-8") !== "")
|
|
|
724 |
{
|
|
|
725 |
$ret = utf8_decode($ret);
|
|
|
726 |
}
|
|
|
727 |
fclose($fp);
|
|
|
728 |
unset($fp);
|
|
|
729 |
phpDocumentor_out('Parsing '.$ptext.$tutorial['path'].'...');
|
|
|
730 |
flush();
|
|
|
731 |
$tuteparser->parse($ret,$tutorial);
|
|
|
732 |
phpDocumentor_out("done\n");
|
|
|
733 |
flush();
|
|
|
734 |
} else
|
|
|
735 |
{
|
|
|
736 |
phpDocumentor_out('Error '.$ptext.$tutorial['path'].' doesn\'t exist'."\n");
|
|
|
737 |
flush();
|
|
|
738 |
}
|
|
|
739 |
default :
|
|
|
740 |
break;
|
|
|
741 |
}
|
|
|
742 |
}
|
|
|
743 |
}
|
|
|
744 |
phpDocumentor_out("done\n");
|
|
|
745 |
flush();
|
|
|
746 |
phpDocumentor_out("\n\nGeneral Parsing Stage\n\n");
|
|
|
747 |
flush();
|
|
|
748 |
foreach($filelist as $file)
|
|
|
749 |
{
|
|
|
750 |
phpDocumentor_out("Reading file $file");
|
|
|
751 |
flush();
|
|
|
752 |
$this->parse->parse($a = $this->setup->readPhpFile($file, $this->render->quietMode),$file,$base,$this->packages);
|
|
|
753 |
|
|
|
754 |
}
|
|
|
755 |
$b = (time() - $this->parse_start_time);
|
|
|
756 |
phpDocumentor_out("done\n");
|
|
|
757 |
flush();
|
|
|
758 |
// render output
|
|
|
759 |
phpDocumentor_out("\nConverting From Abstract Parsed Data\n");
|
|
|
760 |
flush();
|
|
|
761 |
$this->render->output();
|
|
|
762 |
$a = (time() - $this->parse_start_time);
|
|
|
763 |
$c = ($a - $b);
|
|
|
764 |
phpDocumentor_out("\nParsing time: $b seconds\n");
|
|
|
765 |
phpDocumentor_out("\nConversion time: $c seconds\n");
|
|
|
766 |
phpDocumentor_out("\nTotal Documentation Time: $a seconds\n");
|
|
|
767 |
phpDocumentor_out("done\n");
|
|
|
768 |
flush();
|
|
|
769 |
} else
|
|
|
770 |
{
|
|
|
771 |
print "\nERROR: nothing parsed\n";
|
|
|
772 |
exit;
|
|
|
773 |
}
|
|
|
774 |
}
|
|
|
775 |
/**
|
|
|
776 |
* Parse configuration file phpDocumentor.ini
|
|
|
777 |
*/
|
|
|
778 |
function parseIni()
|
|
|
779 |
{
|
|
|
780 |
phpDocumentor_out("Parsing configuration file phpDocumentor.ini...\n");
|
|
|
781 |
flush();
|
|
|
782 |
if ('/var/www/pear' != '@'.'DATA-DIR@')
|
|
|
783 |
{
|
|
|
784 |
$options = phpDocumentor_parse_ini_file(str_replace('\\','/', '/var/www/pear/PhpDocumentor') . PATH_DELIMITER . 'phpDocumentor.ini',true);
|
|
|
785 |
phpDocumentor_out(" (found in " . '/var/www/pear/PhpDocumentor' . PATH_DELIMITER . ")...\n");
|
|
|
786 |
} else {
|
|
|
787 |
$options = phpDocumentor_parse_ini_file(str_replace('\\','/',$GLOBALS['_phpDocumentor_install_dir']) . PATH_DELIMITER . 'phpDocumentor.ini',true);
|
|
|
788 |
phpDocumentor_out(" (found in " . $GLOBALS['_phpDocumentor_install_dir'] . PATH_DELIMITER . ")...\n");
|
|
|
789 |
}
|
|
|
790 |
|
|
|
791 |
if (!$options)
|
|
|
792 |
{
|
|
|
793 |
print "ERROR: cannot open phpDocumentor.ini in directory " . $GLOBALS['_phpDocumentor_install_dir']."\n";
|
|
|
794 |
print "-Is phpdoc in either the path or include_path in your php.ini file?";
|
|
|
795 |
exit;
|
|
|
796 |
}
|
|
|
797 |
|
|
|
798 |
foreach($options as $var => $values)
|
|
|
799 |
{
|
|
|
800 |
if ($var != 'DEBUG')
|
|
|
801 |
{
|
|
|
802 |
// phpDocumentor_out("\n$var");
|
|
|
803 |
if ($var != '_phpDocumentor_setting' && $var != '_phpDocumentor_options' && $var != '_phpDocumentor_install_dir' ) $values = array_values($values);
|
|
|
804 |
// fancy_debug("\n$var",$values);
|
|
|
805 |
$GLOBALS[$var] = $values;
|
|
|
806 |
}
|
|
|
807 |
}
|
|
|
808 |
phpDocumentor_out("\ndone\n");
|
|
|
809 |
flush();
|
|
|
810 |
/** Debug Constant */
|
|
|
811 |
if (!defined('PHPDOCUMENTOR_DEBUG')) define("PHPDOCUMENTOR_DEBUG",$options['DEBUG']['PHPDOCUMENTOR_DEBUG']);
|
|
|
812 |
if (!defined('PHPDOCUMENTOR_KILL_WHITESPACE')) define("PHPDOCUMENTOR_KILL_WHITESPACE",$options['DEBUG']['PHPDOCUMENTOR_KILL_WHITESPACE']);
|
|
|
813 |
$GLOBALS['_phpDocumentor_cvsphpfile_exts'] = $GLOBALS['_phpDocumentor_phpfile_exts'];
|
|
|
814 |
foreach($GLOBALS['_phpDocumentor_cvsphpfile_exts'] as $key => $val)
|
|
|
815 |
{
|
|
|
816 |
$GLOBALS['_phpDocumentor_cvsphpfile_exts'][$key] = "$val,v";
|
|
|
817 |
}
|
|
|
818 |
// none of this stuff is used anymore
|
|
|
819 |
if (isset($GLOBALS['_phpDocumentor_html_allowed']))
|
|
|
820 |
{
|
|
|
821 |
$___htmltemp = array_flip($GLOBALS['_phpDocumentor_html_allowed']);
|
|
|
822 |
$___html1 = array();
|
|
|
823 |
foreach($___htmltemp as $tag => $trans)
|
|
|
824 |
{
|
|
|
825 |
$___html1['<'.$tag.'>'] = htmlentities('<'.$tag.'>');
|
|
|
826 |
$___html1['</'.$tag.'>'] = htmlentities('</'.$tag.'>');
|
|
|
827 |
}
|
|
|
828 |
$GLOBALS['phpDocumentor___html'] = array_flip($___html1);
|
|
|
829 |
}
|
|
|
830 |
}
|
|
|
831 |
|
|
|
832 |
/**
|
|
|
833 |
* Performs character-based validation of Output Converter Template name pieces
|
|
|
834 |
* @param string the name piece (just ONE of either Output, Converter, or Template piece)
|
|
|
835 |
* @param string any extra characters to allow beyond the default character set
|
|
|
836 |
* @return string|bool the clean name, or FALSE if piece is deemed invalid
|
|
|
837 |
* @access private
|
|
|
838 |
*/
|
|
|
839 |
function cleanConverterNamePiece($name, $extra_characters_to_allow = '')
|
|
|
840 |
{
|
|
|
841 |
$name = str_replace("\\", "/", $name);
|
|
|
842 |
// security: ensure no opportunity exists to use "../.." pathing in this value
|
|
|
843 |
$name = preg_replace('/[^a-zA-Z0-9' . $extra_characters_to_allow . '_-]/', "", $name);
|
|
|
844 |
|
|
|
845 |
// absolutely positively do NOT allow two consecutive dots ".."
|
|
|
846 |
if (strpos($name, '..') > -1) $name = false;
|
|
|
847 |
return $name;
|
|
|
848 |
}
|
|
|
849 |
|
|
|
850 |
/**
|
|
|
851 |
* Figures out what output converter to use
|
|
|
852 |
* @param string Output Converter Template name
|
|
|
853 |
* @access private
|
|
|
854 |
* @global array
|
|
|
855 |
* @uses cleanConverterNamePieces
|
|
|
856 |
* @uses phpDocumentor_out
|
|
|
857 |
*/
|
|
|
858 |
function setupConverters($output = false)
|
|
|
859 |
{
|
|
|
860 |
global $_phpDocumentor_setting;
|
|
|
861 |
if ($output)
|
|
|
862 |
{
|
|
|
863 |
$_phpDocumentor_setting['output'] = $output;
|
|
|
864 |
}
|
|
|
865 |
if (isset($_phpDocumentor_setting['output']) && !empty($_phpDocumentor_setting['output']))
|
|
|
866 |
{
|
|
|
867 |
$c = explode(',',$_phpDocumentor_setting['output']);
|
|
|
868 |
for($i=0; $i< count($c); $i++)
|
|
|
869 |
{
|
|
|
870 |
$c[$i] = explode(':',$c[$i]);
|
|
|
871 |
$a = $c[$i][0];
|
|
|
872 |
if (isset($c[$i][0]))
|
|
|
873 |
{
|
|
|
874 |
$a = $this->cleanConverterNamePiece($c[$i][0]);
|
|
|
875 |
}
|
|
|
876 |
else
|
|
|
877 |
{
|
|
|
878 |
$a = false;
|
|
|
879 |
}
|
|
|
880 |
if (isset($c[$i][1]))
|
|
|
881 |
{
|
|
|
882 |
/*
|
|
|
883 |
* must allow "/" due to options like "DocBook/peardoc2"
|
|
|
884 |
*/
|
|
|
885 |
$b = $this->cleanConverterNamePiece($c[$i][1], '\/');
|
|
|
886 |
}
|
|
|
887 |
else
|
|
|
888 |
{
|
|
|
889 |
$b = false;
|
|
|
890 |
}
|
|
|
891 |
if (isset($c[$i][2]))
|
|
|
892 |
{
|
|
|
893 |
/*
|
|
|
894 |
* must allow "." due to options like "phpdoc.de"
|
|
|
895 |
* must allow "/" due to options like "DOM/default"
|
|
|
896 |
*/
|
|
|
897 |
$d = $this->cleanConverterNamePiece($c[$i][2], '.\/');
|
|
|
898 |
if (substr($d,-1) != "/")
|
|
|
899 |
{
|
|
|
900 |
$d .= "/";
|
|
|
901 |
}
|
|
|
902 |
else
|
|
|
903 |
{
|
|
|
904 |
$d = 'default/';
|
|
|
905 |
}
|
|
|
906 |
}
|
|
|
907 |
if (strtoupper(trim($a)) == 'HTML' && (trim($b) == 'default'))
|
|
|
908 |
{
|
|
|
909 |
phpDocumentor_out("WARNING: HTMLdefaultConverter is deprecated, using HTMLframesConverter.\n");
|
|
|
910 |
phpDocumentor_out("WARNING: template output is identical, HTMLframes is more flexible.\n");
|
|
|
911 |
phpDocumentor_out("WARNING: please adjust your usage\n");
|
|
|
912 |
flush();
|
|
|
913 |
$b = 'frames'; // change default to frames.
|
|
|
914 |
}
|
|
|
915 |
$this->render->addConverter(strtoupper(trim($a)),trim($b),trim($d));
|
|
|
916 |
}
|
|
|
917 |
} else
|
|
|
918 |
{
|
|
|
919 |
$this->render->addConverter('HTML','frames','default/');
|
|
|
920 |
}
|
|
|
921 |
if (empty($this->render->converters)) addErrorDie(PDERROR_NO_CONVERTERS);
|
|
|
922 |
}
|
|
|
923 |
}
|
|
|
924 |
|
|
|
925 |
/**
|
|
|
926 |
* Fuzzy logic to interpret the boolean args' intent
|
|
|
927 |
* @param string the command-line option to analyze
|
|
|
928 |
* @return boolean our best guess of the value's boolean intent
|
|
|
929 |
*/
|
|
|
930 |
function decideOnOrOff($value_to_guess = 'NO VALUE WAS PASSED')
|
|
|
931 |
{
|
|
|
932 |
$these_probably_mean_yes = array(
|
|
|
933 |
'', // "--hidden" with no value
|
|
|
934 |
'on', // "--hidden on"
|
|
|
935 |
'y', 'yes', // "--hidden y"
|
|
|
936 |
'true', // "--hidden true"
|
|
|
937 |
'1' // "--hidden 1"
|
|
|
938 |
);
|
|
|
939 |
$best_guess = false; // default to "false", "off", "no", "take a hike"
|
|
|
940 |
|
|
|
941 |
if (in_array(strtolower(trim($value_to_guess)), $these_probably_mean_yes))
|
|
|
942 |
{
|
|
|
943 |
$best_guess = true;
|
|
|
944 |
}
|
|
|
945 |
return $best_guess;
|
|
|
946 |
}
|
|
|
947 |
|
|
|
948 |
/**
|
|
|
949 |
* Print parse information if quiet setting is off
|
|
|
950 |
*/
|
|
|
951 |
function phpDocumentor_out($string)
|
|
|
952 |
{
|
|
|
953 |
global $_phpDocumentor_setting;
|
|
|
954 |
if ((isset($_phpDocumentor_setting['quiet'])) ? !decideOnOrOff($_phpDocumentor_setting['quiet']) : true)
|
|
|
955 |
{
|
|
|
956 |
print $string;
|
|
|
957 |
}
|
|
|
958 |
|
|
|
959 |
}
|
|
|
960 |
|
|
|
961 |
/**
|
|
|
962 |
* Crash in case of known, dangerous bug condition
|
|
|
963 |
*
|
|
|
964 |
* Checks the PHP version that is executing PhpDocumentor,
|
|
|
965 |
* in case a known PHP/PEAR bug condition could be triggered
|
|
|
966 |
* by the PhpDocumentor execution.
|
|
|
967 |
* @param string $php_version the PHP version that contains the bug
|
|
|
968 |
* @param string $php_bug_number the PHP bug number (if any)
|
|
|
969 |
* @param string $pear_bug_number the PEAR bug number (if any)
|
|
|
970 |
*/
|
|
|
971 |
function checkForBugCondition($php_version, $php_bug_number = 'none', $pear_bug_number = 'none')
|
|
|
972 |
{
|
|
|
973 |
if (version_compare(phpversion(), $php_version) == 0)
|
|
|
974 |
{
|
|
|
975 |
addErrorDie(PDERROR_DANGEROUS_PHP_BUG_EXISTS, $php_version, $php_bug_number, $pear_bug_number);
|
|
|
976 |
}
|
|
|
977 |
}
|
|
|
978 |
?>
|