summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/TClientScriptManager.php7
-rw-r--r--framework/Web/UI/TControl.php2
-rw-r--r--framework/Web/UI/TTemplateControl.php2
-rw-r--r--framework/Web/UI/TThemeManager.php6
-rw-r--r--framework/Web/UI/WebControls/TBaseValidator.php30
-rw-r--r--framework/Web/UI/WebControls/TBoundColumn.php10
-rw-r--r--framework/Web/UI/WebControls/TButtonColumn.php9
-rw-r--r--framework/Web/UI/WebControls/TCheckBoxColumn.php10
-rw-r--r--framework/Web/UI/WebControls/TDataGrid.php5
-rw-r--r--framework/Web/UI/WebControls/TDatePicker.php94
-rw-r--r--framework/Web/UI/WebControls/TEditCommandColumn.php22
-rw-r--r--framework/Web/UI/WebControls/THyperLinkColumn.php9
-rw-r--r--framework/Web/UI/WebControls/TListControl.php74
-rw-r--r--framework/Web/UI/WebControls/TValidationSummary.php26
14 files changed, 230 insertions, 76 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index d1f3f457..504cfb40 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -623,13 +623,12 @@ abstract class TClientSideOptions extends TComponent
/**
* Ensure that the javascript statements are wrapped in a javascript
- * function block. Default has no wrapping. Override this method to
- * customize the wrapping javascript function block.
+ * function block as <code>function(sender, parameter){ //code }</code>.
*/
protected function ensureFunction($javascript)
{
- return $javascript;
+ return "function(sender, parameter){ {$javascript} }";
}
}
-?>
+?> \ No newline at end of file
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 4e9361aa..a347b0ba 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -941,7 +941,7 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
{
foreach($this->_rf[self::RF_CONTROLS] as $control)
{
- if($control instanceof $type)
+ if(is_object($control) && get_class($control)===$type)
$controls[]=$control;
if(($control instanceof TControl) && $control->getHasControls())
$controls=array_merge($controls,$control->findControlsByType($type));
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index 3bbe52c5..7d1f2d7e 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -235,6 +235,8 @@ class TTemplateControl extends TCompositeControl
foreach($this->_contents as $id=>$content)
$master->injectContent($id,$content);
}
+ else if(!empty($this->_contents))
+ throw new TConfigurationException('templatecontrol_mastercontrol_required',get_class($this));
parent::initRecursive($namingContainer);
}
}
diff --git a/framework/Web/UI/TThemeManager.php b/framework/Web/UI/TThemeManager.php
index 245f8049..1d80d0c5 100644
--- a/framework/Web/UI/TThemeManager.php
+++ b/framework/Web/UI/TThemeManager.php
@@ -292,10 +292,10 @@ class TTheme extends TApplicationComponent implements ITheme
$template=new TTemplate(file_get_contents($themePath.'/'.$file),$themePath,$themePath.'/'.$file);
foreach($template->getItems() as $skin)
{
- if($skin[0]!==-1)
- throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath));
- else if(!isset($skin[2])) // a text string, ignored
+ if(!isset($skin[2])) // a text string, ignored
continue;
+ else if($skin[0]!==-1)
+ throw new TConfigurationException('theme_control_nested',$skin[1],dirname($themePath));
$type=$skin[1];
$id=isset($skin[2]['skinid'])?$skin[2]['skinid']:0;
unset($skin[2]['skinid']);
diff --git a/framework/Web/UI/WebControls/TBaseValidator.php b/framework/Web/UI/WebControls/TBaseValidator.php
index ff026b49..a6d044ff 100644
--- a/framework/Web/UI/WebControls/TBaseValidator.php
+++ b/framework/Web/UI/WebControls/TBaseValidator.php
@@ -85,7 +85,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
*/
private $_registered=false;
/**
- * @var TClientSideValidatorOptions validator client-script options.
+ * @var TValidatorClientSide validator client-script options.
*/
private $_clientSide;
/**
@@ -167,7 +167,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
$options['ControlCssClass'] = $this->getControlCssClass();
$options['ControlType'] = $this->getClientControlClass($control);
-
+
//get date format from date picker target control
if($control instanceof TDatePicker)
$options['DateFormat'] = $control->getDateFormat();
@@ -194,7 +194,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
}
/**
- * Gets the TClientSideValidatorOptions that allows modification of the client-
+ * Gets the TValidatorClientSide that allows modification of the client-
* side validator events.
*
* The client-side validator supports the following events.
@@ -207,21 +207,21 @@ abstract class TBaseValidator extends TLabel implements IValidator
*
* You can attach custom javascript code to each of these events
*
- * @return TClientSideValidatorOptions javascript validator event options.
+ * @return TValidatorClientSide javascript validator event options.
*/
public function getClientSide()
{
if(is_null($this->_clientSide))
- $this->_clientSide = $this->createClientSideOptions();
+ $this->_clientSide = $this->createClientSide();
return $this->_clientSide;
}
/**
- * @return TClientSideValidatorOptions javascript validator event options.
+ * @return TValidatorClientSide javascript validator event options.
*/
- protected function createClientSideOptions()
+ protected function createClientSide()
{
- return new TClientSideValidatorOptions;
+ return new TValidatorClientSide;
}
/**
@@ -568,11 +568,11 @@ abstract class TBaseValidator extends TLabel implements IValidator
}
/**
- * TClientSideValidatorOptions class.
+ * TValidatorClientSide class.
*
* Client-side validator events can be modified through the {@link
* TBaseValidator::getClientSide ClientSide} property of a validator. The
- * subproperties of ClientSide are those of the TClientSideValidatorOptions
+ * subproperties of ClientSide are those of the TValidatorClientSide
* properties. The client-side validator supports the following events.
*
* The <tt>OnValidate</tt> event is raise before the validator validation
@@ -590,7 +590,7 @@ abstract class TBaseValidator extends TLabel implements IValidator
* @package System.Web.UI.WebControls
* @since 3.0
*/
-class TClientSideValidatorOptions extends TClientSideOptions
+class TValidatorClientSide extends TClientSideOptions
{
/**
* @return string javascript code for client-side OnValidate event.
@@ -659,10 +659,8 @@ class TClientSideValidatorOptions extends TClientSideOptions
*/
public function getObserveChanges()
{
- if(($option=$this->getOption('ObserveChanges'))!==null)
- return $option;
- else
- return true;
+ $changes = $this->getOption('ObserveChanges');
+ return is_null($changes) ? true : $changes;
}
/**
@@ -678,4 +676,4 @@ class TClientSideValidatorOptions extends TClientSideOptions
}
}
-?> \ No newline at end of file
+?>
diff --git a/framework/Web/UI/WebControls/TBoundColumn.php b/framework/Web/UI/WebControls/TBoundColumn.php
index 5975ec02..26fad32b 100644
--- a/framework/Web/UI/WebControls/TBoundColumn.php
+++ b/framework/Web/UI/WebControls/TBoundColumn.php
@@ -26,6 +26,15 @@ Prado::using('System.Web.UI.WebControls.TDataGridColumn');
* If {@link setReadOnly ReadOnly} is false, TBoundColumn will display cells in edit mode
* with textboxes. Otherwise, a static text is displayed.
*
+ * When a datagrid row is in edit mode, the textbox control in the TBoundColumn
+ * can be accessed by one of the following two methods:
+ * <code>
+ * $datagridItem->BoundColumnID->TextBox
+ * $datagridItem->BoundColumnID->Controls[0]
+ * </code>
+ * The second method is possible because the textbox control created within the
+ * datagrid cell is the first child.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -103,6 +112,7 @@ class TBoundColumn extends TDataGridColumn
{
$textBox=Prado::createComponent('System.Web.UI.WebControls.TTextBox');
$cell->getControls()->add($textBox);
+ $cell->registerObject('TextBox',$textBox);
$control=$textBox;
}
if(($dataField=$this->getDataField())!=='')
diff --git a/framework/Web/UI/WebControls/TButtonColumn.php b/framework/Web/UI/WebControls/TButtonColumn.php
index 20844f14..fdcf58d3 100644
--- a/framework/Web/UI/WebControls/TButtonColumn.php
+++ b/framework/Web/UI/WebControls/TButtonColumn.php
@@ -39,6 +39,14 @@ Prado::using('System.Web.UI.WebControls.TImageButton');
* The buttons' <b>CausesValidation</b> and <b>ValidationGroup</b> property values
* are determined by the column's corresponding properties.
*
+ * The buttons in the column can be accessed by one of the following two methods:
+ * <code>
+ * $datagridItem->ButtonColumnID->Button
+ * $datagridItem->ButtonColumnID->Controls[0]
+ * </code>
+ * The second method is possible because the button control created within the
+ * datagrid cell is the first child.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -238,6 +246,7 @@ class TButtonColumn extends TDataGridColumn
if($this->getDataTextField()!=='' || ($buttonType==='ImageButton' && $this->getDataImageUrlField()!==''))
$button->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
$cell->getControls()->add($button);
+ $cell->registerObject('Button',$button);
}
}
diff --git a/framework/Web/UI/WebControls/TCheckBoxColumn.php b/framework/Web/UI/WebControls/TCheckBoxColumn.php
index 4df1e695..d7fac8cf 100644
--- a/framework/Web/UI/WebControls/TCheckBoxColumn.php
+++ b/framework/Web/UI/WebControls/TCheckBoxColumn.php
@@ -28,6 +28,15 @@ Prado::using('System.Web.UI.WebControls.TCheckBox');
* TCheckBoxColumn will display an enabled checkbox provided the cells are
* in edit mode. Otherwise, the checkboxes will be disabled to prevent from editting.
*
+ * The checkbox control in the TCheckBoxColumn can be accessed by one of
+ * the following two methods:
+ * <code>
+ * $datagridItem->CheckBoxColumnID->CheckBox
+ * $datagridItem->CheckBoxColumnID->Controls[0]
+ * </code>
+ * The second method is possible because the checkbox control created within the
+ * datagrid cell is the first child.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -87,6 +96,7 @@ class TCheckBoxColumn extends TDataGridColumn
$checkBox->setEnabled(false);
$cell->setHorizontalAlign('Center');
$cell->getControls()->add($checkBox);
+ $cell->registerObject('CheckBox',$checkBox);
if($this->getDataField()!=='')
$checkBox->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
}
diff --git a/framework/Web/UI/WebControls/TDataGrid.php b/framework/Web/UI/WebControls/TDataGrid.php
index e27f6ead..ad30ff3f 100644
--- a/framework/Web/UI/WebControls/TDataGrid.php
+++ b/framework/Web/UI/WebControls/TDataGrid.php
@@ -1075,6 +1075,11 @@ class TDataGrid extends TBaseDataList implements INamingContainer
$cell=new TTableHeaderCell;
else
$cell=new TTableCell;
+ if(($id=$column->getID())!=='')
+ {
+ $cell->setID($id);
+ $item->registerObject($id,$cell);
+ }
$column->initializeCell($cell,$index,$itemType);
$cells->add($cell);
$index++;
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index 001c7c46..0c3e0b9a 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -19,8 +19,6 @@ Prado::using('System.Web.UI.WebControls.TTextBox');
*
* TDatePicker class.
*
- * Be aware, this control is EXPERIMENTAL and is not stablized yet.
- *
* TDatePicker displays a text box for date input purpose.
* When the text box receives focus, a calendar will pop up and users can
* pick up from it a date that will be automatically entered into the text box.
@@ -69,14 +67,18 @@ Prado::using('System.Web.UI.WebControls.TTextBox');
class TDatePicker extends TTextBox
{
/**
+ * @var TDatePickerClientScript validator client-script options.
+ */
+ private $_clientScript;
+ /**
* AutoPostBack is not supported.
*/
public function setAutoPostBack($value)
{
throw new TNotSupportedException('tdatepicker_autopostback_unsupported',
- get_class($this));
+ get_class($this));
}
-
+
/**
* @return string the format of the date string
*/
@@ -278,7 +280,7 @@ class TDatePicker extends TTextBox
{
return $this->getText();
}
-
+
/**
* @param string date string
*/
@@ -288,6 +290,31 @@ class TDatePicker extends TTextBox
}
/**
+ * Gets the TDatePickerClientScript to set the TDatePicker event handlers.
+ *
+ * The date picker on the client-side supports the following events.
+ * # <tt>OnDateChanged</tt> -- raised when the date is changed.
+ *
+ * You can attach custom javascript code to each of these events
+ *
+ * @return TDatePickerClientScript javascript validator event options.
+ */
+ public function getClientSide()
+ {
+ if(is_null($this->_clientScript))
+ $this->_clientScript = $this->createClientScript();
+ return $this->_clientScript;
+ }
+
+ /**
+ * @return TDatePickerClientScript javascript validator event options.
+ */
+ protected function createClientScript()
+ {
+ return new TDatePickerClientScript;
+ }
+
+ /**
* Returns the value to be validated.
* This methid is required by IValidatable interface.
* @return integer the value of the property to be validated.
@@ -394,7 +421,7 @@ class TDatePicker extends TTextBox
$year = intval($values[$key.'$year']);
else
$year = $date['year'];
-
+
$date = @mktime(0, 0, 0, $month, $day, $year);
$pattern = $this->getDateFormat();
@@ -421,6 +448,9 @@ class TDatePicker extends TTextBox
$options['Trigger'] = $this->getDatePickerButtonID();
$options = array_merge($options, $this->getCulturalOptions());
+ if(!is_null($this->_clientScript))
+ $options = array_merge($options,
+ $this->_clientScript->getOptions()->toArray());
return $options;
}
@@ -583,7 +613,7 @@ class TDatePicker extends TTextBox
$writer->addAttribute('name', $this->getUniqueID().'$month');
$writer->addAttribute('class', 'datepicker_month_options');
if($this->getReadOnly() || !$this->getEnabled(true))
- $writer->addAttribute('disabled', 'disabled');
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$this->renderDropDownListOptions($writer,
$this->getLocalizedMonthNames($info), $selected-1);
@@ -604,8 +634,8 @@ class TDatePicker extends TTextBox
switch($formatter->getMonthPattern())
{
case 'MMM': return $info->getAbbreviatedMonthNames();
- case 'MM':
- $array = array();
+ case 'MM':
+ $array = array();
for($i=1;$i<=12;$i++)
$array[$i-1] = $i < 10 ? '0'.$i : $i;
return $array;
@@ -629,7 +659,7 @@ class TDatePicker extends TTextBox
$writer->addAttribute('id', $this->getClientID().'_year');
$writer->addAttribute('name', $this->getUniqueID().'$year');
if($this->getReadOnly() || !$this->getEnabled(true))
- $writer->addAttribute('disabled', 'disabled');
+ $writer->addAttribute('disabled', 'disabled');
$writer->renderBeginTag('select');
$writer->addAttribute('class', 'datepicker_year_options');
$this->renderDropDownListOptions($writer, $years, $selected);
@@ -705,7 +735,7 @@ class TDatePicker extends TTextBox
else
throw new TConfigurationException('datepicker_calendarstyle_invalid',$style);
}
-
+
/**
* Publish the spacer.gif for IE iframe source.
* @return string the URL for the spacer.gif.
@@ -739,16 +769,54 @@ class TDatePicker extends TTextBox
{
$cs = $this->getPage()->getClientScript();
$cs->registerPradoScript("datepicker");
-
+
if(!$cs->isEndScriptRegistered('TDatePicker.spacer'))
{
$spacer = $this->publishIFrameSpacer();
$code = "Prado.WebUI.TDatePicker.spacer = '$spacer';";
$cs->registerEndScript('TDatePicker.spacer', $code);
}
- $cs->registerPostBackControl('Prado.WebUI.TDatePicker', $this->getDatePickerOptions());
+
+ $options = TJavaScript::encode($this->getDatePickerOptions());
+ $code = "new Prado.WebUI.TDatePicker($options);";
+ $cs->registerEndScript("prado:".$this->getClientID(), $code);
}
}
}
+/**
+ * TDatePickerClientScript class.
+ *
+ * Client-side date picker event {@link setOnDateChanged OnDateChanged}
+ * can be modified through the {@link TDatePicker:: getClientSide ClientSide}
+ * property of a date picker.
+ *
+ * The <tt>OnDateChanged</tt> event is raise when the date picker's date
+ * is changed.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @version $Revision: $ $Date: $
+ * @package System.Web.UI.WebControls
+ * @since 3.0.4
+ */
+class TDatePickerClientScript extends TClientSideOptions
+{
+ /**
+ * Javascript code to execute when the date picker's date is changed.
+ * @param string javascript code
+ */
+ public function setOnDateChanged($javascript)
+ {
+ $this->setFunction('OnDateChanged', $javascript);
+ }
+
+ /**
+ * @return string javascript code to execute when the date picker's date is changed.
+ */
+ public function getOnDateChanged()
+ {
+ return $this->getOption('OnDateChanged');
+ }
+}
+
?>
diff --git a/framework/Web/UI/WebControls/TEditCommandColumn.php b/framework/Web/UI/WebControls/TEditCommandColumn.php
index 65e389bd..c742ef11 100644
--- a/framework/Web/UI/WebControls/TEditCommandColumn.php
+++ b/framework/Web/UI/WebControls/TEditCommandColumn.php
@@ -38,6 +38,14 @@ Prado::using('System.Web.UI.WebControls.TDataGridColumn');
* properties affect the corresponding properties of the edit and update buttons.
* The cancel button does not cause validation by default.
*
+ * The command buttons in the column can be accessed by one of the following methods:
+ * <code>
+ * $datagridItem->ButtonColumnID->EditButton (or UpdateButton, CancelButton)
+ * $datagridItem->ButtonColumnID->Controls[0]
+ * </code>
+ * The second method is possible because the button control created within the
+ * datagrid cell is the first child.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -154,13 +162,21 @@ class TEditCommandColumn extends TDataGridColumn
{
parent::initializeCell($cell,$columnIndex,$itemType);
if($itemType===TDataGrid::IT_ITEM || $itemType===TDataGrid::IT_ALTERNATINGITEM || $itemType===TDataGrid::IT_SELECTEDITEM)
- $cell->getControls()->add($this->createButton('Edit',$this->getEditText(),false,''));
+ {
+ $button=$this->createButton('Edit',$this->getEditText(),false,'');
+ $cell->getControls()->add($button);
+ $cell->registerObject('EditButton',$button);
+ }
else if($itemType===TDataGrid::IT_EDITITEM)
{
$controls=$cell->getControls();
- $controls->add($this->createButton('Update',$this->getUpdateText(),$this->getCausesValidation(),$this->getValidationGroup()));
+ $button=$this->createButton('Update',$this->getUpdateText(),$this->getCausesValidation(),$this->getValidationGroup());
+ $controls->add($button);
+ $cell->registerObject('UpdateButton',$button);
$controls->add('&nbsp;');
- $controls->add($this->createButton('Cancel',$this->getCancelText(),false,''));
+ $button=$this->createButton('Cancel',$this->getCancelText(),false,'');
+ $controls->add($button);
+ $cell->registerObject('CancelButton',$button);
}
}
diff --git a/framework/Web/UI/WebControls/THyperLinkColumn.php b/framework/Web/UI/WebControls/THyperLinkColumn.php
index 9fc1e3d2..b8dbb607 100644
--- a/framework/Web/UI/WebControls/THyperLinkColumn.php
+++ b/framework/Web/UI/WebControls/THyperLinkColumn.php
@@ -36,6 +36,14 @@ Prado::using('System.Web.UI.WebControls.THyperLink');
* The same rule applies to {@link setNavigateUrl NavigateUrl} and
* {@link setDataNavigateUrlField DataNavigateUrlField} properties.
*
+ * The hyperlinks in the column can be accessed by one of the following two methods:
+ * <code>
+ * $datagridItem->HyperLinkColumnID->HyperLink
+ * $datagridItem->HyperLinkColumnID->Controls[0]
+ * </code>
+ * The second method is possible because the hyperlink control created within the
+ * datagrid cell is the first child.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -178,6 +186,7 @@ class THyperLinkColumn extends TDataGridColumn
if($this->getDataTextField()!=='' || $this->getDataNavigateUrlField()!=='')
$link->attachEventHandler('OnDataBinding',array($this,'dataBindColumn'));
$cell->getControls()->add($link);
+ $cell->registerObject('HyperLink',$link);
}
}
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php
index 8c1537b0..76c59903 100644
--- a/framework/Web/UI/WebControls/TListControl.php
+++ b/framework/Web/UI/WebControls/TListControl.php
@@ -94,6 +94,8 @@ abstract class TListControl extends TDataBoundControl
*/
private $_cachedSelectedIndex=-1;
private $_cachedSelectedValue=null;
+ private $_cachedSelectedIndices=null;
+ private $_cachedSelectedValues=null;
/**
* @return string tag name of the list control
@@ -213,20 +215,34 @@ abstract class TListControl extends TDataBoundControl
// so we make them be effective now
if($this->_cachedSelectedValue!==null)
{
- $index=$items->findIndexByValue($this->_cachedSelectedValue);
- if($index===-1 || ($this->_cachedSelectedIndex!==-1 && $this->_cachedSelectedIndex!==$index))
- throw new TInvalidDataValueException('listcontrol_selection_invalid',get_class($this));
- $this->setSelectedIndex($index);
- $this->_cachedSelectedValue=null;
- $this->_cachedSelectedIndex=-1;
+ $this->setSelectedValue($this->_cachedSelectedValue);
+ $this->resetCachedSelections();
}
else if($this->_cachedSelectedIndex!==-1)
{
$this->setSelectedIndex($this->_cachedSelectedIndex);
- $this->_cachedSelectedIndex=-1;
+ $this->resetCachedSelections();
+ }
+ else if($this->_cachedSelectedValues!==null)
+ {
+ $this->setSelectedValues($this->_cachedSelectedValues);
+ $this->resetCachedSelections();
+ }
+ else if($this->_cachedSelectedIndices!==null)
+ {
+ $this->setSelectedIndices($this->_cachedSelectedIndices);
+ $this->resetCachedSelections();
}
}
+ private function resetCachedSelections()
+ {
+ $this->_cachedSelectedValue=null;
+ $this->_cachedSelectedIndex=-1;
+ $this->_cachedSelectedValues=null;
+ $this->_cachedSelectedIndices=null;
+ }
+
/**
* Creates a collection object to hold list items.
* This method may be overriden to create a customized collection.
@@ -461,16 +477,22 @@ abstract class TListControl extends TDataBoundControl
*/
public function setSelectedIndices($indices)
{
- if($this->_items)
+ if($this->getIsMultiSelect())
{
- $this->clearSelection();
- $n=$this->_items->getCount();
- foreach($indices as $index)
+ if($this->_items)
{
- if($index>=0 && $index<$n)
- $this->_items->itemAt($index)->setSelected(true);
+ $this->clearSelection();
+ $n=$this->_items->getCount();
+ foreach($indices as $index)
+ {
+ if($index>=0 && $index<$n)
+ $this->_items->itemAt($index)->setSelected(true);
+ }
}
+ $this->_cachedSelectedIndices=$indices;
}
+ else
+ throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this));
if($this->getAdapter() instanceof IListControlAdapter)
$this->getAdapter()->setSelectedIndices($indices);
@@ -544,20 +566,26 @@ abstract class TListControl extends TDataBoundControl
*/
public function setSelectedValues($values)
{
- if($this->_items)
+ if($this->getIsMultiSelect())
{
- $this->clearSelection();
- $lookup=array();
- foreach($this->_items as $item)
- $lookup[$item->getValue()]=$item;
- foreach($values as $value)
+ if($this->_items)
{
- if(isset($lookup["$value"]))
- $lookup["$value"]->setSelected(true);
- else
- throw new TInvalidDataValueException('listcontrol_selectedvalue_invalid',get_class($this),$value);
+ $this->clearSelection();
+ $lookup=array();
+ foreach($this->_items as $item)
+ $lookup[$item->getValue()]=$item;
+ foreach($values as $value)
+ {
+ if(isset($lookup["$value"]))
+ $lookup["$value"]->setSelected(true);
+ else
+ throw new TInvalidDataValueException('listcontrol_selectedvalue_invalid',get_class($this),$value);
+ }
}
+ $this->_cachedSelectedValues=$values;
}
+ else
+ throw new TNotSupportedException('listcontrol_multiselect_unsupported',get_class($this));
if($this->getAdapter() instanceof IListControlAdapter)
$this->getAdapter()->setSelectedValues($values);
diff --git a/framework/Web/UI/WebControls/TValidationSummary.php b/framework/Web/UI/WebControls/TValidationSummary.php
index cfb57c5b..796a62f0 100644
--- a/framework/Web/UI/WebControls/TValidationSummary.php
+++ b/framework/Web/UI/WebControls/TValidationSummary.php
@@ -40,7 +40,7 @@ class TValidationSummary extends TWebControl
* @var TClientSideValidationSummaryOptions validation client side options.
*/
private $_clientSide;
-
+
/**
* Constructor.
* This method sets the foreground color to red.
@@ -232,7 +232,7 @@ class TValidationSummary extends TWebControl
if($this->getEnableClientScript() && !$cs->isEndScriptRegistered($scriptKey))
{
$manager['FormID'] = $formID;
- $options = TJavaScript::encode($manager);
+ $options = TJavaScript::encode($manager);
$cs->registerPradoScript('validator');
$cs->registerEndScript($scriptKey, "new Prado.ValidationManager({$options});");
}
@@ -262,7 +262,7 @@ class TValidationSummary extends TWebControl
$options['Refresh'] = $this->getAutoUpdate();
$options['ValidationGroup'] = $this->getValidationGroup();
$options['Display'] = $this->getDisplay();
-
+
if(!is_null($this->_clientSide))
$options = array_merge($options,$this->_clientSide->getOptions()->toArray());
@@ -279,7 +279,7 @@ class TValidationSummary extends TWebControl
$this->_clientSide = $this->createClientScript();
return $this->_clientSide;
}
-
+
/**
* @return TClientSideValidationSummaryOptions javascript validation summary
* event options.
@@ -388,20 +388,20 @@ class TValidationSummary extends TWebControl
/**
* TClientSideValidationSummaryOptions class.
- *
+ *
* Client-side validation summary events such as {@link setOnHideSummary
* OnHideSummary} and {@link setOnShowSummary OnShowSummary} can be modified
* through the {@link TBaseValidator:: getClientSide ClientSide} property of a
* validation summary.
- *
+ *
* The <tt>OnHideSummary</tt> event is raise when the validation summary
* requests to hide the messages.
- *
+ *
* The <tt>OnShowSummary</tt> event is raised when the validation summary
* requests to show the messages.
- *
+ *
* See the quickstart documentation for further details.
- *
+ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
@@ -416,7 +416,7 @@ class TClientSideValidationSummaryOptions extends TClientSideOptions
{
return $this->getOption('OnHideSummary');
}
-
+
/**
* Client-side OnHideSummary validation summary event is raise when all the
* validators are valid. This will override the default client-side
@@ -427,7 +427,7 @@ class TClientSideValidationSummaryOptions extends TClientSideOptions
{
$this->setFunction('OnHideSummary', $javascript);
}
-
+
/**
* Client-side OnShowSummary event is raise when one or more validators are
* not valid. This will override the default client-side validation summary
@@ -438,7 +438,7 @@ class TClientSideValidationSummaryOptions extends TClientSideOptions
{
$this->setFunction('OnShowSummary', $javascript);
}
-
+
/**
* @return string javascript code for client-side OnShowSummary event.
*/
@@ -460,4 +460,4 @@ class TClientSideValidationSummaryOptions extends TClientSideOptions
}
}
-?> \ No newline at end of file
+?>