diff options
| -rw-r--r-- | .gitattributes | 2 | ||||
| -rw-r--r-- | HISTORY | 2 | ||||
| -rw-r--r-- | framework/Exceptions/messages/messages.txt | 6 | ||||
| -rw-r--r-- | framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js | 3 | ||||
| -rw-r--r-- | framework/Web/UI/ActiveControls/TActiveTableCell.php | 244 | ||||
| -rw-r--r-- | framework/Web/UI/ActiveControls/TActiveTableRow.php | 262 | 
6 files changed, 519 insertions, 0 deletions
| diff --git a/.gitattributes b/.gitattributes index ed6774d4..0ebf45f9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2683,6 +2683,8 @@ framework/Web/UI/ActiveControls/TActivePager.php -text  framework/Web/UI/ActiveControls/TActivePanel.php -text  framework/Web/UI/ActiveControls/TActiveRatingList.php -text  framework/Web/UI/ActiveControls/TActiveRepeater.php -text +framework/Web/UI/ActiveControls/TActiveTableCell.php -text +framework/Web/UI/ActiveControls/TActiveTableRow.php -text  framework/Web/UI/ActiveControls/TActiveTextBox.php -text  framework/Web/UI/ActiveControls/TAutoComplete.php -text  framework/Web/UI/ActiveControls/TBaseActiveControl.php -text @@ -6,6 +6,8 @@ NEW: Port Yii's Models and Behaviors (Daniel + Robin)  NEW: Add TActiveDataList (Marcosanobre, Robin)  NEW: Add TActiveRepeater (LCS Team, Christophe)  NEW: Add TActiveDatagrid (LCS Team, Christophe) +NEW: Add TActiveTableRow (LCS Team) +NEW: Add TActiveTableCell (LCS Team)  ENH: Issue#173 - Add "dragdropextra" (superghosting) patch, mouse coordinates and key status to drag & drop controls (Christophe, DevWorx)  Version 3.1.6 to be released diff --git a/framework/Exceptions/messages/messages.txt b/framework/Exceptions/messages/messages.txt index ee5fc317..f9e30b1d 100644 --- a/framework/Exceptions/messages/messages.txt +++ b/framework/Exceptions/messages/messages.txt @@ -473,3 +473,9 @@ response_status_reason_missing			= HTTP 1.1 need reason for extended status-code  response_status_reason_badchars			= For HTTP 1.1 header, the token status-reason must not contain token CR or LF  activefileupload_temppath_invalid		= TActiveFileUpload TempPath path '{0}' does not exist or is not writable by Web server process. + +tactivetablecell_control_outoftable		= {0} '{1}' must be enclosed within a TTableRow control. +tactivetablecell_control_notincollection = {0} '{1}' no member of the TTableCellCollection of the parent TTableRow control. + +tactivetablerow_control_outoftable		= {0} '{1}' must be enclosed within a TTable control. +tactivetablerow_control_notincollection = {0} '{1}' no member of the TTableRowCollection of the parent TTable control.
\ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index 56395d44..05334463 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -391,3 +391,6 @@ Prado.WebUI.TValueTriggeredCallback = Base.extend(  		Prado.WebUI.TValueTriggeredCallback.timers[id].stopObserving();
  	}
  });
 +
 +Prado.WebUI.TActiveTableCell = Class.extend(Prado.WebUI.CallbackControl);
 +Prado.WebUI.TActiveTableRow = Class.extend(Prado.WebUI.CallbackControl);
\ No newline at end of file diff --git a/framework/Web/UI/ActiveControls/TActiveTableCell.php b/framework/Web/UI/ActiveControls/TActiveTableCell.php new file mode 100644 index 00000000..833ce6e7 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveTableCell.php @@ -0,0 +1,244 @@ +<?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$ + */ + +/** + * Includes the following used classes + */ +Prado::using('System.Web.UI.WebControls.TTableRow'); +Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); +Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter'); + +/** + * TActiveTableCell class. + * + * TActiveTableCell is the active counterpart to the original {@link TTableCell} control + * and displays a table cell. The horizontal and vertical alignments of the cell + * are specified via {@link setHorizontalAlign HorizontalAlign} and + * {@link setVerticalAlign VerticalAlign} properties, respectively. + * + * TActiveTableCell allows the contents of the table cell to be changed during callback. When + * {@link onCellSelected CellSelected} property is set, selecting (clicking on) the cell will + * perform a callback request causing {@link onCellSelected OnCellSelected} event to be fired. + * + * It will also bubble the {@link onCellSelected OnCellSelected} event up to it's parent + * {@link TActiveTableRow} control which will fire up the event handlers if implemented. + * + * TActiveTableCell allows the client-side cell contents to be updated during a + * callback response by getting a new writer, invoking the render method and flushing the + * output, similar to a {@link TActivePanel} control. + * <code> + * function callback_request($sender, $param) + * { + *     $this->active_cell->render($param->getNewWriter()); + * } + * </code> + * + * Please refer to the original documentation of the regular counterpart for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @version $Id$ + * @since 3.2 + */ +class TActiveTableCell extends TTableCell implements ICallbackEventHandler, IActiveControl +{ + +	/** +	* @var TTable parent row control containing the cell +	*/ +	private $_row; + +	/** +	 * Creates a new callback control, sets the adapter to TActiveControlAdapter. +	 */ +	public function __construct() +	{ +		parent::__construct(); +			$this->setAdapter(new TActiveControlAdapter($this)); +	} + +	/** +	 * @return TBaseActiveCallbackControl standard callback control options. +	 */ +	public function getActiveControl() +	{ +		return $this->getAdapter()->getBaseActiveControl(); +	} + +	/** +	 * @return string corresponding javascript class name for this TActiveTableCell. +	 */ +	protected function getClientClassName() +	{ +		return 'Prado.WebUI.TActiveTableCell'; +	} + +	/** +	 * Raises the callback event. This method is required by {@link ICallbackEventHandler} +	 * interface. It will raise {@link onCellSelected OnCellSelected} event with a +	 * {@link TActiveTableCellEventParameter} containing the zero-based index of the +	 * TActiveTableCell. +	 * This method is mainly used by framework and control developers. +	 * @param TCallbackEventParameter the event parameter +	 */ +	public function raiseCallbackEvent($param) +	{ +		$parameter = new TActiveTableCellEventParameter($this->getResponse(), $param->getCallbackParameter(), $this->getCellIndex()); +		$this->onCellSelected($parameter); +		$this->raiseBubbleEvent($this, $parameter); +	} + +	/** +	 * This method is invoked when a callback is requested. The method raises +	 * 'OnCellSelected' event to fire up the event handlers. If you override this +	 * method, be sure to call the parent implementation so that the event +	 * handler can be invoked. +	 * @param TActiveTableCellEventParameter event parameter to be passed to the event handlers +	 */ +	public function onCellSelected($param) +	{ +		$this->raiseEvent('OnCellSelected', $this, $param); +	} + +	/** +	 * Ensure that the ID attribute is rendered and registers the javascript code +	 * for initializing the active control if the event handler for the +	 * {@link onCellSelected OnCellSelected} event is set. +	 * @param THtmlWriter the writer responsible for rendering +	 */ +	protected function addAttributesToRender($writer) +	{ +		parent::addAttributesToRender($writer); +		$writer->addAttribute('id', $this->getClientID()); +		if ($this->hasEventHandler('OnCellSelected')) +			$this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getPostBackOptions()); +	} + +	/** +	 * Renders and replaces the cell's content on the client-side. When render() is +	 * called before the OnPreRender event, such as when render() is called during +	 * a callback event handler, the rendering is defered until OnPreRender event +	 * is raised. +	 * @param THtmlWriter html writer +	 */ +	public function render($writer) +	{ +		if ($this->getHasPreRendered()) +		{ +			parent::render($writer); +			if ($this->getActiveControl()->canUpdateClientSide()) +				$this->getPage()->getCallbackClient()->replaceContent($this, $writer); +		} +		else { +			$this->getPage()->getAdapter()->registerControlToRender($this, $writer); +			// If we update a TActiveTableCell on callback, we shouldn't update all childs, +			// because the whole content will be replaced by the parent. +			if ($this->getHasControls()) +			{ +				foreach ($this->findControlsByType('IActiveControl', false) as $control) +					$control->getActiveControl()->setEnableUpdate(false); +			} +		} +	} + +	/** +	 * Returns postback specifications for the table cell. +	 * This method is used by framework and control developers. +	 * @return array parameters about how the row defines its postback behavior. +	 */ +	protected function getPostBackOptions() +	{ +		$options['ID'] = $this->getClientID(); +		$options['EventTarget'] = $this->getUniqueID(); +		return $options; +	} + +	/** +	 * Returns the zero-based index of the TActiveTableCell within the {@link TTableCellCollection} +	 * of the parent {@link TTableRow} control. Raises a {@link TConfigurationException} if the cell +	 * is no member of the cell collection. +	 * @return integer the zero-based index of the cell +	 */ +	public function getCellIndex() +	{ +		foreach ($this->getRow()->getCells() as $key => $row) +			if ($row == $this) return $key; +		throw new TConfigurationException('tactivetablecell_control_notincollection', get_class($this), $this->getUniqueID()); +	} + +	/** +	 * Returns the parent {@link TTableRow} control by looping through all parents until a {@link TTableRow} +	 * is found. Raises a {@link TConfigurationException} if no row control is found. +	 * @return TTableRow the parent row control +	 */ +	public function getRow() +	{ +		if ($this->_row === null) +		{ +			$row = $this->getParent(); +			while (!($row instanceof TTableRow) && $row !== null) +			{ +				$row = $row->getParent(); +			} +			if ($row instanceof TTableRow) $this->_row = $row; +			else throw new TConfigurationException('tactivetablecell_control_outoftable', get_class($this), $this->getUniqueID()); +		} +		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.2 + */ +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 new file mode 100644 index 00000000..31287617 --- /dev/null +++ b/framework/Web/UI/ActiveControls/TActiveTableRow.php @@ -0,0 +1,262 @@ +<?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$ + */ + +/** + * Includes the following used classes + */ +Prado::using('System.Web.UI.WebControls.TTableRow'); +Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); +Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter'); + +/** + * TActiveTableRow class. + * + * TActiveTableRow is the active counterpart to the original {@link TTableRow} control + * and displays a table row. The table cells in the row can be accessed + * via {@link getCells Cells}. The horizontal and vertical alignments of the row + * are specified via {@link setHorizontalAlign HorizontalAlign} and + * {@link setVerticalAlign VerticalAlign} properties, respectively. + * + * TActiveTableRow allows the contents of the table row to be changed during callback. When + * {@link onRowSelected RowSelected} property is set, selecting (clicking on) the row will + * perform a callback request causing {@link onRowSelected OnRowSelected} event to be fired. + * + * It will also respond to a bubbled {@link onCellSelected OnCellSelected} event of a + * {@link TActiveTableCell} child control and fire a {@link onRowSelected OnRowSelected} event. + * + * TActiveTableRow allows the client-side row contents to be updated during a + * callback response by getting a new writer, invoking the render method and flushing the + * output, similar to a {@link TActivePanel} control. + * <code> + * function callback_request($sender, $param) + * { + *     $this->active_row->render($param->getNewWriter()); + * } + * </code> + * + * Please refer to the original documentation of the regular counterpart for usage. + * + * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de> + * @package System.Web.UI.ActiveControls + * @version $Id$ + * @since 3.2 + */ +class TActiveTableRow extends TTableRow implements ICallbackEventHandler, IActiveControl +{ + +	/** +	 * @var TTable parent table control containing the row +	 */ +	private $_table; + +	/** +	 * Creates a new callback control, sets the adapter to TActiveControlAdapter. +	 * */ +	public function __construct() +	{ +		parent::__construct(); +		$this->setAdapter(new TActiveControlAdapter($this)); +	} + +	/** +	 * @return TBaseActiveCallbackControl standard callback control options. +	 */ +	public function getActiveControl() +	{ +		return $this->getAdapter()->getBaseActiveControl(); +	} + +	/** +	 * @return string corresponding javascript class name for this TActiveTableRow. +	 */ +	protected function getClientClassName() +	{ +		return 'Prado.WebUI.TActiveTableRow'; +	} + +	/** +	 * Raises the callback event. This method is required by {@link ICallbackEventHandler} +	 * interface. It will raise {@link onRowSelected OnRowSelected} event with a +	 * {@link TActiveTableRowEventParameter} containing the zero-based index of the +	 * TActiveTableRow. +	 * This method is mainly used by framework and control developers. +	 * @param TCallbackEventParameter the event parameter +	 */ +	public function raiseCallbackEvent($param) +	{ +		$parameter = new TActiveTableRowEventParameter($this->getResponse(), $param->getCallbackParameter(), $this->getRowIndex()); +		$this->onRowSelected($parameter); +	} + +	/** +	 * This method overrides parent's implementation and raises the control's +	 * callback event. This will fire the {@link onRowSelected OnRowSelected} +	 * event if an appropriate event handler is implemented. +	 * @param TControl the sender of the event +	 * @param TEventParameter event parameter +	 * @return boolean whether the event bubbling should stop here. +	 */ +	public function bubbleEvent($sender, $param) +	{ +		if ($param instanceof TActiveTableCellEventParameter) +		{ +			$this->raiseCallbackEvent($param); +			return true; +		} +		else return false; +	} + +	/** +	 * This method is invoked when a callback is requested. The method raises +	 * 'OnRowSelected' event to fire up the event handlers. If you override this +	 * method, be sure to call the parent implementation so that the event +	 * handler can be invoked. +	 * @param TActiveTableRowEventParameter event parameter to be passed to the event handlers +	 */ +	public function onRowSelected($param) +	{ +		$this->raiseEvent('OnRowSelected', $this, $param); +	} + +	/** +	 * Ensure that the ID attribute is rendered and registers the javascript code +	 * for initializing the active control if the event handler for the +	 * {@link onRowSelected OnRowSelected} event is set. +	 * @param THtmlWriter the writer responsible for rendering +	 */ +	protected function addAttributesToRender($writer) +	{ +		parent::addAttributesToRender($writer); +		$writer->addAttribute('id', $this->getClientID()); +		if ($this->hasEventHandler('OnRowSelected')) +			$this->getActiveControl()->registerCallbackClientScript($this->getClientClassName(), $this->getPostBackOptions()); +	} + +	/** +	 * Renders and replaces the row's content on the client-side. When render() is +	 * called before the OnPreRender event, such as when render() is called during +	 * a callback event handler, the rendering is defered until OnPreRender event +	 * is raised. +	 * @param THtmlWriter html writer +	 */ +	public function render($writer) +	{ +		if ($this->getHasPreRendered()) +		{ +			parent::render($writer); +			if ($this->getActiveControl()->canUpdateClientSide()) +				$this->getPage()->getCallbackClient()->replaceContent($this, $writer); +		} +		else +		{ +			$this->getPage()->getAdapter()->registerControlToRender($this, $writer); +			// If we update a TActiveTableRow on callback, we shouldn't update all childs, +			// because the whole content will be replaced by the parent. +			if ($this->getHasControls()) +			{ +				foreach ($this->findControlsByType('IActiveControl', false) as $control) +					$control->getActiveControl()->setEnableUpdate(false); +			} +		} +	} + +	/** +	 * Returns postback specifications for the table row. +	 * This method is used by framework and control developers. +	 * @return array parameters about how the row defines its postback behavior. +	 */ +	protected function getPostBackOptions() +	{ +		$options['ID'] = $this->getClientID(); +		$options['EventTarget'] = $this->getUniqueID(); +		return $options; +	} + +	/** +	 * Returns the zero-based index of the TActiveTableRow within the {@link TTableRowCollection} +	 * of the parent {@link TTable} control. Raises a {@link TConfigurationException} if the row +	 * is no member of the row collection. +	 * @return integer the zero-based index of the row +	 */ +	public function getRowIndex() +	{ +		foreach ($this->getTable()->getRows() as $key => $row) +			if ($row == $this) return $key; +		throw new TConfigurationException('tactivetablerow_control_notincollection', get_class($this), $this->getUniqueID()); +	} + +	/** +	 * Returns the parent {@link TTable} control by looping through all parents until a {@link TTable} +	 * is found. Raises a {@link TConfigurationException} if no table control is found. +	 * @return TTable the parent table control +	 */ +	public function getTable() +	{ +		if ($this->_table === null) +		{ +			$table = $this->getParent(); +			while (!($table instanceof TTable) && $table !== null) +			{ +				$table = $table->getParent(); +			} +			if ($table instanceof TTable) $this->_table = $table; +			else throw new TConfigurationException('tactivetablerow_control_outoftable', get_class($this), $this->getUniqueID()); +		} +		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.2 + */ +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 | 
