templates\index.tpl
@@ -36,9 +36,9 @@ <div id="fileList"> <table border="0" cellspacing="2" cellpadding="3"> <?php $oddrow = true; -$preLen = strlen(CbIOHelper::getCommonPathPrefix(array_keys($fileList))) + 1; +$preLen = strlen(CbIOHelper::getCommonPathPrefix(array_keys($fileList))); // Find out which types of errors have been found $occuringErrorTypes = array ( 'CPD' => false, @@ -70,8 +70,9 @@ foreach ($fileList as $filename => $f) { $tag = $oddrow ? 'odd' : 'even'; $oddrow = !$oddrow; $shortName = substr($filename, $preLen); + $shortName = str_replace('\\', '/', $shortName); $errors = $f->getErrorCount(); $warnings = $f->getWarningCount(); $counts = array_fill_keys($occuringErrorTypes, ''); @@ -80,9 +81,9 @@ $counts[$issue->foundBy] += 1; } echo "<tr class='$tag'>"; - echo "<td><a class='fileLink' href='$shortName.html'>$shortName</a></td>"; + echo "<td><a class='fileLink' href='./$shortName.html'>$shortName</a></td>"; echo "<td align='center'><span class='errorCount'>$errors</span></td>"; echo "<td align='center'><span class='warningCount'>$warnings</span></td>"; foreach ($counts as $count) {
File.php
@@ -212,9 +212,9 @@ $first = $first->name(); $second = $second->name(); $prefix = CbIOHelper::getCommonPathPrefix(array($first, $second)); - $prelen = strlen($prefix) + 1; + $prelen = strlen($prefix); $first = substr($first, $prelen); $second = substr($second, $prelen);
Helper\IOHelper.php
@@ -151,9 +151,10 @@ { if (DIRECTORY_SEPARATOR == substr($target, - 1, 1)) { $target = substr($target, 0, -1); } - $dirs = explode('/', $target); + $dirs = explode(DIRECTORY_SEPARATOR, $target); $path = ''; foreach ($dirs as $folder) { if (!is_dir($path = $path . $folder . DIRECTORY_SEPARATOR)) { mkdir($path); @@ -246,8 +247,12 @@ $prefix = dirname(array_shift($filenames)); foreach ($filenames as $filename) { $prefix = self::_getCommonPathPrefix($prefix, $filename); } + + if (substr($prefix, -1, 1) !== DIRECTORY_SEPARATOR) { + $prefix .= DIRECTORY_SEPARATOR; + } return $prefix; } /** @@ -260,9 +265,10 @@ { if (strpos($path, $currentPrefix . DIRECTORY_SEPARATOR) === 0 || $currentPrefix == '/' || $currentPrefix == '' - || $currentPrefix == '.') { + || $currentPrefix == '.' + || preg_match('/^[A-Z]\:\\\\\$/', $currentPrefix) === 1) { return $currentPrefix; } return self::_getCommonPathPrefix(dirname($currentPrefix), $path); }
View\ViewAbstract.php
@@ -113,9 +113,10 @@ if (!$this->_outputDir) { throw new Exception("Specified output directory '$outputDir'" . 'does not exist'); } - + $this->_outputDir .= DIRECTORY_SEPARATOR; + $this->_ioHelper = $ioHelper; } /** @@ -181,10 +182,9 @@ * In this method, all directories have a trailing DIRECTORY_SEPARATOR. * This is important so that $curDir doesn't become empty if we go * up to the root directory ('/' on linux) */ - $curDir = CbIOHelper::getCommonPathPrefix(array_keys($fileList)) - . DIRECTORY_SEPARATOR; + $curDir = CbIOHelper::getCommonPathPrefix(array_keys($fileList)); $preLen = strlen($curDir); $ret = '<ul>'; foreach ($fileList as $name => $file) { @@ -213,8 +213,9 @@ } $curDir = $dir; } + $name = str_replace('\\', '/', $name); $shortName = substr($name, $preLen); $fileName = basename($name); $count = ''; if ($file->getErrorCount() != 0 || $file->getWarningCount() != 0) {