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 / Anchor.php next >
Encoding:
PHP Script  |  2008-07-02  |  1.7 KB  |  88 lines

  1. <?php
  2.  
  3. /**
  4. * Parses for anchor targets.
  5. * @category Text
  6. * @package Text_Wiki
  7. * @author Manuel Holtgrewe <purestorm at ggnore dot net>
  8. *
  9. * @author Paul M. Jones <pmjones@php.net>
  10. * @license LGPL
  11. * @version $Id: Anchor.php,v 1.3 2005/02/23 17:38:29 pmjones Exp $
  12. */
  13.  
  14. /**
  15. * This class implements a Text_Wiki_Parse to add an anchor target name
  16. * in the wiki page.
  17. *
  18. * @author Manuel Holtgrewe <purestorm at ggnore dot net>
  19. *
  20. * @author Paul M. Jones <pmjones at ciaweb dot net>
  21. *
  22. * @category Text
  23. * @package Text_Wiki
  24. */
  25.  
  26. class Text_Wiki_Parse_Anchor extends Text_Wiki_Parse {
  27.     
  28.     
  29.     /**
  30.     * 
  31.     * The regular expression used to find source text matching this
  32.     * rule.  Looks like a macro: [[# anchor_name]]
  33.     * 
  34.     * @access public
  35.     * 
  36.     * @var string
  37.     * 
  38.     */
  39.     
  40.     var $regex = '/(\[\[# )([-_A-Za-z0-9.]+?)( .+)?(\]\])/i';
  41.     
  42.     
  43.     /**
  44.     * 
  45.     * Generates a token entry for the matched text.  Token options are:
  46.     * 
  47.     * 'text' => The full matched text, not including the <code></code> tags.
  48.     * 
  49.     * @access public
  50.     *
  51.     * @param array &$matches The array of matches from parse().
  52.     *
  53.     * @return A delimited token number to be used as a placeholder in
  54.     * the source text.
  55.     *
  56.     */
  57.     
  58.     function process(&$matches) {
  59.     
  60.         $name = $matches[2];
  61.         $text = $matches[3];
  62.         
  63.         $start = $this->wiki->addToken(
  64.             $this->rule,
  65.             array('type' => 'start', 'name' => $name)
  66.         );
  67.         
  68.         $end = $this->wiki->addToken(
  69.             $this->rule,
  70.             array('type' => 'end', 'name' => $name)
  71.         );
  72.         
  73.         // done, place the script output directly in the source
  74.         return $start . trim($text) . $end;
  75.     }
  76. }
  77. ?>
  78.