includes/wikiengine/Render/Plain/List.php
changeset 1027 98c052fc3337
parent 1026 f0431eb8161e
child 1028 dde4416dea00
equal deleted inserted replaced
1026:f0431eb8161e 1027:98c052fc3337
     1 <?php
       
     2 
       
     3 
       
     4 class Text_Wiki_Render_Plain_List extends Text_Wiki_Render {
       
     5     
       
     6     /**
       
     7     * 
       
     8     * Renders a token into text matching the requested format.
       
     9     * 
       
    10     * This rendering method is syntactically and semantically compliant
       
    11     * with XHTML 1.1 in that sub-lists are part of the previous list item.
       
    12     * 
       
    13     * @access public
       
    14     * 
       
    15     * @param array $options The "options" portion of the token (second
       
    16     * element).
       
    17     * 
       
    18     * @return string The text rendered from the token options.
       
    19     * 
       
    20     */
       
    21     
       
    22     function token($options)
       
    23     {
       
    24         // make nice variables (type, level, count)
       
    25         extract($options);
       
    26         
       
    27         // set up indenting so that the results look nice; we do this
       
    28         // in two steps to avoid str_pad mathematics.  ;-)
       
    29         $pad = str_pad('', $level, "\t");
       
    30         $pad = str_replace("\t", '    ', $pad);
       
    31                 
       
    32         switch ($type) {
       
    33         
       
    34         case 'bullet_list_start':
       
    35             break;
       
    36         
       
    37         case 'bullet_list_end':
       
    38             if ($level == 0) {
       
    39                 return "\n\n";
       
    40             }
       
    41             break;
       
    42         
       
    43         case 'number_list_start':
       
    44             break;
       
    45         
       
    46         case 'number_list_end':
       
    47             if ($level == 0) {
       
    48                 return "\n\n";
       
    49             }
       
    50             break;
       
    51         
       
    52         case 'bullet_item_start':
       
    53         case 'number_item_start':
       
    54             return "\n$pad";
       
    55             break;
       
    56         
       
    57         case 'bullet_item_end':
       
    58         case 'number_item_end':
       
    59         default:
       
    60             // ignore item endings and all other types.
       
    61             // item endings are taken care of by the other types
       
    62             // depending on their place in the list.
       
    63             return;
       
    64             break;
       
    65         }
       
    66     }
       
    67 }
       
    68 ?>