));
switch ($config['driver']) {
- case 'Css':
- if ($config['app'] == 'horde') {
- $driver = 'Horde_Core_Mime_Viewer_Css';
- }
- $params['registry'] = $GLOBALS['registry'];
- break;
-
case 'Deb':
case 'Rpm':
$params['monospace'] = 'fixed';
$params['viewer_callback'] = array($this, 'getViewerCallback');
break;
+ case 'Syntaxhighlighter':
+ if ($config['app'] == 'horde') {
+ $driver = 'Horde_Core_Mime_Viewer_Syntaxhighlighter';
+ }
+ $params['registry'] = $GLOBALS['registry'];
+ break;
+
case 'Tgz':
$params['gzip'] = Horde_Compress::factory('Gzip');
$params['monospace'] = 'fixed';
+++ /dev/null
-<?php
-/**
- * The Horde_Core_Mime_Viewer_Css class extends the base CSS driver by adding
- * the necessary stylesheets to the full rendered version.
- *
- * Copyright 2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package Core
- */
-class Horde_Core_Mime_Viewer_Css extends Horde_Mime_Viewer_Css
-{
- /**
- * Constructor.
- *
- * @param Horde_Mime_Part $mime_part The object with the data to be
- * rendered.
- * @param array $conf Configuration:
- * <pre>
- * 'registry' - (Horde_Registry) Registry object.
- * </pre>
- *
- * @throws InvalidArgumentException
- */
- public function __construct(Horde_Mime_Part $part, array $conf = array())
- {
- $this->_required = array_merge($this->_required, array(
- 'registry'
- ));
-
- parent::__construct($part, $conf);
- }
-
- /**
- * Return the full rendered version of the Horde_Mime_Part object.
- *
- * @return array See parent::render().
- */
- protected function _render()
- {
- $ret = $this->_renderInline();
-
- // Need Horde headers for CSS tags.
- if (!empty($ret)) {
- $templates = $this->getConfigParam('registry')->get('templates', 'horde');
-
- reset($ret);
- Horde::startBuffer();
- require $templates . '/common-header.inc';
- echo $ret[key($ret)]['data'];
- require $templates . '/common-footer.inc';
- $ret[key($ret)]['data'] = Horde::endBuffer();
- }
-
- return $ret;
- }
-
-}
--- /dev/null
+<?php
+/**
+ * The Horde_Mime_Viewer_Syntaxhighlighter class renders source code appropriate
+ * for highlighting with http://alexgorbatchev.com/SyntaxHighlighter/.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author Chuck Hagenbuch <chuck@horde.org>
+ * @category Horde
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package Mime_Viewer
+ */
+class Horde_Core_Mime_Viewer_Syntaxhighlighter extends Horde_Mime_Viewer_Syntaxhighlighter
+{
+ protected static $_shLoaded = false;
+ protected static $_shBrushes = array();
+
+ /**
+ * Return the rendered inline version of the Horde_Mime_Part object.
+ *
+ * @return array See parent::render().
+ */
+ protected function _renderInline()
+ {
+ /* Determine the language and brush from the mime type. */
+ $mimeType = $this->_mimepart->getType();
+ $language = $this->_mimeTypeToLanguage($mimeType);
+ $brush = $this->_languageToBrush($language);
+
+ if (!self::$_shLoaded) {
+ Horde::addScriptFile('syntaxhighlighter/scripts/shCore.js', 'horde', true);
+ Horde::addInlineScript(array(
+ 'SyntaxHighlighter.defaults[\'toolbar\'] = false',
+ 'SyntaxHighlighter.all()',
+ ), 'dom');
+ self::$_shLoaded = true;
+
+ $sh_js_fs = $this->getConfigParam('registry')->get('jsfs', 'horde') . '/syntaxhighlighter/styles/';
+ $sh_js_uri = Horde::url($this->getConfigParam('registry')->get('jsuri', 'horde'), false, -1) . '/syntaxhighlighter/styles/';
+ Horde_Themes::includeStylesheetFiles(array('additional' => array(
+ array('f' => $sh_js_fs . 'shCoreEclipse.css', 'u' => $sh_js_uri . 'shCoreEclipse.css'),
+ array('f' => $sh_js_fs . 'shThemeEclipse.css', 'u' => $sh_js_uri . 'shThemeEclipse.css'),
+ )));
+ }
+ if (empty(self::$_shBrushes[$brush])) {
+ Horde::addScriptFile('syntaxhighlighter/scripts/shBrush' . $brush . '.js', 'horde', true);
+ self::$_shBrushes[$brush] = true;
+ }
+
+ $results = '<pre class="brush: ' . $language . '; toolbar: false;">' . htmlspecialchars($this->_mimepart->getContents(), ENT_QUOTES, $this->getConfigParam('charset')) . '</pre>';
+ return $this->_renderReturn(
+ $results,
+ 'text/html; charset=' . $this->getConfigParam('charset')
+ );
+ }
+}
</dir> <!-- /lib/Horde/Core/LoginTasks -->
<dir name="Mime">
<dir name="Viewer">
- <file name="Css.php" role="php" />
+ <file name="Syntaxhighlighter.php" role="php" />
<file name="Vcard.php" role="php" />
</dir> <!-- /lib/Horde/Core/Mime/Viewer -->
</dir> <!-- /lib/Horde/Core/Mime -->
<install as="Horde/Core/Factory/View.php" name="lib/Horde/Core/Factory/View.php" />
<install as="Horde/Core/Log/Logger.php" name="lib/Horde/Core/Log/Logger.php" />
<install as="Horde/Core/LoginTasks/Backend/Horde.php" name="lib/Horde/Core/LoginTasks/Backend/Horde.php" />
- <install as="Horde/Core/Mime/Viewer/Css.php" name="lib/Horde/Core/Mime/Viewer/Css.php" />
+ <install as="Horde/Core/Mime/Viewer/Syntaxhighlighter.php" name="lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php" />
<install as="Horde/Core/Mime/Viewer/Vcard.php" name="lib/Horde/Core/Mime/Viewer/Vcard.php" />
<install as="Horde/Core/Notification/Hordelog.php" name="lib/Horde/Core/Notification/Hordelog.php" />
<install as="Horde/Core/Notification/Status.php" name="lib/Horde/Core/Notification/Status.php" />
<?php
/**
- * The Horde_Mime_Viewer_SyntaxHighlighter class renders source code appropriate
- * for highlighting with SyntaxHighlighter.
+ * The Horde_Mime_Viewer_Syntaxhighlighter class renders source code appropriate
+ * for highlighting with http://alexgorbatchev.com/SyntaxHighlighter/.
*
* Copyright 2003-2010 The Horde Project (http://www.horde.org/)
*
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @package Mime_Viewer
*/
-class Horde_Mime_Viewer_SyntaxHighlighter extends Horde_Mime_Viewer_Base
+class Horde_Mime_Viewer_Syntaxhighlighter extends Horde_Mime_Viewer_Base
{
- protected static $_shLoaded = false;
- protected static $_shBrushes = array();
-
/**
* This driver's display capabilities.
*
{
/* Determine the language and brush from the mime type. */
$mimeType = $this->_mimepart->getType();
- if (strpos($mimeType, '/') === false) {
- $mimeType = "application/x-$mimeType";
- }
$language = $this->_mimeTypeToLanguage($mimeType);
$brush = $this->_languageToBrush($language);
- if (!self::$_shLoaded) {
- Horde::addScriptFile('syntaxhighlighter/scripts/shCore.js', 'horde', true);
- Horde::addInlineScript(array(
- 'SyntaxHighlighter.defaults[\'toolbar\'] = false',
- 'SyntaxHighlighter.all()',
- ), 'dom');
- self::$_shLoaded = true;
-
- $sh_js_fs = $GLOBALS['injector']->getInstance('Horde_Registry')->get('jsfs', 'horde') . '/syntaxhighlighter/styles/';
- $sh_js_uri = Horde::url($GLOBALS['injector']->getInstance('Horde_Registry')->get('jsuri', 'horde'), false, -1) . '/syntaxhighlighter/styles/';
- Horde_Themes::includeStylesheetFiles(array('additional' => array(
- array('f' => $sh_js_fs . 'shCoreEclipse.css', 'u' => $sh_js_uri . 'shCoreEclipse.css'),
- array('f' => $sh_js_fs . 'shThemeEclipse.css', 'u' => $sh_js_uri . 'shThemeEclipse.css'),
- )));
- }
- if (empty(self::$_shBrushes[$brush])) {
- Horde::addScriptFile('syntaxhighlighter/scripts/shBrush' . $brush . '.js', 'horde', true);
- self::$_shBrushes[$brush] = true;
- }
-
$results = '<pre class="brush: ' . $language . '">' . htmlspecialchars($this->_mimepart->getContents(), ENT_QUOTES, $this->getConfigParam('charset')) . '</pre>';
return $this->_renderReturn(
$results,
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
-Replaced external or PHP-based syntax highlighters with javascript SyntaxHighlighter
+Replaced external or PHP-based syntax highlighters with javascript SyntaxHighlighter: http://alexgorbatchev.com/SyntaxHighlighter/
</notes>
<contents>
<dir baseinstalldir="/" name="/">
<file name="Security.php" role="php" />
<file name="Simple.php" role="php" />
<file name="Smil.php" role="php" />
- <file name="SyntaxHighlighter.php" role="php" />
+ <file name="Syntaxhighlighter.php" role="php" />
<file name="Tgz.php" role="php" />
<file name="Tnef.php" role="php" />
<file name="Wordperfect.php" role="php" />
<install as="Horde/Mime/Viewer/Security.php" name="lib/Horde/Mime/Viewer/Security.php" />
<install as="Horde/Mime/Viewer/Simple.php" name="lib/Horde/Mime/Viewer/Simple.php" />
<install as="Horde/Mime/Viewer/Smil.php" name="lib/Horde/Mime/Viewer/Smil.php" />
- <install as="Horde/Mime/Viewer/SyntaxHighlighter.php" name="lib/Horde/Mime/Viewer/SyntaxHighlighter.php" />
+ <install as="Horde/Mime/Viewer/Syntaxhighlighter.php" name="lib/Horde/Mime/Viewer/Syntaxhighlighter.php" />
<install as="Horde/Mime/Viewer/Tgz.php" name="lib/Horde/Mime/Viewer/Tgz.php" />
<install as="Horde/Mime/Viewer/Tnef.php" name="lib/Horde/Mime/Viewer/Tnef.php" />
<install as="Horde/Mime/Viewer/Wordperfect.php" name="lib/Horde/Mime/Viewer/Wordperfect.php" />
<date>2010-10-02</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
-Replaced external or PHP-based syntax highlighters with javascript SyntaxHighlighter
+Replaced external or PHP-based syntax highlighters with javascript SyntaxHighlighter: http://alexgorbatchev.com/SyntaxHighlighter/
</notes>
</release>
</changelog>
<?php
-
-require_once 'Text/Wiki/Render/Xhtml/Code.php';
-
/**
* @package Wicked
*/
$part->setContents($options['text']);
$part->setType("x-extension/$type");
- $viewer = new Horde_Mime_Viewer_SyntaxHighlighter($part, array('charset' => $GLOBALS['registry']->getCharset()));
+ $viewer = new Horde_Core_Mime_Viewer_Syntaxhighlighter($part, array('registry' => $GLOBALS['registry'], 'charset' => $GLOBALS['registry']->getCharset()));
$data = $viewer->render('inline');
$data = reset($data);
return $data['data'];