commit 143f10631ead05c49496354a3755167203cc2464
parent 4338bc7124e13db09a36212553359416efde3e8b
Author: Jan Dankert <develop@jandankert.de>
Date: Fri, 21 Feb 2020 00:27:41 +0100
Fix of some template bugs.
Diffstat:
11 files changed, 70 insertions(+), 49 deletions(-)
diff --git a/modules/template-engine/Element.class.php b/modules/template-engine/Element.class.php
@@ -22,12 +22,12 @@ class Element
*/
protected $children = [];
+
/**
- * @param $wrapperElement Element
- * @return $this
- * @deprecated
+ * @param $element Element
*/
- public function addWrapper($wrapperElement ) {
+ public function asChildOf($element ) {
+ $element->addChild($this);
return $this;
}
diff --git a/modules/template-engine/components/html/checkbox/Checkbox.class.php b/modules/template-engine/components/html/checkbox/Checkbox.class.php
@@ -19,13 +19,6 @@ class CheckboxComponent extends Component
{
$checkbox = (new CMSElement('input'))->addAttribute('type','checkbox');
- if ( $this->label ) {
- $label = new CMSElement('label');
- $label->addStyleClass('or-form-row')->addStyleClass('or-form-checkbox');
- $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
- $checkbox->addWrapper($label);
- }
-
$checkbox->addAttribute('name',$this->name);
if ( $this->readonly )
$checkbox->addAttribute('disabled','disabled');
@@ -46,6 +39,14 @@ class CheckboxComponent extends Component
$checkbox->addChild( $hidden );
}
+ if ( $this->label ) {
+ $label = new CMSElement('label');
+ $label->addStyleClass('or-form-row')->addStyleClass('or-form-checkbox');
+ $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
+ $label->addChild($checkbox);
+ return $label;
+ }
+
return $checkbox;
}
}
diff --git a/modules/template-engine/components/html/form/Form.class.php b/modules/template-engine/components/html/form/Form.class.php
@@ -161,6 +161,10 @@ class FormComponent extends Component
);
}
+ $this->adoptiveElement = (new HtmlElement('div'))->asChildOf($form);
+
+ $form->addChild( $actionBar );
+
return $form;
}
}
\ No newline at end of file
diff --git a/modules/template-engine/components/html/group/Group.class.php b/modules/template-engine/components/html/group/Group.class.php
@@ -51,9 +51,11 @@ class GroupComponent extends Component
}
$group = new HtmlElement('div');
- $group->addStyleClass('closable')->addWrapper($fieldset);
+ $group->addStyleClass('closable')->asChildOf($fieldset);
- return $group;
+ $this->adoptiveElement = $group;
+
+ return $fieldset;
}
}
\ No newline at end of file
diff --git a/modules/template-engine/components/html/input/Input.class.php b/modules/template-engine/components/html/input/Input.class.php
@@ -3,6 +3,7 @@
namespace template_engine\components;
use modules\template_engine\CMSElement;
+use modules\template_engine\HtmlElement;
use modules\template_engine\Value;
use modules\template_engine\ValueExpression;
@@ -43,13 +44,6 @@ class InputComponent extends FieldComponent
{
$input = (new CMSElement('input'));
- if ( $this->label ) {
- $label = new CMSElement('label');
- $label->addStyleClass('or-form-row')->addStyleClass('or-form-input');
- $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
- $input->addWrapper($label);
- }
-
$input->addAttribute('name',$this->name);
if ( $this->readonly )
$input->addAttribute('disabled','disabled');
@@ -82,6 +76,15 @@ class InputComponent extends FieldComponent
//if(isset($this->icon))
// echo '<img src="'.OR_THEMES_DIR.'default/images/icon_'.$this->htmlvalue($this->icon). IMG_ICON_EXT .'" width="16" height="16" />';
- return $input;
+
+ if ( $this->label ) {
+ $label = new CMSElement('label');
+ $label->addStyleClass('or-form-row')->addStyleClass('or-form-input');
+ $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
+ $input->asChildOf($label);
+ return $label;
+ }
+
+ return (new HtmlElement('div'))->addStyleClass('inputholder')->addChild($input);
}
}
\ No newline at end of file
diff --git a/modules/template-engine/components/html/inputarea/Inputarea.class.php b/modules/template-engine/components/html/inputarea/Inputarea.class.php
@@ -36,14 +36,6 @@ class InputareaComponent extends FieldComponent
{
$textarea = (new CMSElement('textarea'));
- if ( $this->label ) {
- $label = new CMSElement('label');
- $label->addStyleClass('or-form-row')->addStyleClass('or-form-checkbox');
- $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
-
- $textarea->addWrapper($label);
- }
-
$textarea->addAttribute('name',$this->name);
$textarea->addAttribute('disabled',$this->readonly);
$textarea->addAttribute('maxlength',$this->maxlength);
@@ -66,6 +58,16 @@ class InputareaComponent extends FieldComponent
else
$textarea->content(Value::createExpression(ValueExpression::TYPE_DATA_VAR,$this->name));
+
+ if ( $this->label ) {
+ $label = new CMSElement('label');
+ $label->addStyleClass('or-form-row')->addStyleClass('or-form-checkbox');
+ $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
+
+ $textarea->asChildOf($label);
+ return $label;
+ }
+
return $textarea;
}
}
\ No newline at end of file
diff --git a/modules/template-engine/components/html/newline/Newline.class.php b/modules/template-engine/components/html/newline/Newline.class.php
@@ -3,6 +3,7 @@
namespace template_engine\components;
use modules\template_engine\Element;
+use modules\template_engine\HtmlElement;
/**
* Newline-Component
@@ -12,7 +13,7 @@ class NewlineComponent extends Component
public function createElement()
{
- return (new Element('br'));
+ return (new HtmlElement('br'));
}
}
diff --git a/modules/template-engine/components/html/password/Password.class.php b/modules/template-engine/components/html/password/Password.class.php
@@ -34,8 +34,6 @@ class PasswordComponent extends FieldComponent
else
$input->addAttribute('value',Value::createExpression(ValueExpression::TYPE_DATA_VAR,$this->name));
- $input->addWrapper( (new HtmlElement('div'))->addStyleClass('inputholder'));
-
- return $input;
+ return (new HtmlElement('div'))->addStyleClass('inputholder')->addChild($input);
}
}
\ No newline at end of file
diff --git a/modules/template-engine/components/html/radio/Radio.class.php b/modules/template-engine/components/html/radio/Radio.class.php
@@ -35,12 +35,6 @@ class RadioComponent extends FieldComponent
$radio = (new CMSElement('input'))->addAttribute('type','radio');
- if ( $this->label ) {
- $label = new CMSElement('label');
- $label->addStyleClass('or-form-row')->addStyleClass('or-form-radio');
- $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
- $radio->addWrapper($label);
- }
$radio->addAttribute('name',$this->name);
$radio->addAttribute('disabled',$this->readonly);
@@ -55,6 +49,14 @@ class RadioComponent extends FieldComponent
if ( $this->class )
$radio->addStyleClass($this->class);
+ if ( $this->label ) {
+ $label = new CMSElement('label');
+ $label->addStyleClass('or-form-row')->addStyleClass('or-form-radio');
+ $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
+ $radio->asChildOf($label);
+ return $label;
+ }
+
return $radio;
}
}
diff --git a/modules/template-engine/components/html/selectbox/Selectbox.class.php b/modules/template-engine/components/html/selectbox/Selectbox.class.php
@@ -60,12 +60,6 @@ class SelectboxComponent extends Component
{
$selectbox = (new CMSElement('input'));
- if ( $this->label ) {
- $label = new CMSElement('label');
- $label->addStyleClass('or-form-row')->addStyleClass('or-form-input');
- $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
- $selectbox->addWrapper($label);
- }
$selectbox->addAttribute('name',$this->name);
//$selectbox->addAttribute('disabled',$this->readonly);
@@ -106,6 +100,15 @@ class SelectboxComponent extends Component
// Nur 1 Eintrag in Liste, da die Selectbox 'disabled' ist, muss ein hidden-Feld her.
//echo '< ? php if (count($'.$this->varname($this->list).')==1) { ? >'.'<input type="hidden" name="'.$this->htmlvalue($this->name).'" value="'.'< ? php echo array_keys($'.$this->varname($this->list).')[0] ? >'.'" />'.'< ? php } ? >';
- return $selectbox;
+ if ( $this->label ) {
+ $label = new CMSElement('label');
+ $label->addStyleClass('or-form-row')->addStyleClass('or-form-input');
+ $label->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content($this->label));
+ $selectbox->asChildOf($label);
+ return $label;
+ }
+ else {
+ return $selectbox;
+ }
}
}
diff --git a/modules/template-engine/components/html/text/Text.class.php b/modules/template-engine/components/html/text/Text.class.php
@@ -96,11 +96,16 @@ class TextComponent extends HtmlComponent
if ( $this->label ) {
- $text->addWrapper( (new HtmlElement('span' ))->addStyleClass('or-form-input') );
- $text->addWrapper( (new HtmlElement('label'))->addStyleClass('or-form-row')->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content('message:'.$this->label)));
+ $span = (new HtmlElement('span' ))->addStyleClass('or-form-input');
+ $label = (new HtmlElement('label'))->addChild($span)->addStyleClass('or-form-row')->addChild( (new CMSElement('span'))->addStyleClass('or-form-label')->content('message:'.$this->label));
+
+ $this->adoptiveElement = $text;
+ return $label;
+
+ }else {
+ return $text;
}
- return $text;
}
}