home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Text / Wiki / Parse / Default / Tt.php < prev    next >
Encoding:
PHP Script  |  2008-07-02  |  1.6 KB  |  84 lines

  1. <?php
  2.  
  3. /**
  4. * Find source text marked for teletype (monospace).
  5. * @category Text
  6. * @package Text_Wiki
  7. * @author Paul M. Jones <pmjones@php.net>
  8. * @license LGPL
  9. * @version $Id: Tt.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
  10. */
  11.  
  12. /**
  13. * Find source text marked for teletype (monospace).
  14. * Defined by text surrounded by two curly braces. On parsing, the text
  15. * itself is left in place, but the starting and ending instances of
  16. * curly braces are replaced with tokens.
  17. * Token options are:
  18. * 'type' => ['start'|'end'] The starting or ending point of the
  19. * teletype text.  The text itself is left in the source.
  20. * @category Text
  21. * @package Text_Wiki
  22. * @author Paul M. Jones <pmjones@php.net>
  23. */
  24.  
  25. class Text_Wiki_Parse_Tt extends Text_Wiki_Parse {
  26.     
  27.     
  28.     /**
  29.     * 
  30.     * The regular expression used to parse the source text.
  31.     * 
  32.     * @access public
  33.     * 
  34.     * @var string
  35.     * 
  36.     * @see parse()
  37.     * 
  38.     */
  39.     
  40.     var $regex = "/{{({*?.*}*?)}}/U";
  41.     
  42.     
  43.     /**
  44.     * 
  45.     * Generates a replacement for the matched text. 
  46.     * 
  47.     * @access public
  48.     *
  49.     * @param array &$matches The array of matches from parse().
  50.     *
  51.     * @return string A pair of delimited tokens to be used as a
  52.     * placeholder in the source text surrounding the teletype text.
  53.     *
  54.     */
  55.     
  56.     function process(&$matches)
  57.     {
  58.         $start = $this->wiki->addToken(
  59.             $this->rule, array('type' => 'start')
  60.         );
  61.         
  62.         $end = $this->wiki->addToken(
  63.             $this->rule, array('type' => 'end')
  64.         );
  65.         
  66.         return $start . $matches[1] . $end;
  67.     }
  68. }
  69. ?>