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

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