$local_api_copy = JComponentHelper::getParams('com_easycreator')->get('local_api_copy'); if ($local_api_copy) { if (strrpos($local_api_copy, '/') + 1 != strlen($local_api_copy)) { //-- Add a slash $local_api_copy .= '/'; } if (strpos($local_api_copy, '//')) { $local_api_copy = substr($local_api_copy, strpos($local_api_copy, '//') + 2); } $formats[] = array('api local', $local_api_copy . '[package]/[class].html#[method]', 'apilocal', 'local'); } else { echo '<span style="float: right; background-color: #ffc;">'; echo jgettext('No local API copy specified. you may do this in configuration.'); echo '</span>'; } $cList = getJoomlaClasses(); $packages = getJoomlaPackages(); ecrLoadMedia('php_file_tree'); $fileTree = new EcrFileTree('', '', " onclick=\"changeFrame('[folder]', '[file]');\""); $fileTree->setDir($pathHelp); $fileTree->showExtension = false; ?> <script type="text/javascript"> var fId = '<?php echo $out_format; ?> '; var ECR_DEBUG = <?php echo ECR_DEBUG ? 'true' : 'false'; ?> ;
/** * For JHelp. * * @return void */ public function show_source() { $input = JFactory::getApplication()->input; $rClass = $input->get('class'); $rMethod = $input->get('method'); $classlistPath = JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'jclasslists'; $fName = 'jclasslist_' . str_replace('.', '_', JVERSION); if (!JFile::exists($classlistPath . DS . $fName . '.php')) { echo sprintf(jgettext('The class file for your Joomla version %s has not been build yet.'), JVERSION); echo BR . $classlistPath . DS . $fName . '.php'; return; } JLoader::import($fName, $classlistPath); $cList = getJoomlaClasses(); if (!class_exists($rClass)) { if (array_key_exists($rClass, $cList)) { if (defined('JPATH_PLATFORM')) { $path = JPATH_PLATFORM . DS . 'joomla' . DS . $cList[$rClass][1]; } else { $path = JPATH_LIBRARIES . DS . 'joomla' . DS . $cList[$rClass][1]; } if (!JFile::exists($path)) { echo '<strong style="color: red">' . jgettext('File not found') . '</strong>' . BR; return; } fakeClasses(JFile::getName($cList[$rClass][1])); require_once $path; } if (!class_exists($rClass)) { echo '<strong style="color: red">' . sprintf(jgettext('Class %s not found'), $rClass) . '</strong>' . BR; var_dump($cList); return; } } $class = new ReflectionClass($rClass); $methods = $class->getMethods(); if ($rMethod != 'NULL') { foreach ($methods as $method) { if ($method->name != $rMethod) { continue; } $fileContents = file($method->getFileName()); $code = ''; for ($i = $method->getStartLine() - 1; $i < $method->getEndline(); $i++) { $l = rtrim($fileContents[$i]) . NL; //-- Strip leading tabs if (substr($l, 0, 1) == "\t") { $l = substr($l, 1); } //-- Convert tabs to three spaces $l = str_replace("\t", ' ', $l); $code .= $l; } //for $docComment = nl2br(htmlentities($method->getDocComment())); $pattern = '#(@[a-z]+)#'; $docComment = preg_replace($pattern, '<strong>$1</strong>', $docComment); echo "<h1>{$rClass} - {$rMethod}</h1>"; echo '<div class="path">'; echo '<span class="img icon16-directory" style="font-size: 1.3em; font-weight: bold;">' . str_replace(JPATH_ROOT, '', $method->getFileName()) . '</span> - # ' . $method->getStartLine() . ' - ' . $method->getEndline(); echo '</div>'; echo '<div style="font-size: 1.2em;">' . $docComment . '</div>'; $hlCode = highlight_string('<?php' . NL . $code, true); $hlCode = str_replace('<?php', '', $hlCode); echo '<div style="border: 1px dashed gray; background-color: #eee; padding: 0.5em;">' . $hlCode . '</div>'; } //foreach } else { //-- No method given - output the whole class echo "<h1>{$rClass}</h1>"; /* @var ReflectionMethod $method */ foreach ($methods as $method) { if ($method->getDeclaringClass()->name != $rClass) { continue; } $title = sprintf("%s%s%s%s%s%s%s function <span style='color: blue;'>%s</span> %s", $method->isInternal() ? 'internal' : '', $method->isAbstract() ? ' abstract' : '', $method->isFinal() ? ' final' : '', $method->isPublic() ? ' <span style="color: green;">public</span>' : '', $method->isPrivate() ? ' <strong style="color: orange">private</strong>' : '', $method->isProtected() ? ' <strong style="color: red">protected</strong>' : '', $method->isStatic() ? ' <strong style="color: black">static</strong>' : '', $method->getName(), $method->isConstructor() ? '<span style="color: green;">Konstruktor</span>' : ''); $parameters = $method->getParameters(); $paramString = ''; foreach ($parameters as $parameter) { $s = ''; $s .= sprintf("%s<strong style='color: brown;'>\$%s</strong>", $parameter->isPassedByReference() ? '<strong style="color: blue;"> & </strong>' : '', $parameter->getName()); if ($parameter->isDefaultValueAvailable()) { $def = $parameter->getDefaultValue(); if ($def === null) { $s .= '=null'; } else { if ($def === false) { $s .= '=false'; } else { if ($def === true) { $s .= '=true'; } else { if ($def === array()) { $s .= '=array()'; } else { if ($def === '') { $s .= '=\'\''; } else { $s .= '=' . $parameter->getDefaultValue(); } } } } } } $paramString[] = $s; } //foreach if ($paramString) { $paramString = implode(', ', $paramString); } echo JHTML::tooltip(nl2br(htmlentities($method->getDocComment())), $method->getName()); echo $title . '(' . $paramString . ')'; echo BR; } //foreach } }