summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorJens Klaer <kj.landwehr.software@gmail.com>2015-10-22 10:48:13 +0200
committerJens Klaer <kj.landwehr.software@gmail.com>2015-10-22 10:48:13 +0200
commitfd76b5617e3c136be2f8b5374e7629d2bea77070 (patch)
tree719eff831c25b0e557b321ed826b6d6365496b64 /framework/Web/UI
parenta262ce578b6584ab71421a7fb59d506848f60683 (diff)
extended ISurroundable to provide the surrounding tag in addition to the id
- ISurroundable introducing getSurroundingTag(), adjusted controls implementing the interface - TActiveDataGrid/TActiveRepeater now support changing the container tag to avoid invalid html in specific situations - revised corresponding quickstart demos
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/ActiveControls/TActiveDataGrid.php35
-rw-r--r--framework/Web/UI/ActiveControls/TActiveRepeater.php40
-rw-r--r--framework/Web/UI/TControl.php10
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php22
4 files changed, 83 insertions, 24 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveDataGrid.php b/framework/Web/UI/ActiveControls/TActiveDataGrid.php
index bb5f6c0f..2f23c49f 100644
--- a/framework/Web/UI/ActiveControls/TActiveDataGrid.php
+++ b/framework/Web/UI/ActiveControls/TActiveDataGrid.php
@@ -54,6 +54,11 @@ Prado::using('System.Web.UI.WebControls.TCheckBoxColumn');
*/
class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable {
+ /**
+ * @var string the tag used to render the surrounding container
+ */
+ protected $_surroundingTag='div';
+
/**
* @return string Name of the class used in AutoGenerateColumns mode
*/
@@ -94,11 +99,27 @@ class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable
}
/**
- * Returns the id of the surrounding container (div).
+ * Gets the tag used to render the surrounding container. Defaults to 'div'.
+ * @return string container tag
+ */
+ public function getSurroundingTag() {
+ return $this->_surroundingTag;
+ }
+
+ /**
+ * Sets the tag used to render the surrounding container.
+ * @param string $value container tag
+ */
+ public function setSurroundingTag($value) {
+ $this->_surroundingTag=TPropertyValue::ensureString($value);
+ }
+
+ /**
+ * Returns the id of the surrounding container.
* @return string container id
*/
public function getSurroundingTagID() {
- return $this->ClientID.'_Container';
+ return $this->getClientID().'_Container';
}
/**
@@ -181,14 +202,16 @@ class TActiveDataGrid extends TDataGrid implements IActiveControl, ISurroundable
}
/**
- * Renders the datagrid by writing a div tag with the container id obtained from {@link getSurroundingTagId()}
- * which will be called by the replacement method of the client script to update it's content.
+ * Renders the datagrid by writing a {@link getSurroundingTag()} with the container id obtained
+ * from {@link getSurroundingTagId()} which will be called by the replacement method of the client
+ * script to update it's content.
* @param THtmlWriter writer for the rendering purpose
*/
private function renderDataGrid($writer) {
- $writer->write('<div id="'.$this->getSurroundingTagId().'">');
+ $writer->addAttribute('id',$this->getSurroundingTagID());
+ $writer->renderBeginTag($this->getSurroundingTag());
parent::render($writer);
- $writer->write('</div>');
+ $writer->renderEndTag();
}
}
diff --git a/framework/Web/UI/ActiveControls/TActiveRepeater.php b/framework/Web/UI/ActiveControls/TActiveRepeater.php
index 08aeefab..ad97d30d 100644
--- a/framework/Web/UI/ActiveControls/TActiveRepeater.php
+++ b/framework/Web/UI/ActiveControls/TActiveRepeater.php
@@ -25,10 +25,15 @@
*/
class TActiveRepeater extends TRepeater implements IActiveControl, ISurroundable {
-/**
- * Creates a new callback control, sets the adapter to
- * TActiveControlAdapter.
- */
+ /**
+ * @var string the tag used to render the surrounding container
+ */
+ protected $_surroundingTag='div';
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter.
+ */
public function __construct() {
parent::__construct();
$this->setAdapter(new TActiveControlAdapter($this));
@@ -57,11 +62,27 @@ class TActiveRepeater extends TRepeater implements IActiveControl, ISurroundable
}
/**
- * Returns the id of the surrounding container (span).
+ * Gets the tag used to render the surrounding container. Defaults to 'div'.
+ * @return string container tag
+ */
+ public function getSurroundingTag() {
+ return $this->_surroundingTag;
+ }
+
+ /**
+ * Sets the tag used to render the surrounding container.
+ * @param string $value container tag
+ */
+ public function setSurroundingTag($value) {
+ $this->_surroundingTag=TPropertyValue::ensureString($value);
+ }
+
+ /**
+ * Returns the id of the surrounding container.
* @return string container id
*/
public function getSurroundingTagID() {
- return $this->ClientID.'_Container';
+ return $this->getClientID().'_Container';
}
/**
@@ -96,13 +117,14 @@ class TActiveRepeater extends TRepeater implements IActiveControl, ISurroundable
}
/**
- * Renders the repeater by writing a span tag with the container id obtained from {@link getSurroundingTagID()}
- * which will be called by the replacement method of the client script to update it's content.
+ * Renders the repeater by writing a {@link getSurroundingTag()} with the container id obtained
+ * from {@link getSurroundingTagID()} which will be called by the replacement method of the client
+ * script to update it's content.
* @param THtmlWriter writer for the rendering purpose
*/
private function renderRepeater($writer) {
$writer->addAttribute('id',$this->getSurroundingTagID());
- $writer->renderBeginTag('span');
+ $writer->renderBeginTag($this->getSurroundingTag());
parent::render($writer);
$writer->renderEndTag();
}
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index f12504be..eb5c016e 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -2142,7 +2142,8 @@ interface IButtonControl
* ISurroundable interface
*
* Identifies controls that may create an additional surrounding tag. The id of the
- * tag can be obtained with {@link getSurroundingTagID}.
+ * tag can be obtained with {@link getSurroundingTagID}, the tag used to render the
+ * surrounding container is obtained by {@link getSurroundingTag}.
*
* @package System.Web.UI
* @since 3.1.2
@@ -2150,7 +2151,12 @@ interface IButtonControl
interface ISurroundable
{
/**
- * @return string the id of the embedding tag of the control or the control's clientID if not surrounded
+ * @return string the tag used to wrap the control in (if surrounding is needed).
+ */
+ public function getSurroundingTag();
+
+ /**
+ * @return string the id of the embedding tag of the control or the control's clientID if not surrounded.
*/
public function getSurroundingTagID();
}
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index a28beac7..672aa9b2 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -284,11 +284,19 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
/**
- * @return string the id of the surrounding tag or this clientID if no such tag needed
+ * @return string the tag used to wrap the control in.
+ */
+ public function getSurroundingTag()
+ {
+ return 'span';
+ }
+
+ /**
+ * @return string the id of the surrounding tag or this clientID if no such tag needed.
*/
public function getSurroundingTagID()
{
- return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID();
+ return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID();
}
/**
@@ -318,11 +326,11 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
else
$onclick='';
- if($needspan=$this->getSpanNeeded())
- {
- $writer->addAttribute('id',$this->getSurroundingTagID());
- $writer->renderBeginTag('span');
- }
+ if($needspan=$this->getSpanNeeded())
+ {
+ $writer->addAttribute('id',$this->getSurroundingTagID());
+ $writer->renderBeginTag($this->getSurroundingTag());
+ }
$clientID=$this->getClientID();
if(($text=$this->getText())!=='')
{