diff --git a/classes/phpDoctor.php b/classes/phpDoctor.php index 6af5ac3..9fc50fd 100644 --- a/classes/phpDoctor.php +++ b/classes/phpDoctor.php @@ -269,7 +269,7 @@ public function phpDoctor($config = 'default.ini') if (isset($this->_options['source_path'])) { $this->_sourcePath = array(); foreach (explode(',', $this->_options['source_path']) as $path) { - $this->_sourcePath[] = $this->fixPath($path, getcwd()); + $this->_sourcePath[] = $this->makeAbsolutePath($path, getcwd()); } } @@ -487,7 +487,7 @@ public function makeAbsolutePath($path, $prefix) public function fixPath($path) { if (substr($path, -1, 1) != '/' && substr($path, -1, 1) != '\\') { - return $path.'/'; + return $path.DIRECTORY_SEPARATOR; } else { return $path; } diff --git a/composer.json b/composer.json index 21568a9..ccf28f4 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ ], "require": { "php": ">=5.2.0", - "michelf/php-markdown": "1.3" + "michelf/php-markdown": "1.3", + "easybook/geshi" : "*" }, "require-dev": { "lastcraft/simpletest": "1.1.*" diff --git a/doclets/standard/htmlWriter.php b/doclets/standard/htmlWriter.php index 4234b7b..510ff11 100644 --- a/doclets/standard/htmlWriter.php +++ b/doclets/standard/htmlWriter.php @@ -168,7 +168,7 @@ public function _nav($path) $output .= '<div class="small_links">'."\n"; $output .= '<a href="'.str_repeat('../', $this->_depth).'index.html" target="_top">Frames</a>'."\n"; - $output .= '<a href="'.str_repeat('../', $this->_depth).$path.'" target="_top">No frames</a>'."\n"; + $output .= '<a href="'.str_repeat('../', $this->_depth).str_replace('\\', '/', $path).'" target="_top">No frames</a>'."\n"; $output .= "</div>\n"; $thisClass = strtolower(get_class($this)); if ($thisClass == 'classwriter') { diff --git a/doclets/standard/sourceWriter.php b/doclets/standard/sourceWriter.php index 1ff39de..bcf5423 100644 --- a/doclets/standard/sourceWriter.php +++ b/doclets/standard/sourceWriter.php @@ -84,13 +84,13 @@ public function sourceWriter(&$doclet) $this->_sections[7] = array('title' => 'Todo', 'url' => 'todo-list.html'); $this->_sections[8] = array('title' => 'Index', 'url' => 'index-all.html'); - $this->_depth = substr_count($filename, '/') + 1; + $this->_depth = substr_count(str_replace('\\', '/', $filename), '/') + 1; if (class_exists('GeSHi')) { $geshi = new GeSHi($data[0], 'php'); $source = $geshi->parse_code(); } else { - $source = '<pre>'.$data[0].'</pre>'; + $source = '<pre>'.htmlspecialchars($data[0]).'</pre>'; } ob_start(); diff --git a/doclets/standard/standard.php b/doclets/standard/standard.php index a487055..5a21b4d 100644 --- a/doclets/standard/standard.php +++ b/doclets/standard/standard.php @@ -142,7 +142,7 @@ public function standard(&$rootDoc, $formatter) if (isset($options['include_source'])) $this->_includeSource = $options['include_source']; if ($this->_includeSource) { - @include_once 'geshi/geshi.php'; + if (!class_exists('GeSHi')) @include_once 'geshi/geshi.php'; if (!class_exists('GeSHi')) { $phpdoctor->warning('Could not find GeSHi in "geshi/geshi.php", not pretty printing source'); } diff --git a/phpdoc.php b/phpdoc.php index f9f1803..2313722 100755 --- a/phpdoc.php +++ b/phpdoc.php @@ -24,7 +24,7 @@ // check we are running from the command line if (!isset($argv[0])) { die('This program must be run from the command line using the CLI version of PHP'); - + // check we are using the correct version of PHP } elseif (!defined('T_COMMENT') || !extension_loaded('tokenizer') || version_compare(phpversion(), '5', '<')) { error('You need PHP version 5 or greater with the "tokenizer" extension to run this script, please upgrade'); @@ -35,14 +35,20 @@ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__)); require('classes'.DIRECTORY_SEPARATOR.'phpDoctor.php'); +// include Composer autoloader +$autoloader = dirname(__FILE__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php'; +if (is_readable($autoloader)) { + require_once($autoloader); +} + // get name of config file to use if (!isset($argv[1])) { if (isset($_ENV['PHPDoctor'])) { $argv[1] = $_ENV['PHPDoctor']; - } elseif (is_file(getcwd().'/phpdoctor.ini')) { - $argv[1] = getcwd().'/phpdoctor.ini'; - } elseif (is_file(dirname(__FILE__).'/phpdoctor.ini')) { - $argv[1] = dirname(__FILE__).'/phpdoctor.ini'; + } elseif (is_file(getcwd().DIRECTORY_SEPARATOR.'phpdoctor.ini')) { + $argv[1] = getcwd().DIRECTORY_SEPARATOR.'phpdoctor.ini'; + } elseif (is_file(dirname(__FILE__).DIRECTORY_SEPARATOR.'phpdoctor.ini')) { + $argv[1] = dirname(__FILE__).DIRECTORY_SEPARATOR.'phpdoctor.ini'; } else { die("Usage: phpdoc [config_file]\n"); }