CodeDoc/Data/Param.php
[PHP_CodeDoc] / CodeDoc / Data / Param.php
1 <?php
2
3 // +----------------------------------------------------------------------+
4 // | PHP Version 4                                                        |
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2002 The PHP Group                                |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license,      |
9 // | that is bundled with this package in the file LICENSE, and is        |
10 // | available at 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: Alan Knowles <alan@akbkhome.com>                      |
17 // +----------------------------------------------------------------------+
18 //
19
20 /**
21 *   Method and Class parameter data container
22 *
23 *   @package  PHP_CodeDoc
24 *   @access   public
25 *   @author   Alan Knowles <alan@akbkhome.com>
26 *
27 */
28 class PHP_CodeDoc_Data_Param {
29     var $name ='';        // name of parameter
30     var $Value = '';       // default value
31     var $desc = '';
32     var $type = '';
33     
34     
35     function descToHTML()
36     {
37         
38         $lines = explode("\n", $this->desc);
39         if (count($lines) < 2) {
40             return $this->desc;
41         }
42         if (preg_match('/array/i', $this->type) && preg_match('/\+\s+[a-z0-9_-]+:/', $this->desc)) {
43             // dl list...
44             
45             $ret = array_shift($lines) . "<br/><dl>";
46             $cur = false;
47             $sets = array();
48             foreach($lines as $l) {
49                 $m = array();
50                 if (preg_match('/^\s+\+\s+([a-z0-9_-]+):\s+(.*)$/i', $l, $m)) {
51                     if ($cur) {
52                         $sets[] = $cur;
53                     }
54                     $cur = array('key'=>$m[1], 'val' => $m[2] );
55                     continue;
56                 }
57                 if ($cur) {
58                     $cur['val'] .= "\n" . $l;
59                 }
60                 
61             }
62             if ($cur) {
63                 $sets[] = $cur;
64             }
65             
66             foreach($sets as $kv) {
67                 $ret.="<dt>" . $kv['key'] . '</dt><dd>' . str_replace('\n', '<br/>', htmlspecialchars($kv['val'])) . '</dd>';
68             }
69             return $ret;
70         }
71         
72         
73         return implode('<br/>', $lines);
74         
75         
76         
77         
78         
79         
80     }
81     
82 }
83