Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: patTemplate

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /pattemplate/patTemplate/Function/Highlight.php

Documentation is available at Highlight.php

  1. <?PHP
  2. /**
  3.  * Generic highlighting function using PEAR::Text_Highlighter
  4.  *
  5.  * $Id: Highlight.php 391 2005-04-12 18:09:45Z schst $
  6.  *
  7.  * @package        patTemplate
  8.  * @subpackage    Functions
  9.  * @author        Stephan Schmidt <[email protected]>
  10.  */
  11.  
  12. // Check to ensure this file is within the rest of the framework
  13. defined('JPATH_BASE'or die();
  14.  
  15. /**
  16.  * patTemplate function that highlights PHP code in your templates
  17.  *
  18.  * $Id: Highlight.php 391 2005-04-12 18:09:45Z schst $
  19.  *
  20.  * @package        patTemplate
  21.  * @subpackage    Functions
  22.  * @author        Stephan Schmidt <[email protected]>
  23.  */
  24. {
  25.    /**
  26.     * name of the function
  27.     * @access    private
  28.     * @var        string 
  29.     */
  30.     var $_name = 'Highlight';
  31.  
  32.    /**
  33.     * call the function
  34.     *
  35.     * @access    public
  36.     * @param    array    parameters of the function (= attributes of the tag)
  37.     * @param    string    content of the tag
  38.     * @return    string    content to insert into the template
  39.     */
  40.     function call($params$content)
  41.     {
  42.         if (!include_once 'Text/Highlighter.php'{
  43.             return false;
  44.         }
  45.         include_once 'Text/Highlighter/Renderer/Html.php';
  46.  
  47.         if (!isset($params['type'])) {
  48.             return $content;
  49.         }
  50.         $type $params['type'];
  51.         unset($params['type']);
  52.  
  53.         if (isset($params['numbers']&& defined($params['numbers'])) {
  54.             $params['numbers'constant($params['numbers']);
  55.         }
  56.  
  57.         $renderer    &new Text_Highlighter_Renderer_HTML($params);
  58.         $highlighter &Text_Highlighter::factory($type);
  59.         $highlighter->setRenderer($renderer);
  60.         return $highlighter->highlight(trim($content));
  61.     }
  62. }
  63. ?>

Documentation generated on Mon, 05 Mar 2007 21:06:10 +0000 by phpDocumentor 1.3.1