summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes2
-rw-r--r--HISTORY5
-rw-r--r--buildscripts/classtree/build.php6
-rw-r--r--buildscripts/texbuilder/build.php12
-rw-r--r--buildscripts/texbuilder/quickstart.tex (renamed from buildscripts/texbuilder/prado3_quick_start.tex)0
-rw-r--r--demos/quickstart/protected/controls/Layout.tpl2
-rw-r--r--framework/Web/Services/TPageService.php27
-rw-r--r--framework/Web/UI/TTemplateManager.php78
-rw-r--r--framework/Web/UI/TThemeManager.php2
-rw-r--r--framework/Web/UI/WebControls/TBaseValidator.php38
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php4
-rw-r--r--framework/Web/UI/WebControls/TDataList.php4
-rw-r--r--framework/Web/UI/WebControls/TRepeater.php4
-rw-r--r--framework/Web/UI/WebControls/TTable.php5
-rw-r--r--framework/Xml/TXmlDocument.php36
15 files changed, 167 insertions, 58 deletions
diff --git a/.gitattributes b/.gitattributes
index 40db22fe..e183b3dd 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -24,7 +24,7 @@ buildscripts/phpbuilder/build.php -text
buildscripts/setup.php -text
buildscripts/texbuilder/build.php -text
buildscripts/texbuilder/pages.php -text
-buildscripts/texbuilder/prado3_quick_start.tex -text
+buildscripts/texbuilder/quickstart.tex -text
demos/blog/index.php -text
demos/blog/protected/Common/BlogDataModule.php -text
demos/blog/protected/Common/BlogErrorHandler.php -text
diff --git a/HISTORY b/HISTORY
index 9701e432..49670bd6 100644
--- a/HISTORY
+++ b/HISTORY
@@ -16,6 +16,11 @@ BUG: Ticket#191 - Duplicated postbacks occur when using TButton with validators
BUG: Ticket#213 - PRADO Requirements Checker charset error (Qiang)
CHG: ensureChildControls() is now invoked in TControl::initRecursive (Qiang)
CHG: Postback enabled control will always disable default client-side browser action. (Qiang)
+CHG: CSS and JS files in a theme are now included in page in alphabetic order (Qiang)
+ENH: Ticket#206 - Added OnValidate, OnError, OnSuccess events to validators (Qiang)
+ENH: Ticket#232 - Allow <%# %> and <%= %> embedded within property values (Qiang)
+ENH: TRepeater, TDataList and TDataGrid will store data indices in DataKeys if DataKeyField is not set. (Qiang)
+ENH: Added TPageService.BasePageClass property (Qiang)
Version 3.0.1 June 4, 2006
==========================
diff --git a/buildscripts/classtree/build.php b/buildscripts/classtree/build.php
index ffb4eef3..bc95d1c8 100644
--- a/buildscripts/classtree/build.php
+++ b/buildscripts/classtree/build.php
@@ -13,7 +13,7 @@ $exclusions=array(
);
$a=new ClassTreeBuilder($rootPath,$exclusions);
$a->buildTree();
-$a->saveToFile('classtree.data');
+$a->saveToFile('classes.data');
class ClassTreeBuilder
{
@@ -174,6 +174,10 @@ class ClassTreeBuilder
closedir($folder);
return $files;
}
+
+ public function saveAsTagLib($fileName)
+ {
+ }
}
?> \ No newline at end of file
diff --git a/buildscripts/texbuilder/build.php b/buildscripts/texbuilder/build.php
index cbea9859..c0577c8f 100644
--- a/buildscripts/texbuilder/build.php
+++ b/buildscripts/texbuilder/build.php
@@ -5,7 +5,7 @@
$pdflatexExec = "C:/Wei/miktex/texmf/MiKTeX/bin/pdflatex.exe";
$pdfTex = "$pdflatexExec -interaction=nonstopmode -max-print-line=120 %s";
-$mainTexFile = dirname(__FILE__).'/prado3_quick_start.tex';
+$mainTexFile = dirname(__FILE__).'/quickstart.tex';
//page root location
$base = realpath(dirname(__FILE__).'/../../demos/quickstart/protected/pages/');
@@ -244,14 +244,14 @@ foreach($pages as $chapter => $sections)
echo " Adding $section\n";
$page = $base.'/'.$section;
$current_path = $page;
-
+
//add id to <h1>, <h2>, <3>
$tmp_content = set_header_id(file_get_contents($page),$j++);
file_put_contents($page, $tmp_content);
-
+
$content .= get_section_label($section);
$file_content = file_get_contents($page);
- $tex =
+ $tex =
$content .= parse_html($page,$file_content);
}
@@ -265,7 +265,7 @@ foreach($pages as $chapter => $sections)
if($argc <= 1 && $count > 1)
{
- echo "** Use pdflatex to compile prado3_quick_start.tex to obtain PDF version of quickstart tutorial. **\n";
+ echo "** Use pdflatex to compile quickstart.tex to obtain PDF version of quickstart tutorial. **\n";
exit;
}
if($argv[1] == 'pdf')
@@ -277,7 +277,7 @@ if($argv[1] == 'pdf')
system($command);
system($command); //run it twice
- echo "\n\n** PDF file prado3_quick_start.pdf created **\n\n";
+ echo "\n\n** PDF file quickstart.pdf created **\n\n";
}
else
diff --git a/buildscripts/texbuilder/prado3_quick_start.tex b/buildscripts/texbuilder/quickstart.tex
index ee3010fe..ee3010fe 100644
--- a/buildscripts/texbuilder/prado3_quick_start.tex
+++ b/buildscripts/texbuilder/quickstart.tex
diff --git a/demos/quickstart/protected/controls/Layout.tpl b/demos/quickstart/protected/controls/Layout.tpl
index d4a6a7e5..733bf6e1 100644
--- a/demos/quickstart/protected/controls/Layout.tpl
+++ b/demos/quickstart/protected/controls/Layout.tpl
@@ -19,7 +19,7 @@
</div>
<a href="?">Home</a> |
<a href="http://www.pradosoft.com">PradoSoft.com</a> |
-<a href="prado3_quick_start.pdf">PDF Version</a> |
+<a href="../../docs/quickstart.pdf">PDF Version</a> |
<com:THyperLink ID="PrinterLink" Text="Printer-friendly Version" />
</com:TPanel>
diff --git a/framework/Web/Services/TPageService.php b/framework/Web/Services/TPageService.php
index 1df4ffde..5172f59c 100644
--- a/framework/Web/Services/TPageService.php
+++ b/framework/Web/Services/TPageService.php
@@ -96,6 +96,10 @@ class TPageService extends TService
*/
private $_basePath=null;
/**
+ * @var string base path class in namespace format
+ */
+ private $_basePageClass='TPage';
+ /**
* @var string default page
*/
private $_defaultPage='Home';
@@ -398,6 +402,25 @@ class TPageService extends TService
}
/**
+ * Sets the base page class name (in namespace format).
+ * If a page only has a template file without page class file,
+ * this base page class will be instantiated.
+ * @param string class name
+ */
+ public function setBasePageClass($value)
+ {
+ $this->_basePageClass=$value;
+ }
+
+ /**
+ * @return string base page class name in namespace format. Defaults to 'TPage'.
+ */
+ public function getBasePageClass()
+ {
+ return $this->_basePageClass;
+ }
+
+ /**
* Runs the service.
* This will create the requested page, initializes it with the property values
* specified in the configuration, and executes the page.
@@ -417,9 +440,9 @@ class TPageService extends TService
throw new TConfigurationException('pageservice_pageclass_unknown',$className);
}
else
- $className='TPage';
+ $className=$this->getBasePageClass();
- $this->_page=new $className();
+ $this->_page=Prado::createComponent($className);
$this->_page->setPagePath($this->getRequestedPagePath());
// initialize page properties with those set in configurations
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index cb05fa35..53239bd9 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -383,28 +383,6 @@ class TTemplate extends TApplicationComponent implements ITemplate
* @param string property name
* @param mixed property initial value
*/
- protected function configureControl2($control,$name,$value)
- {
- if(strncasecmp($name,'on',2)===0) // is an event
- $this->configureEvent($control,$name,$value,$control);
- else if(($pos=strrpos($name,'.'))===false) // is a simple property or custom attribute
- $this->configureProperty($control,$name,$value);
- else // is a subproperty
- {
- $subName=substr($name,$pos+1);
- if(strncasecmp($subName,'on',2)===0) // is an event: XXX.YYY.OnZZZ
- {
- $object=$control->getSubProperty(substr($name,0,$pos));
- if(($object instanceof TControl))
- $this->configureEvent($object,$subName,$value,$control);
- else
- $this->configureSubProperty($control,$name,$value);
- }
- else
- $this->configureSubProperty($control,$name,$value);
- }
- }
-
protected function configureControl($control,$name,$value)
{
if(strncasecmp($name,'on',2)===0) // is an event
@@ -414,6 +392,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
else // is a subproperty
$this->configureSubProperty($control,$name,$value);
}
+
/**
* Configures a property of a non-control component.
* @param TComponent component to be configured
@@ -632,7 +611,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
if($matchStart>$textStart)
$tpl[$c++]=array($container,substr($input,$textStart,$matchStart-$textStart));
$textStart=$matchEnd+1;
- $literal=trim(THttpUtility::htmlDecode($match[5][0]));
+ $literal=trim($match[5][0]);
if($str[2]==='=') // expression
$tpl[$c++]=array($container,array(TCompositeLiteral::TYPE_EXPRESSION,$literal));
else if($str[2]==='%') // statements
@@ -851,21 +830,44 @@ class TTemplate extends TApplicationComponent implements ITemplate
*/
protected function parseAttribute($value)
{
- $matches=array();
- if(!preg_match('/\\s*(<%#.*?%>|<%=.*?%>|<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>)\\s*/msS',$value,$matches) || $matches[0]!==$value)
- return THttpUtility::htmlDecode($value);
- $value=THttpUtility::htmlDecode($matches[1]);
- if($value[2]==='#') // databind
- return array(self::CONFIG_DATABIND,substr($value,3,strlen($value)-5));
- else if($value[2]==='=') // a dynamic initialization
- return array(self::CONFIG_EXPRESSION,substr($value,3,strlen($value)-5));
- else if($value[2]==='~') // a URL
- return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
- else if($value[2]==='[')
- return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
- else if($value[2]==='$')
- return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
- return '';
+ if(($n=preg_match_all('/<%[#=].*?%>/msS',$value,$matches,PREG_OFFSET_CAPTURE))>0)
+ {
+ $isDataBind=false;
+ $textStart=0;
+ $expr='';
+ for($i=0;$i<$n;++$i)
+ {
+ $match=$matches[0][$i];
+ $token=$match[0];
+ $offset=$match[1];
+ $length=strlen($token);
+ if($token[2]==='#')
+ $isDataBind=true;
+ if($offset>$textStart)
+ $expr.=".'".strtr(substr($value,$textStart,$offset-$textStart),array("'"=>"\\'","\\"=>"\\\\"))."'";
+ $expr.='.('.substr($token,3,$length-5).')';
+ $textStart=$offset+$length;
+ }
+ $length=strlen($value);
+ if($length>$textStart)
+ $expr.=".'".substr($value,$textStart,$length-$textStart)."'";
+ if($isDataBind)
+ return array(self::CONFIG_DATABIND,ltrim($expr,'.'));
+ else
+ return array(self::CONFIG_EXPRESSION,ltrim($expr,'.'));
+ }
+ else if(preg_match('/\\s*(<%~.*?%>|<%\\$.*?%>|<%\\[.*?\\]%>)\\s*/msS',$value,$matches) && $matches[0]===$value)
+ {
+ $value=$matches[1];
+ if($value[2]==='~') // a URL
+ return array(self::CONFIG_ASSET,trim(substr($value,3,strlen($value)-5)));
+ else if($value[2]==='[')
+ return array(self::CONFIG_LOCALIZATION,trim(substr($value,3,strlen($value)-6)));
+ else if($value[2]==='$')
+ return array(self::CONFIG_PARAMETER,trim(substr($value,3,strlen($value)-5)));
+ }
+ else
+ return $value;
}
protected function validateAttributes($type,$attributes)
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php
index fcb20a81..66bfa8be 100644
--- a/framework/Web/UI/TThemeManager.php
+++ b/framework/Web/UI/TThemeManager.php
@@ -305,6 +305,8 @@ class TTheme extends TApplicationComponent implements ITheme
}
}
closedir($dir);
+ sort($this->_cssFiles);
+ sort($this->_jsFiles);
if($cache!==null)
$cache->set(self::THEME_CACHE_PREFIX.$themePath,array($this->_skins,$this->_cssFiles,$this->_jsFiles,time()));
}
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index 3fe9ee03..1194089e 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -473,10 +473,22 @@ abstract class TBaseValidator extends TLabel implements IValidator
*/
public function validate()
{
+ $this->onValidate();
$this->setIsValid(true);
$control=$this->getValidationTarget();
if($control && $this->getVisible(true) && $this->getEnabled())
- $this->setIsValid($this->evaluateIsValid());
+ {
+ if($this->evaluateIsValid())
+ {
+ $this->setIsValid(true);
+ $this->onSuccess();
+ }
+ else
+ {
+ $this->setIsValid(false);
+ $this->onError();
+ }
+ }
return $this->getIsValid();
}
@@ -504,6 +516,30 @@ abstract class TBaseValidator extends TLabel implements IValidator
abstract protected function evaluateIsValid();
/**
+ * This event is raised when the validator succeeds in validation.
+ */
+ public function onSuccess()
+ {
+ $this->raiseEvent('OnSuccess',$this,null);
+ }
+
+ /**
+ * This event is raised when the validator fails in validation.
+ */
+ public function onError()
+ {
+ $this->raiseEvent('OnError',$this,null);
+ }
+
+ /**
+ * This event is raised right before the validator starts to perform validation.
+ */
+ public function onValidate()
+ {
+ $this->raiseEvent('OnValidate',$this,null);
+ }
+
+ /**
* Renders the validator control.
* @param THtmlWriter writer for the rendering purpose
*/
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index d2625c0d..69798c1a 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -1047,10 +1047,12 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$editIndex=$this->getEditItemIndex();
$index=0;
$dsIndex=$ds->getAllowPaging()?$ds->getFirstIndexInPage():0;
- foreach($ds as $data)
+ foreach($ds as $key=>$data)
{
if($keyField!=='')
$keys->add($this->getDataFieldValue($data,$keyField));
+ else
+ $keys->add($key);
if($index===$editIndex)
$itemType=self::IT_EDITITEM;
else if($index===$selectedIndex)
diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php
index 0bec8921..b2bd9229 100644
--- a/framework/Web/UI/WebControls/TDataList.php
+++ b/framework/Web/UI/WebControls/TDataList.php
@@ -1129,10 +1129,12 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
$hasSeparator=$this->_separatorTemplate!==null;
$selectedIndex=$this->getSelectedItemIndex();
$editIndex=$this->getEditItemIndex();
- foreach($data as $dataItem)
+ foreach($data as $key=>$dataItem)
{
if($keyField!=='')
$keys->add($this->getDataFieldValue($dataItem,$keyField));
+ else
+ $keys->add($key);
if($itemIndex===0 && $this->_headerTemplate!==null)
$this->_header=$this->createItemInternal(-1,'Header',true,null);
if($hasSeparator && $itemIndex>0)
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php
index 2070cb1a..9c1cc4ac 100644
--- a/framework/Web/UI/WebControls/TRepeater.php
+++ b/framework/Web/UI/WebControls/TRepeater.php
@@ -443,10 +443,12 @@ class TRepeater extends TDataBoundControl implements INamingContainer
$items=$this->getItems();
$itemIndex=0;
$hasSeparator=$this->_separatorTemplate!==null;
- foreach($data as $dataItem)
+ foreach($data as $key=>$dataItem)
{
if($keyField!=='')
$keys->add($this->getDataFieldValue($dataItem,$keyField));
+ else
+ $keys->add($key);
if($itemIndex===0 && $this->_headerTemplate!==null)
$this->_header=$this->createItemInternal(-1,self::IT_HEADER,true,null);
if($hasSeparator && $itemIndex>0)
diff --git a/framework/Web/UI/WebControls/TTable.php b/framework/Web/UI/WebControls/TTable.php
index aaed37df..1c58c62e 100644
--- a/framework/Web/UI/WebControls/TTable.php
+++ b/framework/Web/UI/WebControls/TTable.php
@@ -68,11 +68,6 @@ Prado::using('System.Web.UI.WebControls.TTableRow');
class TTable extends TWebControl
{
/**
- * @var TTableRowCollection row collection
- */
- private $_rows=null;
-
- /**
* @return string tag name for the table
*/
protected function getTagName()
diff --git a/framework/Xml/TXmlDocument.php b/framework/Xml/TXmlDocument.php
index ab4b0b7a..0d766c68 100644
--- a/framework/Xml/TXmlDocument.php
+++ b/framework/Xml/TXmlDocument.php
@@ -229,6 +229,42 @@ class TXmlElement extends TComponent
* You can also get the version and encoding of the XML document by
* the Version and Encoding properties.
*
+ * To construct an XML string, you may do the following:
+ * <code>
+ * $doc=new TXmlDocument('1.0','utf-8');
+ * $doc->TagName='Root';
+ *
+ * $proc=new TXmlElement('Proc');
+ * $proc->setAttribute('Name','xxxx');
+ * $doc->Elements[]=$proc;
+ *
+ * $query=new TXmlElement('Query');
+ * $query->setAttribute('ID','xxxx');
+ * $proc->Elements[]=$query;
+ *
+ * $attr=new TXmlElement('Attr');
+ * $attr->setAttribute('Name','aaa');
+ * $attr->Value='1';
+ * $query->Elements[]=$attr;
+ *
+ * $attr=new TXmlElement('Attr');
+ * $attr->setAttribute('Name','bbb');
+ * $attr->Value='1';
+ * $query->Elements[]=$attr;
+ * </code>
+ * The above code represents the following XML string:
+ * <code>
+ * <?xml version="1.0" encoding="utf-8"?>
+ * <Root>
+ * <Proc Name="xxxx">
+ * <Query ID="xxxx">
+ * <Attr Name="aaa">1</Attr>
+ * <Attr Name="bbb">1</Attr>
+ * </Query>
+ * </Proc>
+ * </Root>
+ * </code>
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Xml