Lukas W.
Well-known member
- Affected version
- 2.1.1
Running the following template modification:
Template:
Search:
Replace:
The template compiler will compile this to the following code:
Thus breaking the usage of
Changing the replace to
will fix the issue and the compiler will set all variables on the right positions
Template:
admin:helper_criteria
Search:
Code:
/(<xf:foreach loop="\$customFields".*>.*<\/xf:option>)(\s*<\/xf:checkboxrow>)/sU
Replace:
Code:
$1
<xf:set var="$fieldName" value="thusercriteria_user_field_checked_{$fieldId}" />
<xf:option name="user_criteria[{$fieldName}][rule]" selected="{$criteria.{$fieldName}}" value="{$fieldName}" label="{{ phrase('thusercriteria_has_value') }}"/>
<xf:set var="$fieldName" value="thusercriteria_user_field_unchecked_{$fieldId}" />
<xf:option name="user_criteria[{$fieldName}][rule]" selected="{$criteria.{$fieldName}}" value="{$fieldName}" label="{{ phrase('thusercriteria_has_no_value') }}"/>
<xf:set var="$fieldName" value="thusercriteria_user_field_preg-match_{$fieldId}" />
<xf:option name="user_criteria[{$fieldName}][rule]" value="{$fieldName}" selected="{$criteria.{$fieldName}}" label="{{ phrase('thusercriteria_preg_matches:') }}">
<xf:textbox name="user_criteria[{$fieldName}][data][regex]" value="{$criteria.{$fieldName}.regex}" />
</xf:option>
The template compiler will compile this to the following code:
Code:
$__vars['fieldName'] = 'thusercriteria_user_field_checked_' . $__vars['fieldId'];
$__vars['fieldName'] = 'thusercriteria_user_field_unchecked_' . $__vars['fieldId'];
$__vars['fieldName'] = 'thusercriteria_user_field_preg-match_' . $__vars['fieldId'];
$__compilerTemp24 = array(array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][rule]',
'value' => $__vars['fieldName'],
'selected' => $__vars['criteria'][$__vars['fieldName']],
'label' => ($__vars['choices'] ? 'User choice is among' : 'User value contains text' . $__vars['xf']['language']['label_separator']),
'_dependent' => array('
' . $__compilerTemp21 . '
'),
'_type' => 'option',
)
,array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][rule]',
'selected' => $__vars['criteria'][$__vars['fieldName']],
'value' => $__vars['fieldName'],
'label' => 'User has provided a value',
'_type' => 'option',
)
,array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][rule]',
'selected' => $__vars['criteria'][$__vars['fieldName']],
'value' => $__vars['fieldName'],
'label' => 'User has provided no value',
'_type' => 'option',
)
,array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][rule]',
'value' => $__vars['fieldName'],
'selected' => $__vars['criteria'][$__vars['fieldName']],
'label' => 'User value matches regular expression' . $__vars['xf']['language']['label_separator'],
'_dependent' => array($__templater->formTextBox(array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][data][regex]',
'value' => $__vars['criteria'][$__vars['fieldName']]['regex'],
))),
'_type' => 'option',
));
Thus breaking the usage of
$fieldName
, as they are all three set one after another.Changing the replace to
Code:
$1
<xf:if is="true">
<xf:set var="$fieldName" value="thusercriteria_user_field_checked_{$fieldId}" />
<xf:option name="user_criteria[{$fieldName}][rule]" selected="{$criteria.{$fieldName}}" value="{$fieldName}" label="{{ phrase('thusercriteria_has_value') }}"/>
<xf:set var="$fieldName" value="thusercriteria_user_field_unchecked_{$fieldId}" />
<xf:option name="user_criteria[{$fieldName}][rule]" selected="{$criteria.{$fieldName}}" value="{$fieldName}" label="{{ phrase('thusercriteria_has_no_value') }}"/>
<xf:set var="$fieldName" value="thusercriteria_user_field_preg-match_{$fieldId}" />
<xf:option name="user_criteria[{$fieldName}][rule]" value="{$fieldName}" selected="{$criteria.{$fieldName}}" label="{{ phrase('thusercriteria_preg_matches:') }}">
<xf:textbox name="user_criteria[{$fieldName}][data][regex]" value="{$criteria.{$fieldName}.regex}" />
</xf:option>
</xf:if>
will fix the issue and the compiler will set all variables on the right positions
Code:
if (true) {
$__vars['fieldName'] = 'thusercriteria_user_field_checked_' . $__vars['fieldId'];
$__compilerTemp24[] = array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][rule]',
'selected' => $__vars['criteria'][$__vars['fieldName']],
'value' => $__vars['fieldName'],
'label' => 'User has provided a value',
'_type' => 'option',
);
$__vars['fieldName'] = 'thusercriteria_user_field_unchecked_' . $__vars['fieldId'];
$__compilerTemp24[] = array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][rule]',
'selected' => $__vars['criteria'][$__vars['fieldName']],
'value' => $__vars['fieldName'],
'label' => 'User has provided no value',
'_type' => 'option',
);
$__vars['fieldName'] = 'thusercriteria_user_field_preg-match_' . $__vars['fieldId'];
$__compilerTemp24[] = array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][rule]',
'value' => $__vars['fieldName'],
'selected' => $__vars['criteria'][$__vars['fieldName']],
'label' => 'User value matches regular expression' . $__vars['xf']['language']['label_separator'],
'_dependent' => array($__templater->formTextBox(array(
'name' => 'user_criteria[' . $__vars['fieldName'] . '][data][regex]',
'value' => $__vars['criteria'][$__vars['fieldName']]['regex'],
))),
'_type' => 'option',
);
}