[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/bundled-libs/Text/Wiki/Rule/ -> center.php (source)

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


Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics