function showFunction($func, $parent_class = '') { global $source, $language; if ($parent_class) { $name = $parent_class . $source->tokenizer->language_tokens['T_CLASS_SEPERATOR'] . $func['name']; } else { $name = $func['name']; } $argument_list = '('; $opened_optional_brace = 0; foreach ($func['args'] as $arg) { $comma = $argument_list == '(' ? '' : ','; //$comma is empty for the first argument $this_arg = "{$comma} {$arg['name']}"; if ($arg['optional']) { $opened_optional_brace++; if (isset($arg['default_value'])) { $this_arg = "[{$comma} {$arg['name']} = {$arg['default_value']} "; } else { $this_arg = "[{$comma} {$arg['name']} "; } } $argument_list .= $this_arg; } // We keep the [ open until all arguments are filled - so that we can get an output like this - funcName(argument [, optional_1 [, optional_2 ] ]) $argument_list .= str_repeat(' ]', $opened_optional_brace); $argument_list .= ' )'; $name = $name . $argument_list; if ($func['type'] == 'constructor') { $name .= " [Constructor]"; } ?> ==<?php echo $name; ?> == <?php echo strip_tags(handlePreTags($func['desc']), '<source>'); ?> <?php showArguments($func['args']); if ($func['return']) { ?> ===Returns=== <?php echo $func['return'] . "\n"; } showExample($func['example']); ?> ===Code=== <source lang="<?php echo $language; ?> "> <?php echo $source->tokenizer->language_tokens['T_COMMENT'] . ' File ' . $source->file . ', Line ' . $func['line'] . "\n"; //str_replace("\n", "\n ", $func['code']) print str_replace(array('<', '>', '&'), array('<', '>', '&'), $func['code']); ?> </source> <?php }
function showFunction($func, $parent_class = '') { global $source; $language = $source->language; if ($parent_class) { $name = $parent_class . $source->tokenizer->language_tokens['T_CLASS_SEPERATOR'] . $func['name']; } else { $name = $func['name']; } $argument_list = '('; $opened_optional_brace = 0; foreach ($func['args'] as $arg) { $comma = $argument_list == '(' ? '' : ','; //$comma is empty for the first argument $this_arg = "{$comma} {$arg['name']}"; if (isset($arg['optional']) and $arg['optional']) { $opened_optional_brace++; if (isset($arg['default_value'])) { $this_arg = "[{$comma} {$arg['name']} = {$arg['default_value']} "; } else { $this_arg = "[{$comma} {$arg['name']} "; } } $argument_list .= $this_arg; } // We keep the [ open until all arguments are filled - so that we can get an output like this - funcName(argument [, optional_1 [, optional_2 ] ]) $argument_list .= str_repeat(' ]', $opened_optional_brace); $argument_list .= ' )'; $name = $name . $argument_list; if ($func['type'] == 'constructor') { $name .= " [Constructor]"; } ?> <div class="function" id="function-<?php echo strtolower(($parent_class ? $parent_class . '-' : '') . $func['name']); ?> "> <h3><?php echo $name; ?> </h3> <p><?php echo $func['desc']; ?> </p> <?php if ($func['args']) { ?> <h4>Arguments</h4> <dl> <?php foreach ($func['args'] as $arg) { ?> <dt><?php echo $arg['name']; ?> </dt> <dd> <p><?php echo $arg['desc']; if ($arg['type']) { print "<br /><strong>Data Type: </strong> {$arg['type']}<br />"; } if (isset($arg['optional']) and $arg['optional']) { print "<br /><em>Optional Argument</em>"; if (isset($arg['default_value'])) { print " - if the argument is not provided, the function will use '{$arg['default_value']}' as the default value."; } } ?> </p> </dd> <?php } ?> </dl> <?php } ?> <?php if ($func['return']) { ?> <h4>Returns</h4> <p><?php echo $func['return']; ?> </p> <?php } ?> <?php showExample($func['example']); ?> <div class="code"> <h4>Code</h4> <pre><code class="<?php echo $language; ?> "><?php echo $source->tokenizer->language_tokens['T_COMMENT'] . ' File ' . $source->file . ', Line ' . $func['line'] . "\n"; echo $func['code']; ?> </code></pre> </div> </div> <?php }