3 * This was all in {@link phpdoc.inc}, and now encapsulates the complexity
\r
5 * phpDocumentor :: automatic documentation generator
\r
7 * PHP versions 4 and 5
\r
9 * Copyright (c) 2002-2006 Gregory Beaver
\r
13 * This library is free software; you can redistribute it
\r
14 * and/or modify it under the terms of the GNU Lesser General
\r
15 * Public License as published by the Free Software Foundation;
\r
16 * either version 2.1 of the License, or (at your option) any
\r
19 * This library is distributed in the hope that it will be useful,
\r
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
22 * Lesser General Public License for more details.
\r
24 * You should have received a copy of the GNU Lesser General Public
\r
25 * License along with this library; if not, write to the Free Software
\r
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
\r
28 * @package phpDocumentor
\r
29 * @author Gregory Beaver <cellog@php.net>
\r
30 * @copyright 2002-2006 Gregory Beaver
\r
31 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
\r
32 * @version CVS: $Id: Setup.inc.php,v 1.27 2007/12/09 23:40:07 ashnazg Exp $
\r
33 * @link http://www.phpdoc.org
\r
34 * @link http://pear.php.net/PhpDocumentor
\r
37 error_reporting(E_ALL);
\r
39 /** ensure top-level PhpDocumentor dir is in include path */
\r
40 set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(__FILE__)));
\r
42 /** common settings */
\r
43 include_once("phpDocumentor/common.inc.php");
\r
45 include_once("phpDocumentor/Io.inc");
\r
46 include_once("phpDocumentor/Publisher.inc");
\r
47 include_once("phpDocumentor/Classes.inc");
\r
48 include_once("phpDocumentor/ProceduralPages.inc");
\r
49 include_once("phpDocumentor/IntermediateParser.inc");
\r
50 include_once("phpDocumentor/WordParser.inc");
\r
51 include_once("phpDocumentor/EventStack.inc");
\r
52 include_once("phpDocumentor/ParserData.inc");
\r
53 include_once("phpDocumentor/InlineTags.inc");
\r
54 include_once("phpDocumentor/DocBlockTags.inc");
\r
55 include_once("phpDocumentor/DescHTML.inc");
\r
56 include_once("phpDocumentor/ParserDocBlock.inc");
\r
57 include_once("phpDocumentor/ParserElements.inc");
\r
58 include_once("phpDocumentor/Parser.inc");
\r
59 include_once("phpDocumentor/phpDocumentorTWordParser.inc");
\r
60 include_once("phpDocumentor/phpDocumentorTParser.inc");
\r
61 include_once("phpDocumentor/HighlightParser.inc");
\r
62 include_once("phpDocumentor/TutorialHighlightParser.inc");
\r
63 include_once("phpDocumentor/ParserDescCleanup.inc");
\r
64 include_once("phpDocumentor/PackagePageElements.inc");
\r
65 include_once("phpDocumentor/XMLpackagePageParser.inc");
\r
66 include_once("phpDocumentor/LinkClasses.inc");
\r
67 include_once("phpDocumentor/Converter.inc");
\r
68 include_once("phpDocumentor/Errors.inc");
\r
72 * $interface is either 'web' or is not set at all
\r
73 * @global array $interface
\r
75 if (isset($_GET['interface'])) $interface = $_GET['interface'];
\r
77 * $_phpDocumentor_setting is either the value from the web interface, or is set up by {@link Io::parseArgv()}
\r
78 * @global array $_phpDocumentor_setting
\r
80 if (isset($_GET['setting'])) $_phpDocumentor_setting = $_GET['setting'];
\r
84 * default package name, set using -dn --defaultpackagename
\r
85 * @global string $GLOBALS['phpDocumentor_DefaultPackageName']
\r
86 * @name $phpDocumentor_DefaultPackageName
\r
88 $GLOBALS['phpDocumentor_DefaultPackageName'] = 'default';
\r
91 * default package name, set using -dn --defaultcategoryname
\r
92 * @global string $GLOBALS['phpDocumentor_DefaultCategoryName']
\r
93 * @name $phpDocumentor_DefaultCategoryName
\r
95 $GLOBALS['phpDocumentor_DefaultCategoryName'] = 'default';
\r
98 * @package phpDocumentor
\r
100 class phpDocumentor_setup
\r
104 * @var Parser|phpDocumentorTParser
\r
108 * Used to parse command-line options
\r
113 * Used to organize output from the Parser before Conversion
\r
114 * @var phpDocumentor_IntermediateParser
\r
116 var $render = false;
\r
118 * Packages to create documentation for
\r
121 var $packages = false;
\r
123 * contents of --filename commandline
\r
124 * @tutorial phpDocumentor.howto.pkg#using.command-line.filename
\r
129 * contents of --directory commandline
\r
130 * @tutorial phpDocumentor.howto.pkg#using.command-line.directory
\r
135 * contents of --hidden commandline
\r
136 * @tutorial phpDocumentor.howto.pkg#using.command-line.hidden
\r
139 var $hidden = false;
\r
141 * time that parsing was started, used for informative timing of output
\r
144 var $parse_start_time;
\r
146 * contents of --ignore commandline
\r
147 * @tutorial phpDocumentor.howto.pkg#using.command-line.ignore
\r
150 var $ignore_files = array();
\r
152 * contents of --ignoresymlinks commandline
\r
155 var $ignoresymlinks = false;
\r
158 * Checks PHP version, makes sure it is 4.2.0+, and chooses the
\r
159 * phpDocumentorTParser if version is 4.3.0+
\r
162 function phpDocumentor_setup()
\r
164 global $_phpDocumentor_cvsphpfile_exts, $_phpDocumentor_setting;
\r
165 if (!function_exists('is_a'))
\r
167 print "phpDocumentor requires PHP version 4.2.0 or greater to function";
\r
171 $this->setup = new Io;
\r
172 if (!isset($interface) && !isset($_GET['interface']) && !isset($_phpDocumentor_setting))
\r
174 // Parse the argv settings
\r
175 $_phpDocumentor_setting = $this->setup->parseArgv();
\r
177 if (isset($_phpDocumentor_setting['useconfig']) &&
\r
178 !empty($_phpDocumentor_setting['useconfig'])) {
\r
179 $this->readConfigFile($_phpDocumentor_setting['useconfig']);
\r
182 // set runtime to a large value since this can take quite a while
\r
183 // we can only set_time_limit when not in safe_mode bug #912064
\r
184 if (!ini_get('safe_mode'))
\r
186 set_time_limit(0); // unlimited runtime
\r
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");
\r
192 $phpver = phpversion();
\r
193 $phpdocver = PHPDOCUMENTOR_VER;
\r
194 if (isset($_GET['interface'])) {
\r
195 $phpver = "<b>$phpver</b>";
\r
196 $phpdocver = "<b>$phpdocver</b>";
\r
198 phpDocumentor_out("PHP Version $phpver\n");
\r
199 phpDocumentor_out("phpDocumentor version $phpdocver\n\n");
\r
202 $this->setMemoryLimit();
\r
206 phpDocumentor_out("using tokenizer Parser\n");
\r
207 $this->parse = new phpDocumentorTParser;
\r
210 phpDocumentor_out("No Tokenizer support detected, so using default (slower) Parser..." . PHP_EOL);
\r
212 if (version_compare(phpversion(), '4.3.0', '<')) {
\r
213 phpDocumentor_out(" for faster parsing, recompile PHP with --enable-tokenizer." . PHP_EOL );
\r
215 phpDocumentor_out(" for faster parsing, recompile PHP without --disable-tokenizer." . PHP_EOL );
\r
218 $this->parse = new Parser;
\r
223 * Get phpDocumentor settings from a user configuration file
\r
224 * @param string user configuration file
\r
226 function readConfigFile($file)
\r
228 global $_phpDocumentor_setting, $_phpDocumentor_options;
\r
230 $file = str_replace(array('..','.ini','\\'),array('','','/'),$file);
\r
231 if (is_file($file . '.ini'))
\r
233 $_phpDocumentor_setting = phpDocumentor_parse_ini_file($file.'.ini');
\r
236 if ('@DATA-DIR@' != '@'.'DATA-DIR@')
\r
238 $configdir = str_replace('\\','/', '@DATA-DIR@/PhpDocumentor') . PATH_DELIMITER . 'user' . PATH_DELIMITER;
\r
240 $configdir = str_replace('\\','/',$GLOBALS['_phpDocumentor_install_dir']) . PATH_DELIMITER . 'user' . PATH_DELIMITER;
\r
242 if (isset($_phpDocumentor_options['userdir'])) $configdir = $_phpDocumentor_options['userdir'];
\r
243 if (substr($configdir,-1) != '/')
\r
247 $_phpDocumentor_setting = phpDocumentor_parse_ini_file( $configdir . $file . '.ini');
\r
248 if (empty($_phpDocumentor_setting['defaultpackagename']))
\r
250 $_phpDocumentor_setting['defaultpackagename'] = 'default';
\r
253 // don't want a loop condition!
\r
254 unset($_phpDocumentor_setting['useconfig']);
\r
258 * Get phpDocumentor settings from command-line or web interface
\r
260 function readCommandLineSettings()
\r
262 global $_phpDocumentor_setting,$interface,$_phpDocumentor_RIC_files;
\r
263 // subscribe $render class to $parse class events
\r
264 if (!isset($_phpDocumentor_setting['junk'])) $_phpDocumentor_setting['junk'] = '';
\r
265 if (!isset($_phpDocumentor_setting['title'])) $_phpDocumentor_setting['title'] = 'Generated Documentation';
\r
266 $temp_title = $_phpDocumentor_setting['title'];
\r
267 $this->render = new phpDocumentor_IntermediateParser($temp_title);
\r
268 if (isset($_phpDocumentor_setting['help']) || $_phpDocumentor_setting['junk'] == "-h" || $_phpDocumentor_setting['junk'] == "--help")
\r
270 echo $this->setup->displayHelpMsg();
\r
274 // set to parse hidden files
\r
275 $this->hidden = (isset($_phpDocumentor_setting['hidden'])) ? decideOnOrOff($_phpDocumentor_setting['hidden']) : false;
\r
277 // set to parse through symlinks
\r
278 $this->ignoresymlinks = (isset($_phpDocumentor_setting['ignoresymlinks'])) ? decideOnOrOff($_phpDocumentor_setting['ignoresymlinks']) : false;
\r
280 // set to parse elements marked private with @access private
\r
281 $this->render->setParsePrivate((isset($_phpDocumentor_setting['parseprivate'])) ? decideOnOrOff($_phpDocumentor_setting['parseprivate']) : false);
\r
283 // set to print warnings when undocumented elements are spotted
\r
284 $this->render->setUndocumentedElementWarningsMode((isset($_phpDocumentor_setting['undocumentedelements'])) ? decideOnOrOff($_phpDocumentor_setting['undocumentedelements']) : false);
\r
286 if (isset($_phpDocumentor_setting['ignoretags']))
\r
288 $ignoretags = explode(',', $_phpDocumentor_setting['ignoretags']);
\r
289 $ignoretags = array_map('trim', $ignoretags);
\r
291 foreach($ignoretags as $tag)
\r
293 if (!in_array($tag,array('@global', '@access', '@package', '@ignore', '@name', '@param', '@return', '@staticvar', '@var')))
\r
296 $_phpDocumentor_setting['ignoretags'] = $tags;
\r
299 if (isset($_phpDocumentor_setting['readmeinstallchangelog']))
\r
301 $_phpDocumentor_setting['readmeinstallchangelog'] = explode(',',str_replace(' ','',$_phpDocumentor_setting['readmeinstallchangelog']));
\r
303 foreach($_phpDocumentor_setting['readmeinstallchangelog'] as $ric)
\r
305 $rics[] = strtoupper(trim($ric));
\r
307 $_phpDocumentor_RIC_files = $rics;
\r
310 if (isset($_phpDocumentor_setting['javadocdesc']) && $_phpDocumentor_setting['javadocdesc'] == 'on')
\r
312 $this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock';
\r
316 if (isset($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
\r
318 $_phpDocumentor_setting['sourcecode'] = true;
\r
321 $_phpDocumentor_setting['sourcecode'] = false;
\r
325 if (isset($_phpDocumentor_setting['sourcecode']) && $_phpDocumentor_setting['sourcecode'] == 'on')
\r
327 addWarning(PDERROR_SOURCECODE_IGNORED);
\r
329 $_phpDocumentor_setting['sourcecode'] = false;
\r
331 if (isset($_phpDocumentor_setting['converterparams']))
\r
333 $_phpDocumentor_setting['converterparams'] = explode($_phpDocumentor_setting['converterparams']);
\r
334 foreach($_phpDocumentor_setting['converterparams'] as $i => $p)
\r
336 $_phpDocumentor_setting['converterparams'][$i] = trim($p);
\r
339 if (isset($_phpDocumentor_setting['customtags']) && !empty($_phpDocumentor_setting['customtags']))
\r
341 $c = explode(',',$_phpDocumentor_setting['customtags']);
\r
342 for($i=0;$i<count($c); $i++)
\r
344 $GLOBALS['_phpDocumentor_tags_allowed'][] = trim($c[$i]);
\r
347 if (isset($_phpDocumentor_setting['pear']))
\r
349 if ($_phpDocumentor_setting['pear'] === 'off') $_phpDocumentor_setting['pear'] = false;
\r
350 if ($_phpDocumentor_setting['pear'] === 'on') $_phpDocumentor_setting['pear'] = true;
\r
352 if (!isset($_phpDocumentor_setting['pear'])) $_phpDocumentor_setting['pear'] = false;
\r
353 // set to change the default package name from "default" to whatever you want
\r
354 if (isset($_phpDocumentor_setting['defaultpackagename']))
\r
356 $GLOBALS['phpDocumentor_DefaultPackageName'] = trim($_phpDocumentor_setting['defaultpackagename']);
\r
358 // set to change the default category name from "default" to whatever you want
\r
359 if (isset($_phpDocumentor_setting['defaultcategoryname']))
\r
361 $GLOBALS['phpDocumentor_DefaultCategoryName'] = trim($_phpDocumentor_setting['defaultcategoryname']);
\r
364 // set the mode (quiet or verbose)
\r
365 $this->render->setQuietMode((isset($_phpDocumentor_setting['quiet'])) ? decideOnOrOff($_phpDocumentor_setting['quiet']) : false);
\r
367 // Setup the different classes
\r
368 if (isset($_phpDocumentor_setting['templatebase']))
\r
370 $this->render->setTemplateBase(trim($_phpDocumentor_setting['templatebase']));
\r
372 if (isset($_phpDocumentor_setting['target']) && !empty($_phpDocumentor_setting['target']))
\r
374 $this->render->setTargetDir(trim($_phpDocumentor_setting['target']));
\r
378 echo "a target directory must be specified\n try phpdoc -h\n";
\r
381 if (!empty($_phpDocumentor_setting['packageoutput']))
\r
383 $this->packages = explode(",",trim($_phpDocumentor_setting['packageoutput']));
\r
384 foreach($this->packages as $p => $v)
\r
386 $this->packages[$p] = trim($v);
\r
389 if (!empty($_phpDocumentor_setting['filename'])) {
\r
390 $this->files = trim($_phpDocumentor_setting['filename']);
\r
392 if (!empty($_phpDocumentor_setting['directory'])) {
\r
393 $this->dirs = trim($_phpDocumentor_setting['directory']);
\r
397 function checkIgnoreTag($tagname, $inline = false)
\r
399 global $_phpDocumentor_setting;
\r
400 $tagname = '@'.$tagname;
\r
401 if (!isset($_phpDocumentor_setting['ignoretags'])) return false;
\r
402 if ($inline) $tagname = '{'.$tagname.'}';
\r
403 return in_array($tagname, $_phpDocumentor_setting['ignoretags']);
\r
407 * Allow a memory_limit setting in phpDocumentor.ini to override php.ini or default memory limit
\r
408 * @todo recognize "K" and "G" in memory_limit settings, rather than just "M"
\r
410 function setMemoryLimit() {
\r
411 global $_phpDocumentor_options;
\r
412 $DEFAULT_MEMORY_SIZE_MINIMUM = 256;
\r
414 // PhpDoc memory_limit from phpDocumentor.ini overrides all other considerations
\r
415 if (isset($_phpDocumentor_options['memory_limit'])) {
\r
416 $phpdoc_ini_setting = str_replace('M', '', $_phpDocumentor_options['memory_limit']);
\r
418 // allow phpdoc.ini to DISABLE the setting via "= -1"
\r
419 if ($phpdoc_ini_setting == -1)
\r
421 $memory_setting_to_use = $phpdoc_ini_setting;
\r
422 $max_mem_log_message = "setting disabled by phpDocumentor.ini...\n";
\r
426 $memory_setting_to_use = $phpdoc_ini_setting . "M";
\r
427 $max_mem_log_message = "set at " . $memory_setting_to_use . " by phpDocumentor.ini...\n";
\r
430 $php_ini_setting = str_replace('M', '', ini_get('memory_limit'));
\r
432 // allow php.ini to DISABLE the setting via "= -1"
\r
433 if ($php_ini_setting == -1)
\r
435 // allow it to remain disabled
\r
436 $memory_setting_to_use = $php_ini_setting;
\r
437 $max_mem_log_message = "setting disabled by php.ini...\n";
\r
441 // memory_limit from php.ini must be at least the default minimum
\r
442 $memory_setting_to_use = ($php_ini_setting > $DEFAULT_MEMORY_SIZE_MINIMUM) ? $php_ini_setting . "M" : $DEFAULT_MEMORY_SIZE_MINIMUM . "M";
\r
443 $max_mem_log_message = "set at " . $memory_setting_to_use . " after considering php.ini...\n";
\r
446 if (ini_set("memory_limit", $memory_setting_to_use))
\r
448 // PHP had to have been compiled with "--enable-memory-limit" to allow setting the value explicitly
\r
449 phpDocumentor_out("Maximum memory usage " . $max_mem_log_message);
\r
453 // PHP must not have been compiled with "--enable-memory-limit", so we cannot modify it...
\r
454 // no need to notify user of this unless they tried using memory_limit in their phpDocumentor.ini...
\r
455 if (isset($phpdoc_ini_setting))
\r
457 phpDocumentor_out("Unable to alter memory_limit via your phpDocumentor.ini... perhaps PHP wasn't compiled with \"--enable-memory-limit\"?\n");
\r
462 function setJavadocDesc()
\r
464 $this->parse->eventHandlers[PARSER_EVENT_DOCBLOCK] = 'JavaDochandleDocblock';
\r
467 function setParsePrivate($flag = true)
\r
469 $this->render->setParsePrivate($flag);
\r
472 function setQuietMode($flag = true)
\r
474 $this->render->setQuietMode($flag);
\r
477 function setUndocumentedElementWarnings($flag = true)
\r
479 $this->render->setUndocumentedElementWarnings($flag);
\r
482 function setTargetDir($target)
\r
484 $this->render->setTargetDir($target);
\r
487 function setTemplateBase($dir)
\r
489 $this->render->setTemplateBase($dir);
\r
492 function setPackageOutput($po)
\r
494 $this->packages = explode(",",$po);
\r
495 array_map('trim', $this->packages);
\r
498 function setTitle($ti)
\r
500 $this->render = new phpDocumentor_IntermediateParser($ti);
\r
503 function setFilesToParse($files)
\r
505 $this->files = $files;
\r
508 function setDirectoriesToParse($dirs)
\r
510 $this->dirs = $dirs;
\r
513 function parseHiddenFiles($flag = true)
\r
515 $this->hidden = $flag;
\r
518 function setIgnore($ig)
\r
520 if (strstr($ig,","))
\r
522 $this->ignore_files = explode(",",$ig);
\r
525 $this->ignore_files = array($ig);
\r
527 $this->ignore_files = array_map('trim', $this->ignore_files);
\r
530 function createDocs($title = false)
\r
532 $this->parse_start_time = time();
\r
533 global $_phpDocumentor_setting;
\r
534 if (!$this->render)
\r
536 $this->render = new phpDocumentor_IntermediateParser($title);
\r
538 // setup ignore list
\r
539 $this->ignore_files =array();
\r
540 if(isset($_phpDocumentor_setting['ignore']))
\r
542 $this->setIgnore($_phpDocumentor_setting['ignore']);
\r
544 $this->parse->subscribe("*",$this->render);
\r
545 // parse the directory
\r
546 if (!empty($this->files))
\r
548 $files = explode(",",$this->files);
\r
549 foreach($files as $file)
\r
551 $file = trim($file);
\r
552 $test = $this->setup->getAllFiles($file);
\r
555 foreach($test as $file)
\r
557 $file = trim($file);
\r
558 $dir = realpath(dirname($file));
\r
559 $dir = strtr($dir, "\\", "/");
\r
560 $dir = str_replace('//','/',$dir);
\r
561 // strip trailing directory seperator
\r
562 if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
\r
564 $dir = substr($dir,0,-1);
\r
566 $file = strtr(realpath($file), "\\", "/");
\r
567 $file = str_replace('//','/',$file);
\r
569 if (!$this->setup->checkIgnore(basename($file),dirname($file),$this->ignore_files,true,$this->ignoresymlinks))
\r
571 $filelist[] = str_replace('\\','/',$file);
\r
573 phpDocumentor_out("File $file Ignored\n");
\r
579 $dir = dirname(realpath($file));
\r
580 $dir = strtr($dir, "\\", "/");
\r
581 $dir = str_replace('//','/',$dir);
\r
582 // strip trailing directory seperator
\r
583 if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
\r
585 $dir = substr($dir,0,-1);
\r
587 $base = count(explode("/",$dir));
\r
588 $file = strtr(realpath($file), "\\", "/");
\r
589 $file = str_replace('//','/',$file);
\r
592 if (!$this->setup->checkIgnore(basename($file),dirname($file),$this->ignore_files,true,$this->ignoresymlinks))
\r
594 $filelist[] = str_replace('\\','/',$file);
\r
596 phpDocumentor_out("File $file Ignored\n");
\r
602 if (!empty($this->dirs))
\r
604 $dirs = explode(",",$this->dirs);
\r
605 foreach($dirs as $dir)
\r
608 $dir = realpath($dir);
\r
610 phpDocumentor_out('ERROR: "' . $olddir . '" does not exist, skipping');
\r
614 $dir = strtr($dir, "\\", "/");
\r
615 $dir = str_replace('//','/',$dir);
\r
616 // strip trailing directory seperator
\r
617 if (substr($dir,-1) == "/" || substr($dir,-1) == "\\")
\r
619 $dir = substr($dir,0,-1);
\r
621 $files = $this->setup->dirList($dir,$this->hidden,$this->ignoresymlinks);
\r
622 if (is_array($files))
\r
624 foreach($files as $file)
\r
626 $file = strtr($file, '\\', '/');
\r
627 // file's subpath, relative to $dir
\r
628 $file_subpath = str_replace('\\', '/', realpath(dirname($file)));
\r
629 $file_subpath = preg_replace('~^' . preg_quote($dir, '~') . '~', '', $file_subpath);
\r
631 if (!$this->setup->checkIgnore(basename($file), $file_subpath, $this->ignore_files,true,$this->ignoresymlinks))
\r
633 $filelist[] = $file;
\r
635 phpDocumentor_out("File $file Ignored\n");
\r
642 if (isset($filelist))
\r
644 if (PHPDOCUMENTOR_WINDOWS)
\r
646 // case insensitive array_unique
\r
647 usort($filelist,'strnatcasecmp');
\r
650 $newarray = array();
\r
653 $element = current($filelist);
\r
654 for ($n=0;$n<sizeof($filelist);$n++)
\r
656 if (strtolower(next($filelist)) != strtolower($element))
\r
658 $newarray[$i] = $element;
\r
659 $element = current($filelist);
\r
663 $filelist = $newarray;
\r
664 } else $filelist = array_unique($filelist);
\r
666 $base = count(explode("/",$source_base = $this->setup->getBase($filelist)));
\r
667 define("PHPDOCUMENTOR_BASE",$source_base);
\r
668 list($filelist,$ric) = $this->setup->getReadmeInstallChangelog($source_base, $filelist);
\r
669 phpDocumentor_out("\n\nGrabbing README/INSTALL/CHANGELOG\n");
\r
671 foreach($ric as $file)
\r
673 phpDocumentor_out(basename($file).'...');
\r
675 $fp = fopen($file,'r');
\r
676 $contents = fread($fp,filesize($file));
\r
677 $this->render->HandleEvent(PHPDOCUMENTOR_EVENT_README_INSTALL_CHANGELOG, array(basename($file),$contents));
\r
680 phpDocumentor_out("\ndone\n");
\r
682 list($filelist,$tutorials) = $this->setup->getTutorials($filelist);
\r
683 phpDocumentor_out("\n\nTutorial/Extended Documentation Parsing Stage\n\n");
\r
685 if (count($tutorials))
\r
687 $tuteparser = new XMLPackagePageParser;
\r
688 $tuteparser->subscribe('*',$this->render);
\r
689 foreach($tutorials as $tutorial)
\r
691 switch($tutorial['tutetype'])
\r
696 switch($tutorial['tutetype'])
\r
699 $ptext = 'Package-level Docs ';
\r
700 if (!empty($tutorial['subpackage']))
\r
701 $ptext = 'Sub-Package Docs ';
\r
704 $ptext = 'Class-level Docs ';
\r
707 $ptext = 'Procedural-level Docs ';
\r
710 $fp = @fopen($tutorial['path'],"r");
\r
713 $ret = fread($fp,filesize($tutorial['path']));
\r
715 if (stristr($ret, "utf-8") !== "")
\r
717 $ret = utf8_decode($ret);
\r
721 phpDocumentor_out('Parsing '.$ptext.$tutorial['path'].'...');
\r
723 $tuteparser->parse($ret,$tutorial);
\r
724 phpDocumentor_out("done\n");
\r
728 phpDocumentor_out('Error '.$ptext.$tutorial['path'].' doesn\'t exist'."\n");
\r
736 phpDocumentor_out("done\n");
\r
738 phpDocumentor_out("\n\nGeneral Parsing Stage\n\n");
\r
740 foreach($filelist as $file)
\r
742 phpDocumentor_out("Reading file $file");
\r
744 $this->parse->parse($a = $this->setup->readPhpFile($file, $this->render->quietMode),$file,$base,$this->packages);
\r
747 $b = (time() - $this->parse_start_time);
\r
748 phpDocumentor_out("done\n");
\r
751 phpDocumentor_out("\nConverting From Abstract Parsed Data\n");
\r
753 $this->render->output();
\r
754 $a = (time() - $this->parse_start_time);
\r
756 phpDocumentor_out("\nParsing time: $b seconds\n");
\r
757 phpDocumentor_out("\nConversion time: $c seconds\n");
\r
758 phpDocumentor_out("\nTotal Documentation Time: $a seconds\n");
\r
759 phpDocumentor_out("done\n");
\r
763 print "\nERROR: nothing parsed\n";
\r
768 * Parse configuration file phpDocumentor.ini
\r
770 function parseIni()
\r
772 phpDocumentor_out("Parsing configuration file phpDocumentor.ini...\n");
\r
774 if ('@DATA-DIR@' != '@'.'DATA-DIR@')
\r
776 $options = phpDocumentor_parse_ini_file(str_replace('\\','/', '@DATA-DIR@/PhpDocumentor') . PATH_DELIMITER . 'phpDocumentor.ini',true);
\r
777 phpDocumentor_out(" (found in " . '@DATA-DIR@/PhpDocumentor' . PATH_DELIMITER . ")...\n");
\r
779 $options = phpDocumentor_parse_ini_file(str_replace('\\','/',$GLOBALS['_phpDocumentor_install_dir']) . PATH_DELIMITER . 'phpDocumentor.ini',true);
\r
780 phpDocumentor_out(" (found in " . $GLOBALS['_phpDocumentor_install_dir'] . PATH_DELIMITER . ")...\n");
\r
785 print "ERROR: cannot open phpDocumentor.ini in directory " . $GLOBALS['_phpDocumentor_install_dir']."\n";
\r
786 print "-Is phpdoc in either the path or include_path in your php.ini file?";
\r
790 foreach($options as $var => $values)
\r
792 if ($var != 'DEBUG')
\r
794 // phpDocumentor_out("\n$var");
\r
795 if ($var != '_phpDocumentor_setting' && $var != '_phpDocumentor_options' && $var != '_phpDocumentor_install_dir' ) $values = array_values($values);
\r
796 // fancy_debug("\n$var",$values);
\r
797 $GLOBALS[$var] = $values;
\r
800 phpDocumentor_out("\ndone\n");
\r
802 /** Debug Constant */
\r
803 if (!defined('PHPDOCUMENTOR_DEBUG')) define("PHPDOCUMENTOR_DEBUG",$options['DEBUG']['PHPDOCUMENTOR_DEBUG']);
\r
804 if (!defined('PHPDOCUMENTOR_KILL_WHITESPACE')) define("PHPDOCUMENTOR_KILL_WHITESPACE",$options['DEBUG']['PHPDOCUMENTOR_KILL_WHITESPACE']);
\r
805 $GLOBALS['_phpDocumentor_cvsphpfile_exts'] = $GLOBALS['_phpDocumentor_phpfile_exts'];
\r
806 foreach($GLOBALS['_phpDocumentor_cvsphpfile_exts'] as $key => $val)
\r
808 $GLOBALS['_phpDocumentor_cvsphpfile_exts'][$key] = "$val,v";
\r
810 // none of this stuff is used anymore
\r
811 if (isset($GLOBALS['_phpDocumentor_html_allowed']))
\r
813 $___htmltemp = array_flip($GLOBALS['_phpDocumentor_html_allowed']);
\r
814 $___html1 = array();
\r
815 foreach($___htmltemp as $tag => $trans)
\r
817 $___html1['<'.$tag.'>'] = htmlentities('<'.$tag.'>');
\r
818 $___html1['</'.$tag.'>'] = htmlentities('</'.$tag.'>');
\r
820 $GLOBALS['phpDocumentor___html'] = array_flip($___html1);
\r
825 * Performs character-based validation of Output Converter Template name pieces
\r
826 * @param string the name piece (just ONE of either Output, Converter, or Template piece)
\r
827 * @param string any extra characters to allow beyond the default character set
\r
828 * @return string|bool the clean name, or FALSE if piece is deemed invalid
\r
831 function cleanConverterNamePiece($name, $extra_characters_to_allow = '')
\r
833 $name = str_replace("\\", "/", $name);
\r
834 // security: ensure no opportunity exists to use "../.." pathing in this value
\r
835 $name = preg_replace('/[^a-zA-Z0-9' . $extra_characters_to_allow . '_-]/', "", $name);
\r
837 // absolutely positively do NOT allow two consecutive dots ".."
\r
838 if (strpos($name, '..') > -1) $name = false;
\r
843 * Figures out what output converter to use
\r
844 * @param string Output Converter Template name
\r
847 * @uses cleanConverterNamePieces
\r
848 * @uses phpDocumentor_out
\r
850 function setupConverters($output = false)
\r
852 global $_phpDocumentor_setting;
\r
855 $_phpDocumentor_setting['output'] = $output;
\r
857 if (isset($_phpDocumentor_setting['output']) && !empty($_phpDocumentor_setting['output']))
\r
859 $c = explode(',',$_phpDocumentor_setting['output']);
\r
860 for($i=0; $i< count($c); $i++)
\r
862 $c[$i] = explode(':',$c[$i]);
\r
864 if (isset($c[$i][0]))
\r
866 $a = $this->cleanConverterNamePiece($c[$i][0]);
\r
872 if (isset($c[$i][1]))
\r
875 * must allow "/" due to options like "DocBook/peardoc2"
\r
877 $b = $this->cleanConverterNamePiece($c[$i][1], '\/');
\r
883 if (isset($c[$i][2]))
\r
886 * must allow "." due to options like "phpdoc.de"
\r
887 * must allow "/" due to options like "DOM/default"
\r
889 $d = $this->cleanConverterNamePiece($c[$i][2], '.\/');
\r
890 if (substr($d,-1) != "/")
\r
899 if (strtoupper(trim($a)) == 'HTML' && (trim($b) == 'default'))
\r
901 phpDocumentor_out("WARNING: HTMLdefaultConverter is deprecated, using HTMLframesConverter.\n");
\r
902 phpDocumentor_out("WARNING: template output is identical, HTMLframes is more flexible.\n");
\r
903 phpDocumentor_out("WARNING: please adjust your usage\n");
\r
905 $b = 'frames'; // change default to frames.
\r
907 $this->render->addConverter(strtoupper(trim($a)),trim($b),trim($d));
\r
911 $this->render->addConverter('HTML','frames','default/');
\r
913 if (empty($this->render->converters)) addErrorDie(PDERROR_NO_CONVERTERS);
\r
918 * Fuzzy logic to interpret the boolean args' intent
\r
919 * @param string the command-line option to analyze
\r
920 * @return boolean our best guess of the value's boolean intent
\r
922 function decideOnOrOff($value_to_guess = 'NO VALUE WAS PASSED')
\r
924 $these_probably_mean_yes = array(
\r
925 '', // "--hidden" with no value
\r
926 'on', // "--hidden on"
\r
927 'y', 'yes', // "--hidden y"
\r
928 'true', // "--hidden true"
\r
929 '1' // "--hidden 1"
\r
931 $best_guess = false; // default to "false", "off", "no", "take a hike"
\r
933 if (in_array(strtolower(trim($value_to_guess)), $these_probably_mean_yes))
\r
935 $best_guess = true;
\r
937 return $best_guess;
\r
941 * Print parse information if quiet setting is off
\r
943 function phpDocumentor_out($string)
\r
945 global $_phpDocumentor_setting;
\r
946 if ((isset($_phpDocumentor_setting['quiet'])) ? !decideOnOrOff($_phpDocumentor_setting['quiet']) : true)
\r
954 * Crash in case of known, dangerous bug condition
\r
956 * Checks the PHP version that is executing PhpDocumentor,
\r
957 * in case a known PHP/PEAR bug condition could be triggered
\r
958 * by the PhpDocumentor execution.
\r
959 * @param string $php_version the PHP version that contains the bug
\r
960 * @param string $php_bug_number the PHP bug number (if any)
\r
961 * @param string $pear_bug_number the PEAR bug number (if any)
\r
963 function checkForBugCondition($php_version, $php_bug_number = 'none', $pear_bug_number = 'none')
\r
965 if (version_compare(phpversion(), $php_version) == 0)
\r
967 addErrorDie(PDERROR_DANGEROUS_PHP_BUG_EXISTS, $php_version, $php_bug_number, $pear_bug_number);
\r