[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/libraries/pattemplate/patTemplate/Function/ -> Highlight.php (source)

   1  <?PHP
   2  /**
   3   * Generic highlighting function using PEAR::Text_Highlighter
   4   *
   5   * $Id: Highlight.php 10381 2008-06-01 03:35:53Z pasamio $
   6   *
   7   * @package        patTemplate
   8   * @subpackage    Functions
   9   * @author        Stephan Schmidt <schst@php.net>
  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 10381 2008-06-01 03:35:53Z pasamio $
  19   *
  20   * @package        patTemplate
  21   * @subpackage    Functions
  22   * @author        Stephan Schmidt <schst@php.net>
  23   */
  24  class patTemplate_Function_Highlight extends patTemplate_Function
  25  {
  26      /**
  27      * name of the function
  28      * @access    private
  29      * @var        string
  30      */
  31      var $_name = 'Highlight';
  32  
  33      /**
  34      * call the function
  35      *
  36      * @access    public
  37      * @param    array    parameters of the function (= attributes of the tag)
  38      * @param    string    content of the tag
  39      * @return    string    content to insert into the template
  40      */
  41  	function call($params, $content)
  42      {
  43          if (!include_once 'Text/Highlighter.php') {
  44              return false;
  45          }
  46          include_once 'Text/Highlighter/Renderer/Html.php';
  47  
  48          if (!isset($params['type'])) {
  49              return $content;
  50          }
  51          $type = $params['type'];
  52          unset($params['type']);
  53  
  54          if (isset($params['numbers']) && defined($params['numbers'])) {
  55              $params['numbers'] = constant($params['numbers']);
  56          }
  57  
  58          $renderer    = &new Text_Highlighter_Renderer_HTML($params);
  59          $highlighter = &Text_Highlighter::factory($type);
  60          $highlighter->setRenderer($renderer);
  61          return $highlighter->highlight(trim($content));
  62      }
  63  }
  64  ?>


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1