From: Chuck Hagenbuch Date: Tue, 22 Sep 2009 21:31:07 +0000 (-0400) Subject: Revert to older, more colorful, non-line-chopping PHP highlighting X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=852e5397817356e5aa4e4fb1b7e49b4319b0d31e;p=horde.git Revert to older, more colorful, non-line-chopping PHP highlighting --- diff --git a/framework/Mime/lib/Horde/Mime/Viewer/Php.php b/framework/Mime/lib/Horde/Mime/Viewer/Php.php index 56b4f21af..2799b0a8a 100644 --- a/framework/Mime/lib/Horde/Mime/Viewer/Php.php +++ b/framework/Mime/lib/Horde/Mime/Viewer/Php.php @@ -51,16 +51,14 @@ class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source */ protected function _renderInline() { - ini_set('highlight.comment', 'comment'); - ini_set('highlight.default', 'default'); - ini_set('highlight.keyword', 'keyword'); - ini_set('highlight.string', 'string'); - ini_set('highlight.html', 'html'); - $code = $this->_mimepart->getContents(); - $text = (strpos($code, '_lineNumber(str_replace('<?php ', '', highlight_string('_lineNumber(highlight_string($code, true)); + if (strpos($code, ''), array('', "\n"), $text)); + $text = $this->_lineNumber($text); return array( $this->_mimepart->getMimeId() => array( @@ -70,89 +68,4 @@ class Horde_Mime_Viewer_Php extends Horde_Mime_Viewer_Source ) ); } - - /** - * Add line numbers to a block of code. - * - * @param string $code The code to number. - * - * @return string The code with line numbers added. - */ - protected function _lineNumber($code) - { - // Clean up. - $code = preg_replace( - array( - '/\s*/', - '/\s*/', - '/\s*<\/span>\s*<\/span>\s*<\/code>/', - '/\s*<\/font>\s*<\/font>\s*<\/code>/' - ), '', $code); - - $code = str_replace( - array(' ', '&', '
', '',), - array(' ', '&', "\n", '',), - $code); - - $code = trim($code); - - // Normalize newlines. - $code = str_replace("\r", '', $code); - $code = preg_replace('/\n\n\n+/', "\n\n", $code); - - $results = array('
    '); - $previous = false; - - $lines = explode("\n", $code); - reset($lines); - while (list($lineno, $line) = each($lines)) { - if (substr($line, 0, 7) == '') { - $previous = false; - $line = substr($line, 7); - } - - if (empty($line)) { - $line = ' '; - } - - if ($previous) { - $line = "" . $line; - } - - // Save the previous style. - if (strpos($line, '') { - $previous = false; - } elseif ($previous) { - $line .= ''; - } - - $results[] = '
  1. ' . $line . '
  2. '; - } - - $results[] = '
'; - - return implode("\n", $results); - } - }