Skip to content

Commit

Permalink
Remove obsolete code - showSource
Browse files Browse the repository at this point in the history
  • Loading branch information
elkuku committed Oct 22, 2017
1 parent c054ad5 commit aca6806
Showing 1 changed file with 0 additions and 189 deletions.
189 changes: 0 additions & 189 deletions admin/controllers/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,195 +167,6 @@ public function edit_part()
echo $ecrPart->edit($project->autoCodes[$ecrPart->key]);
}

/**
* 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('&lt;?php', '', $hlCode);
echo '<div style="border: 1px dashed gray; background-color: #eee; padding: 0.5em;">'.$hlCode.'</div>';
}
}
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>",
//-- C$parameter->isOptional() ? '<strong style="color: blue;">optional</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;
}

if($paramString)
{
$paramString = implode(', ', $paramString);
}

echo JHTML::tooltip(nl2br(htmlentities($method->getDocComment())), $method->getName());
echo $title.'('.$paramString.')';
echo BR;
}
}
}

/**
* Executes a function inside a 'part' from templates/parts folder.
*
Expand Down

0 comments on commit aca6806

Please sign in to comment.