"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "public_html/lists/base/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php" between
phplist-3.4.5.tgz and phplist-3.4.6.tgz

About: phpList is a one-way email announcement delivery system for newsletters, publicity lists, notifications, and many other uses (requires PHP and MySQL).

CodeHelper.php  (phplist-3.4.5.tgz):CodeHelper.php  (phplist-3.4.6.tgz)
skipping to change at line 113 skipping to change at line 113
return implode(', ', $result); return implode(', ', $result);
} }
/** /**
* Returns an excerpt of a code file around the given line number. * Returns an excerpt of a code file around the given line number.
* *
* @param string $file A file path * @param string $file A file path
* @param int $line The selected line number * @param int $line The selected line number
* *
* @return string An HTML string * @return string|null An HTML string
*/ */
public function fileExcerpt($file, $line) public function fileExcerpt($file, $line)
{ {
if (is_readable($file)) { if (is_readable($file)) {
if (\extension_loaded('fileinfo')) { if (\extension_loaded('fileinfo')) {
$finfo = new \finfo(); $finfo = new \finfo();
// Check if the file is an application/octet-stream (eg. Phar fi le) because highlight_file cannot parse these files // Check if the file is an application/octet-stream (eg. Phar fi le) because highlight_file cannot parse these files
if ('application/octet-stream' === $finfo->file($file, FILEINFO_ MIME_TYPE)) { if ('application/octet-stream' === $finfo->file($file, FILEINFO_ MIME_TYPE)) {
return; return '';
} }
} }
// highlight_file could throw warnings // highlight_file could throw warnings
// see https://bugs.php.net/bug.php?id=25725 // see https://bugs.php.net/25725
$code = @highlight_file($file, true); $code = @highlight_file($file, true);
// remove main code/span tags // remove main code/span tags
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s ', '\\1', $code); $code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s ', '\\1', $code);
$content = explode('<br />', $code); $content = explode('<br />', $code);
$lines = []; $lines = [];
for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)) ; $i <= $max; ++$i) { for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)) ; $i <= $max; ++$i) {
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><cod e>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>'; $lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><cod e>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
} }
return '<ol start="'.max($line - 3, 1).'">'.implode("\n", $lines).'< /ol>'; return '<ol start="'.max($line - 3, 1).'">'.implode("\n", $lines).'< /ol>';
} }
return null;
} }
/** /**
* Formats a file path. * Formats a file path.
* *
* @param string $file An absolute file path * @param string $file An absolute file path
* @param int $line The line number * @param int $line The line number
* @param string $text Use this text for the link rather than the file path * @param string $text Use this text for the link rather than the file path
* *
* @return string * @return string
 End of changes. 4 change blocks. 
3 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)