home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / Images.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  3.1 KB  |  85 lines

  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.4 2004/02/05 16:39:45 sjr Exp $
  20. //
  21.  
  22. /**
  23. * @package  HTML_BBCodeParser
  24. * @author   Stijn de Reede  <sjr@gmx.co.uk>
  25. */
  26.  
  27.  
  28. require_once('HTML/BBCodeParser.php');
  29.  
  30.  
  31.  
  32.  
  33. class HTML_BBCodeParser_Filter_Images extends HTML_BBCodeParser
  34. {
  35.  
  36.     /**
  37.     * An array of tags parsed by the engine
  38.     *
  39.     * @access   private
  40.     * @var      array
  41.     */
  42.     var $_definedTags = array(  'img' => array( 'htmlopen'  => 'img',
  43.                                                 'htmlclose' => '',
  44.                                                 'allowed'   => 'none',
  45.                                                 'attributes'=> array(   'img'   => 'src=%2$s%1$s%2$s',
  46.                                                                         'w'     => 'width=%2$s%1$d%2$s',
  47.                                                                         'h'     => 'height=%2$s%1$d%2$s')
  48.                                                 )
  49.                               );
  50.  
  51.  
  52.  
  53.  
  54.     /**
  55.     * Executes statements before the actual array building starts
  56.     *
  57.     * This method should be overwritten in a filter if you want to do
  58.     * something before the parsing process starts. This can be useful to
  59.     * allow certain short alternative tags which then can be converted into
  60.     * proper tags with preg_replace() calls.
  61.     * The main class walks through all the filters and and calls this
  62.     * method if it exists. The filters should modify their private $_text
  63.     * variable.
  64.     *
  65.     * @return   none
  66.     * @access   private
  67.     * @see      $_text
  68.     * @author   Stijn de Reede  <sjr@gmx.co.uk>
  69.     */
  70.     function _preparse()
  71.     {
  72.         $options = PEAR::getStaticProperty('HTML_BBCodeParser','_options');
  73.         $o = $options['open'];
  74.         $c = $options['close'];
  75.         $oe = $options['open_esc'];
  76.         $ce = $options['close_esc'];
  77.         $this->_preparsed = preg_replace("!".$oe."img(".$ce."|\s.*".$ce.")(.*)".$oe."/img".$ce."!Ui", $o."img=\\2\\1".$o."/img".$c, $this->_text);
  78.     }
  79.  
  80.  
  81. }
  82.  
  83.  
  84. ?>
  85.