Location: PHPKode > projects > JavaScript PHP Window Manager > jpwm0.32/php/class.jphandler.php
<?php
	require_once 'class.window.php';
	require_once 'applications.php';


	// Include all app-specific functions
	$apps = getApplicationList('../apps/');
	foreach($apps as $info)
	{
		if($info[0] == 'php' && is_file('../apps/' . $info['file'] . '/functions.php'))
		{
			require_once '../apps/' . $info['file'] . '/functions.php';
		}
	}
	
	class jpHandler
	{
		function collectFromJS($args)
		{
			$args = explode(' ', $args);
			
			if(count($args) > 1)
				$args = $this->parseArgs($args);
			else
				array_push($args, '');
			
			$function = array_shift($args);
			
			if(is_callable($function))
			{
				return call_user_func($function, $args);
			}
			else
				return 'error: Function ' . $function .'() does not exist.';

				
		}
		
		// Finds strings within the arguments
		function parseArgs($parseArgs)
		{
			$returnArgs = array();
			$i = 0;
			$string = false;
			foreach($parseArgs as $arg)
			{
				if(substr($arg, 0, 1) == '"')
				{
					$returnArgs[$i] = $arg;
					$string = true;
				}
				elseif(substr($arg, -1, 1) == '"')
				{
					$returnArgs[$i] .= " ".$arg;
					$string = false;
				}
				elseif($string == true)
				{
					$returnArgs[$i] .= " ".$arg;
				}
				else
				{
					if(strlen($arg) > 0)
						$returnArgs[] .= $arg;
					$i++;
				}
			}
			return $returnArgs;
		}
	}
?>
Return current item: JavaScript PHP Window Manager