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

Source for file embed.php

Documentation is available at embed.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at                              |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Paul M. Jones <pmjones@ciaweb.net>                          |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: embed.php,v 1.4 2004/03/11 18:12:49 pmjones Exp $
  20.  
  21.  
  22. /**
  23. * This class implements a Text_Wiki_Rule to embed the contents of a URL
  24. * inside the page at render-time.  Typically used to get script output.
  25. * This differs from the 'include' rule, which incorporates results at
  26. * parse-time; 'embed' output does not get parsed by Text_Wiki, while
  27. * 'include' ouput does.
  28. *
  29. * This rule is inherently not secure; it allows cross-site scripting to
  30. * occur if the embedded output has <script> or other similar tags.  Be
  31. * careful.
  32. *
  33. @author Paul M. Jones <pmjones@ciaweb.net>
  34. *
  35. @package Text_Wiki
  36. *
  37. */
  38.  
  39.     
  40.     
  41.     /**
  42.     * 
  43.     * The regular expression used to find source text matching this
  44.     * rule.
  45.     * 
  46.     * @access public
  47.     * 
  48.     * @var string 
  49.     * 
  50.     */
  51.     
  52.     var $regex = '/(\[\[embed )(.+?)(\]\])/i';
  53.     
  54.     
  55.     /**
  56.     * 
  57.     * Generates a token entry for the matched text.  Token options are:
  58.     * 
  59.     * 'text' => The full matched text, not including the <code></code> tags.
  60.     * 
  61.     * @access public
  62.     *
  63.     * @param array &$matches The array of matches from parse().
  64.     *
  65.     * @return delimited token number to be used as a placeholder in
  66.     *  the source text.
  67.     *
  68.     */
  69.     
  70.     function process(&$matches)
  71.     {    
  72.         $options = array('path' => $matches[2]);
  73.         return $this->addToken($options);
  74.     }
  75.     
  76.     
  77.     /**
  78.     * 
  79.     * Renders a token into text matching the requested format.
  80.     * 
  81.     * @access public
  82.     * 
  83.     * @param array $options The "options" portion of the token (second
  84.     *  element).
  85.     * 
  86.     * @return string The text rendered from the token options.
  87.     * 
  88.     */
  89.     
  90.     function renderXhtml($options)
  91.     {
  92.         $file $this->_conf['base'$options['path'];
  93.         ob_start();
  94.         include($file);
  95.         $output ob_get_contents();
  96.         ob_end_clean();
  97.         return $output;
  98.     }
  99. }
  100. ?>

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