comtype ) { case 'component': $comPath = 'components'.DS.$project->com_com_name; // $scopes = array( 'administrator', ''); // foreach ($scopes as $scope) // { $scope = 'administrator'; #$scope = ''; $scopePath = JPATH_ROOT; $scopePath .=( $scope ) ? DS.$scope : ''; $scopePath .= DS.$comPath; $this->addReflectionFile('controllers', $scopePath.DS.'controller.php'); $types = array('controllers', 'models', 'tables'); foreach( $types as $type ) { if( ! isset($this->files[$type])) { $this->files[$type] = array(); } if( ! JFolder::exists($scopePath.DS.$type)) { continue; } $files = JFolder::files($scopePath.DS.$type); if( $files ) { foreach( $files as $file ) { $this->addReflectionFile($type, $scopePath.DS.$type.DS.$file); }//foreach } }//foreach if( ! isset($this->files['views']) ) { $this->files['views'] = array(); } if( JFolder::exists($scopePath.DS.'views')) { $views = JFolder::folders($scopePath.DS.'views'); foreach ($views as $view) { $files = JFolder::files($scopePath.DS.'views'.DS.$view); foreach ($files as $file) { $this->addReflectionFile('views', $scopePath.DS.'views'.DS.$view.DS.$file, $view); }//foreach }//foreach } break; default: echo 'Sorry '.$project->comtype.' not supported yet..'; break; } }//function function aj_reflectProject($project) { switch( $project->comtype ) { case 'component': $this->initBattleField(); $comPath = 'components'.DS.$project->com_com_name; // $scopes = array( 'administrator', ''); // foreach ($scopes as $scope) // { $scope = 'administrator'; #$scope = ''; $scopePath = JPATH_ROOT; $scopePath .=( $scope ) ? DS.$scope : ''; $scopePath .= DS.$comPath; $this->basePath = $scopePath; # $this->addReflectionFile('controllers', $scopePath.DS.'controller.php'); $this->aj_addFile('controllers', 'controller.php'); $types = array('controllers', 'models', 'tables'); ?> files[$type])) { $this->files[$type] = array(); } if( ! JFolder::exists($scopePath.DS.$type)) { continue; } $files = JFolder::files($scopePath.DS.$type); if( $files ) { foreach( $files as $file ) { # $this->addReflectionFile($type, $scopePath.DS.$type.DS.$file); $this->aj_addFile($type, $type.DS.$file); }//foreach } }//foreach if( ! isset($this->files['views']) ) { $this->files['views'] = array(); } if( JFolder::exists($scopePath.DS.'views')) { $views = JFolder::folders($scopePath.DS.'views'); foreach ($views as $view) { $files = JFolder::files($scopePath.DS.'views'.DS.$view); foreach ($files as $file) { ?> addReflectionFile('views', $scopePath.DS.'views'.DS.$view.DS.$file, $view); $this->aj_addFile('views', 'views'.DS.$view.DS.$file); }//foreach }//foreach } break; default: echo 'Sorry '.$project->comtype.' not supported yet..'; break; }//switch ?>
Models Tables
Controllers Views
'; print_r($this->declared_classes); echo '
';
	}//function
	
	public function addReflectionFile($type, $fileName, $subtype = '')
	{
		$allClasses = get_declared_classes();

		$rName = JFile::getName($fileName);
		if( $this->requireIfExists($fileName) )
		{
			$foundClasses = array_diff(get_declared_classes(), $allClasses);
			if( ! count($foundClasses))
			{
				ecrHTML::displayMessage(array(JText::_('No classes found'), $fileName),  'error');
				
				return false;
			}
			
			$reflection = new JObject();
			
			foreach( $foundClasses as $clas )
			{
				$theClass = new ReflectionClass($clas);
				$reflection->parentName = $theClass->getParentClass()->name;
				$properties = $theClass->getProperties();
				$cMethods =  $theClass->getMethods();
				
				$reflection->methods = array();
				foreach ($cMethods as $cMethod)
				{
					$mPath = $cMethod->getFileName();
#					echo '

'.$mPath.'

'; $pClass= $cMethod->getDeclaringClass(); $mPath= $cMethod->getDeclaringClass()->getFileName(); if( $mPath != $fileName ) { continue; } $s = $cMethod->getName(); $method = new JObject(); $method->name = $cMethod->getName(); $method->startLine = $cMethod->getStartLine(); $method->endLine = $cMethod->getEndLine(); $method->docComment = $cMethod->getDocComment(); $method->parameters = array(); $method->fileName = $mPath; #$reflection->methods[$s] = new JObject(); // } // if( $s != $displayClassName ) // { // // $indent++; // echo '

'; // # echo str_repeat("  ", $indent); // echo ( $displayClassName ) ? 'Extends '.$s : $s; // echo '

'; // $displayClassName = $s; // // } $paramString = array(); $parameters = $cMethod->getParameters(); foreach( $parameters as $parameter ) { $oParameter = new JObject(); $oParameter->name = $parameter->getName(); $oParameter->isOptional = $parameter->isOptional(); $oParameter->isPassedByReference = $parameter->isPassedByReference(); $oParameter->isDefaultValueAvailable = $parameter->isDefaultValueAvailable(); $method->parameters[] = $oParameter; #$color =($parameter->isOptional() ) ? 'blue' : 'brown'; $s = ''; $s .= sprintf("%s$%s", # $parameter->isOptional() ? 'optional ' : '', $parameter->isPassedByReference() ? ' & ' : '', $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 $paramString = implode(', ', $paramString); # $titel .= '( '.$paramString.' )'; switch ($type) { case 'controllers': $this->inspectMethod(&$method, $cMethod); break; case 'models': $this->inspectMethod(&$method, $cMethod); break; case 'views': $this->inspectMethod(&$method, $cMethod); break; case 'tables': $this->inspectMethod(&$method, $cMethod); break; default: echo '
No inspection for type '.$type.'
'; $method->jcommands = array(); break; }//switch $reflection->methods[] = $method; }//foreach methods if( $subtype ) { $this->files[$type][$subtype][$rName] = $reflection; } else { $this->files[$type][$rName] = $reflection; } }//foreach classes } }//function private function inspectMethod(&$method, $cMethod) { $fileName = $cMethod->getFileName(); $fileContents = explode("\n", JFile::read($fileName) ); $startLine = $cMethod->getStartLine(); $endLine = $cMethod->getEndLine(); $method->jcommands = array(); # echo '
';
		for( $i = $startLine-1; $i< $endLine; $i++)
		{
			
			//-- do we have a $this ?
			if( ! strpos($fileContents[$i], '$this') === false)
			{
#	echo $fileContents[$i].NL;
				$commandLine = trim($fileContents[$i]);
				$jCommand = new JObject();
				
				$jCommand->raw = trim($fileContents[$i]);
				$pattern = '/\$this->(\w+)/';//(\w+)/';
				preg_match($pattern, $commandLine, $matches);//, PREG_OFFSET_CAPTURE, 3);
#				print_r($matches);
				if( isset($matches[1]))
				{
					$paramString = trim(substr($commandLine, (strpos($commandLine, '$this') + strlen('$this->') + strlen($matches[1]))));
					if( substr($paramString, strlen($paramString)-1) == ';')
					{
						//-- we have a semicolon at end of line.. proceed
						$paramString = substr($paramString, 0,strlen($paramString)-1);
						if( substr($paramString,0,1) == '(')
						{
							$paramString = substr($paramString,1);
							if( substr($paramString, strlen($paramString)-1) == ')')
							{
								$paramString = substr($paramString, 0, strlen($paramString)-1);
							}
						}
		#				echo substr($paramString,0,1);
		#				echo substr($paramString, strlen($paramString)-1);
					}
					
#					echo $paramString.NL;
					$jCommand->name = $matches[1];
					$jCommand->params = $paramString;
					$pattern = '/\$this->(\w+)/';//(\w+)/';
					preg_match($pattern, $fileContents[$i], $matches);//, PREG_OFFSET_CAPTURE, 3);
	#				print_r($matches);
				$method->jcommands[] = $jCommand;
				}
			}
		}//for
#		echo '
'; }//function public function inspectTemplate($fileName) { $fileContents = explode("\n", JFile::read($fileName) ); $jCommands = array(); foreach ($fileContents as $line) { if( ! strpos($line, '$this') === false) { $jCommand = new JObject(); # echo $fileContents[$i].NL; $commandLine = trim($line); $jCommand->raw = $commandLine; $pattern = '/\$this->(\w+)/';//(\w+)/'; preg_match($pattern, $commandLine, $matches);//, PREG_OFFSET_CAPTURE, 3); if( isset($matches[1])) { $paramString = trim(substr($commandLine, (strpos($commandLine, '$this') + strlen('$this->') + strlen($matches[1])))); // if( substr($paramString, strlen($paramString)-1) == ';') // { // //-- we have a semicolon at end of line.. proceed // $paramString = substr($paramString, 0,strlen($paramString)-1); // if( substr($paramString,0,1) == '(') // { // $paramString = substr($paramString,1); // if( substr($paramString, strlen($paramString)-1) == ')') // { // $paramString = substr($paramString, 0, strlen($paramString)-1); // } // } // # echo substr($paramString,0,1); // # echo substr($paramString, strlen($paramString)-1); // } # echo $paramString.NL; $jCommand->name = $matches[1]; $jCommand->params = $paramString; $jCommands[] = $jCommand; } } }//foreach return $jCommands; }//function public function getReflections() { return $this->files; }//function private function requireIfExists($fileName) { if( file_exists($fileName) ) { include_once $fileName; return true; } if( defined( 'ECR_DEBUG')) ecrHTML::displayMessage(JText::sprintf('File %s not found', $fileName), 'error'); return false; }//function }//class