summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-03-17 03:16:13 +0000
committerxue <>2006-03-17 03:16:13 +0000
commit261c29ece2ccf37e6419b9886cefd29f9dbb3c89 (patch)
treebb67b9d5bb719827ead69017fd52908a6438bb23
parent3ec0ec6275b1ab8a95b2696febcdd0284732fce2 (diff)
Using constants as item types.
-rw-r--r--framework/Web/UI/WebControls/TBoundColumn.php8
-rw-r--r--framework/Web/UI/WebControls/TButtonColumn.php2
-rw-r--r--framework/Web/UI/WebControls/TCheckBoxColumn.php10
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php91
-rw-r--r--framework/Web/UI/WebControls/TDataGridColumn.php4
-rw-r--r--framework/Web/UI/WebControls/TDataList.php19
-rw-r--r--framework/Web/UI/WebControls/TEditCommandColumn.php4
-rw-r--r--framework/Web/UI/WebControls/THyperLinkColumn.php8
-rw-r--r--framework/Web/UI/WebControls/TRepeater.php52
-rw-r--r--framework/Web/UI/WebControls/TTemplateColumn.php14
-rw-r--r--framework/Web/UI/WebControls/TWizard.php250
-rw-r--r--framework/core.php2
12 files changed, 319 insertions, 145 deletions
diff --git a/framework/Web/UI/WebControls/TBoundColumn.php b/framework/Web/UI/WebControls/TBoundColumn.php
index 393d5c11..5975ec02 100644
--- a/framework/Web/UI/WebControls/TBoundColumn.php
+++ b/framework/Web/UI/WebControls/TBoundColumn.php
@@ -97,7 +97,7 @@ class TBoundColumn extends TDataGridColumn
parent::initializeCell($cell,$columnIndex,$itemType);
switch($itemType)
{
- case 'EditItem':
+ case TDataGrid::IT_EDITITEM:
$control=$cell;
if(!$this->getReadOnly())
{
@@ -108,9 +108,9 @@ class TBoundColumn extends TDataGridColumn
if(($dataField=$this->getDataField())!=='')
$control->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
break;
- case 'Item':
- case 'AlternatingItem':
- case 'SelectedItem':
+ case TDataGrid::IT_ITEM:
+ case TDataGrid::IT_ALTERNATINGITEM:
+ case TDataGrid::IT_SELECTEDITEM:
if($this->getDataField()!=='')
$cell->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
break;
diff --git a/framework/Web/UI/WebControls/TButtonColumn.php b/framework/Web/UI/WebControls/TButtonColumn.php
index dc506b0a..12b38171 100644
--- a/framework/Web/UI/WebControls/TButtonColumn.php
+++ b/framework/Web/UI/WebControls/TButtonColumn.php
@@ -168,7 +168,7 @@ class TButtonColumn extends TDataGridColumn
public function initializeCell($cell,$columnIndex,$itemType)
{
parent::initializeCell($cell,$columnIndex,$itemType);
- if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem' || $itemType==='EditItem')
+ if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM || $itemType===TDataGrid::IT_EDITITEM)
{
if($this->getButtonType()==='LinkButton')
$button=Prado::createComponent('System.Web.UI.WebControls.TLinkButton');
diff --git a/framework/Web/UI/WebControls/TCheckBoxColumn.php b/framework/Web/UI/WebControls/TCheckBoxColumn.php
index f695bcdc..4df1e695 100644
--- a/framework/Web/UI/WebControls/TCheckBoxColumn.php
+++ b/framework/Web/UI/WebControls/TCheckBoxColumn.php
@@ -14,6 +14,10 @@
* TDataGridColumn class file
*/
Prado::using('System.Web.UI.WebControls.TDataGridColumn');
+/**
+ * TCheckBox class file
+ */
+Prado::using('System.Web.UI.WebControls.TCheckBox');
/**
* TCheckBoxColumn class
@@ -76,10 +80,10 @@ class TCheckBoxColumn extends TDataGridColumn
public function initializeCell($cell,$columnIndex,$itemType)
{
parent::initializeCell($cell,$columnIndex,$itemType);
- if($itemType==='EditItem' || $itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem')
+ if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM || $itemType===TDataGrid::IT_EDITITEM)
{
- $checkBox=Prado::createComponent('System.Web.UI.WebControls.TCheckBox');
- if($this->getReadOnly() || $itemType!=='EditItem')
+ $checkBox=new TCheckBox;
+ if($this->getReadOnly() || $itemType!==TDataGrid::IT_EDITITEM)
$checkBox->setEnabled(false);
$cell->setHorizontalAlign('Center');
$cell->getControls()->add($checkBox);
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index d9924cd2..0157b643 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -134,6 +134,21 @@ Prado::using('System.Web.UI.WebControls.TTable');
*/
class TDataGrid extends TBaseDataList implements INamingContainer
{
+ /**
+ * datagrid item types
+ */
+ const IT_HEADER='Header';
+ const IT_FOOTER='Footer';
+ const IT_ITEM='Item';
+ const IT_SEPARATOR='Separator';
+ const IT_ALTERNATINGITEM='AlternatingItem';
+ const IT_EDITITEM='EditItem';
+ const IT_SELECTEDITEM='SelectedItem';
+ const IT_PAGER='Pager';
+
+ /**
+ * Command name that TDataGrid understands.
+ */
const CMD_SELECT='Select';
const CMD_EDIT='Edit';
const CMD_UPDATE='Update';
@@ -395,14 +410,14 @@ class TDataGrid extends TBaseDataList implements INamingContainer
if($current>=0 && $current<$itemCount)
{
$item=$items->itemAt($current);
- if($item->getItemType()!=='EditItem')
- $item->setItemType($current%2?'AlternatingItem':'Item');
+ if($item->getItemType()!==self::IT_EDITITEM)
+ $item->setItemType($current%2?self::IT_ALTERNATINGITEM:self::IT_ITEM);
}
if($value>=0 && $value<$itemCount)
{
$item=$items->itemAt($value);
- if($item->getItemType()!=='EditItem')
- $item->setItemType('SelectedItem');
+ if($item->getItemType()!==self::IT_EDITITEM)
+ $item->setItemType(self::IT_SELECTEDITEM);
}
}
}
@@ -445,9 +460,9 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$items=$this->getItems();
$itemCount=$items->getCount();
if($current>=0 && $current<$itemCount)
- $items->itemAt($current)->setItemType($current%2?'AlternatingItem':'Item');
+ $items->itemAt($current)->setItemType($current%2?self::IT_ALTERNATINGITEM:self::IT_ITEM);
if($value>=0 && $value<$itemCount)
- $items->itemAt($value)->setItemType('EditItem');
+ $items->itemAt($value)->setItemType(self::IT_EDITITEM);
}
}
@@ -901,7 +916,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$column->initialize();
if($allowPaging)
$this->createPager(-1,-1,$columnCount,$ds);
- $this->_header=$this->createItemInternal(-1,-1,'Header',false,null,$columns);
+ $this->_header=$this->createItemInternal(-1,-1,self::IT_HEADER,false,null,$columns);
$selectedIndex=$this->getSelectedItemIndex();
$editIndex=$this->getEditItemIndex();
$index=0;
@@ -909,18 +924,18 @@ class TDataGrid extends TBaseDataList implements INamingContainer
foreach($ds as $data)
{
if($index===$editIndex)
- $itemType='EditItem';
+ $itemType=self::IT_EDITITEM;
else if($index===$selectedIndex)
- $itemType='SelectedItem';
+ $itemType=self::IT_SELECTEDITEM;
else if($index % 2)
- $itemType='AlternatingItem';
+ $itemType=self::IT_ALTERNATINGITEM;
else
- $itemType='Item';
+ $itemType=self::IT_ITEM;
$items->add($this->createItemInternal($index,$dsIndex,$itemType,false,null,$columns));
$index++;
$dsIndex++;
}
- $this->_footer=$this->createItemInternal(-1,-1,'Footer',false,null,$columns);
+ $this->_footer=$this->createItemInternal(-1,-1,self::IT_FOOTER,false,null,$columns);
if($allowPaging)
$this->createPager(-1,-1,$columnCount,$ds);
}
@@ -963,7 +978,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$allowPaging=$ds->getAllowPaging();
if($allowPaging)
$this->createPager(-1,-1,$columnCount,$ds);
- $this->_header=$this->createItemInternal(-1,-1,'Header',true,null,$columns);
+ $this->_header=$this->createItemInternal(-1,-1,self::IT_HEADER,true,null,$columns);
$selectedIndex=$this->getSelectedItemIndex();
$editIndex=$this->getEditItemIndex();
$index=0;
@@ -973,18 +988,18 @@ class TDataGrid extends TBaseDataList implements INamingContainer
if($keyField!=='')
$keys->add($this->getDataFieldValue($data,$keyField));
if($index===$editIndex)
- $itemType='EditItem';
+ $itemType=self::IT_EDITITEM;
else if($index===$selectedIndex)
- $itemType='SelectedItem';
+ $itemType=self::IT_SELECTEDITEM;
else if($index % 2)
- $itemType='AlternatingItem';
+ $itemType=self::IT_ALTERNATINGITEM;
else
- $itemType='Item';
+ $itemType=self::IT_ITEM;
$items->add($this->createItemInternal($index,$dsIndex,$itemType,true,$data,$columns));
$index++;
$dsIndex++;
}
- $this->_footer=$this->createItemInternal(-1,-1,'Footer',true,null,$columns);
+ $this->_footer=$this->createItemInternal(-1,-1,self::IT_FOOTER,true,null,$columns);
if($allowPaging)
$this->createPager(-1,-1,$columnCount,$ds);
$this->setViewState('ItemCount',$index,0);
@@ -1003,7 +1018,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
/**
* Creates a datagrid item instance based on the item type and index.
* @param integer zero-based item index
- * @param string item type, may be 'Header', 'Footer', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'.
+ * @param string item type, may be self::IT_HEADER, self::IT_FOOTER, self::IT_ITEM, self::IT_SEPARATOR, self::IT_ALTERNATINGITEM, self::IT_SELECTEDITEM, self::IT_EDITITEM.
* @return TDataGridItem created data list item
*/
protected function createItem($itemIndex,$dataSourceIndex,$itemType)
@@ -1045,7 +1060,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$index=0;
foreach($columns as $column)
{
- if($itemType==='Header')
+ if($itemType===self::IT_HEADER)
$cell=new TTableHeaderCell;
else
$cell=new TTableCell;
@@ -1057,7 +1072,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
private function createPager($itemIndex,$dataSourceIndex,$columnSpan,$pagedDataSource)
{
- $item=$this->createItem($itemIndex,$dataSourceIndex,'Pager');
+ $item=$this->createItem($itemIndex,$dataSourceIndex,self::IT_PAGER);
$this->initializePager($item,$columnSpan,$pagedDataSource);
$this->onItemCreated(new TDataGridItemEventParameter($item));
$this->getControls()->add($item);
@@ -1258,9 +1273,9 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
else
{
- $column->setHeaderText('Item');
+ $column->setHeaderText(self::IT_ITEM);
$column->setDataField($key);
- $column->setSortExpression('Item');
+ $column->setSortExpression(self::IT_ITEM);
$autoColumns->add($column);
}
}
@@ -1322,31 +1337,31 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$itemType=$item->getItemType();
switch($itemType)
{
- case 'Header':
+ case self::IT_HEADER:
if($headerStyle)
$item->getStyle()->mergeWith($headerStyle);
if(!$this->getShowHeader())
$item->setVisible(false);
break;
- case 'Footer':
+ case self::IT_FOOTER:
if($footerStyle)
$item->getStyle()->mergeWith($footerStyle);
if(!$this->getShowFooter())
$item->setVisible(false);
break;
- case 'Separator':
+ case self::IT_SEPARATOR:
if($separatorStyle)
$item->getStyle()->mergeWith($separatorStyle);
break;
- case 'Item':
+ case self::IT_ITEM:
if($itemStyle)
$item->getStyle()->mergeWith($itemStyle);
break;
- case 'AlternatingItem':
+ case self::IT_ALTERNATINGITEM:
if($alternatingItemStyle)
$item->getStyle()->mergeWith($alternatingItemStyle);
break;
- case 'SelectedItem':
+ case self::IT_SELECTEDITEM:
if($selectedItemStyle)
$item->getStyle()->mergeWith($selectedItemStyle);
if($index % 2==1)
@@ -1360,7 +1375,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$item->getStyle()->mergeWith($alternatingItemStyle);
}
break;
- case 'EditItem':
+ case self::IT_EDITITEM:
if($editItemStyle)
$item->getStyle()->mergeWith($editItemStyle);
if($index % 2==1)
@@ -1374,7 +1389,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$item->getStyle()->mergeWith($alternatingItemStyle);
}
break;
- case 'Pager':
+ case self::IT_PAGER:
if($pagerStyle)
{
$item->getStyle()->mergeWith($pagerStyle);
@@ -1393,7 +1408,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
default:
break;
}
- if($this->_columns && $itemType!=='Pager')
+ if($this->_columns && $itemType!==self::IT_PAGER)
{
$n=$this->_columns->getCount();
$cells=$item->getCells();
@@ -1405,9 +1420,9 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$cell->setVisible(false);
else
{
- if($itemType==='Header')
+ if($itemType===self::IT_HEADER)
$style=$column->getHeaderStyle(false);
- else if($itemType==='Footer')
+ else if($itemType===self::IT_FOOTER)
$style=$column->getFooterStyle(false);
else
$style=$column->getItemStyle(false);
@@ -1416,7 +1431,7 @@ class TDataGrid extends TBaseDataList implements INamingContainer
}
}
}
- else if($itemType==='Pager' && $invisibleColumns>0)
+ else if($itemType===self::IT_PAGER && $invisibleColumns>0)
{
$cell=$item->getCells()->itemAt(0);
$cell->setColumnSpan($cell->getColumnSpan()-$invisibleColumns);
@@ -1689,7 +1704,7 @@ class TDataGridItem extends TTableRow implements INamingContainer
}
/**
- * @return string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'
+ * @return string item type.
*/
public function getItemType()
{
@@ -1697,11 +1712,11 @@ class TDataGridItem extends TTableRow implements INamingContainer
}
/**
- * @param mixed data to be associated with the item
+ * @param string item type, can be 'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager'
*/
public function setItemType($value)
{
- $this->_itemType=TPropertyValue::ensureEnum($value,'Header','Footer','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager');
+ $this->_itemType=$value;
}
/**
diff --git a/framework/Web/UI/WebControls/TDataGridColumn.php b/framework/Web/UI/WebControls/TDataGridColumn.php
index 6206e595..e8cc81aa 100644
--- a/framework/Web/UI/WebControls/TDataGridColumn.php
+++ b/framework/Web/UI/WebControls/TDataGridColumn.php
@@ -275,7 +275,7 @@ abstract class TDataGridColumn extends TApplicationComponent
{
switch($itemType)
{
- case 'Header':
+ case TDataGrid::IT_HEADER:
$sortExpression=$this->getSortExpression();
$allowSorting=$sortExpression!=='' && (!$this->_owner || $this->_owner->getAllowSorting());
if($allowSorting)
@@ -317,7 +317,7 @@ abstract class TDataGridColumn extends TApplicationComponent
}
}
break;
- case 'Footer':
+ case TDataGrid::IT_FOOTER:
if(($text=$this->getFooterText())==='')
$text='&nbsp;';
$cell->setText($text);
diff --git a/framework/Web/UI/WebControls/TDataList.php b/framework/Web/UI/WebControls/TDataList.php
index 56e8d43c..f5f4b9fa 100644
--- a/framework/Web/UI/WebControls/TDataList.php
+++ b/framework/Web/UI/WebControls/TDataList.php
@@ -99,6 +99,15 @@ Prado::using('System.Web.UI.WebControls.TRepeatInfo');
class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUser
{
/**
+ * Command name that TDataList understands.
+ */
+ const CMD_SELECT='Select';
+ const CMD_EDIT='Edit';
+ const CMD_UPDATE='Update';
+ const CMD_DELETE='Delete';
+ const CMD_CANCEL='Cancel';
+
+ /**
* @var TDataListItemCollection item list
*/
private $_items=null;
@@ -645,28 +654,28 @@ class TDataList extends TBaseDataList implements INamingContainer, IRepeatInfoUs
{
$this->onItemCommand($param);
$command=$param->getCommandName();
- if(strcasecmp($command,'select')===0)
+ if(strcasecmp($command,self::CMD_SELECT)===0)
{
$this->setSelectedItemIndex($param->getItem()->getItemIndex());
$this->onSelectedIndexChanged(null);
return true;
}
- else if(strcasecmp($command,'edit')===0)
+ else if(strcasecmp($command,self::CMD_EDIT)===0)
{
$this->onEditCommand($param);
return true;
}
- else if(strcasecmp($command,'delete')===0)
+ else if(strcasecmp($command,self::CMD_DELETE)===0)
{
$this->onDeleteCommand($param);
return true;
}
- else if(strcasecmp($command,'update')===0)
+ else if(strcasecmp($command,self::CMD_UPDATE)===0)
{
$this->onUpdateCommand($param);
return true;
}
- else if(strcasecmp($command,'cancel')===0)
+ else if(strcasecmp($command,self::CMD_CANCEL)===0)
{
$this->onCancelCommand($param);
return true;
diff --git a/framework/Web/UI/WebControls/TEditCommandColumn.php b/framework/Web/UI/WebControls/TEditCommandColumn.php
index abc372a0..65e389bd 100644
--- a/framework/Web/UI/WebControls/TEditCommandColumn.php
+++ b/framework/Web/UI/WebControls/TEditCommandColumn.php
@@ -153,9 +153,9 @@ class TEditCommandColumn extends TDataGridColumn
public function initializeCell($cell,$columnIndex,$itemType)
{
parent::initializeCell($cell,$columnIndex,$itemType);
- if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem')
+ if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM)
$cell->getControls()->add($this->createButton('Edit',$this->getEditText(),false,''));
- else if($itemType==='EditItem')
+ else if($itemType===TDataGrid::IT_EDITITEM)
{
$controls=$cell->getControls();
$controls->add($this->createButton('Update',$this->getUpdateText(),$this->getCausesValidation(),$this->getValidationGroup()));
diff --git a/framework/Web/UI/WebControls/THyperLinkColumn.php b/framework/Web/UI/WebControls/THyperLinkColumn.php
index 96e905cd..9fc1e3d2 100644
--- a/framework/Web/UI/WebControls/THyperLinkColumn.php
+++ b/framework/Web/UI/WebControls/THyperLinkColumn.php
@@ -14,6 +14,10 @@
* TDataGridColumn class file
*/
Prado::using('System.Web.UI.WebControls.TDataGridColumn');
+/**
+ * THyperLink class file
+ */
+Prado::using('System.Web.UI.WebControls.THyperLink');
/**
* THyperLinkColumn class
@@ -165,9 +169,9 @@ class THyperLinkColumn extends TDataGridColumn
public function initializeCell($cell,$columnIndex,$itemType)
{
parent::initializeCell($cell,$columnIndex,$itemType);
- if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem' || $itemType==='EditItem')
+ if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM || $itemType===TDataGrid::IT_EDITITEM)
{
- $link=Prado::createComponent('System.Web.UI.WebControls.THyperLink');
+ $link=new THyperLink;
$link->setText($this->getText());
$link->setNavigateUrl($this->getNavigateUrl());
$link->setTarget($this->getTarget());
diff --git a/framework/Web/UI/WebControls/TRepeater.php b/framework/Web/UI/WebControls/TRepeater.php
index 4fa2f9ae..3d57fbd5 100644
--- a/framework/Web/UI/WebControls/TRepeater.php
+++ b/framework/Web/UI/WebControls/TRepeater.php
@@ -57,6 +57,16 @@ Prado::using('System.Web.UI.WebControls.TDataBoundControl');
class TRepeater extends TDataBoundControl implements INamingContainer
{
/**
+ * Repeater item types
+ */
+ const IT_HEADER='Header';
+ const IT_FOOTER='Footer';
+ const IT_EMPTY='Empty';
+ const IT_ITEM='Item';
+ const IT_SEPARATOR='Separator';
+ const IT_ALTERNATINGITEM='AlternatingItem';
+
+ /**
* @var ITemplate template for repeater items
*/
private $_itemTemplate=null;
@@ -251,7 +261,7 @@ class TRepeater extends TDataBoundControl implements INamingContainer
/**
* Creates a repeater item instance based on the item type and index.
* @param integer zero-based item index
- * @param string item type, may be 'Header', 'Footer', 'Empty', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'.
+ * @param string item type, may be 'Header', 'Footer', 'Empty', 'Item', 'Separator', 'AlternatingItem'.
* @return TRepeaterItem created repeater item
*/
protected function createItem($itemIndex,$itemType)
@@ -263,7 +273,7 @@ class TRepeater extends TDataBoundControl implements INamingContainer
* Creates a repeater item and does databinding if needed.
* This method invokes {@link createItem} to create a new repeater item.
* @param integer zero-based item index.
- * @param string item type, may be 'Header', 'Footer', 'Empty', 'Item', 'Separator', 'AlternatingItem', 'SelectedItem', 'EditItem'.
+ * @param string item type, may be 'Header', 'Footer', 'Empty', 'Item', 'Separator', 'AlternatingItem'.
* @param boolean whether to do databinding for the item
* @param mixed data to be associated with the item
* @return TRepeaterItem the created item
@@ -301,16 +311,12 @@ class TRepeater extends TDataBoundControl implements INamingContainer
$template=null;
switch($item->getItemType())
{
- case 'Header': $template=$this->_headerTemplate; break;
- case 'Footer': $template=$this->_footerTemplate; break;
- case 'Empty': $template=$this->_emptyTemplate; break;
- case 'Item': $template=$this->_itemTemplate; break;
- case 'Separator': $template=$this->_separatorTemplate; break;
- case 'AlternatingItem': $template=$this->_alternatingItemTemplate===null ? $this->_itemTemplate : $this->_alternatingItemTemplate; break;
- case 'SelectedItem':
- case 'EditItem':
- default:
- break;
+ case self::IT_HEADER: $template=$this->_headerTemplate; break;
+ case self::IT_FOOTER: $template=$this->_footerTemplate; break;
+ case self::IT_EMPTY : $template=$this->_emptyTemplate; break;
+ case self::IT_ITEM : $template=$this->_itemTemplate; break;
+ case self::IT_SEPARATOR : $template=$this->_separatorTemplate; break;
+ case self::IT_ALTERNATINGITEM : $template=$this->_alternatingItemTemplate===null ? $this->_itemTemplate : $this->_alternatingItemTemplate; break;
}
if($template!==null)
$template->instantiateIn($item);
@@ -374,19 +380,19 @@ class TRepeater extends TDataBoundControl implements INamingContainer
$items=$this->getItems();
$hasSeparator=$this->_separatorTemplate!==null;
if($this->_headerTemplate!==null)
- $this->_header=$this->createItemInternal(-1,'Header',false,null);
+ $this->_header=$this->createItemInternal(-1,self::IT_HEADER,false,null);
for($i=0;$i<$itemCount;++$i)
{
if($hasSeparator && $i>0)
- $this->createItemInternal($i-1,'Separator',false,null);
- $itemType=$i%2==0?'Item':'AlternatingItem';
+ $this->createItemInternal($i-1,self::IT_SEPARATOR,false,null);
+ $itemType=$i%2==0?self::IT_ITEM:self::IT_ALTERNATINGITEM;
$items->add($this->createItemInternal($i,$itemType,false,null));
}
if($this->_footerTemplate!==null)
- $this->_footer=$this->createItemInternal(-1,'Footer',false,null);
+ $this->_footer=$this->createItemInternal(-1,self::IT_FOOTER,false,null);
}
else if($this->_emptyTemplate!==null)
- $this->createItemInternal(-1,'Empty',false,null);
+ $this->createItemInternal(-1,self::IT_EMPTY,false,null);
$this->clearChildState();
}
@@ -405,17 +411,17 @@ class TRepeater extends TDataBoundControl implements INamingContainer
foreach($data as $dataItem)
{
if($itemIndex===0 && $this->_headerTemplate!==null)
- $this->_header=$this->createItemInternal(-1,'Header',true,null);
+ $this->_header=$this->createItemInternal(-1,self::IT_HEADER,true,null);
if($hasSeparator && $itemIndex>0)
- $this->createItemInternal($itemIndex-1,'Separator',true,null);
- $itemType=$itemIndex%2==0?'Item':'AlternatingItem';
+ $this->createItemInternal($itemIndex-1,self::IT_SEPARATOR,true,null);
+ $itemType=$itemIndex%2==0?self::IT_ITEM:self::IT_ALTERNATINGITEM;
$items->add($this->createItemInternal($itemIndex,$itemType,true,$dataItem));
$itemIndex++;
}
if($itemIndex>0 && $this->_footerTemplate!==null)
- $this->_footer=$this->createItemInternal(-1,'Footer',true,null);
+ $this->_footer=$this->createItemInternal(-1,self::IT_FOOTER,true,null);
if($itemIndex===0 && $this->_emptyTemplate!==null)
- $this->createItemInternal(-1,'Empty',true,null);
+ $this->createItemInternal(-1,self::IT_EMPTY,true,null);
$this->setViewState('ItemCount',$itemIndex,0);
}
@@ -622,7 +628,7 @@ class TRepeaterItem extends TControl implements INamingContainer
public function __construct($itemIndex,$itemType)
{
$this->_itemIndex=$itemIndex;
- $this->_itemType=TPropertyValue::ensureEnum($itemType,'Header','Footer','Empty','Item','AlternatingItem','SelectedItem','EditItem','Separator','Pager');
+ $this->_itemType=$itemType;
}
/**
diff --git a/framework/Web/UI/WebControls/TTemplateColumn.php b/framework/Web/UI/WebControls/TTemplateColumn.php
index 08c4e2c6..f83e3290 100644
--- a/framework/Web/UI/WebControls/TTemplateColumn.php
+++ b/framework/Web/UI/WebControls/TTemplateColumn.php
@@ -138,18 +138,18 @@ class TTemplateColumn extends TDataGridColumn
$template=null;
switch($itemType)
{
- case 'Header':
+ case TDataGrid::IT_HEADER:
$template=$this->_headerTemplate;
break;
- case 'Footer':
+ case TDataGrid::IT_FOOTER:
$template=$this->_footerTemplate;
break;
- case 'Item':
- case 'AlternatingItem':
- case 'SelectedItem':
+ case TDataGrid::IT_ITEM:
+ case TDataGrid::IT_ALTERNATINGITEM:
+ case TDataGrid::IT_SELECTEDITEM:
$template=$this->_itemTemplate;
break;
- case 'EditItem':
+ case TDataGrid::IT_EDITITEM:
$template=$this->_editItemTemplate===null?$this->_itemTemplate:$this->_editItemTemplate;
break;
}
@@ -159,7 +159,7 @@ class TTemplateColumn extends TDataGridColumn
$cell->getControls()->clear();
$template->instantiateIn($cell);
}
- else if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem' || $itemType==='EditItem')
+ else if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM || $itemType===TDataGrid::IT_EDITITEM)
$cell->setText('&nbsp;');
}
}
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index 75a571a5..29d97a45 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -2,18 +2,10 @@
Prado::using('System.Web.UI.WebControls.TMultiView');
Prado::using('System.Web.UI.WebControls.TPanel');
-
-/**
-
-containment relationship
-
-wizard <div>
- sidebar <div>
- header <div>
- step <div>
- <div>
- navigation
-*/
+Prado::using('System.Web.UI.WebControls.TButton');
+Prado::using('System.Web.UI.WebControls.TLinkButton');
+Prado::using('System.Web.UI.WebControls.TImageButton');
+Prado::using('System.Web.UI.WebControls.TDataList');
/**
* Class TWizard.
@@ -64,10 +56,14 @@ class TWizard extends TWebControl implements INamingContainer
private $_wizardSteps=null;
private $_header;
+ private $_stepContent;
+ private $_sideBar;
private $_startNavigation;
private $_stepNavigation;
private $_finishNavigation;
private $_activeStepIndexSet=false;
+ private $_sideBarDataList;
+
/**
* @return string tag name for the wizard
*/
@@ -82,7 +78,7 @@ class TWizard extends TWebControl implements INamingContainer
$this->getWizardSteps()->add($object);
}
- // SideBarDataList, History
+ // SideBarDataLis
/**
* @return TWizardStep the currently active wizard step
@@ -111,7 +107,11 @@ class TWizard extends TWebControl implements INamingContainer
{
$multiView->setActiveViewIndex($value);
$this->_activeStepIndexSet=true;
- // update sidebar list
+ if($this->_sideBarDataList!==null && $this->getSideBarTemplate()!==null)
+ {
+ $this->_sideBarDataList->setSelectedIndex($this->getActiveStepIndex());
+ $this->_sideBarDataList->dataBind();
+ }
}
}
@@ -289,7 +289,7 @@ class TWizard extends TWebControl implements INamingContainer
{
if(($style=$this->getViewState('NavigationButtonStyle',null))===null)
{
- $style=new TWizardNavigationButtonStyle;
+ $style=new TStyle;
$this->setViewState('NavigationButtonStyle',$style,null);
}
return $style;
@@ -560,24 +560,47 @@ class TWizard extends TWebControl implements INamingContainer
protected function applyControlProperties()
{
$this->applyHeaderProperties();
+ $this->applySideBarProperties();
+ $this->applyStepContentProperties();
$this->applyNavigationProperties();
}
protected function applyHeaderProperties()
{
- $headerTemplate=$this->getHeaderTemplate();
- if($headerTemplate===null && $this->getHeaderText()==='')
- $this->_header->setVisible(false);
- else
+ if(($style=$this->getViewState('HeaderStyle',null))!==null)
+ $this->_header->getStyle()->mergeWith($style);
+ if($this->getHeaderTemplate()===null)
{
- if(($style=$this->getViewState('HeaderStyle',null))!==null)
- $this->_header->getStyle()->mergeWith($style);
- if($headerTemplate===null)
+ $this->_header->getControls()->clear();
+ $this->_header->getControls()->add($this->getHeaderText());
+ }
+ }
+
+ protected function applySideBarProperties()
+ {
+ if($this->_sideBarDataList!==null && $this->getDisplaySideBar())
+ {
+ $this->_sideBarDataList->setDataSource($this->getWizardSteps());
+ $this->_sideBarDataList->setSelectedItemIndex($this->getActiveStepIndex());
+ $this->_sideBarDataList->dataBind();
+ if($this->getSideBarTemplate()!==null)
{
- $this->_header->getControls()->clear();
- $this->_header->getControls()->add($this->getHeaderText());
+ $style=$this->getSideBarButtonStyle();
+ foreach($this->_sideBarDataList->getItems() as $item)
+ {
+ if(($button=$item->findControl('SideBarButton'))!==null)
+ $button->getStyle()->mergeWith($style);
+ }
}
}
+ if(($style=$this->getViewState('SideBarStyle',null))!==null)
+ $this->_sideBar->getStyle()->mergeWith($style);
+ }
+
+ protected function applyStepContentProperties()
+ {
+ if(($style=$this->getViewState('StepStyle',null))!==null)
+ $this->_stepContent->getStyle()->mergeWith($style);
}
protected function applyNavigationProperties()
@@ -700,77 +723,180 @@ class TWizard extends TWebControl implements INamingContainer
return $type;
}
- protected function createChildControls()
+ protected function reset()
{
- // reset wizard in case this was invoked previously
$this->getControls()->clear();
$this->_header=null;
+ $this->_stepContent=null;
+ $this->_sideBar=null;
+ $this->_sideBarDataList=null;
$this->_startNavigation=null;
$this->_stepNavigation=null;
$this->_finishNavigation=null;
- // side bar
- if($this->getDisplaySideBar())
- {
- // render side bar here
- }
+ }
+
+ protected function createChildControls()
+ {
+ $this->reset();
+ $this->createSideBar();
+ $this->createHeader();
+ $this->createStepContents();
+ $this->createNavigation();
+// $this->clearChildState();
+ }
- // header
+ protected function createHeader()
+ {
$this->_header=new TPanel;
if(($template=$this->getHeaderTemplate())!==null)
$template->instantiateIn($this->_header);
else
$this->_header->getControls()->add($this->getHeaderText());
$this->getControls()->add($this->_header);
+ }
- // steps
- $content=new TPanel;
- $content->setID('WizardStep');
- $content->getControls()->add($this->getMultiView());
- $this->getMultiView()->setActiveViewIndex(0);
- $this->getControls()->add($content);
+ protected function createSideBar()
+ {
+ if($this->getDisplaySideBar())
+ {
+ if(($template=$this->getSideBarTemplate())!==null)
+ {
+ $this->_sideBar=new TPanel;
+ $template->instantiateIn($this->_sideBar);
+ }
+ else
+ $this->_sideBar=$this->createDefaultSideBar();
- $this->createStartNavigation();
- $this->createStepNavigation();
- $this->createFinishNavigation();
+ $this->getControls()->add($this->_sideBar);
- $this->clearChildState();
+ if(($this->_sideBarDataList=$this->_sideBar->findControl('SideBarList'))!==null)
+ {
+ $this->_sideBarDataList->attachEventHandler('OnItemCommand',array($this,'dataListItemCommand'));
+ $this->_sideBarDataList->attachEventHandler('OnItemDataBound',array($this,'dataListItemDataBound'));
+ $this->_sideBarDataList->setDataSource($this->getWizardSteps());
+ $this->_sideBarDataList->setSelectedItemIndex($this->getActiveStepIndex());
+ $this->_sideBarDataList->dataBind();
+ }
+ }
+ else
+ {
+ $this->_sideBar=new TPanel;
+ $this->getControls()->add($this->_sideBar);
+ }
+ }
+
+ protected function createDefaultSideBar()
+ {
+ $sideBar=new TPanel;
+ $dataList=new TDataList;
+ $dataList->setID('SideBarList');
+ $dataList->getSelectedItemStyle()->getFont()->setBold(true);
+ $dataList->setItemTemplate(new TWizardSideBarListItemTemplate);
+ $sideBar->getControls()->add($dataList);
+ return $sideBar;
+ }
+
+ public function dataListItemCommand($sender,$param)
+ {
+ $item=$param->getItem();
+ if($param->getCommandName()===self::CMD_MOVETO)
+ {
+ $stepIndex=$this->getActiveStepIndex();
+ $newStepIndex=TPropertyValue::ensureInteger($param->getCommandParameter());
+ $navParam=new TWizardNavigationEventParameter($stepIndex);
+ $navParam->setNextStepIndex($newStepIndex);
+ if($sender!==null && ($page=$this->getPage())!==null && !$page->getIsValid())
+ $navParam->setCancelNavigation(true);
+ $this->_activeStepIndexSet=false;
+ $this->onSideBarButtonClick($navParam);
+ if(!$navParam->getCancelNavigation())
+ {
+ if(!$this->_activeStepIndexSet && $this->allowNavigationToStep($newStepIndex))
+ $this->setActiveStepIndex($newStepIndex);
+ }
+ else
+ $this->setActiveStepIndex($stepIndex);
+ }
+ }
+
+ public function dataListItemDataBound($sender,$param)
+ {
+ $item=$param->getItem();
+ $itemType=$item->getItemType();
+ if($itemType==='Item' || $itemType==='AlternatingItem' || $itemType==='SelectedItem' || $itemType==='EditItem')
+ {
+ if(($button=$item->findControl('SideBarButton'))!==null)
+ {
+ $step=$item->getDataItem();
+ if(($this->getStepType($step)==='Complete'))
+ $button->setEnabled(false);
+ if(($title=$step->getTitle())!=='')
+ $button->setText($title);
+ else
+ $button->setText($step->getID(false));
+ $index=$this->getWizardSteps()->indexOf($step);
+ $button->setCommandName(self::CMD_MOVETO);
+ $button->setCommandParameter("$index");
+ //if($button->getCausesValidation())
+ // $button->attachEventHandler('OnCommand',array($this,'onCommand'));
+ }
+ }
+ }
+
+ protected function createStepContents()
+ {
+ $this->_stepContent=new TPanel;
+ $this->_stepContent->getControls()->add($this->getMultiView());
+ $this->getMultiView()->setActiveViewIndex(0);
+ $this->getControls()->add($this->_stepContent);
+ }
+
+ protected function createNavigation()
+ {
+ $controls=$this->getControls();
+ $this->_startNavigation=$this->createStartNavigation();
+ $controls->add($this->_startNavigation);
+ $this->_stepNavigation=$this->createStepNavigation();
+ $controls->add($this->_stepNavigation);
+ $this->_finishNavigation=$this->createFinishNavigation();
+ $controls->add($this->_finishNavigation);
}
protected function createStartNavigation()
{
if(($template=$this->getStartNavigationTemplate())!==null)
{
- $this->_startNavigation=new TPanel;
- $template->instantiateIn($this->_startNavigation);
+ $navigation=new TPanel;
+ $template->instantiateIn($navigation);
}
else
- $this->_startNavigation=$this->createDefaultStartNavigation();
- $this->getControls()->add($this->_startNavigation);
+ $navigation=$this->createDefaultStartNavigation();
+ return $navigation;
}
protected function createStepNavigation()
{
if(($template=$this->getStepNavigationTemplate())!==null)
{
- $this->_stepNavigation=new TPanel;
- $template->instantiateIn($this->_stepNavigation);
+ $navigation=new TPanel;
+ $template->instantiateIn($navigation);
}
else
- $this->_stepNavigation=$this->createDefaultStepNavigation();
- $this->getControls()->add($this->_stepNavigation);
+ $navigation=$this->createDefaultStepNavigation();
+ return $navigation;
}
protected function createFinishNavigation()
{
if(($template=$this->getFinishNavigationTemplate())!==null)
{
- $this->_finishNavigation=new TPanel;
- $template->instantiateIn($this->_finishNavigation);
+ $navigation=new TPanel;
+ $template->instantiateIn($navigation);
}
else
- $this->_finishNavigation=$this->createDefaultFinishNavigation();
- $this->getControls()->add($this->_finishNavigation);
+ $navigation=$this->createDefaultFinishNavigation();
+ return $navigation;
}
protected function createDefaultStartNavigation()
@@ -820,13 +946,13 @@ class TWizard extends TWebControl implements INamingContainer
switch($buttonStyle->getButtonType())
{
case 'Button':
- $button=Prado::createComponent('System.Web.UI.WebControls.TButton');
+ $button=new TButton;
break;
case 'Link' :
- $button=Prado::createComponent('System.Web.UI.WebControls.TLinkButton');
+ $button=new TLinkButton;
break;
case 'Image' :
- $button=Prado::createComponent('System.Web.UI.WebControls.TImageButton');
+ $button=new TImageButton;
$button->setImageUrl($style->getImageUrl());
break;
default:
@@ -1301,4 +1427,14 @@ class TWizardNavigationEventParameter extends TEventParameter
}
}
+class TWizardSideBarListItemTemplate extends TComponent implements ITemplate
+{
+ public function instantiateIn($parent)
+ {
+ $button=new TLinkButton;
+ $button->setID('SideBarButton');
+ $parent->getControls()->add($button);
+ }
+}
+
?> \ No newline at end of file
diff --git a/framework/core.php b/framework/core.php
index cd66e08c..77841fb2 100644
--- a/framework/core.php
+++ b/framework/core.php
@@ -402,7 +402,7 @@ class PradoBase
*/
public static function getVersion()
{
- return '3.0b';
+ return '3.0RC1';
}
/**