Overview

Packages

  • None
  • Wicked

Classes

  • Text_Wiki_Parse_Heading2
  • Text_Wiki_Parse_Toc2
  • Text_Wiki_Render_Latex_Heading2
  • Text_Wiki_Render_Latex_Toc2
  • Text_Wiki_Render_Plain_Heading2
  • Text_Wiki_Render_Plain_Toc2
  • Text_Wiki_Render_Rst
  • Text_Wiki_Render_Rst_Blockquote
  • Text_Wiki_Render_Rst_Bold
  • Text_Wiki_Render_Rst_Code
  • Text_Wiki_Render_Rst_Deflist
  • Text_Wiki_Render_Rst_Emphasis
  • Text_Wiki_Render_Rst_Freelink
  • Text_Wiki_Render_Rst_Heading2
  • Text_Wiki_Render_Rst_Links
  • Text_Wiki_Render_Rst_List
  • Text_Wiki_Render_Rst_Newline
  • Text_Wiki_Render_Rst_Paragraph
  • Text_Wiki_Render_Rst_Raw
  • Text_Wiki_Render_Rst_Toc2
  • Text_Wiki_Render_Rst_Tt
  • Text_Wiki_Render_Rst_Url
  • Text_Wiki_Render_Xhtml_Attribute
  • Text_Wiki_Render_Xhtml_Code2
  • Text_Wiki_Render_Xhtml_Freelink2
  • Text_Wiki_Render_Xhtml_Heading2
  • Text_Wiki_Render_Xhtml_Image2
  • Text_Wiki_Render_Xhtml_Interwiki
  • Text_Wiki_Render_Xhtml_Registrylink
  • Text_Wiki_Render_Xhtml_Toc2
  • Text_Wiki_Render_Xhtml_Url
  • Text_Wiki_Render_Xhtml_Wickedblock
  • Text_Wiki_Render_Xhtml_Wikilink2
  • Wicked
  • Wicked_Api
  • Wicked_Driver
  • Wicked_Driver_Sql
  • Wicked_Exception
  • Wicked_Factory_Driver
  • Wicked_Page
  • Wicked_Page_AddPage
  • Wicked_Page_AllPages
  • Wicked_Page_AttachedFiles
  • Wicked_Page_BackLinks
  • Wicked_Page_DeletePage
  • Wicked_Page_EditPage
  • Wicked_Page_LeastPopular
  • Wicked_Page_LikePages
  • Wicked_Page_MergeOrRename
  • Wicked_Page_MostPopular
  • Wicked_Page_NewPage
  • Wicked_Page_RecentChanges
  • Wicked_Page_RevertPage
  • Wicked_Page_Search
  • Wicked_Page_StandardHistoryPage
  • Wicked_Page_StandardPage
  • Wicked_Page_SyncDiff
  • Wicked_Page_SyncPages
  • Wicked_Sync
  • Wicked_Sync_Wicked
  • Wicked_Test
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Renders a definition list for a Wiki page.
 4:  *
 5:  * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file COPYING for license information (GPLv2). If
 8:  * you did not receive this file, see
 9:  * http://www.horde.org/licenses/gpl
10:  *
11:  * PHP version 5
12:  *
13:  * @category Horde
14:  * @package  Wicked
15:  * @author   Gunnar Wrobel <wrobel@pardus.de>
16:  * @link     http://www.horde.org/apps/wicked
17:  * @license  http://www.horde.org/licenses/gpl GNU General Public License, version 2
18:  */
19: 
20: /**
21:  * Renders a definition list for a Wiki page.
22:  *
23:  * @category Horde
24:  * @package  Wicked
25:  * @author   Gunnar Wrobel <wrobel@pardus.de>
26:  * @link     http://www.horde.org/apps/wicked
27:  * @license  http://www.horde.org/licenses/gpl GNU General Public License, version 2
28:  */
29: class Text_Wiki_Render_Rst_Deflist extends Text_Wiki_Render
30: {
31:     /**
32:      * Renders a token into text matching the requested format.
33:      * 
34:      * @param array $options The "options" portion of the token (second
35:      * element).
36:      * 
37:      * @return string The text rendered from the token options.
38:      */
39:     public function token($options)
40:     {
41:         $type = $options['type'];
42:         switch ($type) {
43:         case 'list_start':
44:             $this->wiki->registerRenderCallback(array($this, 'deflist'));
45:             return '';
46:         case 'list_end':
47:             $this->wiki->popRenderCallback();
48:             return Text_Wiki_Render_Rst_Links::append();
49:         case 'term_end':
50:         case 'narr_end':
51:             return $this->wiki->delim;
52:         case 'term_start':
53:         case 'narr_start':
54:         default:
55:             return '';
56: 
57:         }
58:     }
59: 
60:     public function deflist($block)
61:     {
62:         $elements = explode($this->wiki->delim, $block);
63:         $term = false;
64:         $list = array();
65:         foreach ($elements as $element) {
66:             if ($term === false) {
67:                 $term = $element;
68:             } else {
69:                 $list[$term] = $element;
70:                 $term = false;
71:             }
72:         }
73:         $term_length = max(array_map('strlen', array_keys($list)));
74:         $result = '';
75:         foreach ($list as $term => $info) {
76:             $lead = Horde_String::pad($term . ': ', $term_length + 2);
77:             $definition = Horde_String::wordwrap(
78:                 $lead . $info,
79:                 max(80, $term_length + 30),
80:                 "\n" . str_repeat(' ', $term_length + 3)
81:             );
82:             $result .= ':' . $definition . "\n";
83:         }
84:         $result .= "\n";
85:         return $result;
86:     }
87: }
88: 
API documentation generated by ApiGen