summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormikl <>2008-04-17 16:16:03 +0000
committermikl <>2008-04-17 16:16:03 +0000
commit2ff1a4bcb650b0dce241c2d947fbf59759c2efff (patch)
treeadc1c4fa758f67f5c404f7f1d320fd5dbf8296e9
parent5f6f3f560b826b6b4f9f98bb4e83724b28e454d6 (diff)
Fixed #622
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientScript.php68
-rw-r--r--framework/Web/UI/TControl.php18
-rw-r--r--framework/Web/UI/WebControls/TCheckBox.php39
3 files changed, 109 insertions, 16 deletions
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
index 4ddb0654..d372e057 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -164,6 +164,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function setAttribute($control, $name, $value)
{
+ if ($control instanceof TControl && $control instanceof IControlContainer)
+ $control=$control->getContainerClientID();
$this->callClientFunction('Prado.Element.setAttribute',array($control, $name, $value));
}
@@ -191,6 +193,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function show($element)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Element.show', $element);
}
@@ -200,6 +204,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function hide($element)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Element.hide', $element);
}
@@ -211,6 +217,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function toggle($element, $effect=null, $options=array())
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Element.toggle', array($element,$effect,$options));
}
@@ -220,6 +228,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function remove($element)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Element.remove', $element);
}
@@ -236,6 +246,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function update($element, $content)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->replace($element, $content, 'Element.update');
}
@@ -246,6 +258,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function addCssClass($element, $cssClass)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Element.addClassName', array($element, $cssClass));
}
@@ -256,6 +270,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function removeCssClass($element, $cssClass)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Element.removeClassName', array($element, $cssClass));
}
@@ -276,6 +292,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function scrollTo($element)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Element.scrollTo', $element);
}
@@ -296,6 +314,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function setStyle($element, $styles)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction('Prado.Element.setStyle', array($element, $styles));
}
@@ -306,6 +326,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function appendContent($element, $content)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->replace($element, $content, 'Prado.Element.Insert.append');
}
@@ -316,6 +338,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function prependContent($element, $content)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->replace($element, $content, 'Prado.Element.Insert.prepend');
}
@@ -326,6 +350,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function insertContentAfter($element, $content)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->replace($element, $content, 'Prado.Element.Insert.after');
}
@@ -336,6 +362,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function insertContentBefore($element, $content)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->replace($element, $content, 'Prado.Element.Insert.before');
}
@@ -378,6 +406,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function replaceContent($element,$content)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->replace($element, $content);
}
@@ -428,6 +458,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function visualEffect($type, $element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->callClientFunction($type, array($element, $options));
}
@@ -438,6 +470,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function appear($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Appear', $element, $options);
}
@@ -448,6 +482,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function blindDown($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.BlindDown', $element, $options);
}
@@ -458,6 +494,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function blindUp($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.BlindUp', $element, $options);
}
@@ -469,6 +507,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function dropOut($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.DropOut', $element, $options);
}
@@ -479,6 +519,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function fade($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Fade', $element, $options);
}
@@ -489,6 +531,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function fold($element, $options = null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Fold', $element, $options);
}
@@ -499,6 +543,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function grow($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Grow', $element, $options);
}
@@ -509,6 +555,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function puff($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Puff', $element, $options);
}
@@ -519,6 +567,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function pulsate($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Pulsate', $element, $options);
}
@@ -529,6 +579,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function shake($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Shake', $element, $options);
}
@@ -539,6 +591,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function shrink($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Shrink', $element, $options);
}
@@ -549,6 +603,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function slideDown($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.SlideDown', $element, $options);
}
@@ -559,6 +615,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function slideUp($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.SlideUp', $element, $options);
}
@@ -569,6 +627,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function squish($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.Squish', $element, $options);
}
@@ -579,6 +639,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function switchOff($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Effect.SwitchOff', $element, $options);
}
@@ -589,6 +651,8 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function highlight($element, $options=null)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$this->visualEffect('Prado.Effect.Highlight', $element, $options);
}
@@ -599,9 +663,11 @@ class TCallbackClientScript extends TApplicationComponent
*/
public function setOpacity($element, $value)
{
+ if ($element instanceof TControl && $element instanceof IControlContainer)
+ $element=$element->getContainerClientID();
$value = TPropertyValue::ensureFloat($value);
$this->callClientFunction('Element.setOpacity', array($element,$value));
}
}
-?> \ No newline at end of file
+?>
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index d43ddf10..f20cd2d1 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -2152,6 +2152,22 @@ interface IButtonControl
}
/**
+ * IControlContainer interface
+ *
+ * If a control can have an additional surrounding tag, it should implement this interface.
+ *
+ * @package System.Web.UI
+ * @since 3.1.2
+ */
+interface IControlContainer
+{
+ /**
+ * @return string the id of the container html tag or of the input control itself if no container present.
+ */
+ public function getContainerClientID();
+}
+
+/**
* TBroadcastEventParameter class
*
* TBroadcastEventParameter encapsulates the parameter data for
@@ -2358,4 +2374,4 @@ class TCompositeLiteral extends TComponent implements IRenderable, IBindable
}
}
-?> \ No newline at end of file
+?>
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php
index 7a0fc603..4061f217 100644
--- a/framework/Web/UI/WebControls/TCheckBox.php
+++ b/framework/Web/UI/WebControls/TCheckBox.php
@@ -40,7 +40,7 @@
* @package System.Web.UI.WebControls
* @since 3.0
*/
-class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer
+class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer, IControlContainer
{
private $_dataChanged=false;
@@ -268,6 +268,14 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
/**
+ * @return string the id of the surrounding tag or this clientID if no such tag present
+ */
+ public function getContainerClientID()
+ {
+ return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID();
+ }
+
+ /**
* Renders the checkbox control.
* This method overrides the parent implementation by rendering a checkbox input element
* and a span element if needed.
@@ -276,17 +284,10 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
public function render($writer)
{
$this->getPage()->ensureRenderInForm($this);
- $needSpan=false;
if($this->getHasStyle())
- {
$this->getStyle()->addAttributesToRender($writer);
- $needSpan=true;
- }
if(($tooltip=$this->getToolTip())!=='')
- {
$writer->addAttribute('title',$tooltip);
- $needSpan=true;
- }
if($this->getHasAttributes())
{
$attributes=$this->getAttributes();
@@ -295,17 +296,17 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
if(($onclick=$attributes->remove('onclick'))===null)
$onclick='';
if($attributes->getCount())
- {
$writer->addAttributes($attributes);
- $needSpan=true;
- }
if($value!==null)
$attributes->add('value',$value);
}
else
$onclick='';
- if($needSpan)
+ if($needspan=$this->getSpanNeeded())
+ {
+ $writer->addAttribute('id',$this->getContainerClientID());
$writer->renderBeginTag('span');
+ }
$clientID=$this->getClientID();
if(($text=$this->getText())!=='')
{
@@ -322,7 +323,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
}
else
$this->renderInputTag($writer,$clientID,$onclick);
- if($needSpan)
+ if($needspan)
$writer->renderEndTag();
}
@@ -391,6 +392,16 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl
$this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
}
+ /**
+ * Check if we need a span tag to surround this control. The span tag will be created if
+ * the Text property is set for this control.
+ *
+ * @return bool wether this control needs a surrounding span tag
+ */
+ protected function getSpanNeeded() {
+ return $this->getText()!=='';
+ }
+
/**
* Renders a label beside the checkbox.
* @param THtmlWriter the writer for the rendering purpose
@@ -500,4 +511,4 @@ class TTextAlign extends TEnumerable
const Right='Right';
}
-?> \ No newline at end of file
+?>