HTML_BBCodeParser
[ class tree: HTML_BBCodeParser ] [ index: HTML_BBCodeParser ] [ all elements ]

Source for file Images.php

Documentation is available at Images.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Stijn de Reede <sjr@gmx.co.uk>                               |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Images.php,v 1.6 2007/06/04 21:12:29 dufuz Exp $
  20. //
  21.  
  22. /**
  23. @package  HTML_BBCodeParser
  24. @author   Stijn de Reede  <sjr@gmx.co.uk>
  25. */
  26. require_once 'HTML/BBCodeParser.php';
  27.  
  28. class HTML_BBCodeParser_Filter_Images extends HTML_BBCodeParser
  29. {
  30.  
  31.     /**
  32.     * An array of tags parsed by the engine
  33.     *
  34.     * @access   private
  35.     * @var      array 
  36.     */
  37.     var $_definedTags = array(
  38.         'img' => array(
  39.             'htmlopen'  => 'img',
  40.             'htmlclose' => '',
  41.             'allowed'   => 'none',
  42.             'attributes'=> array(
  43.                 'img'   => 'src=%2$s%1$s%2$s',
  44.                 'w'     => 'width=%2$s%1$d%2$s',
  45.                 'h'     => 'height=%2$s%1$d%2$s',
  46.                 'alt'   => 'alt=%2$s%1$s%2$s',
  47.             )
  48.         )
  49.     );
  50.  
  51.     /**
  52.     * Executes statements before the actual array building starts
  53.     *
  54.     * This method should be overwritten in a filter if you want to do
  55.     * something before the parsing process starts. This can be useful to
  56.     * allow certain short alternative tags which then can be converted into
  57.     * proper tags with preg_replace() calls.
  58.     * The main class walks through all the filters and and calls this
  59.     * method if it exists. The filters should modify their private $_text
  60.     * variable.
  61.     *
  62.     * @return   none 
  63.     * @access   private
  64.     * @see      $_text
  65.     * @author   Stijn de Reede  <sjr@gmx.co.uk>
  66.     */
  67.     function _preparse()
  68.     {
  69.         $options = PEAR::getStaticProperty('HTML_BBCodeParser','_options');
  70.         $o  $options['open'];
  71.         $c  $options['close'];
  72.         $oe $options['open_esc'];
  73.         $ce $options['close_esc'];
  74.         $this->_preparsed preg_replace(
  75.             "!".$oe."img(\s?.*)".$ce."(.*)".$oe."/img".$ce."!Ui",
  76.             $o."img=\$2\$1".$c.$o."/img".$c,
  77.             $this->_text);
  78.     }
  79. }

Documentation generated on Tue, 05 Jun 2007 17:30:06 -0400 by phpDocumentor 1.3.2. PEAR Logo Copyright © PHP Group 2004.