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. // $Id: Image.php,v 1.2 2004/09/25 19:05:13 pmjones Exp $
  3.  
  4.  
  5. /**
  6. * 
  7. * This class implements a Text_Wiki_Parse to embed the contents of a URL
  8. * inside the page.  Typically used to get script output.
  9. *
  10. * This rule is inherently not secure; it allows cross-site scripting to
  11. * occur if the embedded output has <script> or other similar tags.  Be
  12. * careful.
  13. *
  14. * In the future, we'll add a rule config options to set the base embed
  15. * path so that it is limited to one directory.
  16. *
  17. * @author Paul M. Jones <pmjones@ciaweb.net>
  18. *
  19. * @package Text_Wiki
  20. *
  21. */
  22.  
  23.     
  24.     
  25.     /**
  26.     * 
  27.     * The regular expression used to find source text matching this
  28.     * rule.
  29.     * 
  30.     * @access public
  31.     * 
  32.     * @var string 
  33.     * 
  34.     */
  35.     
  36.     var $regex = '/(\[\[image )(.+?)(\]\])/i';
  37.     
  38.     
  39.     /**
  40.     * 
  41.     * Generates a token entry for the matched text.  Token options are:
  42.     * 
  43.     * 'src' => The image source, typically a relative path name.
  44.     *
  45.     * 'opts' => Any macro options following the source.
  46.     * 
  47.     * @access public
  48.     *
  49.     * @param array &$matches The array of matches from parse().
  50.     *
  51.     * @return A delimited token number to be used as a placeholder in
  52.     *  the source text.
  53.     *
  54.     */
  55.     
  56.     function process(&$matches)
  57.     {
  58.         $pos = strpos($matches[2], ' ');
  59.         
  60.         if ($pos === false) {
  61.             $options = array(
  62.                 'src' => $matches[2],
  63.                 'attr' => array());
  64.         } else {
  65.             // everything after the space is attribute arguments
  66.             $options = array(
  67.                 'src' => substr($matches[2], 0, $pos),
  68.                 'attr' => $this->getAttrs(substr($matches[2], $pos+1))
  69.             );
  70.         }
  71.         
  72.         return $this->wiki->addToken($this->rule, $options);
  73.     }
  74. }
  75. ?>

Documentation generated on Mon, 11 Mar 2019 13:56:53 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.