diff options
Diffstat (limited to 'framework')
49 files changed, 2293 insertions, 1969 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveBoundColumn.php b/framework/Web/UI/ActiveControls/TActiveBoundColumn.php new file mode 100644 index 00000000..47300ca4 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveBoundColumn.php @@ -0,0 +1,87 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + + +/** + * TActiveBoundColumn class + * + * TActiveBoundColumn represents a column that is bound to a field in a data source. + * The cells in the column will be displayed using the data indexed by + * {@link setDataField DataField}. You can customize the display by + * setting {@link setDataFormatString DataFormatString}. + * + * This is the active counterpart to the {@link TBoundColumn} control. For that purpose, + * if sorting is allowed, the header links/buttons are replaced by active controls. + * + * Please refer to the original documentation of the {@link TBoundColumn} for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveBoundColumn extends TBoundColumn { + protected function initializeHeaderCell($cell,$columnIndex) { + $text=$this->getHeaderText(); + + if(($classPath=$this->getHeaderRenderer())!=='') { + $control=Prado::createComponent($classPath); + if($control instanceof IDataRenderer) { + if($control instanceof IItemDataRenderer) { + $item=$cell->getParent(); + $control->setItemIndex($item->getItemIndex()); + $control->setItemType($item->getItemType()); + } + $control->setData($text); + } + $cell->getControls()->add($control); + } + else if($this->getAllowSorting()) { + $sortExpression=$this->getSortExpression(); + if(($url=$this->getHeaderImageUrl())!=='') { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); + $button->setImageUrl($url); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + if($text!=='') { + $button->setAlternateText($text); + $button->setToolTip($text); + } + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else if($text!=='') { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); + $button->setText($text); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else + $cell->setText(' '); + } + else { + if(($url=$this->getHeaderImageUrl())!=='') { + $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); + $image->setImageUrl($url); + if($text!=='') { + $image->setAlternateText($text); + $image->setToolTip($text); + } + $cell->getControls()->add($image); + } + else if($text!=='') + $cell->setText($text); + else + $cell->setText(' '); + } + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveButtonColumn.php b/framework/Web/UI/ActiveControls/TActiveButtonColumn.php new file mode 100644 index 00000000..4857f2e8 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveButtonColumn.php @@ -0,0 +1,54 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + + +/** + * TActiveButtonColumn class + * + * TActiveButtonColumn contains a user-defined command button, such as Add or Remove, + * that corresponds with each row in the column. + * + * This is the active counterpart to the {@link TButtonColumn} control where the + * button is replaced by the appropriate active button control. + * + * Please refer to the original documentation of the {@link TButtonColumn} for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveButtonColumn extends TButtonColumn { + public function initializeCell($cell,$columnIndex,$itemType) { + if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) { + $buttonType=$this->getButtonType(); + if($buttonType===TButtonColumnType::LinkButton) + $button=new TActiveLinkButton; + else if($buttonType===TButtonColumnType::PushButton) + $button=new TActiveButton; + else // image button + { + $button=new TActiveImageButton; + $button->setImageUrl($this->getImageUrl()); + $button->setToolTip($this->getText()); + } + $button->setText($this->getText()); + $button->setCommandName($this->getCommandName()); + $button->setCausesValidation($this->getCausesValidation()); + $button->setValidationGroup($this->getValidationGroup()); + if($this->getDataTextField()!=='' || ($buttonType===TButtonColumnType::ImageButton && $this->getDataImageUrlField()!=='')) + $button->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); + $cell->getControls()->add($button); + $cell->registerObject('Button',$button); + } + else + parent::initializeCell($cell,$columnIndex,$itemType); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxColumn.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxColumn.php new file mode 100644 index 00000000..222d24e7 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxColumn.php @@ -0,0 +1,116 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveCheckBoxColumn class + * + * TActiveCheckBoxColumn represents a checkbox column that is bound to a field in a data source. + * + * This is the active counterpart to the {@link TCheckBoxColumn} control. For that purpose, + * if sorting is allowed, the header links/buttons are replaced by active controls. + * + * Please refer to the original documentation of the {@link TCheckBoxColumn} for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveCheckBoxColumn extends TCheckBoxColumn +{ + /** + * Initializes the specified cell to its initial values. + * This method overrides the parent implementation. + * It creates a checkbox inside the cell. + * If the column is read-only or if the item is not in edit mode, + * the checkbox will be set disabled. + * @param TTableCell the cell to be initialized. + * @param integer the index to the Columns property that the cell resides in. + * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) + */ + public function initializeCell($cell,$columnIndex,$itemType) + { + if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) + { + $checkBox=new TActiveCheckBox; + if($this->getReadOnly() || $itemType!==TListItemType::EditItem) + $checkBox->setEnabled(false); + $cell->setHorizontalAlign('Center'); + $cell->getControls()->add($checkBox); + $cell->registerObject('CheckBox',$checkBox); + if($this->getDataField()!=='') + $checkBox->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); + } + else + parent::initializeCell($cell,$columnIndex,$itemType); + } + + protected function initializeHeaderCell($cell,$columnIndex) + { + $text=$this->getHeaderText(); + + if(($classPath=$this->getHeaderRenderer())!=='') + { + $control=Prado::createComponent($classPath); + if($control instanceof IDataRenderer) + { + if($control instanceof IItemDataRenderer) + { + $item=$cell->getParent(); + $control->setItemIndex($item->getItemIndex()); + $control->setItemType($item->getItemType()); + } + $control->setData($text); + } + $cell->getControls()->add($control); + } + else if($this->getAllowSorting()) + { + $sortExpression=$this->getSortExpression(); + if(($url=$this->getHeaderImageUrl())!=='') + { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); + $button->setImageUrl($url); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + if($text!=='') + $button->setAlternateText($text); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else if($text!=='') + { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); + $button->setText($text); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else + $cell->setText(' '); + } + else + { + if(($url=$this->getHeaderImageUrl())!=='') + { + $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); + $image->setImageUrl($url); + if($text!=='') + $image->setAlternateText($text); + $cell->getControls()->add($image); + } + else if($text!=='') + $cell->setText($text); + else + $cell->setText(' '); + } + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php index ea174c94..2ee7ce5f 100644 --- a/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php +++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxList.php @@ -124,20 +124,4 @@ class TActiveCheckBoxList extends TCheckBoxList implements IActiveControl, ICall { return 'Prado.WebUI.TActiveCheckBoxList'; } -} - -class TActiveCheckBoxListItem extends TActiveCheckBox -{ - /** - * Override client implementation to avoid emitting the javascript - * - * @param THtmlWriter the writer for the rendering purpose - * @param string checkbox id - * @param string onclick js - */ - protected function renderInputTag($writer,$clientID,$onclick) - { - TCheckBox::renderInputTag($writer,$clientID,$onclick); - } -} - +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveCheckBoxListItem.php b/framework/Web/UI/ActiveControls/TActiveCheckBoxListItem.php new file mode 100644 index 00000000..931b78f2 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveCheckBoxListItem.php @@ -0,0 +1,25 @@ +<?php +/** + * TActiveCheckBoxList class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +class TActiveCheckBoxListItem extends TActiveCheckBox +{ + /** + * Override client implementation to avoid emitting the javascript + * + * @param THtmlWriter the writer for the rendering purpose + * @param string checkbox id + * @param string onclick js + */ + protected function renderInputTag($writer,$clientID,$onclick) + { + TCheckBox::renderInputTag($writer,$clientID,$onclick); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php index bf1bc9f5..8557f2c1 100644 --- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php @@ -167,382 +167,4 @@ class TActiveControlAdapter extends TControlAdapter { return $this->_stateTracker; } -} - -/** - * TCallbackPageStateTracker class. - * - * Tracking changes to the page state during callback. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TCallbackPageStateTracker -{ - /** - * @var TMap new view state data - */ - private $_states; - /** - * @var TMap old view state data - */ - private $_existingState; - /** - * @var TControl the control tracked - */ - private $_control; - /** - * @var object null object. - */ - private $_nullObject; - - /** - * Constructor. Add a set of default states to track. - * @param TControl control to track. - */ - public function __construct($control) - { - $this->_control = $control; - $this->_existingState = new TMap; - $this->_nullObject = new stdClass; - $this->_states = new TMap; - $this->addStatesToTrack(); - } - - /** - * Add a list of view states to track. Each state is added - * to the StatesToTrack property with the view state name as key. - * The value should be an array with two enteries. The first entery - * is the name of the class that will calculate the state differences. - * The second entry is a php function/method callback that handles - * the changes in the viewstate. - */ - protected function addStatesToTrack() - { - $states = $this->getStatesToTrack(); - $states['Visible'] = array('TScalarDiff', array($this, 'updateVisible')); - $states['Enabled'] = array('TScalarDiff', array($this, 'updateEnabled')); - $states['Attributes'] = array('TMapCollectionDiff', array($this, 'updateAttributes')); - $states['Style'] = array('TStyleDiff', array($this, 'updateStyle')); - $states['TabIndex'] = array('TScalarDiff', array($this, 'updateTabIndex')); - $states['ToolTip'] = array('TScalarDiff', array($this, 'updateToolTip')); - $states['AccessKey'] = array('TScalarDiff', array($this, 'updateAccessKey')); - } - - /** - * @return TMap list of viewstates to track. - */ - protected function getStatesToTrack() - { - return $this->_states; - } - - /** - * Start tracking view state changes. The clone function on objects are called - * for those viewstate having an object as value. - */ - public function trackChanges() - { - foreach($this->_states as $name => $value) - { - $obj = $this->_control->getViewState($name); - $this->_existingState[$name] = is_object($obj) ? clone($obj) : $obj; - } - } - - /** - * @return array list of viewstate and the changed data. - */ - protected function getChanges() - { - $changes = array(); - foreach($this->_states as $name => $details) - { - $new = $this->_control->getViewState($name); - $old = $this->_existingState[$name]; - if($new !== $old) - { - $diff = new $details[0]($new, $old, $this->_nullObject); - if(($change = $diff->getDifference()) !== $this->_nullObject) - $changes[] = array($details[1],array($change)); - } - } - return $changes; - } - - /** - * For each of the changes call the corresponding change handlers. - */ - public function respondToChanges() - { - foreach($this->getChanges() as $change) - call_user_func_array($change[0], $change[1]); - } - - /** - * @return TCallbackClientScript callback client scripting - */ - protected function client() - { - return $this->_control->getPage()->getCallbackClient(); - } - - /** - * Updates the tooltip. - * @param string new tooltip - */ - protected function updateToolTip($value) - { - $this->client()->setAttribute($this->_control, 'title', $value); - } - - /** - * Updates the tab index. - * @param integer tab index - */ - protected function updateTabIndex($value) - { - $this->client()->setAttribute($this->_control, 'tabindex', $value); - } - - /** - * Updates the modifier access key - * @param string access key - */ - protected function updateAccessKey($value) - { - $this->client()->setAttribute($this->_control, 'accesskey', $value); - } - - /** - * Hides or shows the control on the client-side. The control must be - * already rendered on the client-side. - * @param boolean true to show the control, false to hide. - */ - protected function updateVisible($visible) - { - if($visible === false) - $this->client()->replaceContent($this->_control,"<span id=\"".$this->_control->getClientID()."\" style=\"display:none\" ></span>"); - else - $this->client()->replaceContent($this->_control,$this->_control); - } - - /** - * Enables or Disables the control on the client-side. - * @param boolean true to enable the control, false to disable. - */ - protected function updateEnabled($enable) - { - $this->client()->setAttribute($this->_control, 'disabled', $enable===false); - } - - /** - * Updates the CSS style on the control on the client-side. - * @param array list of new CSS style declarations. - */ - protected function updateStyle($style) - { - if($style['CssClass']!==null) - $this->client()->setAttribute($this->_control, 'class', $style['CssClass']); - if(count($style['Style']) > 0) - $this->client()->setStyle($this->_control, $style['Style']); - } - - /** - * Updates/adds a list of attributes on the control. - * @param array list of attribute name-value pairs. - */ - protected function updateAttributes($attributes) - { - foreach($attributes as $name => $value) - $this->client()->setAttribute($this->_control, $name, $value); - } -} - -/** - * Calculates the viewstate changes during the request. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -abstract class TViewStateDiff -{ - /** - * @var mixed updated viewstate - */ - protected $_new; - /** - * @var mixed viewstate value at the begining of the request. - */ - protected $_old; - /** - * @var object null value. - */ - protected $_null; - - /** - * Constructor. - * @param mixed updated viewstate value. - * @param mixed viewstate value at the begining of the request. - * @param object representing the null value. - */ - public function __construct($new, $old, $null) - { - $this->_new = $new; - $this->_old = $old; - $this->_null = $null; - } - - /** - * @return mixed view state changes, nullObject if no difference. - */ - public abstract function getDifference(); -} - -/** - * TScalarDiff class. - * - * Calculate the changes to a scalar value. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TScalarDiff extends TViewStateDiff -{ - /** - * @return mixed update viewstate value. - */ - public function getDifference() - { - if(gettype($this->_new) === gettype($this->_old) - && $this->_new === $this->_old) - return $this->_null; - else - return $this->_new; - } -} - -/** - * TStyleDiff class. - * - * Calculates the changes to the Style properties. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TStyleDiff extends TViewStateDiff -{ - /** - * @param TStyle control style - * @return array all the style properties combined. - */ - protected function getCombinedStyle($obj) - { - if(!($obj instanceof TStyle)) - return array(); - $style = $obj->getStyleFields(); - $style = array_merge($style,$this->getStyleFromString($obj->getCustomStyle())); - if($obj->hasFont()) - $style = array_merge($style, $this->getStyleFromString($obj->getFont()->toString())); - return $style; - } - - /** - * @param string CSS custom style string. - * @param array CSS style as name-value array. - */ - protected function getStyleFromString($string) - { - $style = array(); - if(!is_string($string)) return $style; - - foreach(explode(';',$string) as $sub) - { - $arr=explode(':',$sub); - if(isset($arr[1]) && trim($arr[0])!=='') - $style[trim($arr[0])] = trim($arr[1]); - } - return $style; - } - - /** - * @return string changes to the CSS class name. - */ - protected function getCssClassDiff() - { - if($this->_old===null) - { - return ($this->_new!==null) && $this->_new->hasCssClass() - ? $this->_new->getCssClass() : null; - } - else - { - return $this->_old->getCssClass() !== $this->_new->getCssClass() ? - $this->_new->getCssClass() : null; - } - } - - /** - * @return array list of changes to the control style. - */ - protected function getStyleDiff() - { - $diff = array_diff_assoc( - $this->getCombinedStyle($this->_new), - $this->getCombinedStyle($this->_old)); - return count($diff) > 0 ? $diff : null; - } - - /** - * @return array list of changes to the control style and CSS class name. - */ - public function getDifference() - { - if($this->_new===null) - return $this->_null; - else - { - $css = $this->getCssClassDiff(); - $style = $this->getStyleDiff(); - if(($css!==null) || ($style!==null)) - return array('CssClass' => $css, 'Style' => $style); - else - $this->_null; - } - } -} - -/** - * TAttributesDiff class. - * - * Calculate the changes to attributes collection. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TMapCollectionDiff extends TViewStateDiff -{ - /** - * @return array updates to the attributes collection. - */ - public function getDifference() - { - if($this->_old===null) - { - return ($this->_new!==null) ? $this->_new->toArray() : $this->_null; - } - else - { - $new = $this->_new->toArray(); - $old = $this->_old->toArray(); - $diff = array_diff_assoc($new, $old); - return count($diff) > 0 ? $diff : $this->_null; - } - } -} - +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php index f05704fc..e51bd4d2 100644 --- a/framework/Web/UI/ActiveControls/TActiveCustomValidator.php +++ b/framework/Web/UI/ActiveControls/TActiveCustomValidator.php @@ -178,85 +178,4 @@ class TActiveCustomValidator extends TCustomValidator { return 'Prado.WebUI.TActiveCustomValidator'; } -} - -/** - * Custom Validator callback client side options class. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TActiveCustomValidatorClientSide extends TCallbackClientSide -{ - /** - * @return string javascript code for client-side OnValidate event. - */ - public function getOnValidate() - { - return $this->getOption('OnValidate'); - } - - /** - * Client-side OnValidate validator event is raise before the validators - * validation functions are called. - * @param string javascript code for client-side OnValidate event. - */ - public function setOnValidate($javascript) - { - $this->setFunction('OnValidate', $javascript); - } - - /** - * Client-side OnSuccess event is raise after validation is successfull. - * This will override the default client-side validator behaviour. - * @param string javascript code for client-side OnSuccess event. - */ - public function setOnValidationSuccess($javascript) - { - $this->setFunction('OnValidationSuccess', $javascript); - } - - /** - * @return string javascript code for client-side OnSuccess event. - */ - public function getOnValidationSuccess() - { - return $this->getOption('OnValidationSuccess'); - } - - /** - * Client-side OnError event is raised after validation failure. - * This will override the default client-side validator behaviour. - * @param string javascript code for client-side OnError event. - */ - public function setOnValidationError($javascript) - { - $this->setFunction('OnValidationError', $javascript); - } - - /** - * @return string javascript code for client-side OnError event. - */ - public function getOnValidationError() - { - return $this->getOption('OnValidationError'); - } - - /** - * @param boolean true to revalidate when the control to validate changes value. - */ - public function setObserveChanges($value) - { - $this->setOption('ObserveChanges', TPropertyValue::ensureBoolean($value)); - } - - /** - * @return boolean true to observe changes. - */ - public function getObserveChanges() - { - $changes = $this->getOption('ObserveChanges'); - return ($changes===null) ? true : $changes; - } -} +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveCustomValidatorClientSide.php b/framework/Web/UI/ActiveControls/TActiveCustomValidatorClientSide.php new file mode 100644 index 00000000..d6ec4bac --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveCustomValidatorClientSide.php @@ -0,0 +1,91 @@ +<?php +/** + * TActiveCustomValidator class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * Custom Validator callback client side options class. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TActiveCustomValidatorClientSide extends TCallbackClientSide +{ + /** + * @return string javascript code for client-side OnValidate event. + */ + public function getOnValidate() + { + return $this->getOption('OnValidate'); + } + + /** + * Client-side OnValidate validator event is raise before the validators + * validation functions are called. + * @param string javascript code for client-side OnValidate event. + */ + public function setOnValidate($javascript) + { + $this->setFunction('OnValidate', $javascript); + } + + /** + * Client-side OnSuccess event is raise after validation is successfull. + * This will override the default client-side validator behaviour. + * @param string javascript code for client-side OnSuccess event. + */ + public function setOnValidationSuccess($javascript) + { + $this->setFunction('OnValidationSuccess', $javascript); + } + + /** + * @return string javascript code for client-side OnSuccess event. + */ + public function getOnValidationSuccess() + { + return $this->getOption('OnValidationSuccess'); + } + + /** + * Client-side OnError event is raised after validation failure. + * This will override the default client-side validator behaviour. + * @param string javascript code for client-side OnError event. + */ + public function setOnValidationError($javascript) + { + $this->setFunction('OnValidationError', $javascript); + } + + /** + * @return string javascript code for client-side OnError event. + */ + public function getOnValidationError() + { + return $this->getOption('OnValidationError'); + } + + /** + * @param boolean true to revalidate when the control to validate changes value. + */ + public function setObserveChanges($value) + { + $this->setOption('ObserveChanges', TPropertyValue::ensureBoolean($value)); + } + + /** + * @return boolean true to observe changes. + */ + public function getObserveChanges() + { + $changes = $this->getOption('ObserveChanges'); + return ($changes===null) ? true : $changes; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveDataGrid.php b/framework/Web/UI/ActiveControls/TActiveDataGrid.php index d5084e2d..04b23843 100644 --- a/framework/Web/UI/ActiveControls/TActiveDataGrid.php +++ b/framework/Web/UI/ActiveControls/TActiveDataGrid.php @@ -190,639 +190,4 @@ class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable parent::render($writer); $writer->write('</div>'); } -} - - -/** - * TActiveBoundColumn class - * - * TActiveBoundColumn represents a column that is bound to a field in a data source. - * The cells in the column will be displayed using the data indexed by - * {@link setDataField DataField}. You can customize the display by - * setting {@link setDataFormatString DataFormatString}. - * - * This is the active counterpart to the {@link TBoundColumn} control. For that purpose, - * if sorting is allowed, the header links/buttons are replaced by active controls. - * - * Please refer to the original documentation of the {@link TBoundColumn} for usage. - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveBoundColumn extends TBoundColumn { - protected function initializeHeaderCell($cell,$columnIndex) { - $text=$this->getHeaderText(); - - if(($classPath=$this->getHeaderRenderer())!=='') { - $control=Prado::createComponent($classPath); - if($control instanceof IDataRenderer) { - if($control instanceof IItemDataRenderer) { - $item=$cell->getParent(); - $control->setItemIndex($item->getItemIndex()); - $control->setItemType($item->getItemType()); - } - $control->setData($text); - } - $cell->getControls()->add($control); - } - else if($this->getAllowSorting()) { - $sortExpression=$this->getSortExpression(); - if(($url=$this->getHeaderImageUrl())!=='') { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); - $button->setImageUrl($url); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - if($text!=='') { - $button->setAlternateText($text); - $button->setToolTip($text); - } - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else if($text!=='') { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); - $button->setText($text); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else - $cell->setText(' '); - } - else { - if(($url=$this->getHeaderImageUrl())!=='') { - $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); - $image->setImageUrl($url); - if($text!=='') { - $image->setAlternateText($text); - $image->setToolTip($text); - } - $cell->getControls()->add($image); - } - else if($text!=='') - $cell->setText($text); - else - $cell->setText(' '); - } - } -} - - -/** - * TActiveEditCommandColumn class - * - * TActiveEditCommandColumn contains the Edit command buttons for editing data items in each row. - * - * TActiveEditCommandColumn will create an edit button if a cell is not in edit mode. - * Otherwise an update button and a cancel button will be created within the cell. - * The button captions are specified using {@link setEditText EditText}, - * {@link setUpdateText UpdateText}, and {@link setCancelText CancelText}. - * - * This is the active counterpart to the {@link TEditCommandColumn} control. The buttons for - * interaction are replaced by active buttons. - * - * Please refer to the original documentation of the {@link TEditCommandColumn} for usage. - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveEditCommandColumn extends TEditCommandColumn { - protected function createButton($commandName,$text,$causesValidation,$validationGroup) { - if($this->getButtonType()===TButtonColumnType::LinkButton) - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); - else if($this->getButtonType()===TButtonColumnType::PushButton) - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveButton'); - else // image buttons - { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); - $button->setToolTip($text); - if(strcasecmp($commandName,'Update')===0) - $url=$this->getUpdateImageUrl(); - else if(strcasecmp($commandName,'Cancel')===0) - $url=$this->getCancelImageUrl(); - else - $url=$this->getEditImageUrl(); - $button->setImageUrl($url); - } - $button->setText($text); - $button->setCommandName($commandName); - $button->setCausesValidation($causesValidation); - $button->setValidationGroup($validationGroup); - return $button; - } -} - - -/** - * TActiveButtonColumn class - * - * TActiveButtonColumn contains a user-defined command button, such as Add or Remove, - * that corresponds with each row in the column. - * - * This is the active counterpart to the {@link TButtonColumn} control where the - * button is replaced by the appropriate active button control. - * - * Please refer to the original documentation of the {@link TButtonColumn} for usage. - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveButtonColumn extends TButtonColumn { - public function initializeCell($cell,$columnIndex,$itemType) { - if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) { - $buttonType=$this->getButtonType(); - if($buttonType===TButtonColumnType::LinkButton) - $button=new TActiveLinkButton; - else if($buttonType===TButtonColumnType::PushButton) - $button=new TActiveButton; - else // image button - { - $button=new TActiveImageButton; - $button->setImageUrl($this->getImageUrl()); - $button->setToolTip($this->getText()); - } - $button->setText($this->getText()); - $button->setCommandName($this->getCommandName()); - $button->setCausesValidation($this->getCausesValidation()); - $button->setValidationGroup($this->getValidationGroup()); - if($this->getDataTextField()!=='' || ($buttonType===TButtonColumnType::ImageButton && $this->getDataImageUrlField()!=='')) - $button->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); - $cell->getControls()->add($button); - $cell->registerObject('Button',$button); - } - else - parent::initializeCell($cell,$columnIndex,$itemType); - } -} - - -/** - * TActiveTemplateColumn class - * - * TActiveTemplateColumn customizes the layout of controls in the column with templates. - * In particular, you can specify {@link setItemTemplate ItemTemplate}, - * {@link setEditItemTemplate EditItemTemplate}, {@link setHeaderTemplate HeaderTemplate} - * and {@link setFooterTemplate FooterTemplate} to customize specific - * type of cells in the column. - * - * This is the active counterpart to the {@link TTemplateColumn} control. For that purpose, - * if sorting is allowed, the header links/buttons are replaced by active controls. - * - * Please refer to the original documentation of the {@link TTemplateColumn} for usage. - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveTemplateColumn extends TTemplateColumn { - protected function initializeHeaderCell($cell,$columnIndex) { - $text=$this->getHeaderText(); - - if(($classPath=$this->getHeaderRenderer())!=='') { - $control=Prado::createComponent($classPath); - if($control instanceof IDataRenderer) { - if($control instanceof IItemDataRenderer) { - $item=$cell->getParent(); - $control->setItemIndex($item->getItemIndex()); - $control->setItemType($item->getItemType()); - } - $control->setData($text); - } - $cell->getControls()->add($control); - } - else if($this->getAllowSorting()) { - $sortExpression=$this->getSortExpression(); - if(($url=$this->getHeaderImageUrl())!=='') { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); - $button->setImageUrl($url); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - if($text!=='') - $button->setAlternateText($text); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else if($text!=='') { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); - $button->setText($text); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else - $cell->setText(' '); - } - else { - if(($url=$this->getHeaderImageUrl())!=='') { - $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); - $image->setImageUrl($url); - if($text!=='') - $image->setAlternateText($text); - $cell->getControls()->add($image); - } - else if($text!=='') - $cell->setText($text); - else - $cell->setText(' '); - } - } -} - -/** - * TActiveHyperLinkColumn class - * - * TActiveHyperLinkColumn contains a hyperlink for each item in the column. - * - * This is the active counterpart to the {@link THyperLinkColumn} control. For that purpose, - * if sorting is allowed, the header links/buttons are replaced by active controls. - * - * Please refer to the original documentation of the {@link THyperLinkColumn} for usage. - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveHyperLinkColumn extends THyperLinkColumn -{ - - protected function initializeHeaderCell($cell,$columnIndex) - { - $text=$this->getHeaderText(); - - if(($classPath=$this->getHeaderRenderer())!=='') - { - $control=Prado::createComponent($classPath); - if($control instanceof IDataRenderer) - { - if($control instanceof IItemDataRenderer) - { - $item=$cell->getParent(); - $control->setItemIndex($item->getItemIndex()); - $control->setItemType($item->getItemType()); - } - $control->setData($text); - } - $cell->getControls()->add($control); - } - else if($this->getAllowSorting()) - { - $sortExpression=$this->getSortExpression(); - if(($url=$this->getHeaderImageUrl())!=='') - { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); - $button->setImageUrl($url); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - if($text!=='') - $button->setAlternateText($text); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else if($text!=='') - { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); - $button->setText($text); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else - $cell->setText(' '); - } - else - { - if(($url=$this->getHeaderImageUrl())!=='') - { - $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); - $image->setImageUrl($url); - if($text!=='') - $image->setAlternateText($text); - $cell->getControls()->add($image); - } - else if($text!=='') - $cell->setText($text); - else - $cell->setText(' '); - } - } -} - -/** - * TActiveCheckBoxColumn class - * - * TActiveCheckBoxColumn represents a checkbox column that is bound to a field in a data source. - * - * This is the active counterpart to the {@link TCheckBoxColumn} control. For that purpose, - * if sorting is allowed, the header links/buttons are replaced by active controls. - * - * Please refer to the original documentation of the {@link TCheckBoxColumn} for usage. - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveCheckBoxColumn extends TCheckBoxColumn -{ - /** - * Initializes the specified cell to its initial values. - * This method overrides the parent implementation. - * It creates a checkbox inside the cell. - * If the column is read-only or if the item is not in edit mode, - * the checkbox will be set disabled. - * @param TTableCell the cell to be initialized. - * @param integer the index to the Columns property that the cell resides in. - * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) - */ - public function initializeCell($cell,$columnIndex,$itemType) - { - if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::SelectedItem || $itemType===TListItemType::EditItem) - { - $checkBox=new TActiveCheckBox; - if($this->getReadOnly() || $itemType!==TListItemType::EditItem) - $checkBox->setEnabled(false); - $cell->setHorizontalAlign('Center'); - $cell->getControls()->add($checkBox); - $cell->registerObject('CheckBox',$checkBox); - if($this->getDataField()!=='') - $checkBox->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); - } - else - parent::initializeCell($cell,$columnIndex,$itemType); - } - - protected function initializeHeaderCell($cell,$columnIndex) - { - $text=$this->getHeaderText(); - - if(($classPath=$this->getHeaderRenderer())!=='') - { - $control=Prado::createComponent($classPath); - if($control instanceof IDataRenderer) - { - if($control instanceof IItemDataRenderer) - { - $item=$cell->getParent(); - $control->setItemIndex($item->getItemIndex()); - $control->setItemType($item->getItemType()); - } - $control->setData($text); - } - $cell->getControls()->add($control); - } - else if($this->getAllowSorting()) - { - $sortExpression=$this->getSortExpression(); - if(($url=$this->getHeaderImageUrl())!=='') - { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); - $button->setImageUrl($url); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - if($text!=='') - $button->setAlternateText($text); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else if($text!=='') - { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); - $button->setText($text); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else - $cell->setText(' '); - } - else - { - if(($url=$this->getHeaderImageUrl())!=='') - { - $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); - $image->setImageUrl($url); - if($text!=='') - $image->setAlternateText($text); - $cell->getControls()->add($image); - } - else if($text!=='') - $cell->setText($text); - else - $cell->setText(' '); - } - } -} - -/** - * TActiveDropDownListColumn class - * - * TActiveDropDownListColumn represents a column that is bound to a field in a data source. - * - * This is the active counterpart to the {@link TDropDownListColumn} control. For that purpose, - * if sorting is allowed, the header links/buttons are replaced by active controls. - * - * Please refer to the original documentation of the {@link TDropDownListColumn} for usage. - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveDropDownListColumn extends TDropDownListColumn -{ - protected function initializeHeaderCell($cell,$columnIndex) - { - $text=$this->getHeaderText(); - - if(($classPath=$this->getHeaderRenderer())!=='') - { - $control=Prado::createComponent($classPath); - if($control instanceof IDataRenderer) - { - if($control instanceof IItemDataRenderer) - { - $item=$cell->getParent(); - $control->setItemIndex($item->getItemIndex()); - $control->setItemType($item->getItemType()); - } - $control->setData($text); - } - $cell->getControls()->add($control); - } - else if($this->getAllowSorting()) - { - $sortExpression=$this->getSortExpression(); - if(($url=$this->getHeaderImageUrl())!=='') - { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); - $button->setImageUrl($url); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - if($text!=='') - $button->setAlternateText($text); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else if($text!=='') - { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); - $button->setText($text); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else - $cell->setText(' '); - } - else - { - if(($url=$this->getHeaderImageUrl())!=='') - { - $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); - $image->setImageUrl($url); - if($text!=='') - $image->setAlternateText($text); - $cell->getControls()->add($image); - } - else if($text!=='') - $cell->setText($text); - else - $cell->setText(' '); - } - } - -} - -/** - * TActiveLiteralColumn class - * - * TActiveLiteralColumn represents a static text column that is bound to a field in a data source. - * The cells in the column will be displayed with static texts using the data indexed by - * {@link setDataField DataField}. You can customize the display by - * setting {@link setDataFormatString DataFormatString}. - * - * If {@link setDataField DataField} is not specified, the cells will be filled - * with {@link setText Text}. - * - * If {@link setEncode Encode} is true, the static texts will be HTML-encoded. - * - * This is the active counterpart to the {@link TLiteralColumn} control. For that purpose, - * if sorting is allowed, the header links/buttons are replaced by active controls. - * - * Please refer to the original documentation of the {@link TLiteralColumn} for usage. - * - * @author Fabio Bas <ctrlaltca@gmail.com> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveLiteralColumn extends TLiteralColumn { - protected function initializeHeaderCell($cell,$columnIndex) { - $text=$this->getHeaderText(); - - if(($classPath=$this->getHeaderRenderer())!=='') { - $control=Prado::createComponent($classPath); - if($control instanceof IDataRenderer) { - if($control instanceof IItemDataRenderer) { - $item=$cell->getParent(); - $control->setItemIndex($item->getItemIndex()); - $control->setItemType($item->getItemType()); - } - $control->setData($text); - } - $cell->getControls()->add($control); - } - else if($this->getAllowSorting()) { - $sortExpression=$this->getSortExpression(); - if(($url=$this->getHeaderImageUrl())!=='') { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); - $button->setImageUrl($url); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - if($text!=='') { - $button->setAlternateText($text); - $button->setToolTip($text); - } - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else if($text!=='') { - $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); - $button->setText($text); - $button->setCommandName(TDataGrid::CMD_SORT); - $button->setCommandParameter($sortExpression); - $button->setCausesValidation(false); - $cell->getControls()->add($button); - } - else - $cell->setText(' '); - } - else { - if(($url=$this->getHeaderImageUrl())!=='') { - $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); - $image->setImageUrl($url); - if($text!=='') { - $image->setAlternateText($text); - $image->setToolTip($text); - } - $cell->getControls()->add($image); - } - else if($text!=='') - $cell->setText($text); - else - $cell->setText(' '); - } - } -} - -/** - * TActiveDataGridPager class. - * - * TActiveDataGridPager represents a pager in an activedatagrid. - * - * @author Fabio Bas <ctrlaltca@gmail.com> - * @package System.Web.UI.ActiveControls - * @since 3.2.1 - */ -class TActiveDataGridPager extends TDataGridPager -{ - protected $_callbackoptions; - - /** - * @return TCallbackClientSide client side request options. - */ - public function getClientSide() - { - if($this->_callbackoptions === null) - $this->_callbackoptions = new TCallbackOptions; - return $this->_callbackoptions->getClientSide(); - } -} - -/** - * TActiveDataGridPagerEventParameter class - * - * TActiveDataGridPagerEventParameter encapsulates the parameter data for - * {@link TActiveDataGrid::onPagerCreated OnPagerCreated} event of {@link TActiveDataGrid} controls. - * The {@link getPager Pager} property indicates the datagrid pager related with the event. - * - * @author Fabio Bas <ctrlaltca@gmail.com> - * @package System.Web.UI.ActiveControls - * @since 3.2.1 - */ -class TActiveDataGridPagerEventParameter extends TDataGridPagerEventParameter -{ - /** - * Constructor. - * @param TActiveDataGridPager datagrid pager related with the corresponding event - */ - public function __construct(TActiveDataGridPager $pager) - { - $this->_pager=$pager; - } -} +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveDataGridPager.php b/framework/Web/UI/ActiveControls/TActiveDataGridPager.php new file mode 100644 index 00000000..5893ec8f --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveDataGridPager.php @@ -0,0 +1,34 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveDataGridPager class. + * + * TActiveDataGridPager represents a pager in an activedatagrid. + * + * @author Fabio Bas <ctrlaltca@gmail.com> + * @package System.Web.UI.ActiveControls + * @since 3.2.1 + */ +class TActiveDataGridPager extends TDataGridPager +{ + protected $_callbackoptions; + + /** + * @return TCallbackClientSide client side request options. + */ + public function getClientSide() + { + if($this->_callbackoptions === null) + $this->_callbackoptions = new TCallbackOptions; + return $this->_callbackoptions->getClientSide(); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveDataGridPagerEventParameter.php b/framework/Web/UI/ActiveControls/TActiveDataGridPagerEventParameter.php new file mode 100644 index 00000000..a37c7a2b --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveDataGridPagerEventParameter.php @@ -0,0 +1,33 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveDataGridPagerEventParameter class + * + * TActiveDataGridPagerEventParameter encapsulates the parameter data for + * {@link TActiveDataGrid::onPagerCreated OnPagerCreated} event of {@link TActiveDataGrid} controls. + * The {@link getPager Pager} property indicates the datagrid pager related with the event. + * + * @author Fabio Bas <ctrlaltca@gmail.com> + * @package System.Web.UI.ActiveControls + * @since 3.2.1 + */ +class TActiveDataGridPagerEventParameter extends TDataGridPagerEventParameter +{ + /** + * Constructor. + * @param TActiveDataGridPager datagrid pager related with the corresponding event + */ + public function __construct(TActiveDataGridPager $pager) + { + $this->_pager=$pager; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveDatePicker.php b/framework/Web/UI/ActiveControls/TActiveDatePicker.php index ad363d9c..1e78a8f5 100755 --- a/framework/Web/UI/ActiveControls/TActiveDatePicker.php +++ b/framework/Web/UI/ActiveControls/TActiveDatePicker.php @@ -159,40 +159,4 @@ class TActiveDatePicker extends TDatePicker implements ICallbackEventHandler, I { return new TActiveDatePickerClientScript; } -} - -/** - * TActiveDatePickerClientScript class. - * - * Client-side date picker event {@link setOnDateChanged OnDateChanged} - * can be modified through the {@link TActiveDatePicker::getClientSide ClientSide} - * property of a date picker. - * - * The <tt>OnDateChanged</tt> event is raise when the date picker's date - * is changed. - * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent - * as parameter to this event - * - * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.2.1 - */ -class TActiveDatePickerClientScript extends TCallbackClientSide -{ - /** - * 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'); - } }
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveDatePickerClientScript.php b/framework/Web/UI/ActiveControls/TActiveDatePickerClientScript.php new file mode 100644 index 00000000..9828b348 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveDatePickerClientScript.php @@ -0,0 +1,47 @@ +<?php +/** + * TActiveDatePicker class file + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @author Christophe Boulain <Christophe.Boulain@gmail.com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveDatePickerClientScript class. + * + * Client-side date picker event {@link setOnDateChanged OnDateChanged} + * can be modified through the {@link TActiveDatePicker::getClientSide ClientSide} + * property of a date picker. + * + * The <tt>OnDateChanged</tt> event is raise when the date picker's date + * is changed. + * The formatted date according to {@link TDatePicker::getDateFormat DateFormat} is sent + * as parameter to this event + * + * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.2.1 + */ +class TActiveDatePickerClientScript extends TCallbackClientSide +{ + /** + * 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'); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveDropDownListColumn.php b/framework/Web/UI/ActiveControls/TActiveDropDownListColumn.php new file mode 100644 index 00000000..def9fd38 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveDropDownListColumn.php @@ -0,0 +1,90 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveDropDownListColumn class + * + * TActiveDropDownListColumn represents a column that is bound to a field in a data source. + * + * This is the active counterpart to the {@link TDropDownListColumn} control. For that purpose, + * if sorting is allowed, the header links/buttons are replaced by active controls. + * + * Please refer to the original documentation of the {@link TDropDownListColumn} for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveDropDownListColumn extends TDropDownListColumn +{ + protected function initializeHeaderCell($cell,$columnIndex) + { + $text=$this->getHeaderText(); + + if(($classPath=$this->getHeaderRenderer())!=='') + { + $control=Prado::createComponent($classPath); + if($control instanceof IDataRenderer) + { + if($control instanceof IItemDataRenderer) + { + $item=$cell->getParent(); + $control->setItemIndex($item->getItemIndex()); + $control->setItemType($item->getItemType()); + } + $control->setData($text); + } + $cell->getControls()->add($control); + } + else if($this->getAllowSorting()) + { + $sortExpression=$this->getSortExpression(); + if(($url=$this->getHeaderImageUrl())!=='') + { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); + $button->setImageUrl($url); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + if($text!=='') + $button->setAlternateText($text); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else if($text!=='') + { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); + $button->setText($text); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else + $cell->setText(' '); + } + else + { + if(($url=$this->getHeaderImageUrl())!=='') + { + $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); + $image->setImageUrl($url); + if($text!=='') + $image->setAlternateText($text); + $cell->getControls()->add($image); + } + else if($text!=='') + $cell->setText($text); + else + $cell->setText(' '); + } + } + +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveEditCommandColumn.php b/framework/Web/UI/ActiveControls/TActiveEditCommandColumn.php new file mode 100644 index 00000000..4f658826 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveEditCommandColumn.php @@ -0,0 +1,56 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + + +/** + * TActiveEditCommandColumn class + * + * TActiveEditCommandColumn contains the Edit command buttons for editing data items in each row. + * + * TActiveEditCommandColumn will create an edit button if a cell is not in edit mode. + * Otherwise an update button and a cancel button will be created within the cell. + * The button captions are specified using {@link setEditText EditText}, + * {@link setUpdateText UpdateText}, and {@link setCancelText CancelText}. + * + * This is the active counterpart to the {@link TEditCommandColumn} control. The buttons for + * interaction are replaced by active buttons. + * + * Please refer to the original documentation of the {@link TEditCommandColumn} for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveEditCommandColumn extends TEditCommandColumn { + protected function createButton($commandName,$text,$causesValidation,$validationGroup) { + if($this->getButtonType()===TButtonColumnType::LinkButton) + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); + else if($this->getButtonType()===TButtonColumnType::PushButton) + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveButton'); + else // image buttons + { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); + $button->setToolTip($text); + if(strcasecmp($commandName,'Update')===0) + $url=$this->getUpdateImageUrl(); + else if(strcasecmp($commandName,'Cancel')===0) + $url=$this->getCancelImageUrl(); + else + $url=$this->getEditImageUrl(); + $button->setImageUrl($url); + } + $button->setText($text); + $button->setCommandName($commandName); + $button->setCausesValidation($causesValidation); + $button->setValidationGroup($validationGroup); + return $button; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveFileUpload.php b/framework/Web/UI/ActiveControls/TActiveFileUpload.php index b478e119..fe016aa1 100755 --- a/framework/Web/UI/ActiveControls/TActiveFileUpload.php +++ b/framework/Web/UI/ActiveControls/TActiveFileUpload.php @@ -446,19 +446,3 @@ EOS; return $this->_busy; } } - -/** - * TActiveFileUploadCallbackParams is an internal class used by {@link TActiveFileUpload}. - * - * @author Bradley Booms <Bradley.Booms@nsighttel.com> - * @author Christophe Boulain <Christophe.Boulain@gmail.com> - * @package System.Web.UI.ActiveControls - */ -class TActiveFileUploadCallbackParams -{ - public $localName; - public $fileName; - public $fileSize; - public $fileType; - public $errorCode; -} diff --git a/framework/Web/UI/ActiveControls/TActiveFileUploadCallbackParams.php b/framework/Web/UI/ActiveControls/TActiveFileUploadCallbackParams.php new file mode 100644 index 00000000..6650aaf8 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveFileUploadCallbackParams.php @@ -0,0 +1,25 @@ +<?php +/** + * TActiveFileUpload.php + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @author Christophe Boulain <Christophe.Boulain@gmail.com> + * @author Gabor Berczi <gabor.berczi@devworx.hu> (issue 349 remote vulnerability fix) + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveFileUploadCallbackParams is an internal class used by {@link TActiveFileUpload}. + * + * @author Bradley Booms <Bradley.Booms@nsighttel.com> + * @author Christophe Boulain <Christophe.Boulain@gmail.com> + * @package System.Web.UI.ActiveControls + */ +class TActiveFileUploadCallbackParams +{ + public $localName; + public $fileName; + public $fileSize; + public $fileType; + public $errorCode; +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveHyperLinkColumn.php b/framework/Web/UI/ActiveControls/TActiveHyperLinkColumn.php new file mode 100644 index 00000000..5ae99374 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveHyperLinkColumn.php @@ -0,0 +1,90 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveHyperLinkColumn class + * + * TActiveHyperLinkColumn contains a hyperlink for each item in the column. + * + * This is the active counterpart to the {@link THyperLinkColumn} control. For that purpose, + * if sorting is allowed, the header links/buttons are replaced by active controls. + * + * Please refer to the original documentation of the {@link THyperLinkColumn} for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveHyperLinkColumn extends THyperLinkColumn +{ + + protected function initializeHeaderCell($cell,$columnIndex) + { + $text=$this->getHeaderText(); + + if(($classPath=$this->getHeaderRenderer())!=='') + { + $control=Prado::createComponent($classPath); + if($control instanceof IDataRenderer) + { + if($control instanceof IItemDataRenderer) + { + $item=$cell->getParent(); + $control->setItemIndex($item->getItemIndex()); + $control->setItemType($item->getItemType()); + } + $control->setData($text); + } + $cell->getControls()->add($control); + } + else if($this->getAllowSorting()) + { + $sortExpression=$this->getSortExpression(); + if(($url=$this->getHeaderImageUrl())!=='') + { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); + $button->setImageUrl($url); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + if($text!=='') + $button->setAlternateText($text); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else if($text!=='') + { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); + $button->setText($text); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else + $cell->setText(' '); + } + else + { + if(($url=$this->getHeaderImageUrl())!=='') + { + $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); + $image->setImageUrl($url); + if($text!=='') + $image->setAlternateText($text); + $cell->getControls()->add($image); + } + else if($text!=='') + $cell->setText($text); + else + $cell->setText(' '); + } + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php index ca88477d..4f1cb56a 100644 --- a/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveListControlAdapter.php @@ -154,102 +154,4 @@ class TActiveListControlAdapter extends TActiveControlAdapter implements IListCo } } } -} - -/** - * TActiveListItemCollection class. - * - * Allows TActiveDropDownList and TActiveListBox to add new options - * during callback response. New options can only be added <b>after</b> the - * {@link TControl::onLoad OnLoad} event. - * - * The {@link getListHasChanged ListHasChanged} property is true when the - * list items has changed. The control responsible for the list needs to - * repopulate the client-side options. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TActiveListItemCollection extends TListItemCollection -{ - /** - * @var IActiveControl control instance. - */ - private $_control; - /** - * @var boolean true if list items were changed. - */ - private $_hasChanged=false; - - /** - * @return boolean true if active controls can update client-side and - * the onLoad event has already been raised. - */ - protected function canUpdateClientSide() - { - return $this->getControl()->getActiveControl()->canUpdateClientSide() - && $this->getControl()->getHasLoaded(); - } - - /** - * @param IActiveControl a active list control. - */ - public function setControl(IActiveControl $control) - { - $this->_control = $control; - } - - /** - * @return IActiveControl active control using the collection. - */ - public function getControl() - { - return $this->_control; - } - - /** - * @return boolean true if the list has changed after onLoad event. - */ - public function getListHasChanged() - { - return $this->_hasChanged; - } - - /** - * Update client-side list items. - */ - public function updateClientSide() - { - $client = $this->getControl()->getPage()->getCallbackClient(); - $client->setListItems($this->getControl(), $this); - $this->_hasChanged=false; - } - - /** - * Inserts an item into the collection. - * The new option is added on the client-side during callback. - * @param integer the location where the item will be inserted. - * The current item at the place and the following ones will be moved backward. - * @param TListItem the item to be inserted. - * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem - */ - public function insertAt($index, $value) - { - parent::insertAt($index, $value); - if($this->canUpdateClientSide()) - $this->_hasChanged = true; - } - - /** - * Removes an item from at specified index. - * @param int zero based index. - */ - public function removeAt($index) - { - parent::removeAt($index); - if($this->canUpdateClientSide()) - $this->_hasChanged = true; - } -} - +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveListItemCollection.php b/framework/Web/UI/ActiveControls/TActiveListItemCollection.php new file mode 100644 index 00000000..9b59b13e --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveListItemCollection.php @@ -0,0 +1,107 @@ +<?php +/** + * TActiveListControlAdapter class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveListItemCollection class. + * + * Allows TActiveDropDownList and TActiveListBox to add new options + * during callback response. New options can only be added <b>after</b> the + * {@link TControl::onLoad OnLoad} event. + * + * The {@link getListHasChanged ListHasChanged} property is true when the + * list items has changed. The control responsible for the list needs to + * repopulate the client-side options. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TActiveListItemCollection extends TListItemCollection +{ + /** + * @var IActiveControl control instance. + */ + private $_control; + /** + * @var boolean true if list items were changed. + */ + private $_hasChanged=false; + + /** + * @return boolean true if active controls can update client-side and + * the onLoad event has already been raised. + */ + protected function canUpdateClientSide() + { + return $this->getControl()->getActiveControl()->canUpdateClientSide() + && $this->getControl()->getHasLoaded(); + } + + /** + * @param IActiveControl a active list control. + */ + public function setControl(IActiveControl $control) + { + $this->_control = $control; + } + + /** + * @return IActiveControl active control using the collection. + */ + public function getControl() + { + return $this->_control; + } + + /** + * @return boolean true if the list has changed after onLoad event. + */ + public function getListHasChanged() + { + return $this->_hasChanged; + } + + /** + * Update client-side list items. + */ + public function updateClientSide() + { + $client = $this->getControl()->getPage()->getCallbackClient(); + $client->setListItems($this->getControl(), $this); + $this->_hasChanged=false; + } + + /** + * Inserts an item into the collection. + * The new option is added on the client-side during callback. + * @param integer the location where the item will be inserted. + * The current item at the place and the following ones will be moved backward. + * @param TListItem the item to be inserted. + * @throws TInvalidDataTypeException if the item being inserted is neither a string nor TListItem + */ + public function insertAt($index, $value) + { + parent::insertAt($index, $value); + if($this->canUpdateClientSide()) + $this->_hasChanged = true; + } + + /** + * Removes an item from at specified index. + * @param int zero based index. + */ + public function removeAt($index) + { + parent::removeAt($index); + if($this->canUpdateClientSide()) + $this->_hasChanged = true; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveLiteralColumn.php b/framework/Web/UI/ActiveControls/TActiveLiteralColumn.php new file mode 100644 index 00000000..6fc198da --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveLiteralColumn.php @@ -0,0 +1,91 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TActiveLiteralColumn class + * + * TActiveLiteralColumn represents a static text column that is bound to a field in a data source. + * The cells in the column will be displayed with static texts using the data indexed by + * {@link setDataField DataField}. You can customize the display by + * setting {@link setDataFormatString DataFormatString}. + * + * If {@link setDataField DataField} is not specified, the cells will be filled + * with {@link setText Text}. + * + * If {@link setEncode Encode} is true, the static texts will be HTML-encoded. + * + * This is the active counterpart to the {@link TLiteralColumn} control. For that purpose, + * if sorting is allowed, the header links/buttons are replaced by active controls. + * + * Please refer to the original documentation of the {@link TLiteralColumn} for usage. + * + * @author Fabio Bas <ctrlaltca@gmail.com> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveLiteralColumn extends TLiteralColumn { + protected function initializeHeaderCell($cell,$columnIndex) { + $text=$this->getHeaderText(); + + if(($classPath=$this->getHeaderRenderer())!=='') { + $control=Prado::createComponent($classPath); + if($control instanceof IDataRenderer) { + if($control instanceof IItemDataRenderer) { + $item=$cell->getParent(); + $control->setItemIndex($item->getItemIndex()); + $control->setItemType($item->getItemType()); + } + $control->setData($text); + } + $cell->getControls()->add($control); + } + else if($this->getAllowSorting()) { + $sortExpression=$this->getSortExpression(); + if(($url=$this->getHeaderImageUrl())!=='') { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); + $button->setImageUrl($url); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + if($text!=='') { + $button->setAlternateText($text); + $button->setToolTip($text); + } + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else if($text!=='') { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); + $button->setText($text); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else + $cell->setText(' '); + } + else { + if(($url=$this->getHeaderImageUrl())!=='') { + $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); + $image->setImageUrl($url); + if($text!=='') { + $image->setAlternateText($text); + $image->setToolTip($text); + } + $cell->getControls()->add($image); + } + else if($text!=='') + $cell->setText($text); + else + $cell->setText(' '); + } + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 8f5055f6..f7b1d82d 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -322,94 +322,4 @@ class TActivePageAdapter extends TControlAdapter $this->_callbackClient = new TCallbackClientScript; return $this->_callbackClient; } -} - -/** - * TCallbackErrorHandler class. - * - * Captures errors and exceptions and send them back during callback response. - * When the application is in debug mode, the error and exception stack trace - * are shown. A TJavascriptLogger must be present on the client-side to view - * the error stack trace. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TCallbackErrorHandler extends TErrorHandler -{ - /** - * Displays the exceptions to the client-side TJavascriptLogger. - * A HTTP 500 status code is sent and the stack trace is sent as JSON encoded. - * @param Exception exception details. - */ - protected function displayException($exception) - { - if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) - { - $response = $this->getApplication()->getResponse(); - $trace = $this->getExceptionStackTrace($exception); - // avoid error on non-utf8 strings - try { - $trace = TJavaScript::jsonEncode($trace); - } catch (Exception $e) { - // strip everythin not 7bit ascii - $trace = preg_replace('/[^(\x20-\x7F)]*/','', serialize($trace)); - } - - // avoid exception loop if headers have already been sent - try { - $response->setStatusCode(500, 'Internal Server Error'); - } catch (Exception $e) { } - - $content = $response->createHtmlWriter(); - $content->getWriter()->setBoundary(TActivePageAdapter::CALLBACK_ERROR_HEADER); - $content->write($trace); - } - else - { - error_log("Error happened while processing an existing error:\n".$exception->__toString()); - header('HTTP/1.0 500 Internal Server Error', true, 500); - } - $this->getApplication()->getResponse()->flush(); - } - - /** - * @param Exception exception details. - * @return array exception stack trace details. - */ - private function getExceptionStackTrace($exception) - { - $data['code']=$exception->getCode() > 0 ? $exception->getCode() : 500; - $data['file']=$exception->getFile(); - $data['line']=$exception->getLine(); - $data['trace']=$exception->getTrace(); - if($exception instanceof TPhpErrorException) - { - // if PHP exception, we want to show the 2nd stack level context - // because the 1st stack level is of little use (it's in error handler) - if(isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line'])) - { - $data['file']=$trace[0]['file']; - $data['line']=$trace[0]['line']; - } - } - $data['type']=get_class($exception); - $data['message']=$exception->getMessage(); - $data['version']=$_SERVER['SERVER_SOFTWARE'].' '.Prado::getVersion(); - $data['time']=@strftime('%Y-%m-%d %H:%M',time()); - return $data; - } -} - -/** - * TInvalidCallbackException class. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TInvalidCallbackException extends TException -{ -} - +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonItem.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonItem.php new file mode 100644 index 00000000..55c5046e --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonItem.php @@ -0,0 +1,26 @@ +<?php +/** + * TActiveRadioButtonList class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + + +class TActiveRadioButtonItem extends TActiveRadioButton +{ + /** + * Override client implementation to avoid emitting the javascript + * + * @param THtmlWriter the writer for the rendering purpose + * @param string checkbox id + * @param string onclick js + */ + protected function renderInputTag($writer,$clientID,$onclick) + { + TRadioButton::renderInputTag($writer,$clientID,$onclick); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php index 84a71951..70b035e4 100644 --- a/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php +++ b/framework/Web/UI/ActiveControls/TActiveRadioButtonList.php @@ -126,20 +126,4 @@ class TActiveRadioButtonList extends TRadioButtonList implements IActiveControl, return 'Prado.WebUI.TActiveRadioButtonList'; } -} - - -class TActiveRadioButtonItem extends TActiveRadioButton -{ - /** - * Override client implementation to avoid emitting the javascript - * - * @param THtmlWriter the writer for the rendering purpose - * @param string checkbox id - * @param string onclick js - */ - protected function renderInputTag($writer,$clientID,$onclick) - { - TRadioButton::renderInputTag($writer,$clientID,$onclick); - } }
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveTableCell.php b/framework/Web/UI/ActiveControls/TActiveTableCell.php index 73e98967..1c01598f 100644 --- a/framework/Web/UI/ActiveControls/TActiveTableCell.php +++ b/framework/Web/UI/ActiveControls/TActiveTableCell.php @@ -203,50 +203,4 @@ class TActiveTableCell extends TTableCell implements ICallbackEventHandler, IAct return $this->_row; } -} - -/** - * TActiveTableCellEventParameter class. - * - * The TActiveTableCellEventParameter provides the parameter passed during the callback - * requestion in the {@link getCallbackParameter CallbackParameter} property. The - * callback response content (e.g. new HTML content) must be rendered - * using an THtmlWriter obtained from the {@link getNewWriter NewWriter} - * property, which returns a <b>NEW</b> instance of TCallbackResponseWriter. - * - * The {@link getSelectedCellIndex SelectedCellIndex} is a zero-based index of the - * TActiveTableCell , -1 if the cell is not part of the cell collection (this shouldn't - * happen though since an exception is thrown before). - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveTableCellEventParameter extends TCallbackEventParameter -{ - - /** - * @var integer the zero-based index of the cell. - */ - private $_selectedCellIndex = -1; - - /** - * Creates a new TActiveTableRowEventParameter. - */ - public function __construct($response, $parameter, $index=-1) - { - parent::__construct($response, $parameter); - $this->_selectedCellIndex = $index; - } - - /** - * Returns the zero-based index of the {@link TActiveTableCell} within the - * {@link TTableCellCollection} of the parent {@link TTableRow} control. - * @return integer the zero-based index of the cell. - */ - public function getSelectedCellIndex() - { - return $this->_selectedCellIndex; - } - }
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveTableCellEventParameter.php b/framework/Web/UI/ActiveControls/TActiveTableCellEventParameter.php new file mode 100644 index 00000000..2c996c1e --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveTableCellEventParameter.php @@ -0,0 +1,57 @@ +<?php +/** + * TActiveTableCell class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + * @version $Id$ + */ + +/** + * TActiveTableCellEventParameter class. + * + * The TActiveTableCellEventParameter provides the parameter passed during the callback + * requestion in the {@link getCallbackParameter CallbackParameter} property. The + * callback response content (e.g. new HTML content) must be rendered + * using an THtmlWriter obtained from the {@link getNewWriter NewWriter} + * property, which returns a <b>NEW</b> instance of TCallbackResponseWriter. + * + * The {@link getSelectedCellIndex SelectedCellIndex} is a zero-based index of the + * TActiveTableCell , -1 if the cell is not part of the cell collection (this shouldn't + * happen though since an exception is thrown before). + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveTableCellEventParameter extends TCallbackEventParameter +{ + + /** + * @var integer the zero-based index of the cell. + */ + private $_selectedCellIndex = -1; + + /** + * Creates a new TActiveTableRowEventParameter. + */ + public function __construct($response, $parameter, $index=-1) + { + parent::__construct($response, $parameter); + $this->_selectedCellIndex = $index; + } + + /** + * Returns the zero-based index of the {@link TActiveTableCell} within the + * {@link TTableCellCollection} of the parent {@link TTableRow} control. + * @return integer the zero-based index of the cell. + */ + public function getSelectedCellIndex() + { + return $this->_selectedCellIndex; + } + +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveTableRow.php b/framework/Web/UI/ActiveControls/TActiveTableRow.php index 6beeb27e..a97ffecf 100644 --- a/framework/Web/UI/ActiveControls/TActiveTableRow.php +++ b/framework/Web/UI/ActiveControls/TActiveTableRow.php @@ -222,49 +222,4 @@ class TActiveTableRow extends TTableRow implements ICallbackEventHandler, IActiv return $this->_table; } -} - -/** - * TActiveTableRowEventParameter class. - * - * The TActiveTableRowEventParameter provides the parameter passed during the callback - * requestion in the {@link getCallbackParameter CallbackParameter} property. The - * callback response content (e.g. new HTML content) must be rendered - * using an THtmlWriter obtained from the {@link getNewWriter NewWriter} - * property, which returns a <b>NEW</b> instance of TCallbackResponseWriter. - * - * The {@link getSelectedRowIndex SelectedRowIndex} is a zero-based index of the - * TActiveTableRow , -1 if the row is not part of the row collection (this shouldn't - * happen though since an exception is thrown before). - * - * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> - * @package System.Web.UI.ActiveControls - * @since 3.1.9 - */ -class TActiveTableRowEventParameter extends TCallbackEventParameter -{ - /** - * @var integer the zero-based index of the row. - */ - private $_selectedRowIndex = -1; - - /** - * Creates a new TActiveTableRowEventParameter. - */ - public function __construct($response, $parameter, $index=-1) - { - parent::__construct($response, $parameter); - $this->_selectedRowIndex = $index; - } - - /** - * Returns the zero-based index of the {@link TActiveTableRow} within the - * {@link TTableRowCollection} of the parent {@link TTable} control. - * @return integer the zero-based index of the row. - */ - public function getSelectedRowIndex() - { - return $this->_selectedRowIndex; - } - }
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveTableRowEventParameter.php b/framework/Web/UI/ActiveControls/TActiveTableRowEventParameter.php new file mode 100644 index 00000000..4500a282 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveTableRowEventParameter.php @@ -0,0 +1,56 @@ +<?php +/** + * TActiveTableRow and TActiveTableRowEventParameter class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + * @version $Id$ + */ + +/** + * TActiveTableRowEventParameter class. + * + * The TActiveTableRowEventParameter provides the parameter passed during the callback + * requestion in the {@link getCallbackParameter CallbackParameter} property. The + * callback response content (e.g. new HTML content) must be rendered + * using an THtmlWriter obtained from the {@link getNewWriter NewWriter} + * property, which returns a <b>NEW</b> instance of TCallbackResponseWriter. + * + * The {@link getSelectedRowIndex SelectedRowIndex} is a zero-based index of the + * TActiveTableRow , -1 if the row is not part of the row collection (this shouldn't + * happen though since an exception is thrown before). + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveTableRowEventParameter extends TCallbackEventParameter +{ + /** + * @var integer the zero-based index of the row. + */ + private $_selectedRowIndex = -1; + + /** + * Creates a new TActiveTableRowEventParameter. + */ + public function __construct($response, $parameter, $index=-1) + { + parent::__construct($response, $parameter); + $this->_selectedRowIndex = $index; + } + + /** + * Returns the zero-based index of the {@link TActiveTableRow} within the + * {@link TTableRowCollection} of the parent {@link TTable} control. + * @return integer the zero-based index of the row. + */ + public function getSelectedRowIndex() + { + return $this->_selectedRowIndex; + } + +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveTemplateColumn.php b/framework/Web/UI/ActiveControls/TActiveTemplateColumn.php new file mode 100644 index 00000000..6826ace9 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveTemplateColumn.php @@ -0,0 +1,84 @@ +<?php +/** + * TActiveDataGrid class file + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @link http://www.landwehr-software.de/ + * @copyright Copyright © 2009 LANDWEHR Computer und Software GmbH + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + + +/** + * TActiveTemplateColumn class + * + * TActiveTemplateColumn customizes the layout of controls in the column with templates. + * In particular, you can specify {@link setItemTemplate ItemTemplate}, + * {@link setEditItemTemplate EditItemTemplate}, {@link setHeaderTemplate HeaderTemplate} + * and {@link setFooterTemplate FooterTemplate} to customize specific + * type of cells in the column. + * + * This is the active counterpart to the {@link TTemplateColumn} control. For that purpose, + * if sorting is allowed, the header links/buttons are replaced by active controls. + * + * Please refer to the original documentation of the {@link TTemplateColumn} for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @since 3.1.9 + */ +class TActiveTemplateColumn extends TTemplateColumn { + protected function initializeHeaderCell($cell,$columnIndex) { + $text=$this->getHeaderText(); + + if(($classPath=$this->getHeaderRenderer())!=='') { + $control=Prado::createComponent($classPath); + if($control instanceof IDataRenderer) { + if($control instanceof IItemDataRenderer) { + $item=$cell->getParent(); + $control->setItemIndex($item->getItemIndex()); + $control->setItemType($item->getItemType()); + } + $control->setData($text); + } + $cell->getControls()->add($control); + } + else if($this->getAllowSorting()) { + $sortExpression=$this->getSortExpression(); + if(($url=$this->getHeaderImageUrl())!=='') { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveImageButton'); + $button->setImageUrl($url); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + if($text!=='') + $button->setAlternateText($text); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else if($text!=='') { + $button=Prado::createComponent('System.Web.UI.WebControls.TActiveLinkButton'); + $button->setText($text); + $button->setCommandName(TDataGrid::CMD_SORT); + $button->setCommandParameter($sortExpression); + $button->setCausesValidation(false); + $cell->getControls()->add($button); + } + else + $cell->setText(' '); + } + else { + if(($url=$this->getHeaderImageUrl())!=='') { + $image=Prado::createComponent('System.Web.UI.WebControls.TActiveImage'); + $image->setImageUrl($url); + if($text!=='') + $image->setAlternateText($text); + $cell->getControls()->add($image); + } + else if($text!=='') + $cell->setText($text); + else + $cell->setText(' '); + } + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TAutoComplete.php b/framework/Web/UI/ActiveControls/TAutoComplete.php index 4ed0d34c..bf297868 100644 --- a/framework/Web/UI/ActiveControls/TAutoComplete.php +++ b/framework/Web/UI/ActiveControls/TAutoComplete.php @@ -364,75 +364,4 @@ class TAutoComplete extends TActiveTextBox implements INamingContainer { return 'Prado.WebUI.TAutoComplete'; } -} - -/** - * TAutCompleteEventParameter contains the {@link getToken Token} requested by - * the user for a partial match of the suggestions. - * - * The {@link getSelectedIndex SelectedIndex} is a zero-based index of the - * suggestion selected by the user, -1 if not suggestion is selected. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TAutoCompleteEventParameter extends TCallbackEventParameter -{ - private $_selectedIndex=-1; - - /** - * Creates a new TCallbackEventParameter. - */ - public function __construct($response, $parameter, $index=-1) - { - parent::__construct($response, $parameter); - $this->_selectedIndex=$index; - } - - /** - * @return int selected suggestion zero-based index, -1 if not selected. - */ - public function getSelectedIndex() - { - return $this->_selectedIndex; - } - - /** - * @return string token for matching a list of suggestions. - */ - public function getToken() - { - return $this->getCallbackParameter(); - } -} - -/** - * TAutoCompleteTemplate class. - * - * TAutoCompleteTemplate is the default template for TAutoCompleteTemplate - * item template. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TAutoCompleteTemplate extends TComponent implements ITemplate -{ - private $_template; - - public function __construct($template) - { - $this->_template = $template; - } - /** - * Instantiates the template. - * It creates a {@link TDataList} control. - * @param TControl parent to hold the content within the template - */ - public function instantiateIn($parent) - { - $parent->getControls()->add($this->_template); - } -} - +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TAutoCompleteEventParameter.php b/framework/Web/UI/ActiveControls/TAutoCompleteEventParameter.php new file mode 100644 index 00000000..1d163967 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TAutoCompleteEventParameter.php @@ -0,0 +1,51 @@ +<?php +/** + * TAutoComplete class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TAutCompleteEventParameter contains the {@link getToken Token} requested by + * the user for a partial match of the suggestions. + * + * The {@link getSelectedIndex SelectedIndex} is a zero-based index of the + * suggestion selected by the user, -1 if not suggestion is selected. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TAutoCompleteEventParameter extends TCallbackEventParameter +{ + private $_selectedIndex=-1; + + /** + * Creates a new TCallbackEventParameter. + */ + public function __construct($response, $parameter, $index=-1) + { + parent::__construct($response, $parameter); + $this->_selectedIndex=$index; + } + + /** + * @return int selected suggestion zero-based index, -1 if not selected. + */ + public function getSelectedIndex() + { + return $this->_selectedIndex; + } + + /** + * @return string token for matching a list of suggestions. + */ + public function getToken() + { + return $this->getCallbackParameter(); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TAutoCompleteTemplate.php b/framework/Web/UI/ActiveControls/TAutoCompleteTemplate.php new file mode 100644 index 00000000..e32f3102 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TAutoCompleteTemplate.php @@ -0,0 +1,39 @@ +<?php +/** + * TAutoComplete class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TAutoCompleteTemplate class. + * + * TAutoCompleteTemplate is the default template for TAutoCompleteTemplate + * item template. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TAutoCompleteTemplate extends TComponent implements ITemplate +{ + private $_template; + + public function __construct($template) + { + $this->_template = $template; + } + /** + * Instantiates the template. + * It creates a {@link TDataList} control. + * @param TControl parent to hold the content within the template + */ + public function instantiateIn($parent) + { + $parent->getControls()->add($this->_template); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TBaseActiveCallbackControl.php b/framework/Web/UI/ActiveControls/TBaseActiveCallbackControl.php new file mode 100644 index 00000000..5ea6b04a --- /dev/null +++ b/framework/Web/UI/ActiveControls/TBaseActiveCallbackControl.php @@ -0,0 +1,270 @@ +<?php +/** + * TBaseActiveControl and TBaseActiveCallbackControl class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TBaseActiveCallbackControl is a common set of options and functionality for + * active controls that can perform callback requests. + * + * The properties of TBaseActiveCallbackControl can be accessed and changed from + * each individual active controls' {@link getActiveControl ActiveControl} + * property. + * + * The following example sets the validation group property of a TCallback component. + * <code> + * <com:TCallback ActiveControl.ValidationGroup="group1" ... /> + * </code> + * + * Additional client-side options and events can be set using the + * {@link getClientSide ClientSide} property. The following example shows + * an alert box when a TCallback component response returns successfully. + * <code> + * <com:TCallback ActiveControl.ClientSide.OnSuccess="alert('ok!')" ... /> + * </code> + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TBaseActiveCallbackControl extends TBaseActiveControl +{ + /** + * Callback client-side options can be set by setting the properties of + * the ClientSide property. E.g. <com:TCallback ActiveControl.ClientSide.OnSuccess="..." /> + * See {@link TCallbackClientSide} for details on the properties of ClientSide. + * @return TCallbackClientSide client-side callback options. + */ + public function getClientSide() + { + if(($client = $this->getOption('ClientSide'))===null) + { + $client = $this->createClientSide(); + $this->setOption('ClientSide', $client); + } + return $client; + } + + /** + * Sets the client side options. Can only be set when client side is null. + * @param TCallbackClientSide client side options. + */ + public function setClientSide($client) + { + if( $this->getOption('ClientSide')===null) + $this->setOption('ClientSide', $client); + else + throw new TConfigurationException( + 'active_controls_client_side_exists', $this->getControl()->getID()); + } + + /** + * @return TCallbackClientSide callback client-side options. + */ + protected function createClientSide() + { + return new TCallbackClientSide; + } + + /** + * Sets default callback options. Takes the ID of a TCallbackOptions + * component to duplicate the client-side + * options for this control. The {@link getClientSide ClientSide} + * subproperties takes precedence over the CallbackOptions property. + * @param string ID of a TCallbackOptions control from which ClientSide + * options are cloned. + */ + public function setCallbackOptions($value) + { + $this->setOption('CallbackOptions', $value, ''); + } + + /** + * @return string ID of a TCallbackOptions control from which ClientSide + * options are duplicated. + */ + public function getCallbackOptions() + { + return $this->getOption('CallbackOptions', ''); + } + + /** + * Returns an array of default callback client-side options. The default options + * are obtained from the client-side options of a TCallbackOptions control with + * ID specified by {@link setCallbackOptions CallbackOptions}. + * @return array list of default callback client-side options. + */ + protected function getDefaultClientSideOptions() + { + if(($id=$this->getCallbackOptions())!=='') + { + if(($pos=strrpos($id,'.'))!==false) + { + $control=$this->getControl()->getSubProperty(substr($id,0,$pos)); + $newid=substr($id,$pos+1); + if ($control!==null) + $control=$control->$newid; + } + else + { + // TCheckBoxList overrides findControl() with a fake implementation + // but accepts a second parameter to use the standard one + $control=$this->getControl()->findControl($id, true); + } + + if($control instanceof TCallbackOptions) + return $control->getClientSide()->getOptions()->toArray(); + else + throw new TConfigurationException('callback_invalid_callback_options', $this->getControl()->getID(), $id); + } + + return array(); + } + + /** + * @return boolean whether callback event trigger by this button will cause + * input validation, default is true + */ + public function getCausesValidation() + { + return $this->getOption('CausesValidation',true); + } + + /** + * @param boolean whether callback event trigger by this button will cause + * input validation + */ + public function setCausesValidation($value) + { + $this->setOption('CausesValidation',TPropertyValue::ensureBoolean($value),true); + } + + /** + * @return string the group of validators which the button causes validation + * upon callback + */ + public function getValidationGroup() + { + return $this->getOption('ValidationGroup',''); + } + + /** + * @param string the group of validators which the button causes validation + * upon callback + */ + public function setValidationGroup($value) + { + $this->setOption('ValidationGroup',$value,''); + } + + /** + * @return boolean whether to perform validation if the callback is + * requested. + */ + public function canCauseValidation() + { + if($this->getCausesValidation()) + { + $group=$this->getValidationGroup(); + return $this->getPage()->getValidators($group)->getCount()>0; + } + else + return false; + } + + /** + * @param mixed callback parameter value. + */ + public function setCallbackParameter($value) + { + $this->setOption('CallbackParameter', $value, ''); + } + + /** + * @return mixed callback parameter value. + */ + public function getCallbackParameter() + { + return $this->getOption('CallbackParameter', ''); + } + + + /** + * @return array list of callback javascript options. + */ + protected function getClientSideOptions() + { + $default = $this->getDefaultClientSideOptions(); + $options = array_merge($default,$this->getClientSide()->getOptions()->toArray()); + $validate = $this->getCausesValidation(); + $options['CausesValidation']= $validate ? '' : false; + $options['ValidationGroup']=$this->getValidationGroup(); + $options['CallbackParameter'] = $this->getCallbackParameter(); + // needed for TCallback + if(!isset($options['EventTarget'])) + $options['EventTarget'] = $this->getControl()->getUniqueID(); + return $options; + } + + /** + * Registers the callback control javascript code. Client-side options are + * merged and passed to the javascript code. This method should be called by + * Active component developers wanting to register the javascript to initialize + * the active component with additional options offered by the + * {@link getClientSide ClientSide} property. + * @param string client side javascript class name. + * @param array additional callback options. + */ + public function registerCallbackClientScript($class,$options=null) + { + $cs = $this->getPage()->getClientScript(); + if(is_array($options)) + $options = array_merge($this->getClientSideOptions(),$options); + else + $options = $this->getClientSideOptions(); + + //remove true as default to save bytes + if($options['CausesValidation']===true) + $options['CausesValidation']=''; + $cs->registerCallbackControl($class, $options); + } + + /** + * Returns the javascript callback request instance. To invoke a callback + * request for this control call the <tt>dispatch()</tt> method on the + * request instance. Example code in javascript + * <code> + * var request = <%= $this->mycallback->ActiveControl->Javascript %>; + * request.setParameter('hello'); + * request.dispatch(); //make the callback request. + * </code> + * + * Alternatively, + * <code> + * //dispatches immediately + * Prado.Callback("<%= $this->mycallback->UniqueID %>", + * $this->mycallback->ActiveControl->JsCallbackOptions); + * </code> + * @return string javascript client-side callback request object (javascript + * code) + */ + public function getJavascript() + { + $client = $this->getPage()->getClientScript(); + return $client->getCallbackReference($this->getControl(),$this->getClientSideOptions()); + } + + /** + * @param string callback requestion options as javascript code. + */ + public function getJsCallbackOptions() + { + return TJavaScript::encode($this->getClientSideOptions()); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index c9b6f36e..9d2fc900 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -130,265 +130,4 @@ class TBaseActiveControl extends TComponent && $this->getEnableUpdate() && ($bDontRequireVisibility || $this->getControl()->getVisible()); } -} - -/** - * TBaseActiveCallbackControl is a common set of options and functionality for - * active controls that can perform callback requests. - * - * The properties of TBaseActiveCallbackControl can be accessed and changed from - * each individual active controls' {@link getActiveControl ActiveControl} - * property. - * - * The following example sets the validation group property of a TCallback component. - * <code> - * <com:TCallback ActiveControl.ValidationGroup="group1" ... /> - * </code> - * - * Additional client-side options and events can be set using the - * {@link getClientSide ClientSide} property. The following example shows - * an alert box when a TCallback component response returns successfully. - * <code> - * <com:TCallback ActiveControl.ClientSide.OnSuccess="alert('ok!')" ... /> - * </code> - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TBaseActiveCallbackControl extends TBaseActiveControl -{ - /** - * Callback client-side options can be set by setting the properties of - * the ClientSide property. E.g. <com:TCallback ActiveControl.ClientSide.OnSuccess="..." /> - * See {@link TCallbackClientSide} for details on the properties of ClientSide. - * @return TCallbackClientSide client-side callback options. - */ - public function getClientSide() - { - if(($client = $this->getOption('ClientSide'))===null) - { - $client = $this->createClientSide(); - $this->setOption('ClientSide', $client); - } - return $client; - } - - /** - * Sets the client side options. Can only be set when client side is null. - * @param TCallbackClientSide client side options. - */ - public function setClientSide($client) - { - if( $this->getOption('ClientSide')===null) - $this->setOption('ClientSide', $client); - else - throw new TConfigurationException( - 'active_controls_client_side_exists', $this->getControl()->getID()); - } - - /** - * @return TCallbackClientSide callback client-side options. - */ - protected function createClientSide() - { - return new TCallbackClientSide; - } - - /** - * Sets default callback options. Takes the ID of a TCallbackOptions - * component to duplicate the client-side - * options for this control. The {@link getClientSide ClientSide} - * subproperties takes precedence over the CallbackOptions property. - * @param string ID of a TCallbackOptions control from which ClientSide - * options are cloned. - */ - public function setCallbackOptions($value) - { - $this->setOption('CallbackOptions', $value, ''); - } - - /** - * @return string ID of a TCallbackOptions control from which ClientSide - * options are duplicated. - */ - public function getCallbackOptions() - { - return $this->getOption('CallbackOptions', ''); - } - - /** - * Returns an array of default callback client-side options. The default options - * are obtained from the client-side options of a TCallbackOptions control with - * ID specified by {@link setCallbackOptions CallbackOptions}. - * @return array list of default callback client-side options. - */ - protected function getDefaultClientSideOptions() - { - if(($id=$this->getCallbackOptions())!=='') - { - if(($pos=strrpos($id,'.'))!==false) - { - $control=$this->getControl()->getSubProperty(substr($id,0,$pos)); - $newid=substr($id,$pos+1); - if ($control!==null) - $control=$control->$newid; - } - else - { - // TCheckBoxList overrides findControl() with a fake implementation - // but accepts a second parameter to use the standard one - $control=$this->getControl()->findControl($id, true); - } - - if($control instanceof TCallbackOptions) - return $control->getClientSide()->getOptions()->toArray(); - else - throw new TConfigurationException('callback_invalid_callback_options', $this->getControl()->getID(), $id); - } - - return array(); - } - - /** - * @return boolean whether callback event trigger by this button will cause - * input validation, default is true - */ - public function getCausesValidation() - { - return $this->getOption('CausesValidation',true); - } - - /** - * @param boolean whether callback event trigger by this button will cause - * input validation - */ - public function setCausesValidation($value) - { - $this->setOption('CausesValidation',TPropertyValue::ensureBoolean($value),true); - } - - /** - * @return string the group of validators which the button causes validation - * upon callback - */ - public function getValidationGroup() - { - return $this->getOption('ValidationGroup',''); - } - - /** - * @param string the group of validators which the button causes validation - * upon callback - */ - public function setValidationGroup($value) - { - $this->setOption('ValidationGroup',$value,''); - } - - /** - * @return boolean whether to perform validation if the callback is - * requested. - */ - public function canCauseValidation() - { - if($this->getCausesValidation()) - { - $group=$this->getValidationGroup(); - return $this->getPage()->getValidators($group)->getCount()>0; - } - else - return false; - } - - /** - * @param mixed callback parameter value. - */ - public function setCallbackParameter($value) - { - $this->setOption('CallbackParameter', $value, ''); - } - - /** - * @return mixed callback parameter value. - */ - public function getCallbackParameter() - { - return $this->getOption('CallbackParameter', ''); - } - - - /** - * @return array list of callback javascript options. - */ - protected function getClientSideOptions() - { - $default = $this->getDefaultClientSideOptions(); - $options = array_merge($default,$this->getClientSide()->getOptions()->toArray()); - $validate = $this->getCausesValidation(); - $options['CausesValidation']= $validate ? '' : false; - $options['ValidationGroup']=$this->getValidationGroup(); - $options['CallbackParameter'] = $this->getCallbackParameter(); - // needed for TCallback - if(!isset($options['EventTarget'])) - $options['EventTarget'] = $this->getControl()->getUniqueID(); - return $options; - } - - /** - * Registers the callback control javascript code. Client-side options are - * merged and passed to the javascript code. This method should be called by - * Active component developers wanting to register the javascript to initialize - * the active component with additional options offered by the - * {@link getClientSide ClientSide} property. - * @param string client side javascript class name. - * @param array additional callback options. - */ - public function registerCallbackClientScript($class,$options=null) - { - $cs = $this->getPage()->getClientScript(); - if(is_array($options)) - $options = array_merge($this->getClientSideOptions(),$options); - else - $options = $this->getClientSideOptions(); - - //remove true as default to save bytes - if($options['CausesValidation']===true) - $options['CausesValidation']=''; - $cs->registerCallbackControl($class, $options); - } - - /** - * Returns the javascript callback request instance. To invoke a callback - * request for this control call the <tt>dispatch()</tt> method on the - * request instance. Example code in javascript - * <code> - * var request = <%= $this->mycallback->ActiveControl->Javascript %>; - * request.setParameter('hello'); - * request.dispatch(); //make the callback request. - * </code> - * - * Alternatively, - * <code> - * //dispatches immediately - * Prado.Callback("<%= $this->mycallback->UniqueID %>", - * $this->mycallback->ActiveControl->JsCallbackOptions); - * </code> - * @return string javascript client-side callback request object (javascript - * code) - */ - public function getJavascript() - { - $client = $this->getPage()->getClientScript(); - return $client->getCallbackReference($this->getControl(),$this->getClientSideOptions()); - } - - /** - * @param string callback requestion options as javascript code. - */ - public function getJsCallbackOptions() - { - return TJavaScript::encode($this->getClientSideOptions()); - } -} - +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TCallbackErrorHandler.php b/framework/Web/UI/ActiveControls/TCallbackErrorHandler.php new file mode 100644 index 00000000..2acdb7e2 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TCallbackErrorHandler.php @@ -0,0 +1,89 @@ +<?php +/** + * TActivePageAdapter, TCallbackErrorHandler and TInvalidCallbackException class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering) + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TCallbackErrorHandler class. + * + * Captures errors and exceptions and send them back during callback response. + * When the application is in debug mode, the error and exception stack trace + * are shown. A TJavascriptLogger must be present on the client-side to view + * the error stack trace. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TCallbackErrorHandler extends TErrorHandler +{ + /** + * Displays the exceptions to the client-side TJavascriptLogger. + * A HTTP 500 status code is sent and the stack trace is sent as JSON encoded. + * @param Exception exception details. + */ + protected function displayException($exception) + { + if($this->getApplication()->getMode()===TApplication::STATE_DEBUG) + { + $response = $this->getApplication()->getResponse(); + $trace = $this->getExceptionStackTrace($exception); + // avoid error on non-utf8 strings + try { + $trace = TJavaScript::jsonEncode($trace); + } catch (Exception $e) { + // strip everythin not 7bit ascii + $trace = preg_replace('/[^(\x20-\x7F)]*/','', serialize($trace)); + } + + // avoid exception loop if headers have already been sent + try { + $response->setStatusCode(500, 'Internal Server Error'); + } catch (Exception $e) { } + + $content = $response->createHtmlWriter(); + $content->getWriter()->setBoundary(TActivePageAdapter::CALLBACK_ERROR_HEADER); + $content->write($trace); + } + else + { + error_log("Error happened while processing an existing error:\n".$exception->__toString()); + header('HTTP/1.0 500 Internal Server Error', true, 500); + } + $this->getApplication()->getResponse()->flush(); + } + + /** + * @param Exception exception details. + * @return array exception stack trace details. + */ + private function getExceptionStackTrace($exception) + { + $data['code']=$exception->getCode() > 0 ? $exception->getCode() : 500; + $data['file']=$exception->getFile(); + $data['line']=$exception->getLine(); + $data['trace']=$exception->getTrace(); + if($exception instanceof TPhpErrorException) + { + // if PHP exception, we want to show the 2nd stack level context + // because the 1st stack level is of little use (it's in error handler) + if(isset($trace[0]) && isset($trace[0]['file']) && isset($trace[0]['line'])) + { + $data['file']=$trace[0]['file']; + $data['line']=$trace[0]['line']; + } + } + $data['type']=get_class($exception); + $data['message']=$exception->getMessage(); + $data['version']=$_SERVER['SERVER_SOFTWARE'].' '.Prado::getVersion(); + $data['time']=@strftime('%Y-%m-%d %H:%M',time()); + return $data; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TCallbackPageStateTracker.php b/framework/Web/UI/ActiveControls/TCallbackPageStateTracker.php new file mode 100644 index 00000000..0c2a37c7 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TCallbackPageStateTracker.php @@ -0,0 +1,201 @@ +<?php +/** + * TActiveControlAdapter and TCallbackPageStateTracker class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TCallbackPageStateTracker class. + * + * Tracking changes to the page state during callback. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TCallbackPageStateTracker +{ + /** + * @var TMap new view state data + */ + private $_states; + /** + * @var TMap old view state data + */ + private $_existingState; + /** + * @var TControl the control tracked + */ + private $_control; + /** + * @var object null object. + */ + private $_nullObject; + + /** + * Constructor. Add a set of default states to track. + * @param TControl control to track. + */ + public function __construct($control) + { + $this->_control = $control; + $this->_existingState = new TMap; + $this->_nullObject = new stdClass; + $this->_states = new TMap; + $this->addStatesToTrack(); + } + + /** + * Add a list of view states to track. Each state is added + * to the StatesToTrack property with the view state name as key. + * The value should be an array with two enteries. The first entery + * is the name of the class that will calculate the state differences. + * The second entry is a php function/method callback that handles + * the changes in the viewstate. + */ + protected function addStatesToTrack() + { + $states = $this->getStatesToTrack(); + $states['Visible'] = array('TScalarDiff', array($this, 'updateVisible')); + $states['Enabled'] = array('TScalarDiff', array($this, 'updateEnabled')); + $states['Attributes'] = array('TMapCollectionDiff', array($this, 'updateAttributes')); + $states['Style'] = array('TStyleDiff', array($this, 'updateStyle')); + $states['TabIndex'] = array('TScalarDiff', array($this, 'updateTabIndex')); + $states['ToolTip'] = array('TScalarDiff', array($this, 'updateToolTip')); + $states['AccessKey'] = array('TScalarDiff', array($this, 'updateAccessKey')); + } + + /** + * @return TMap list of viewstates to track. + */ + protected function getStatesToTrack() + { + return $this->_states; + } + + /** + * Start tracking view state changes. The clone function on objects are called + * for those viewstate having an object as value. + */ + public function trackChanges() + { + foreach($this->_states as $name => $value) + { + $obj = $this->_control->getViewState($name); + $this->_existingState[$name] = is_object($obj) ? clone($obj) : $obj; + } + } + + /** + * @return array list of viewstate and the changed data. + */ + protected function getChanges() + { + $changes = array(); + foreach($this->_states as $name => $details) + { + $new = $this->_control->getViewState($name); + $old = $this->_existingState[$name]; + if($new !== $old) + { + $diff = new $details[0]($new, $old, $this->_nullObject); + if(($change = $diff->getDifference()) !== $this->_nullObject) + $changes[] = array($details[1],array($change)); + } + } + return $changes; + } + + /** + * For each of the changes call the corresponding change handlers. + */ + public function respondToChanges() + { + foreach($this->getChanges() as $change) + call_user_func_array($change[0], $change[1]); + } + + /** + * @return TCallbackClientScript callback client scripting + */ + protected function client() + { + return $this->_control->getPage()->getCallbackClient(); + } + + /** + * Updates the tooltip. + * @param string new tooltip + */ + protected function updateToolTip($value) + { + $this->client()->setAttribute($this->_control, 'title', $value); + } + + /** + * Updates the tab index. + * @param integer tab index + */ + protected function updateTabIndex($value) + { + $this->client()->setAttribute($this->_control, 'tabindex', $value); + } + + /** + * Updates the modifier access key + * @param string access key + */ + protected function updateAccessKey($value) + { + $this->client()->setAttribute($this->_control, 'accesskey', $value); + } + + /** + * Hides or shows the control on the client-side. The control must be + * already rendered on the client-side. + * @param boolean true to show the control, false to hide. + */ + protected function updateVisible($visible) + { + if($visible === false) + $this->client()->replaceContent($this->_control,"<span id=\"".$this->_control->getClientID()."\" style=\"display:none\" ></span>"); + else + $this->client()->replaceContent($this->_control,$this->_control); + } + + /** + * Enables or Disables the control on the client-side. + * @param boolean true to enable the control, false to disable. + */ + protected function updateEnabled($enable) + { + $this->client()->setAttribute($this->_control, 'disabled', $enable===false); + } + + /** + * Updates the CSS style on the control on the client-side. + * @param array list of new CSS style declarations. + */ + protected function updateStyle($style) + { + if($style['CssClass']!==null) + $this->client()->setAttribute($this->_control, 'class', $style['CssClass']); + if(count($style['Style']) > 0) + $this->client()->setStyle($this->_control, $style['Style']); + } + + /** + * Updates/adds a list of attributes on the control. + * @param array list of attribute name-value pairs. + */ + protected function updateAttributes($attributes) + { + foreach($attributes as $name => $value) + $this->client()->setAttribute($this->_control, $name, $value); + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php index cad3c9ee..501f50cd 100755 --- a/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php +++ b/framework/Web/UI/ActiveControls/TCallbackResponseAdapter.php @@ -94,65 +94,4 @@ class TCallbackResponseAdapter extends THttpResponseAdapter { return $this->_redirectUrl; } -} - -/** - * TCallbackResponseWriter class. - * - * TCallbackResponseWriter class enclosed a chunck of content within a - * html comment boundary. This allows multiple chuncks of content to return - * in the callback response and update multiple HTML elements. - * - * The {@link setBoundary Boundary} property sets boundary identifier in the - * HTML comment that forms the boundary. By default, the boundary identifier - * is generated using microtime. - * - * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @package System.Web.UI.ActiveControls - * @since 3.1 - */ -class TCallbackResponseWriter extends TTextWriter -{ - /** - * @var string boundary ID - */ - private $_boundary; - - /** - * Constructor. Generates unique boundary ID using microtime. - */ - public function __construct() - { - $this->_boundary = sprintf('%x',crc32(microtime())); - } - - /** - * @return string boundary identifier. - */ - public function getBoundary() - { - return $this->_boundary; - } - - /** - * @param string boundary identifier. - */ - public function setBoundary($value) - { - $this->_boundary = $value; - } - - /** - * Returns the text content wrapped within a HTML comment with boundary - * identifier as its comment content. - * @return string text content chunck. - */ - public function flush() - { - $content = parent::flush(); - if(empty($content)) - return ""; - return '<!--'.$this->getBoundary().'-->'.$content.'<!--//'.$this->getBoundary().'-->'; - } -} - +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TCallbackResponseWriter.php b/framework/Web/UI/ActiveControls/TCallbackResponseWriter.php new file mode 100644 index 00000000..3a50e02e --- /dev/null +++ b/framework/Web/UI/ActiveControls/TCallbackResponseWriter.php @@ -0,0 +1,70 @@ +<?php +/** + * TCallbackResponseAdapter and TCallbackResponseWriter class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TCallbackResponseWriter class. + * + * TCallbackResponseWriter class enclosed a chunck of content within a + * html comment boundary. This allows multiple chuncks of content to return + * in the callback response and update multiple HTML elements. + * + * The {@link setBoundary Boundary} property sets boundary identifier in the + * HTML comment that forms the boundary. By default, the boundary identifier + * is generated using microtime. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TCallbackResponseWriter extends TTextWriter +{ + /** + * @var string boundary ID + */ + private $_boundary; + + /** + * Constructor. Generates unique boundary ID using microtime. + */ + public function __construct() + { + $this->_boundary = sprintf('%x',crc32(microtime())); + } + + /** + * @return string boundary identifier. + */ + public function getBoundary() + { + return $this->_boundary; + } + + /** + * @param string boundary identifier. + */ + public function setBoundary($value) + { + $this->_boundary = $value; + } + + /** + * Returns the text content wrapped within a HTML comment with boundary + * identifier as its comment content. + * @return string text content chunck. + */ + public function flush() + { + $content = parent::flush(); + if(empty($content)) + return ""; + return '<!--'.$this->getBoundary().'-->'.$content.'<!--//'.$this->getBoundary().'-->'; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TDraggable.php b/framework/Web/UI/ActiveControls/TDraggable.php index fe2ac4cc..8e89f8a2 100755 --- a/framework/Web/UI/ActiveControls/TDraggable.php +++ b/framework/Web/UI/ActiveControls/TDraggable.php @@ -205,42 +205,3 @@ class TDraggable extends TPanel } } - -/** - * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) - * @copyright Copyright © 2008, PradoSoft - * @license http://www.pradosoft.com/license - * @package System.Web.UI.ActiveControls - */ -class TDraggableConstraint extends TEnumerable -{ - const None='None'; - const Horizontal='Horizontal'; - const Vertical='Vertical'; -} - -/** - * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) - * @copyright Copyright © 2008, PradoSoft - * @license http://www.pradosoft.com/license - * @package System.Web.UI.ActiveControls - */ -class TDraggableGhostingOptions extends TEnumerable -{ - const None='None'; - const Ghosting='Ghosting'; - const SuperGhosting='SuperGhosting'; -} - -/** - * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) - * @copyright Copyright © 2008, PradoSoft - * @license http://www.pradosoft.com/license - * @package System.Web.UI.ActiveControls - */ -class TDraggableRevertOptions extends TEnumerable -{ - const None='None'; - const Revert='Revert'; - const Failure='Failure'; -} diff --git a/framework/Web/UI/ActiveControls/TDraggableConstraint.php b/framework/Web/UI/ActiveControls/TDraggableConstraint.php new file mode 100644 index 00000000..9be201ac --- /dev/null +++ b/framework/Web/UI/ActiveControls/TDraggableConstraint.php @@ -0,0 +1,22 @@ +<?php +/** + * TDraggable class file + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ + +/** + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ +class TDraggableConstraint extends TEnumerable +{ + const None='None'; + const Horizontal='Horizontal'; + const Vertical='Vertical'; +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TDraggableGhostingOptions.php b/framework/Web/UI/ActiveControls/TDraggableGhostingOptions.php new file mode 100644 index 00000000..c30d4d69 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TDraggableGhostingOptions.php @@ -0,0 +1,22 @@ +<?php +/** + * TDraggable class file + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ + +/** + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ +class TDraggableGhostingOptions extends TEnumerable +{ + const None='None'; + const Ghosting='Ghosting'; + const SuperGhosting='SuperGhosting'; +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TDraggableRevertOptions.php b/framework/Web/UI/ActiveControls/TDraggableRevertOptions.php new file mode 100644 index 00000000..2fa029a4 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TDraggableRevertOptions.php @@ -0,0 +1,22 @@ +<?php +/** + * TDraggable class file + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ + +/** + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ +class TDraggableRevertOptions extends TEnumerable +{ + const None='None'; + const Revert='Revert'; + const Failure='Failure'; +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php index e0fea5df..988ecfab 100755 --- a/framework/Web/UI/ActiveControls/TDropContainer.php +++ b/framework/Web/UI/ActiveControls/TDropContainer.php @@ -244,74 +244,4 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan } } -} - -/** - * TDropContainerEventParameter class - * - * TDropContainerEventParameter encapsulate the parameter - * data for <b>OnDrop</b> event of TDropContainer components - * - * @author Christophe BOULAIN (Christophe.Boulain@ceram.fr) - * @copyright Copyright © 2008, PradoSoft - * @license http://www.pradosoft.com/license - * @package System.Web.UI.ActiveControls - */ -class TDropContainerEventParameter extends TEventParameter -{ - private $_dragElementId; - private $_screenX; - private $_screenY; - private $_offsetX; - private $_offsetY; - private $_clientX; - private $_clientY; - private $_shiftKey; - private $_ctrlKey; - private $_altKey; - - public function __construct($dropParams) - { - $this->_dragElementId = $dropParams->DragElementID; - $this->_screenX = $dropParams->ScreenX; - $this->_screenY = $dropParams->ScreenY; - $this->_offsetX = isset($dropParams->OffsetX) ? $dropParams->OffsetX : false; - $this->_offsetY = isset($dropParams->OffsetY) ? $dropParams->OffsetY : false; - $this->_clientX = $dropParams->ClientX; - $this->_clientY = $dropParams->ClientY; - $this->_shiftKey = TPropertyValue::ensureBoolean($dropParams->ShiftKey); - $this->_ctrlKey = TPropertyValue::ensureBoolean($dropParams->CtrlKey); - $this->_altKey = TPropertyValue::ensureBoolean($dropParams->AltKey); - } - - public function getDragElementId() { return $this->_dragElementId; } - public function getScreenX() { return $this->_screenX; } - public function getScreenY() { return $this->_screenY; } - public function getOffsetX() { return $this->_offsetX; } - public function geOffsetY() { return $this->_offsetY; } - public function getClientX() { return $this->_clientX; } - public function getClientY() { return $this->_clientY; } - public function getShiftKey() { return $this->_shiftKey; } - public function getCtrlKey() { return $this->_ctrlKey; } - public function getAltKey() { return $this->_altKey; } - - /** - * GetDroppedControl - * - * Compatibility method to get the dropped control - * @return TControl dropped control, or null if not found - */ - public function getDroppedControl () - { - $control=null; - $service=prado::getApplication()->getService(); - if ($service instanceof TPageService) - { - // Find the control - // Warning, this will not work if you have a '_' in your control Id ! - $dropControlId=str_replace(TControl::CLIENT_ID_SEPARATOR,TControl::ID_SEPARATOR,$this->_dragElementId); - $control=$service->getRequestedPage()->findControl($dropControlId); - } - return $control; - } -} +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TDropContainerEventParameter.php b/framework/Web/UI/ActiveControls/TDropContainerEventParameter.php new file mode 100644 index 00000000..3f590683 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TDropContainerEventParameter.php @@ -0,0 +1,80 @@ +<?php +/** + * TDropContainer class file + * + * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ + +/** + * TDropContainerEventParameter class + * + * TDropContainerEventParameter encapsulate the parameter + * data for <b>OnDrop</b> event of TDropContainer components + * + * @author Christophe BOULAIN (Christophe.Boulain@ceram.fr) + * @copyright Copyright © 2008, PradoSoft + * @license http://www.pradosoft.com/license + * @package System.Web.UI.ActiveControls + */ +class TDropContainerEventParameter extends TEventParameter +{ + private $_dragElementId; + private $_screenX; + private $_screenY; + private $_offsetX; + private $_offsetY; + private $_clientX; + private $_clientY; + private $_shiftKey; + private $_ctrlKey; + private $_altKey; + + public function __construct($dropParams) + { + $this->_dragElementId = $dropParams->DragElementID; + $this->_screenX = $dropParams->ScreenX; + $this->_screenY = $dropParams->ScreenY; + $this->_offsetX = isset($dropParams->OffsetX) ? $dropParams->OffsetX : false; + $this->_offsetY = isset($dropParams->OffsetY) ? $dropParams->OffsetY : false; + $this->_clientX = $dropParams->ClientX; + $this->_clientY = $dropParams->ClientY; + $this->_shiftKey = TPropertyValue::ensureBoolean($dropParams->ShiftKey); + $this->_ctrlKey = TPropertyValue::ensureBoolean($dropParams->CtrlKey); + $this->_altKey = TPropertyValue::ensureBoolean($dropParams->AltKey); + } + + public function getDragElementId() { return $this->_dragElementId; } + public function getScreenX() { return $this->_screenX; } + public function getScreenY() { return $this->_screenY; } + public function getOffsetX() { return $this->_offsetX; } + public function geOffsetY() { return $this->_offsetY; } + public function getClientX() { return $this->_clientX; } + public function getClientY() { return $this->_clientY; } + public function getShiftKey() { return $this->_shiftKey; } + public function getCtrlKey() { return $this->_ctrlKey; } + public function getAltKey() { return $this->_altKey; } + + /** + * GetDroppedControl + * + * Compatibility method to get the dropped control + * @return TControl dropped control, or null if not found + */ + public function getDroppedControl () + { + $control=null; + $service=prado::getApplication()->getService(); + if ($service instanceof TPageService) + { + // Find the control + // Warning, this will not work if you have a '_' in your control Id ! + $dropControlId=str_replace(TControl::CLIENT_ID_SEPARATOR,TControl::ID_SEPARATOR,$this->_dragElementId); + $control=$service->getRequestedPage()->findControl($dropControlId); + } + return $control; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TInvalidCallbackException.php b/framework/Web/UI/ActiveControls/TInvalidCallbackException.php new file mode 100644 index 00000000..085f1aa1 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TInvalidCallbackException.php @@ -0,0 +1,22 @@ +<?php +/** + * TActivePageAdapter, TCallbackErrorHandler and TInvalidCallbackException class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @author Gabor Berczi <gabor.berczi@devworx.hu> (lazyload additions & progressive rendering) + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TInvalidCallbackException class. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TInvalidCallbackException extends TException +{ +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TMapCollectionDiff.php b/framework/Web/UI/ActiveControls/TMapCollectionDiff.php new file mode 100644 index 00000000..ff8a4dfe --- /dev/null +++ b/framework/Web/UI/ActiveControls/TMapCollectionDiff.php @@ -0,0 +1,40 @@ +<?php +/** + * TActiveControlAdapter and TCallbackPageStateTracker class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TMapCollectionDiff class. + * + * Calculate the changes to attributes collection. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TMapCollectionDiff extends TViewStateDiff +{ + /** + * @return array updates to the attributes collection. + */ + public function getDifference() + { + if($this->_old===null) + { + return ($this->_new!==null) ? $this->_new->toArray() : $this->_null; + } + else + { + $new = $this->_new->toArray(); + $old = $this->_old->toArray(); + $diff = array_diff_assoc($new, $old); + return count($diff) > 0 ? $diff : $this->_null; + } + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TScalarDiff.php b/framework/Web/UI/ActiveControls/TScalarDiff.php new file mode 100644 index 00000000..ac8ff950 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TScalarDiff.php @@ -0,0 +1,34 @@ +<?php +/** + * TActiveControlAdapter and TCallbackPageStateTracker class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TScalarDiff class. + * + * Calculate the changes to a scalar value. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TScalarDiff extends TViewStateDiff +{ + /** + * @return mixed update viewstate value. + */ + public function getDifference() + { + if(gettype($this->_new) === gettype($this->_old) + && $this->_new === $this->_old) + return $this->_null; + else + return $this->_new; + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TStyleDiff.php b/framework/Web/UI/ActiveControls/TStyleDiff.php new file mode 100644 index 00000000..047eb470 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TStyleDiff.php @@ -0,0 +1,101 @@ +<?php +/** + * TActiveControlAdapter and TCallbackPageStateTracker class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * TStyleDiff class. + * + * Calculates the changes to the Style properties. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +class TStyleDiff extends TViewStateDiff +{ + /** + * @param TStyle control style + * @return array all the style properties combined. + */ + protected function getCombinedStyle($obj) + { + if(!($obj instanceof TStyle)) + return array(); + $style = $obj->getStyleFields(); + $style = array_merge($style,$this->getStyleFromString($obj->getCustomStyle())); + if($obj->hasFont()) + $style = array_merge($style, $this->getStyleFromString($obj->getFont()->toString())); + return $style; + } + + /** + * @param string CSS custom style string. + * @param array CSS style as name-value array. + */ + protected function getStyleFromString($string) + { + $style = array(); + if(!is_string($string)) return $style; + + foreach(explode(';',$string) as $sub) + { + $arr=explode(':',$sub); + if(isset($arr[1]) && trim($arr[0])!=='') + $style[trim($arr[0])] = trim($arr[1]); + } + return $style; + } + + /** + * @return string changes to the CSS class name. + */ + protected function getCssClassDiff() + { + if($this->_old===null) + { + return ($this->_new!==null) && $this->_new->hasCssClass() + ? $this->_new->getCssClass() : null; + } + else + { + return $this->_old->getCssClass() !== $this->_new->getCssClass() ? + $this->_new->getCssClass() : null; + } + } + + /** + * @return array list of changes to the control style. + */ + protected function getStyleDiff() + { + $diff = array_diff_assoc( + $this->getCombinedStyle($this->_new), + $this->getCombinedStyle($this->_old)); + return count($diff) > 0 ? $diff : null; + } + + /** + * @return array list of changes to the control style and CSS class name. + */ + public function getDifference() + { + if($this->_new===null) + return $this->_null; + else + { + $css = $this->getCssClassDiff(); + $style = $this->getStyleDiff(); + if(($css!==null) || ($style!==null)) + return array('CssClass' => $css, 'Style' => $style); + else + $this->_null; + } + } +}
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TViewStateDiff.php b/framework/Web/UI/ActiveControls/TViewStateDiff.php new file mode 100644 index 00000000..a5b229eb --- /dev/null +++ b/framework/Web/UI/ActiveControls/TViewStateDiff.php @@ -0,0 +1,51 @@ +<?php +/** + * TActiveControlAdapter and TCallbackPageStateTracker class file. + * + * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Web.UI.ActiveControls + */ + +/** + * Calculates the viewstate changes during the request. + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @package System.Web.UI.ActiveControls + * @since 3.1 + */ +abstract class TViewStateDiff +{ + /** + * @var mixed updated viewstate + */ + protected $_new; + /** + * @var mixed viewstate value at the begining of the request. + */ + protected $_old; + /** + * @var object null value. + */ + protected $_null; + + /** + * Constructor. + * @param mixed updated viewstate value. + * @param mixed viewstate value at the begining of the request. + * @param object representing the null value. + */ + public function __construct($new, $old, $null) + { + $this->_new = $new; + $this->_old = $old; + $this->_null = $null; + } + + /** + * @return mixed view state changes, nullObject if no difference. + */ + public abstract function getDifference(); +}
\ No newline at end of file |