3 * Common base class of all phpdoc classes
\r
5 * As a kind of common base class PhpdocObject holds
\r
6 * configuration values (e.g. error handling) and debugging
\r
7 * methods (e.g. introspection()). It does not have a constructor,
\r
8 * so you can always inheritig Phpdoc classes from this
\r
9 * class without any trouble.
\r
11 * @author Ulf Wendel <ulf.wendel@phpdoc.de>
\r
12 * @version $Id: PhpdocObject.php,v 1.2 2000/12/03 20:30:42 uw Exp $
\r
15 class PhpdocObject {
\r
18 * Variable containing the latest exceptions.
\r
20 * The way PHPDoc handles errors is a little different from the
\r
21 * official PEAR way. PHPDoc methods do not return
\r
22 * error objects but save them to the class variable $err and try
\r
23 * to return a value that indicates that an error occured.
\r
31 * Default applicationname for the generated HTML files.
\r
35 var $application = "PHPDoc";
\r
38 * Use to save warnings.
\r
45 * Flag determining wheter to print some status messages or not (default: false)
\r
47 * @var boolean $flag_output
\r
48 * @see setFlagOutput()
\r
51 var $flag_output = false;
\r
54 * Sets the output flag - if set to true out() and outl() print messages
\r
56 * @param boolean $flagOutput
\r
58 * @see $flag_output, out(), outl()
\r
61 function setFlagOutput($flagOutput) {
\r
62 $this->flag_output = ($flagOutput) ? true : false;
\r
63 } // end func setFlagOutput
\r
66 * Print a string and flushes the output buffer
\r
67 * @param string $message
\r
69 function out($message) {
\r
70 if (false == $this->flag_output)
\r
78 * Encodes an element name so that it can be used as a file name.
\r
79 * @param string element name
\r
80 * @return string url name
\r
82 function nameToUrl($name) {
\r
83 return preg_replace("@[\s\./\\:]@", "_", $name);
\r
84 } // end func nameToUrl
\r
88 * Print a string, the specified HTML line break sign and flushes the output buffer
\r
89 * @param string $message
\r
91 function outl($message) {
\r
92 if (false == $this->flag_output)
\r
100 * Dumps objects and arrays.
\r
102 * Use this function to get an idea of the internal datastructures used.
\r
103 * The function dumps arrays and objects. It renders the content in
\r
104 * an HTML table. Play with it, you'll see it's very helpful
\r
107 * @param string $title Optional title used in the HTML Table
\r
108 * @param mixed $data Optional array or object that you want to dump.
\r
109 * Fallback to $this.
\r
110 * @param boolean $userfunction Optional flag. If set to false userfunction
\r
111 * in an object are not shown (default). If set to
\r
112 * true, userfunctions are rendered
\r
117 function introspection($title="", $data = "", $userfunction = true) {
\r
122 printf('<table border="1" cellspacing="4" cellpadding="4" bordercolor="Silver">%s',
\r
127 printf('<tr>%s<td colspan=4><b>%s</b></td>%s</tr>%s',
\r
135 while (list($k, $v)=each($data)) {
\r
137 if ("user function"==gettype($v) && !$userfunction)
\r
140 if (is_array($v) || is_object($v)) {
\r
146 <td align="left" valign="top">
\r
147 <font color="%s"><pre><b>%s</b></pre></font>
\r
149 <td align="left" valign="top"><font color="%s"><pre>=></pre></font></td>
\r
150 <td align="left" valign="top" colspan=2>',
\r
154 str_replace("<", "<", $v)
\r
157 $this->introspection("", $v, $userfunction);
\r
159 printf('</td>%s</tr>%s', $this->CR_HTML, $this->CR_HTML);
\r
166 <td align="left" valign="top">
\r
167 <font color="%s"><pre><b>%s</b></pre></font>
\r
169 <td align="left" valign="top"><pre><font color="%s">=></pre></font></td>
\r
170 <td align="left" valign="top"><pre><font color="%s">[%s]</font></pre></td>
\r
171 <td align="left" valign="top"><pre><font color="%s">"%s"</font></pre></td>
\r
179 str_replace("<", "<", $v)
\r
183 print '</table>'.$this->CR_HTML;
\r
184 } // end func introspection
\r
186 } // end class PhpdocObject
\r