diff options
| -rw-r--r-- | .gitattributes | 4 | ||||
| -rw-r--r-- | demos/quickstart/protected/application.xml | 13 | ||||
| -rw-r--r-- | demos/quickstart/protected/logs/logger.xml | 9 | ||||
| -rw-r--r-- | framework/Collections/TList.php | 8 | ||||
| -rw-r--r-- | framework/Log/TEventLog.php | 40 | ||||
| -rw-r--r-- | framework/Log/TLog.php | 13 | ||||
| -rw-r--r-- | framework/Log/TLogManager.php (renamed from framework/Log/TEzcLogger.php) | 22 | ||||
| -rw-r--r-- | framework/TApplication.php | 6 | ||||
| -rw-r--r-- | framework/Web/Services/TPageService.php | 4 | ||||
| -rw-r--r-- | framework/Web/THttpRequest.php | 1 | ||||
| -rw-r--r-- | framework/Web/THttpResponse.php | 2 | ||||
| -rw-r--r-- | framework/Web/UI/TAssetManager.php | 1 | ||||
| -rw-r--r-- | framework/Web/UI/TControl.php | 3 | ||||
| -rw-r--r-- | framework/Web/UI/TForm.php | 1 | ||||
| -rw-r--r-- | framework/Web/UI/TPage.php | 24 | ||||
| -rw-r--r-- | framework/Web/UI/TPageStatePersister.php | 2 | ||||
| -rw-r--r-- | framework/Web/UI/TTemplateControl.php | 3 | ||||
| -rw-r--r-- | framework/Web/UI/TThemeManager.php | 1 | ||||
| -rw-r--r-- | framework/core.php | 12 | ||||
| -rw-r--r-- | framework/prado.php | 120 | ||||
| -rw-r--r-- | tools/phpbuilder/build.php | 54 | ||||
| -rw-r--r-- | tools/phpbuilder/files.txt | 2 | 
22 files changed, 226 insertions, 119 deletions
| diff --git a/.gitattributes b/.gitattributes index 0175b999..8c756097 100644 --- a/.gitattributes +++ b/.gitattributes @@ -31,7 +31,6 @@ demos/quickstart/protected/controls/SampleLayout.tpl -text  demos/quickstart/protected/controls/TTextHighlighter.php -text  demos/quickstart/protected/controls/TopicList.php -text  demos/quickstart/protected/controls/TopicList.tpl -text -demos/quickstart/protected/logs/logger.xml -text  demos/quickstart/protected/pages/Configurations/AppConfig.page -text  demos/quickstart/protected/pages/Configurations/Overview.page -text  demos/quickstart/protected/pages/Configurations/PageConfig.page -text @@ -145,8 +144,7 @@ framework/Log/EventLog/writers/writer_database.php -text  framework/Log/EventLog/writers/writer_file.php -text  framework/Log/EventLog/writers/writer_unix_file.php -text  framework/Log/TEventLog.php -text -framework/Log/TEzcLogger.php -text -framework/Log/TLog.php -text +framework/Log/TLogManager.php -text  framework/Security/TAuthManager.php -text  framework/Security/TAuthorizationRule.php -text  framework/Security/TMembershipManager.php -text diff --git a/demos/quickstart/protected/application.xml b/demos/quickstart/protected/application.xml index d456bd89..d9ae0f44 100644 --- a/demos/quickstart/protected/application.xml +++ b/demos/quickstart/protected/application.xml @@ -2,18 +2,13 @@  <application id="QuickStart" Mode="Debug">
    <modules>
 -	  <module id="logger" class="System.Log.TEventLog" config="protected/logs/logger.xml" >
 -<!-- Logging config can be here or in an external file specified by config=".." above -->
 -<!--
 -		<logger destination="file" directory="./protected/logs/" filename="prado.log">
 -			<filter severity="INFO | NOTICE | WARNING | ERROR | FATAL" />
 -			<filter severity="DEBUG" disabled="true" />
 -		</logger>
 --->
 -	</module>
 +	  <module id="logger" class="System.Log.TEventLog">
 +		<logger destination="file" directory="QuickStart.logs" filename="prado.log" />
 +	  </module>
    </modules>
    <paths>
      <alias id="Controls" path="controls" />
 +	<alias id="QuickStart" path="." />
      <using namespace="Controls.*" />
    </paths>
    <services>
 diff --git a/demos/quickstart/protected/logs/logger.xml b/demos/quickstart/protected/logs/logger.xml deleted file mode 100644 index c02e135a..00000000 --- a/demos/quickstart/protected/logs/logger.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
 -<config>
 - <loggers>
 -	<logger destination="file" directory="./protected/logs/" filename="prado.log">
 -		<filter severity="INFO | NOTICE | WARNING | ERROR | FATAL" />
 -		<filter severity="DEBUG" disabled="true" />
 -	</logger>
 - </loggers>
 -</config>
 diff --git a/framework/Collections/TList.php b/framework/Collections/TList.php index e9e143b2..232e39c6 100644 --- a/framework/Collections/TList.php +++ b/framework/Collections/TList.php @@ -85,6 +85,14 @@ class TList extends TComponent implements IteratorAggregate,ArrayAccess  	}
  	/**
 +	 * @return integer the number of items in the list
 +	 */
 +	public function getLength()
 +	{
 +		return $this->getCount();
 +	}
 +
 +	/**
  	 * Returns the item at the specified offset.
  	 * This method is exactly the same as {@link offsetGet}.
  	 * @param integer the index of the item
 diff --git a/framework/Log/TEventLog.php b/framework/Log/TEventLog.php index d291d3f5..8fb56618 100644 --- a/framework/Log/TEventLog.php +++ b/framework/Log/TEventLog.php @@ -1,7 +1,7 @@  <?php
 -require_once(dirname(__FILE__).'/TLog.php');
 -require_once(dirname(__FILE__).'/TEzcLogger.php');
 +Prado::using('System.Log.ILog');
 +Prado::using('System.Log.TLogManager');
  /**
   * ${classname}
 @@ -12,45 +12,67 @@ require_once(dirname(__FILE__).'/TEzcLogger.php');   * @version $Revision: 1.66 $  $Date: ${DATE} ${TIME} $
   * @package ${package}
   */
 -class TEventLog extends TEzcLogger implements TLog
 +class TEventLog extends TLogManager implements ILog
  {
 +	public function init($config)
 +	{
 +		parent::init($config);
 +		$this->collectInternalLog();
 +	}
 +
 +	public function __destruct()
 +	{
 +		$this->collectInternalLog();
 +	}
 +
 +	protected function collectInternalLog()
 +	{
 +		foreach(Prado::coreLog()->entries as $entry)
 +			$this->log($entry[0], $entry[1], $entry[2]);
 +		Prado::coreLog()->entries = array();
 +	}
  	public function info($msg, $source='Prado', $category='main')
  	{
 -		ezcLog::getInstance()->log($msg, ezcLog::INFO, 
 +		$this->log($msg, ezcLog::INFO, 
  				array('source'=>$source, 'category'=>$category));
  	}
  	public function debug($msg, $source='Prado', $category='main')
  	{
 -		ezcLog::getInstance()->log($msg, ezcLog::DEBUG, 
 +		$this->log($msg, ezcLog::DEBUG, 
  				array('source'=>$source, 'category'=>$category));
  	}
  	public function notice($msg, $source='Prado', $category='main')
  	{
 -		ezcLog::getInstance()->log($msg, ezcLog::NOTICE, 
 +		$this->log($msg, ezcLog::NOTICE, 
  				array('source'=>$source, 'category'=>$category));
  	}
  	public function warn($msg, $source='Prado', $category='main')
  	{
 -		ezcLog::getInstance()->log($msg, ezcLog::WARNING, 
 +		$this->log($msg, ezcLog::WARNING, 
  				array('source'=>$source, 'category'=>$category));
  	}
  	public function error($msg, $source='Prado', $category='main')
  	{
 -		ezcLog::getInstance()->log($msg, ezcLog::NOTICE, 
 +		$this->log($msg, ezcLog::NOTICE, 
  				array('source'=>$source, 'category'=>$category));
  	}
  	public function fatal($msg, $source='Prado', $category='main')
  	{
 -		ezcLog::getInstance()->log($msg, ezcLog::NOTICE, 
 +		$this->log($msg, ezcLog::NOTICE, 
  				array('source'=>$source, 'category'=>$category));
  	}
 +
 +	protected function log($msg, $code, $info)
 +	{
 +		ezcLog::getInstance()->log($msg, $code, $info);
 +	}
  }
  ?>
\ No newline at end of file diff --git a/framework/Log/TLog.php b/framework/Log/TLog.php deleted file mode 100644 index 0a455c84..00000000 --- a/framework/Log/TLog.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php
 -
 -interface TLog
 -{
 -	public function info($msg, $source='Prado', $category='main');
 -	public function debug($msg, $source='Prado', $category='main');
 -	public function notice($msg, $source='Prado', $category='main');
 -	public function warn($msg, $source='Prado', $category='main');
 -	public function error($msg, $source='Prado', $category='main');
 -	public function fatal($msg, $source='Prado', $category='main');
 -}
 -
 -?>
\ No newline at end of file diff --git a/framework/Log/TEzcLogger.php b/framework/Log/TLogManager.php index 11fe6c7f..dba96e3a 100644 --- a/framework/Log/TEzcLogger.php +++ b/framework/Log/TLogManager.php @@ -1,6 +1,6 @@  <?php
 -abstract class TEzcLogger extends TModule
 +abstract class TLogManager extends TModule
  {
  	protected $defaultSeverity = 'INFO | DEBUG | NOTICE | WARNING | ERROR | FATAL';
 @@ -27,12 +27,12 @@ abstract class TEzcLogger extends TModule  		TEzcLoggerLoader::using('ezcLogMap');
  		TEzcLoggerLoader::using('ezcLogContext');
  		TEzcLoggerLoader::using('ezcLogFilter');
 -		$loggers = $xml->getElementsByTagName('logger');
 +
  		$log = ezcLog::getInstance();
 -		foreach($loggers as $logger)
 +		foreach($xml->getElementsByTagName('logger') as $logger)
  		{
 -			$filters = $logger->getElementsByTagName('filter');
  			$logWriter = $this->getLogWriter($logger);
 +			$filters = $logger->getElementsByTagName('filter');
  			foreach($filters as $filter)
  			{
  				$logFilter = new ezcLogFilter();
 @@ -41,6 +41,13 @@ abstract class TEzcLogger extends TModule  				$map = $filter->getAttribute('disabled') ? 'unmap' : 'map';
  				$log->$map($logFilter, $logWriter);
  			}
 +
 +			if($filters->Length < 1)
 +			{
 +				$logFilter = new ezcLogFilter();
 +				$logFilter->severity = $this->getFilterSeverity();
 +				$log->map($logFilter, $logWriter);
 +			}
  		}
  	}
 @@ -55,10 +62,10 @@ abstract class TEzcLogger extends TModule  		}
  	}
 -	protected function getFilterSeverity($string)
 +	protected function getFilterSeverity($string='')
  	{
  		if(empty($string))
 -			$string = $this->defaultServerity;
 +			$string = $this->defaultSeverity;
  		$serverities = explode("|", $string);
  		$mask = 0;
  		foreach($serverities as $Severity)
 @@ -101,7 +108,8 @@ class TEzcLoggerUnixFileWriterFactory  		TEzcLoggerLoader::using('ezcLogWriterFile');
  		TEzcLoggerLoader::using('ezcLogWriterUnixFile');
 -		$dir = $xml->getAttribute('directory');
 +		$path = $xml->getAttribute('directory');
 +		$dir = Prado::getPathOfNamespace($path);
  		$file = $xml->getAttribute('filename');
  		if(empty($file)) $file = 'prado.log';
  		return new ezcLogWriterUnixFile($dir, $file);
 diff --git a/framework/TApplication.php b/framework/TApplication.php index 60fc25b3..0e808858 100644 --- a/framework/TApplication.php +++ b/framework/TApplication.php @@ -35,6 +35,7 @@ require_once(PRADO_DIR.'/Security/TAuthorizationRule.php');   */  require_once(PRADO_DIR.'/Web/Services/TPageService.php'); +  /**   * TApplication class.   * @@ -301,6 +302,7 @@ class TApplication extends TComponent  				if($this->_mode===self::STATE_OFF)  					throw new THttpException(503,'application_service_unavailable');  				$method='on'.self::$_steps[$this->_step]; +				Prado::coreLog("Executing $method");  				$this->$method($this);  				if($this->_requestCompleted && $this->_step<$n-1)  					$this->_step=$n-1; @@ -709,6 +711,7 @@ class TApplication extends TComponent  	 */  	protected function initApplication()  	{ +		Prado::coreLog("Initializing application");  		Prado::setPathOfAlias('Application',$this->_basePath);  		if($this->_configFile===null) @@ -730,7 +733,7 @@ class TApplication extends TComponent  					fclose($fp);  				}  				else -					syslog(LOG_WARNING,'Prado application config cache file "'.$this->_cacheFile.'" cannot be created.'); +					syslog(LOG_WARNING, 'Prado application config cache file "'.$this->_cacheFile.'" cannot be created.');  			}  		}  		else @@ -767,6 +770,7 @@ class TApplication extends TComponent  		$this->_modules=array();  		foreach($config->getModules() as $id=>$moduleConfig)  		{ +			Prado::coreLog("Creating module $id");  			$module=Prado::createComponent($moduleConfig[0]);  			$this->_modules[$id]=$module;  			foreach($moduleConfig[1] as $name=>$value) diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php index 5723269f..8f12c650 100644 --- a/framework/Web/Services/TPageService.php +++ b/framework/Web/Services/TPageService.php @@ -146,6 +146,7 @@ class TPageService extends TService  	 */
  	public function init($config)
  	{
 +		Prado::coreLog("Initializing TPageService");
  		$application=$this->getApplication();
  		$application->setPageService($this);
 @@ -250,6 +251,7 @@ class TPageService extends TService  		// load modules specified in page directory config
  		foreach($pageConfig->getModules() as $id=>$moduleConfig)
  		{
 +			Prado::coreLog("Loading module $id");
  			$module=Prado::createComponent($moduleConfig[0]);
  			$application->setModule($id,$module);
  			foreach($moduleConfig[1] as $name=>$value)
 @@ -425,6 +427,7 @@ class TPageService extends TService  	 */
  	public function run()
  	{
 +		Prado::coreLog("Running page service");
  		$page=null;
  		$path=$this->_basePath.'/'.strtr($this->_pagePath,'.','/');
  		if(is_file($path.self::PAGE_FILE_EXT))
 @@ -611,6 +614,7 @@ class TPageConfiguration extends TComponent  	 */
  	private function loadFromFile($fname,$page)
  	{
 +		Prado::coreLog("Loading $page with file $fname");
  		if(empty($fname) || !is_file($fname))
  			return;
  		$dom=new TXmlDocument;
 diff --git a/framework/Web/THttpRequest.php b/framework/Web/THttpRequest.php index c3c9e33d..bb2eb7b4 100644 --- a/framework/Web/THttpRequest.php +++ b/framework/Web/THttpRequest.php @@ -373,6 +373,7 @@ class THttpRequest extends TModule  				break;
  			}
  		}
 +		Prado::coreLog("Resolving request {$this->_serviceID}={$this->_serviceParam}");
  	}
  	/**
 diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php index ba2f607c..ecaf59d0 100644 --- a/framework/Web/THttpResponse.php +++ b/framework/Web/THttpResponse.php @@ -232,6 +232,7 @@ class THttpResponse extends TModule implements ITextWriter  	{
  		if($this->_bufferOutput)
  			ob_flush();
 +		Prado::coreLog("Flushing output");
  	}
  	/**
 @@ -241,6 +242,7 @@ class THttpResponse extends TModule implements ITextWriter  	{
  		if($this->_bufferOutput)
  			ob_clean();
 +		Prado::coreLog("Clearing output");
  	}
  	/**
 diff --git a/framework/Web/UI/TAssetManager.php b/framework/Web/UI/TAssetManager.php index 0cce2c27..1ff0f47a 100644 --- a/framework/Web/UI/TAssetManager.php +++ b/framework/Web/UI/TAssetManager.php @@ -141,6 +141,7 @@ class TAssetManager extends TModule  	 */
  	public function publishFilePath($path,$checkTimestamp=false)
  	{
 +		Prado::coreLog("Publishing file $path");
  		if(isset($this->_published[$path]))
  			return $this->_published[$path];
  		else if(($fullpath=realpath($path))===false)
 diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 34e9b92f..3ba79478 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -683,8 +683,11 @@ class TControl extends TComponent  	 */
  	public function dataBind()
  	{
 +		Prado::coreLog("Data bind properties");
  		$this->dataBindProperties();
 +		Prado::coreLog("onDataBinding()");
  		$this->onDataBinding(null);
 +		Prado::coreLog("dataBindChildren()");
  		$this->dataBindChildren();
  	}
 diff --git a/framework/Web/UI/TForm.php b/framework/Web/UI/TForm.php index 4cb97911..28c6c3aa 100644 --- a/framework/Web/UI/TForm.php +++ b/framework/Web/UI/TForm.php @@ -53,6 +53,7 @@ class TForm extends TControl  	 */
  	protected function render($writer)
  	{
 +		Prado::coreLog("Rendering form ".$this->getName());
  		$this->addAttributesToRender($writer);
  		$writer->renderBeginTag('form');
  		$page=$this->getPage();
 diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 624ed550..2269079b 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -133,38 +133,59 @@ class TPage extends TTemplateControl  	 */
  	public function run($writer)
  	{
 +		Prado::coreLog("Running page life cycles");
  		$this->determinePostBackMode();
 -
 +		
 +		Prado::coreLog("Page onPreInit()");
  		$this->onPreInit(null);
 +		Prado::coreLog("Page initRecursive()");
  		$this->initRecursive();
 +		Prado::coreLog("Page onInitComplete()");
  		$this->onInitComplete(null);
  		if($this->getIsPostBack())
  		{
  			$this->_restPostData=new TMap;
 +			Prado::coreLog("Page loadPageState()");
  			$this->loadPageState();
 +			Prado::coreLog("Page processPostData()");
  			$this->processPostData($this->_postData,true);
 +			Prado::coreLog("Page onPreLoad()");
  			$this->onPreLoad(null);
 +			Prado::coreLog("Page loadRecursive()");
  			$this->loadRecursive();
 +			Prado::coreLog("Page processPostData()");
  			$this->processPostData($this->_restPostData,false);
 +			Prado::coreLog("Page raiseChangedEvents()");
  			$this->raiseChangedEvents();
 +			Prado::coreLog("Page raisePostBackEvent()");
  			$this->raisePostBackEvent();
 +			Prado::coreLog("Page onLoadComplete()");
  			$this->onLoadComplete(null);
  		}
  		else
  		{
 +			Prado::coreLog("Page onPreLoad()");
  			$this->onPreLoad(null);
 +			Prado::coreLog("Page loadRecursive()");
  			$this->loadRecursive();
 +			Prado::coreLog("Page onLoadComplete()");
  			$this->onLoadComplete(null);
  		}
 +		Prado::coreLog("Page preRenderRecursive()");
  		$this->preRenderRecursive();
 +		Prado::coreLog("Page onPreRenderComplete()");
  		$this->onPreRenderComplete(null);
 +		Prado::coreLog("Page savePageState()");
  		$this->savePageState();
 +		Prado::coreLog("Page onSaveStateComplete()");
  		$this->onSaveStateComplete(null);
 +		Prado::coreLog("Page renderControl()");
  		$this->renderControl($writer);
 +		Prado::coreLog("Page unloadRecursive()");
  		$this->unloadRecursive();
  	}
 @@ -263,6 +284,7 @@ class TPage extends TTemplateControl  		$this->_validated=true;
  		if($this->_validators && $this->_validators->getCount())
  		{
 +			Prado::coreLog("Page validate");
  			if($validationGroup==='')
  			{
  				foreach($this->_validators as $validator)
 diff --git a/framework/Web/UI/TPageStatePersister.php b/framework/Web/UI/TPageStatePersister.php index d312ed84..2711041a 100644 --- a/framework/Web/UI/TPageStatePersister.php +++ b/framework/Web/UI/TPageStatePersister.php @@ -52,6 +52,7 @@ class TPageStatePersister extends TModule implements IStatePersister  	 */
  	public function save($state)
  	{
 +		Prado::coreLog("Saving state");
  		$data=Prado::serialize($state);
  		$hmac=$this->computeHMAC($data,$this->getPrivateKey());
  		if(extension_loaded('zlib'))
 @@ -68,6 +69,7 @@ class TPageStatePersister extends TModule implements IStatePersister  	 */
  	public function load()
  	{
 +		Prado::coreLog("Loading state");
  		$str=base64_decode($this->getApplication()->getRequest()->getItems()->itemAt(TPage::FIELD_PAGESTATE));
  		if($str==='')
  			return null;
 diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php index 9987bc9c..a25a2e41 100644 --- a/framework/Web/UI/TTemplateControl.php +++ b/framework/Web/UI/TTemplateControl.php @@ -101,8 +101,9 @@ class TTemplateControl extends TControl implements INamingContainer  	 */
  	protected function loadTemplate()
  	{
 +		Prado::coreLog("Loading template ".get_class($this));
  		$template=$this->getService()->getTemplateManager()->getTemplateByClassName(get_class($this));
 -		self::$_template[get_class($this)]=$template;
 +		self::$_template[get_class($this)]=$template;		
  		return $template;
  	}
 diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php index bbcd35a6..73745254 100644 --- a/framework/Web/UI/TThemeManager.php +++ b/framework/Web/UI/TThemeManager.php @@ -313,6 +313,7 @@ class TTheme extends TComponent  		{
  			foreach($this->_skins[$type][$id] as $name=>$value)
  			{
 +				Prado::coreLog("Applying skin $name to $type");
  				if(is_array($value))
  				{
  					if($value[0]===TTemplate::CONFIG_EXPRESSION)
 diff --git a/framework/core.php b/framework/core.php index 5c9156e5..b2ae1d45 100644 --- a/framework/core.php +++ b/framework/core.php @@ -42,6 +42,8 @@ require_once(PRADO_DIR.'/Data/TXmlDocument.php');   */
  require_once(PRADO_DIR.'/Web/THttpUtility.php');
 +require_once(PRADO_DIR.'/Log/ILog.php');
 +
  /**
   * IModule interface.
   *
 @@ -770,6 +772,16 @@ class PradoBase  		}
  		return $language;
  	}
 +
 +	public static function coreLog($msg=null)
 +	{
 +		static $logger;
 +		if(is_null($logger))
 +			$logger = new TInternalLogger();
 +		if(!empty($msg))
 +			$logger->info($msg);
 +		return $logger;
 +	}
  }
  ?>
\ No newline at end of file diff --git a/framework/prado.php b/framework/prado.php index ed6a4f49..844394f7 100644 --- a/framework/prado.php +++ b/framework/prado.php @@ -1,61 +1,61 @@ -<?php -/** - * Prado bootstrap file. - * - * This file is intended to be included in the entry script of Prado applications. - * It defines Prado class by extending PradoBase, a static class providing globally - * available functionalities to Prado applications. It also sets PHP error and - * exception handler functions, and provides a __autoload function which automatically - * loads a class file if the class is not defined. - * - * @author Qiang Xue <qiang.xue@gmail.com> - * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005 PradoSoft - * @license http://www.pradosoft.com/license/ - * @version $Revision: $  $Date: $ - * @package System - */ - -/** - * Includes the Prado core header file - */ -require_once(dirname(__FILE__).'/core.php'); - -/** - * Defines Prado class if not defined. - */ -if(!class_exists('Prado',false)) -{ -	class Prado extends PradoBase -	{ -	} -} - -/** - * Defines __autoload function if not defined. - */ -if(!function_exists('__autoload')) -{ -	function __autoload($className) -	{ -		include_once($className.Prado::CLASS_FILE_EXT); -		if(!class_exists($className,false)) -			Prado::fatalError("Class file for '$className' cannot be found."); -	} -} - -/** - * Sets error handler to be Prado::phpErrorHandler - */ -set_error_handler(array('Prado','phpErrorHandler'),error_reporting()); -/** - * Sets exception handler to be Prado::exceptionHandler - */ -set_exception_handler(array('Prado','exceptionHandler')); - -/** - * Includes TApplication class file - */ -require_once(dirname(__FILE__).'/TApplication.php'); - +<?php
 +/**
 + * Prado bootstrap file.
 + *
 + * This file is intended to be included in the entry script of Prado applications.
 + * It defines Prado class by extending PradoBase, a static class providing globally
 + * available functionalities to Prado applications. It also sets PHP error and
 + * exception handler functions, and provides a __autoload function which automatically
 + * loads a class file if the class is not defined.
 + *
 + * @author Qiang Xue <qiang.xue@gmail.com>
 + * @link http://www.pradosoft.com/
 + * @copyright Copyright © 2005 PradoSoft
 + * @license http://www.pradosoft.com/license/
 + * @version $Revision: $  $Date: $
 + * @package System
 + */
 +
 +/**
 + * Includes the Prado core header file
 + */
 +require_once(dirname(__FILE__).'/core.php');
 +
 +/**
 + * Defines Prado class if not defined.
 + */
 +if(!class_exists('Prado',false))
 +{
 +	class Prado extends PradoBase
 +	{
 +	}
 +}
 +
 +/**
 + * Defines __autoload function if not defined.
 + */
 +if(!function_exists('__autoload'))
 +{
 +	function __autoload($className)
 +	{
 +		include_once($className.Prado::CLASS_FILE_EXT);
 +		if(!class_exists($className,false))
 +			Prado::fatalError("Class file for '$className' cannot be found.");
 +	}
 +}
 +
 +/**
 + * Sets error handler to be Prado::phpErrorHandler
 + */
 +set_error_handler(array('Prado','phpErrorHandler'),error_reporting());
 +/**
 + * Sets exception handler to be Prado::exceptionHandler
 + */
 +set_exception_handler(array('Prado','exceptionHandler'));
 +
 +/**
 + * Includes TApplication class file
 + */
 +require_once(dirname(__FILE__).'/TApplication.php');
 +
  ?>
\ No newline at end of file diff --git a/tools/phpbuilder/build.php b/tools/phpbuilder/build.php index a96ab12f..24626b85 100644 --- a/tools/phpbuilder/build.php +++ b/tools/phpbuilder/build.php @@ -42,14 +42,58 @@ foreach($lines as $line)  		continue;
  	echo 'adding '.FRAMEWORK_DIR.'/'.$line."\n";
  	$input=file_get_contents(FRAMEWORK_DIR.'/'.$line);
 -	$input=strtr($input,"\r",'');
 -	$input=preg_replace('/\/\*.*?\*\//s','',$input);
 -	$input=preg_replace('/^Prado::using\([^\*]*?\);/m','',$input);
 -	$input=preg_replace('/^(require|require_once)\s*\(.*?;/m','',$input);
 -	$input=preg_replace('/^(include|include_once)\s*\(.*?;/m','',$input);
 +	$input = strip_comments($input);
 +	$input=strtr($input,"\r",' ');
 +	$input=preg_replace("/\s*(\n+\s*){2,}\s*/m","\n",$input);
 +	$input=preg_replace('/^Prado::using\([^\*]*?\);/mu','',$input);
 +	$input=preg_replace('/^(require|require_once)\s*\(.*?;/mu','',$input);
 +	$input=preg_replace('/^(include|include_once)\s*\(.*?;/mu','',$input);
 +
 +	//remove internal logging
 +	$input=preg_replace('/^\s*Prado::coreLog.*\s*;\s*$/mu','',$input);
 +
  	$output.=$input;
  }
  file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$output);
 +function strip_comments($source)
 +{
 +  $tokens = token_get_all($source);
 +  /* T_ML_COMMENT does not exist in PHP 5.
 +   * The following three lines define it in order to
 +   * preserve backwards compatibility.
 +   *
 +   * The next two lines define the PHP 5-only T_DOC_COMMENT,
 +   * which we will mask as T_ML_COMMENT for PHP 4.
 +   */
 +  if (!defined('T_ML_COMMENT')) {
 +    @define('T_ML_COMMENT', T_COMMENT);
 +  } else {
 +    @define('T_DOC_COMMENT', T_ML_COMMENT);
 +  }
 +  $output = '';
 +  foreach ($tokens as $token) {
 +    if (is_string($token)) {
 +      // simple 1-character token
 +      $output .= $token;
 +    } else {
 +      // token array
 +      list($id, $text) = $token;
 +      switch ($id) { 
 +        case T_COMMENT: 
 +        case T_ML_COMMENT: // we've defined this
 +        case T_DOC_COMMENT: // and this
 +          // no action on comments
 +          break;
 +        default:
 +          // anything else -> output "as is"
 +          $output .= $text;
 +          break;
 +      }
 +    }
 +  }
 +  return $output;
 +}
 +
  ?>
\ No newline at end of file diff --git a/tools/phpbuilder/files.txt b/tools/phpbuilder/files.txt index 22218685..011259de 100644 --- a/tools/phpbuilder/files.txt +++ b/tools/phpbuilder/files.txt @@ -16,7 +16,7 @@ Web/Services/TPageService.php  Web/UI/TTemplateManager.php
  Web/UI/TThemeManager.php
  Web/UI/TAssetManager.php
 -Web/UI/THiddenFieldPageStatePersister.php
 +Web/UI/TPageStatePersister.php
  Web/UI/TControl.php
  Web/UI/TTemplateControl.php
  Web/UI/TForm.php
 | 
