Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Manual {
- private $smarty;
- private $className = null;
- private $prodClass = null;
- public function __construct()
- {
- $this->smarty = new Smarty;
- $this->smarty->compile_check = true;
- $this->smarty->debugging = false;
- $this->smarty->caching = false;
- $this->smarty->template_dir = './tpl/' . LANGUAGE . '/' . DESIGN . '/manual/';
- $this->smarty->compile_dir = './tpl/' . LANGUAGE . '/' . DESIGN . '/compiled/';
- $this->smarty->config_dir = './configs/';
- $this->smarty->cache_dir = './cache/';
- }
- private function getMethods($manual) {
- $methods = $this->prodClass->getMethods();
- $return = null;
- if($manual == true) {
- foreach($methods as $method) {
- $fileExsists = file_exists('./tpl/' . LANGUAGE . '/' . DESIGN . '/manual/' . 'template.'.$this->className.'.tpl');
- $this->smarty->assign('method', $method->getName());
- $return .= "<a name='".$method->getName()."'><h3>" . $method->getName() . "</h3></a><br />";
- if($fileExsists)
- $return .= $this->smarty->fetch('template.'.$this->className.'.tpl') . "<br /><br />";
- else
- $return .= "Es ist kein Manual für diese Klasse angelegt!<br /><br />";
- }
- }else{
- foreach($methods as $method) {
- $parametersReturn = null;
- $parameters = $method->getParameters();
- if($method->isStatic() == true) $return .= "static ";
- if($method->isPublic() == true) $return .= "public ";
- if($method->isProtected() == true) $return .= "protected ";
- if($method->isPrivate() == true) $return .= "private ";
- foreach($parameters as $param) {
- if($param->isOptional() == true)
- {
- $parametersReturn = substr($parametersReturn, 0, -2);
- if($param->isDefaultValueAvailable() == true) {
- $default = ($param->getDefaultValue()) ? $param->getDefaultValue() : "''";
- $parametersReturn .= ' [, $' . $param->getName() . ' = ' . $default . '] , ';
- }else
- $parametersReturn .= ' [, $' . $param->getName() . ' ] , ';
- }else{
- if($param->isDefaultValueAvailable() == true)
- $parametersReturn .= '$' . $param->getName() . ' = \'' . $param->getDefaultValue() . '\'';
- else
- $parametersReturn .= '$' . $param->getName() . ', ';
- }
- }
- $parametersReturn = substr($parametersReturn, 0, -2);
- $return .= "<a href='#".$method->getName()."'>" . $method->getName() . " ( ".$parametersReturn." )</a> <br />";
- }
- }
- return $return;
- }
- private function getVariables() {
- $variablesReturn = null;
- $vars = $this->prodClass->getProperties();
- foreach($vars as $var) {
- if($var->isStatic() == true) $variablesReturn .= "static ";
- if($var->isPublic() == true) $variablesReturn .= "public ";
- if($var->isProtected() == true) $variablesReturn .= "protected ";
- if($var->isPrivate() == true) $variablesReturn .= "private ";
- $variablesReturn .= $var->getName() . " = '" . @$var->getValue() . "';<br />";
- }
- return $variablesReturn;
- }
- private function getConstants() {
- $constantsReturn = null;
- $consts = $this->prodClass->getConstants();
- foreach($consts as $name => $constant)
- $constantsReturn .= $name . " = '" . $constant . "';<br />";
- return $constantsReturn;
- }
- public function __call($name, $arguments) {
- $output = null;
- $class = null;
- $this->className = $arguments[0];
- $this->prodClass = new ReflectionClass($this->className);
- if($this->prodClass->isAbstract()) $class .= "abstract, ";
- if($this->prodClass->isFinal()) $class .= "final, ";
- $class = substr($class, 0, -2);
- $output .= "<b>Die Klasse <i>" . $this->className . "</i> (ist) <i>" . $class . "</i> und hat folgende Methoden:</b><br /><br />";
- $output .= $this->getMethods(false);
- $output .= "<br /><b>und folgende Variablen:</b><br /><br />";
- $output .= $this->getVariables();
- $output .= "<br /><b>und folgende Konstanten:</b><br /><br />";
- $output .= $this->getConstants();
- $output .= "<br /><b>Manual zu der Klasse:</b><br /><br />";
- $output .= $this->getMethods(true);
- die($output);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement