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

Source for file Include.php

Documentation is available at Include.php

  1. <?php
  2. // $Id: Include.php,v 1.3 2004/09/25 19:05:13 pmjones Exp $
  3.  
  4.  
  5. /**
  6. * 
  7. * This class implements a Text_Wiki_Parse to include the results of a
  8. * script directly into the source at parse-time; thus, the output of the
  9. * script will be parsed by Text_Wiki.  This differs from the 'embed'
  10. * rule, which incorporates the results at render-time, meaning that the
  11. * 'embed' content is not parsed by Text_Wiki.
  12. *
  13. * DANGER!
  14. * 
  15. * This rule is inherently not secure; it allows cross-site scripting to
  16. * occur if the embedded output has <script> or other similar tags.  Be
  17. * careful.
  18. *
  19. * @author Paul M. Jones <pmjones@ciaweb.net>
  20. *
  21. * @package Text_Wiki
  22. *
  23. */
  24.  
  25.     
  26.     var $conf = array(
  27.         'base' => '/path/to/scripts/'
  28.     );
  29.     
  30.     var $file = null;
  31.     
  32.     var $output = null;
  33.     
  34.     var $vars = null;
  35.  
  36.     /**
  37.     * 
  38.     * The regular expression used to find source text matching this
  39.     * rule.
  40.     * 
  41.     * @access public
  42.     * 
  43.     * @var string 
  44.     * 
  45.     */
  46.     
  47.     var $regex = '/(\[\[include )(.+?)( .+?)?(\]\])/i';
  48.     
  49.     
  50.     /**
  51.     * 
  52.     * Includes the results of the script directly into the source; the output
  53.     * will subsequently be parsed by the remaining Text_Wiki rules.
  54.     * 
  55.     * @access public
  56.     *
  57.     * @param array &$matches The array of matches from parse().
  58.     *
  59.     * @return The results of the included script.
  60.     *
  61.     */
  62.     
  63.     function process(&$matches)
  64.     {
  65.         // save the file location
  66.         $this->file = $this->getConf('base', './') . $matches[2];
  67.  
  68.         // extract attribs as variables in the local space
  69.         $this->vars = $this->getAttrs($matches[3]);
  70.         unset($this->vars['this']);
  71.         extract($this->vars);
  72.  
  73.         // run the script
  74.         ob_start();
  75.         include($this->file);
  76.         $this->output = ob_get_contents();
  77.         ob_end_clean();
  78.     
  79.         // done, place the script output directly in the source
  80.         return $this->output;
  81.     }
  82. }
  83. ?>

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