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. * This class implements a Text_Wiki_Parse to embed the contents of a URL
  7. * inside the page.  Typically used to get script output.
  8. *
  9. * This rule is inherently not secure; it allows cross-site scripting to
  10. * occur if the embedded output has <script> or other similar tags.  Be
  11. * careful.
  12. *
  13. * In the future, we'll add a rule config options to set the base embed
  14. * path so that it is limited to one directory.
  15. *
  16. @author Paul M. Jones <pmjones@ciaweb.net>
  17. *
  18. @package Text_Wiki
  19. *
  20. */
  21.  
  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 = '/(\[\[image )(.+?)(\]\])/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 delimited token number to be used as a placeholder in
  51.     *  the source text.
  52.     *
  53.     */
  54.     
  55.     function process(&$matches)
  56.     {
  57.         $pos strpos($matches[2]' ');
  58.         
  59.         if ($pos === false{
  60.             $options = array(
  61.                 'src' => $matches[2],
  62.                 'attr' => array());
  63.         else {
  64.             // everything after the space is attribute arguments
  65.             $options = array(
  66.                 'src' => substr($matches[2]0$pos),
  67.                 'attr' => $this->getAttrs(substr($matches[2]$pos+1))
  68.             );
  69.         }
  70.         
  71.         return $this->wiki->addToken($this->rule$options);
  72.     }
  73. }
  74. ?>

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