web/enmi/Zend/Markup/Renderer/Html/List.php
changeset 19 1c2f13fd785c
parent 0 4eba9c11703f
equal deleted inserted replaced
18:bd595ad770fc 19:1c2f13fd785c
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Markup
       
    17  * @subpackage Renderer_Html
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: List.php 20270 2010-01-13 22:37:41Z kokx $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Markup_Renderer_Html_HtmlAbstract
       
    25  */
       
    26 require_once 'Zend/Markup/Renderer/Html/HtmlAbstract.php';
       
    27 
       
    28 /**
       
    29  * Tag interface
       
    30  *
       
    31  * @category   Zend
       
    32  * @package    Zend_Markup
       
    33  * @subpackage Renderer_Html
       
    34  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    36  */
       
    37 class Zend_Markup_Renderer_Html_List extends Zend_Markup_Renderer_Html_HtmlAbstract
       
    38 {
       
    39 
       
    40     /**
       
    41      * Convert the token
       
    42      *
       
    43      * @param Zend_Markup_Token $token
       
    44      * @param string $text
       
    45      *
       
    46      * @return string
       
    47      */
       
    48     public function convert(Zend_Markup_Token $token, $text)
       
    49     {
       
    50         $type = null;
       
    51         if ($token->hasAttribute('list')) {
       
    52             // because '01' == '1'
       
    53             if ($token->getAttribute('list') === '01') {
       
    54                 $type = 'decimal-leading-zero';
       
    55             } else {
       
    56                 switch ($token->getAttribute('list')) {
       
    57                     case '1':
       
    58                         $type = 'decimal';
       
    59                         break;
       
    60                     case 'i':
       
    61                         $type = 'lower-roman';
       
    62                         break;
       
    63                     case 'I':
       
    64                         $type = 'upper-roman';
       
    65                         break;
       
    66                     case 'a':
       
    67                         $type = 'lower-alpha';
       
    68                         break;
       
    69                     case 'A':
       
    70                         $type = 'upper-alpha';
       
    71                         break;
       
    72 
       
    73                     // the following type is unsupported by IE (including IE8)
       
    74                     case 'alpha':
       
    75                         $type = 'lower-greek';
       
    76                         break;
       
    77 
       
    78                     // the CSS names itself
       
    79                     case 'armenian': // unsupported by IE (including IE8)
       
    80                     case 'decimal':
       
    81                     case 'decimal-leading-zero': // unsupported by IE (including IE8)
       
    82                     case 'georgian': // unsupported by IE (including IE8)
       
    83                     case 'lower-alpha':
       
    84                     case 'lower-greek': // unsupported by IE (including IE8)
       
    85                     case 'lower-latin': // unsupported by IE (including IE8)
       
    86                     case 'lower-roman':
       
    87                     case 'upper-alpha':
       
    88                     case 'upper-latin': // unsupported by IE (including IE8)
       
    89                     case 'upper-roman':
       
    90                         $type = $token->getAttribute('list');
       
    91                         break;
       
    92                 }
       
    93             }
       
    94         }
       
    95 
       
    96         if (null !== $type) {
       
    97             return "<ol style=\"list-style-type: {$type}\">{$text}</ol>";
       
    98         } else {
       
    99             return "<ul>{$text}</ul>";
       
   100         }
       
   101     }
       
   102 
       
   103 }