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

Source for file Image.php

Documentation is available at Image.php

  1. <?php
  2.  
  3. /**
  4. * Parses for image placement.
  5. @category Text
  6. @package Text_Wiki
  7. @author bertrand Gugger <bertrand@toggg.com>
  8. @author Justin Patrin <papercrane@reversefold.com>
  9. @author Paul M. Jones <pmjones@php.net>
  10. @license LGPL
  11. @version $Id: Image.php 191168 2005-07-21 20:56:15Z justinpatrin $
  12. */
  13.  
  14. class Text_Wiki_Parse_Image extends Text_Wiki_Parse {
  15.     
  16.     
  17.     /**
  18.     * 
  19.     * The regular expression used to find source text matching this
  20.     * rule.
  21.     * 
  22.     * @access public
  23.     * 
  24.     * @var string 
  25.     * 
  26.     */
  27.     
  28.     var $regex = '/{img\s+(.+?)\s*}/i';
  29.     
  30.     
  31.     /**
  32.     * 
  33.     * Generates a token entry for the matched text.  Token options are:
  34.     * 
  35.     * 'src' => The image source, typically a relative path name.
  36.     *
  37.     * 'opts' => Any macro options following the source.
  38.     * 
  39.     * @access public
  40.     *
  41.     * @param array &$matches The array of matches from parse().
  42.     *
  43.     * @return delimited token number to be used as a placeholder in
  44.     *  the source text.
  45.     *
  46.     */
  47.     
  48.     function process(&$matches)
  49.     {
  50.         $options = array('src' => '''attr' => array('border' => '0'));
  51.         $src $link $align $desc '';
  52.         preg_match_all('/(\w+)\s*=\s*((&quot;|\'|"|&apos;|&#34;|&#39;)(.*?)\3|\S*)/',
  53.                        str_replace(array('}''{')''$matches[1])$splitsPREG_SET_ORDER);
  54.  
  55.         foreach ($splits as $attr{
  56.             if (isset($attr[4])) {
  57.                 $attr[2$attr[4];
  58.             }
  59.             $attr[1== strtolower($attr[1]);
  60.             switch ($attr[1]{
  61.             case 'src':
  62.                 $options['src'$attr[2];
  63.                 break;
  64.             case 'height':
  65.             case 'width':
  66.             case 'alt':
  67.                 $options['attr'][$attr[1]] $attr[2];
  68.                 break;
  69.             case 'link':
  70. //                $link = $attr[2];
  71.                 $options['attr'][$attr[1]] $attr[2];
  72.                 break;
  73.             case 'align':
  74.                 $align $attr[2];
  75.                 break;
  76.             case 'desc':
  77.                 $desc $attr[2];
  78.                 break;
  79.             case 'imalign':;
  80.                 $options['attr']['align'$attr[2];
  81.                 break;
  82.             case 'usemap':
  83.                 $options['attr']['usemap''#'.$attr[2];
  84.                 break;
  85.             }
  86.         }
  87. /*        if ($link) {
  88.             $this->wiki->addToken('Url', $options);
  89.         }
  90.             
  91.         
  92.         if ($pos === false) {
  93.             $options = array(
  94.                 'src' => $matches[2],
  95.                 'attr' => array());
  96.         } else {
  97.             // everything after the space is attribute arguments
  98.             $options = array(
  99.                 'src' => substr($matches[2], 0, $pos),
  100.                 'attr' => $this->getAttrs(substr($matches[2], $pos+1))
  101.             );
  102.         }
  103. */
  104.         return $this->wiki->addToken($this->rule$options);
  105.     }
  106. }
  107. ?>

Documentation generated on Mon, 11 Mar 2019 15:32:44 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.