summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-03-31 16:16:36 +0000
committerxue <>2006-03-31 16:16:36 +0000
commitcf5bdd1f8f3919f06ee3f8de9d71ff156fada0ab (patch)
treee7d120d76412643e6ff0c5719ecafb85751a7d5d
parente1aa60ec21bed10014d1ca9316910c36e8d43ee3 (diff)
Updated the script for generating pradolite.php.
-rw-r--r--.gitattributes1
-rw-r--r--buildscripts/phpbuilder/build.php184
-rw-r--r--buildscripts/phpbuilder/files.txt102
-rw-r--r--framework/Web/UI/TPage.php2
-rw-r--r--framework/Web/UI/TPageStatePersister.php2
5 files changed, 117 insertions, 174 deletions
diff --git a/.gitattributes b/.gitattributes
index c36622ca..738db28d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -16,7 +16,6 @@ buildscripts/phing/tasks/PhpLintTask.php -text
buildscripts/phing/tasks/XmlLintTask.php -text
buildscripts/phing/tasks/ZendCodeAnalyzerTask.php -text
buildscripts/phpbuilder/build.php -text
-buildscripts/phpbuilder/files.txt -text
buildscripts/setup.php -text
buildscripts/texbuilder/build.php -text
buildscripts/texbuilder/prado3_quick_start.pdf -text
diff --git a/buildscripts/phpbuilder/build.php b/buildscripts/phpbuilder/build.php
index 4f427388..e95b9ea7 100644
--- a/buildscripts/phpbuilder/build.php
+++ b/buildscripts/phpbuilder/build.php
@@ -3,8 +3,15 @@
/**
* Prado build file.
*
- * This script compresses a list of Prado PHP script files
- * and merges them into one for performance redistribution.
+ * This is a command line script that can be run simply by "php build.php".
+ *
+ * This script expands prado.php into a file that contains the content
+ * of prado.php and all its included (directly or indirectly) files.
+ * Comments and trace statements are stripped off to further improve
+ * performance.
+ *
+ * The generated file is named pradolite.php and is placed under the
+ * 'framework' directory.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.pradosoft.com/
@@ -15,88 +22,127 @@
*/
/**
- * The merged file name
- */
-define('OUTPUT_FILE','pradolite.php');
-/**
* The framework directory
*/
define('FRAMEWORK_DIR',realpath(dirname(__FILE__).'/../../framework'));
/**
- * The file containing script list to be built
+ * The merged file name
*/
-define('SCRIPT_FILES',dirname(__FILE__).'/files.txt');
+define('OUTPUT_FILE','pradolite.php');
-if(FRAMEWORK_DIR===false)
+
+if(FRAMEWORK_DIR===false || !is_file(FRAMEWORK_DIR.'/prado.php'))
die('Unable to determine the installation directory of Prado Framework.');
-if(!is_file(SCRIPT_FILES))
- die('Unable to read '.SCRIPT_FILES.'.');
-$output='';
+$lastupdate=date('Y/m/d H:i:s');
+$comments="
+/**
+ * File Name: pradolite.php
+ * Last Update: $lastupdate
+ * Generated By: buildscripts/phpbuilder/build.php
+ *
+ * This file is used in lieu of prado.php to boost PRADO application performance.
+ * It is generated by expanding prado.php with included files.
+ * Comments and trace statements are stripped off.
+ *
+ * Do not modify this file manually.
+ */
+";
-$lines=file(SCRIPT_FILES);
-foreach($lines as $line)
-{
- $line=trim($line);
- if($line==='' || $line[0]==='#')
- continue;
- echo 'adding '.FRAMEWORK_DIR.'/'.$line."\n";
- $input=file_get_contents(FRAMEWORK_DIR.'/'.$line);
- $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);
- $input=preg_replace('/^\s*/m','',$input);
+$content=unfold_file(FRAMEWORK_DIR.'/prado.php');
+$content="<?php\n".preg_replace('/^(\?>|<\?php)/mu','',$content)."\n?>";
+$content=strip_comments($content);
+$content=preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$content);
+$content=strip_empty_lines($content);
+$content=substr_replace($content,$comments,5,0);
+file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$content);
+echo "Done.\n";
- //remove internal logging
- $input=preg_replace('/^\s*Prado::trace.*\s*;\s*$/mu','',$input);
+exit();
- $output.=$input;
+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;
}
-$output=str_replace('?><?php','',$output);
-
-file_put_contents(FRAMEWORK_DIR.'/'.OUTPUT_FILE,$output);
+function strip_empty_lines($string)
+{
+ $string = preg_replace("/[\r\n]+[\s\t]*[\r\n]+/", "\n", $string);
+ $string = preg_replace("/^[\s\t]*[\r\n]+/", "", $string);
+ return $string;
+}
-function strip_comments($source)
+function unfold_file($fileName)
{
- $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;
+ static $unfoldedFiles=array();
+ $pattern='^(Prado::using|require_once|include_once)\s*\(([^\*]*?)\);';
+ echo "adding $fileName...\n";
+ $content=file_get_contents($fileName);
+ while(preg_match("/$pattern/m",$content,$matches,PREG_OFFSET_CAPTURE))
+ {
+ $offset=$matches[0][1];
+ $length=strlen($matches[0][0]);
+ $type=$matches[1][0];
+ $file=trim($matches[2][0],"'\"");
+ if($type==='Prado::using')
+ {
+ $file=substr_replace(strtr($file,'.','/'),FRAMEWORK_DIR,0,6).'.php';
+ }
+ else
+ {
+ $file=strtr($file,'"',"'");
+ if(($pos=strpos($file,"'"))!==false)
+ $file=FRAMEWORK_DIR.'/'.substr($file,$pos+1);
+ else
+ die('Unable to process file '.$fileName.' about '.$matches[0][0]);
+ }
+ if(($file=realpath($file))===false || !is_file($file))
+ die('Unable to process file '.$fileName.' about '.$matches[0][0]);
+ if(isset($unfoldedFiles[$file]))
+ {
+ $content=substr_replace($content,'',$offset,$length);
+ }
+ else
+ {
+ $unfoldedFiles[$file]=true;
+ $content=substr_replace($content,unfold_file($file),$offset,$length);
+ }
+ }
+ return $content;
}
?> \ No newline at end of file
diff --git a/buildscripts/phpbuilder/files.txt b/buildscripts/phpbuilder/files.txt
deleted file mode 100644
index 2c5e03f6..00000000
--- a/buildscripts/phpbuilder/files.txt
+++ /dev/null
@@ -1,102 +0,0 @@
-TComponent.php
-TApplicationComponent.php
-Exceptions/TException.php
-
-Collections/TList.php
-Collections/TMap.php
-Collections/TStack.php
-Collections/TAttributeCollection.php
-# Collections/TPagedDataSource.php
-# Collections/TDummyDataSource.php
-
-Xml/TXmlDocument.php
-Web/THttpUtility.php
-Web/Javascripts/TJavaScript.php
-Data/TCache.php
-Log/TLogger.php
-
-core.php
-prado.php
-TApplication.php
-
-Exceptions/TErrorHandler.php
-Web/THttpRequest.php
-Web/THttpResponse.php
-Web/THttpSession.php
-Web/TAssetManager.php
-Security/TAuthorizationRule.php
-Security/TSecurityManager.php
-Web/Services/TPageService.php
-Web/UI/THtmlWriter.php
-Web/UI/TTemplateManager.php
-Web/UI/TThemeManager.php
-Web/UI/TControlAdapter.php
-Web/UI/TControl.php
-Web/UI/TTemplateControl.php
-Web/UI/TForm.php
-Web/UI/TClientScriptManager.php
-Web/UI/TPage.php
-Web/UI/TPageStatePersister.php
-Web/UI/WebControls/TFont.php
-Web/UI/WebControls/TStyle.php
-Web/UI/WebControls/TWebControlAdapter.php
-Web/UI/WebControls/TWebControl.php
-# Web/UI/WebControls/TPlaceHolder.php
-# Web/UI/WebControls/TLiteral.php
-# Web/UI/WebControls/TLabel.php
-# Web/UI/WebControls/TImage.php
-# Web/UI/WebControls/TImageButton.php
-# Web/UI/WebControls/TButton.php
-# Web/UI/WebControls/TCheckBox.php
-# Web/UI/WebControls/TRadioButton.php
-# Web/UI/WebControls/TTextBox.php
-# Web/UI/WebControls/TTextHighlighter.php
-# Web/UI/WebControls/TPanel.php
-Web/UI/WebControls/TContent.php
-Web/UI/WebControls/TContentPlaceHolder.php
-Web/UI/WebControls/TExpression.php
-Web/UI/WebControls/TStatements.php
-# Web/UI/WebControls/TFileUpload.php
-Web/UI/WebControls/THead.php
-# Web/UI/WebControls/THiddenField.php
-# Web/UI/WebControls/THyperLink.php
-# Web/UI/WebControls/TTableCell.php
-# Web/UI/WebControls/TTableHeaderCell.php
-# Web/UI/WebControls/TTableRow.php
-# Web/UI/WebControls/TTable.php
-
-# Web/UI/WebControls/TDataSourceControl.php
-# Web/UI/WebControls/TDataSourceView.php
-
-# Web/UI/WebControls/TDataBoundControl.php
-# Web/UI/WebControls/TCheckBoxList.php
-# Web/UI/WebControls/TRadioButtonList.php
-# Web/UI/WebControls/TBulletedList.php
-
-# Web/UI/WebControls/TListControl.php
-# Web/UI/WebControls/TListBox.php
-# Web/UI/WebControls/TDropDownList.php
-
-# Web/UI/WebControls/TJavascriptLogger.php
-# Web/UI/WebControls/TLinkButton.php
-
-# Web/UI/WebControls/TBaseValidator.php
-# Web/UI/WebControls/TRequiredFieldValidator.php
-# Web/UI/WebControls/TCompareValidator.php
-# Web/UI/WebControls/TRegularExpressionValidator.php
-# Web/UI/WebControls/TEmailAddressValidator.php
-# Web/UI/WebControls/TCustomValidator.php
-# Web/UI/WebControls/TValidationSummary.php
-
-# Web/UI/WebControls/TRepeatInfo.php
-# Web/UI/WebControls/TRepeater.php
-
-# Web/UI/WebControls/TBaseDataList.php
-# Web/UI/WebControls/TDataList.php
-# Web/UI/WebControls/TDataGrid.php
-# Web/UI/WebControls/TDataGridColumn.php
-# Web/UI/WebControls/TBoundColumn.php
-# Web/UI/WebControls/TButtonColumn.php
-# Web/UI/WebControls/TEditCommandColumn.php
-# Web/UI/WebControls/THyperLinkColumn.php
-# Web/UI/WebControls/TTemplateColumn.php
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index e13f21c1..b68c4996 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -568,6 +568,7 @@ class TPage extends TTemplateControl
*/
protected function loadPageState()
{
+ Prado::trace("Loading state",'System.Web.UI.TPage');
$state=$this->getStatePersister()->load();
$this->loadStateRecursive($state,$this->getEnableViewState());
}
@@ -577,6 +578,7 @@ class TPage extends TTemplateControl
*/
protected function savePageState()
{
+ Prado::trace("Saving state",'System.Web.UI.TPage');
$state=&$this->saveStateRecursive($this->getEnableViewState());
$this->getStatePersister()->save($state);
}
diff --git a/framework/Web/UI/TPageStatePersister.php b/framework/Web/UI/TPageStatePersister.php
index b16d9f7d..3551b5f6 100644
--- a/framework/Web/UI/TPageStatePersister.php
+++ b/framework/Web/UI/TPageStatePersister.php
@@ -54,7 +54,6 @@ class TPageStatePersister extends TApplicationComponent implements IPageStatePer
*/
public function save($state)
{
- Prado::trace("Saving state",'System.Web.UI.TPageStatePersister');
if($this->_page->getEnableStateValidation())
$data=$this->getApplication()->getSecurityManager()->hashData(Prado::serialize($state));
else
@@ -73,7 +72,6 @@ class TPageStatePersister extends TApplicationComponent implements IPageStatePer
*/
public function load()
{
- Prado::trace("Loading state",'System.Web.UI.TPageStatePersister');
$str=base64_decode($this->getRequest()->itemAt(TPage::FIELD_PAGESTATE));
if($str==='')
return null;