Skip to content

Commit 879d1ff

Browse files
committed
Use custom frozen template see BT#11194
1 parent 3df9956 commit 879d1ff

File tree

6 files changed

+68
-23
lines changed

6 files changed

+68
-23
lines changed

main/inc/lib/pear/HTML/QuickForm.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ public function validate()
15821582
* @access public
15831583
* @throws HTML_QuickForm_Error
15841584
*/
1585-
public function freeze($elementList=null)
1585+
public function freeze($elementList = null, $setTemplateFrozen = '')
15861586
{
15871587
if (!isset($elementList)) {
15881588
$this->_freezeAll = true;
@@ -1597,6 +1597,9 @@ public function freeze($elementList=null)
15971597
foreach (array_keys($this->_elements) as $key) {
15981598
$name = $this->_elements[$key]->getName();
15991599
if ($this->_freezeAll || isset($elementList[$name])) {
1600+
if (!empty($setTemplateFrozen)) {
1601+
$this->_elements[$key]->setCustomFrozenTemplate($setTemplateFrozen);
1602+
}
16001603
$this->_elements[$key]->freeze();
16011604
unset($elementList[$name]);
16021605
}

main/inc/lib/pear/HTML/QuickForm/Renderer/Default.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ private function _prepareTemplate(HTML_QuickForm_element $element, $required, $e
303303
$template = $element->getTemplate(
304304
$this->getForm()->getLayout()
305305
);
306+
if ($element->isFrozen()) {
307+
$customFrozentemplate = $element->getCustomFrozenTemplate();
308+
if (!empty($customFrozentemplate)) {
309+
$template = $customFrozentemplate;
310+
}
311+
}
306312
} else {
307313
$template = $this->getForm()->getDefaultElementTemplate();
308314
}

main/inc/lib/pear/HTML/QuickForm/element.php

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3-
42
/**
53
* Base class for form elements
64
*
@@ -39,8 +37,8 @@ class HTML_QuickForm_element extends HTML_Common
3937
{
4038
private $layout;
4139
private $icon;
42-
43-
// {{{ properties
40+
private $template;
41+
private $customFrozenTemplate = '';
4442

4543
/**
4644
* Label of the field
@@ -87,9 +85,9 @@ class HTML_QuickForm_element extends HTML_Common
8785
* @param string Name of the element
8886
* @param mixed Label(s) for the element
8987
* @param mixed Associative array of tag attributes or HTML attributes name="value" pairs
90-
* @since 1.0
91-
* @access public
92-
* @return void
88+
* @since 1.0
89+
* @access public
90+
* @return void
9391
*/
9492
public function __construct($elementName = null, $elementLabel = null, $attributes = null)
9593
{
@@ -98,8 +96,7 @@ public function __construct($elementName = null, $elementLabel = null, $attribut
9896
$this->setName($elementName);
9997
}
10098
if (isset($elementLabel)) {
101-
102-
$labelFor = "";
99+
$labelFor = '';
103100
// Default Inputs generate this
104101
if (!empty($attributes['id'])) {
105102
$labelFor = $attributes['id'];
@@ -159,7 +156,7 @@ public function setIcon($icon)
159156
* @access public
160157
* @return float
161158
*/
162-
function apiVersion()
159+
public function apiVersion()
163160
{
164161
return 3.2;
165162
} // end func apiVersion
@@ -174,7 +171,7 @@ function apiVersion()
174171
* @access public
175172
* @return string
176173
*/
177-
function getType()
174+
public function getType()
178175
{
179176
return $this->_type;
180177
} // end func getType
@@ -190,7 +187,7 @@ function getType()
190187
* @access public
191188
* @return void
192189
*/
193-
function setName($name)
190+
public function setName($name)
194191
{
195192
// interface method
196193
} //end func setName
@@ -205,7 +202,7 @@ function setName($name)
205202
* @access public
206203
* @return string
207204
*/
208-
function getName()
205+
public function getName()
209206
{
210207
// interface method
211208
} //end func getName
@@ -221,7 +218,7 @@ function getName()
221218
* @access public
222219
* @return void
223220
*/
224-
function setValue($value)
221+
public function setValue($value)
225222
{
226223
// interface
227224
} // end func setValue
@@ -236,7 +233,7 @@ function setValue($value)
236233
* @access public
237234
* @return mixed
238235
*/
239-
function getValue()
236+
public function getValue()
240237
{
241238
// interface
242239
return null;
@@ -251,7 +248,7 @@ function getValue()
251248
* @access public
252249
* @return void
253250
*/
254-
function freeze()
251+
public function freeze()
255252
{
256253
$this->_flagFrozen = true;
257254
} //end func freeze
@@ -266,7 +263,7 @@ function freeze()
266263
* @return void
267264
* @since 3.2.4
268265
*/
269-
function unfreeze()
266+
public function unfreeze()
270267
{
271268
$this->_flagFrozen = false;
272269
}
@@ -294,9 +291,6 @@ public function getFrozenHtml()
294291
//
295292
} //end func getFrozenHtml
296293

297-
// }}}
298-
// {{{ _getPersistantData()
299-
300294
/**
301295
* Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on
302296
*
@@ -552,4 +546,38 @@ function _prepareValue($value, $assoc)
552546
}
553547
}
554548
}
549+
550+
/**
551+
* @param mixed $template
552+
* @return HTML_QuickForm_element
553+
*/
554+
public function setTemplate($template)
555+
{
556+
$this->template = $template;
557+
558+
return $this;
559+
}
560+
561+
/**
562+
* @return string
563+
*/
564+
public function getCustomFrozenTemplate()
565+
{
566+
return $this->customFrozenTemplate;
567+
}
568+
569+
/**
570+
* @param string $customFrozenTemplate
571+
* @return HTML_QuickForm_element
572+
*/
573+
public function setCustomFrozenTemplate($customFrozenTemplate)
574+
{
575+
$this->customFrozenTemplate = $customFrozenTemplate;
576+
577+
return $this;
578+
}
579+
580+
581+
582+
555583
}

main/inc/lib/pear/HTML/QuickForm/input.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ function getValue()
143143
*/
144144
public function toHtml()
145145
{
146-
if ($this->_flagFrozen) {
146+
if ($this->isFrozen()) {
147147
return $this->getFrozenHtml();
148148
} else {
149149
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />';

main/inc/lib/pear/HTML/QuickForm/text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function setMaxlength($maxlength)
235235
*/
236236
public function toHtml()
237237
{
238-
if ($this->_flagFrozen) {
238+
if ($this->isFrozen()) {
239239
return $this->getFrozenHtml();
240240
} else {
241241
return '<input ' . $this->_getAttrString($this->_attributes) . ' />';

main/inc/lib/usermanager.lib.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,14 @@ public static function create_user(
477477
// variables for the default template
478478
$tplContent->assign('complete_name', stripslashes(api_get_person_name($firstName, $lastName)));
479479
$tplContent->assign('user_added', $user);
480+
481+
$renderer = FormValidator::getDefaultRenderer();
482+
483+
// Form template
484+
$elementTemplate = ' {label}: {element} <br />';
485+
$renderer->setElementTemplate($elementTemplate);
486+
$form->freeze(null, $elementTemplate);
487+
480488
/** @var FormValidator $form */
481489
$form->freeze();
482490
$form->removeElement('submit');

0 commit comments

Comments
 (0)