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

Source for file center.php

Documentation is available at center.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: center.php,v 1.1 2004/03/25 15:08:20 pmjones Exp $
  20.  
  21.  
  22. /**
  23. * This class implements a Text_Wiki_Rule to find lines marked for centering.
  24. * The line must start with "= " (i.e., an equal-sign followed by a space).
  25. *
  26. @author Paul M. Jones <pmjones@ciaweb.net>
  27. *
  28. @package Text_Wiki
  29. *
  30. */
  31.  
  32.     
  33.     
  34.     /**
  35.     * 
  36.     * The regular expression used to find source text matching this
  37.     * rule.
  38.     * 
  39.     * @access public
  40.     * 
  41.     * @var string 
  42.     * 
  43.     */
  44.     
  45.     //var $regex = '/\n(\<center\>)\n(.+)\n(\<\/center\>)\n/Umsi';
  46.     var $regex = '/\n\= (.*?)\n/';
  47.     
  48.     /**
  49.     * 
  50.     * Generates a token entry for the matched text.
  51.     * 
  52.     * @access public
  53.     *
  54.     * @param array &$matches The array of matches from parse().
  55.     *
  56.     * @return delimited token number to be used as a placeholder in
  57.     *  the source text.
  58.     *
  59.     */
  60.     
  61.     function process(&$matches)
  62.     {
  63.         $start $this->addToken(array('type' => 'start'));
  64.         $end $this->addToken(array('type' => 'end'));
  65.         //return "\n" . $start . "\n" . $matches[2] . "\n\n" . $end . "\n";
  66.         return "\n" $start $matches[1$end "\n";
  67.     }
  68.     
  69.     
  70.     /**
  71.     * 
  72.     * Renders a token into text matching the requested format.
  73.     * 
  74.     * @access public
  75.     * 
  76.     * @param array $options The "options" portion of the token (second
  77.     *  element).
  78.     * 
  79.     * @return string The text rendered from the token options.
  80.     * 
  81.     */
  82.     
  83.     function renderXhtml($options)
  84.     {
  85.         if ($options['type'== 'start'{
  86.             //return "\n<center>\n";
  87.             return '<div style="text-align: center;">';
  88.         }
  89.         
  90.         if ($options['type'== 'end'{
  91.             //return "</center>\n";
  92.             return '</div>';
  93.         }
  94.     }
  95. }
  96. ?>

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