)
{
if (
empty($string)
|| (
strpos($string, 'exists())
{
return $cache->get();
}
foreach ($tags as $i => $tag)
{
if (StringHelper::is_alphanumeric($tag[0]))
{
$tag = '{' . $tag;
}
$tags[$i] = $tag;
if ($include_closing_tags)
{
$tags[] = RegEx::replace('^([^a-z0-9]+)', '\1/', $tag);
}
}
return $cache->set([$tags, self::protectArray($tags, 1)]);
}
/**
* Protect the input fields in the string
*
* @param string $string
*/
private static function protectFieldsInputFields(&$string)
{
if (strpos($string, ''
. '|'
. ')\s*)+'
);
}
/**
* Protect the fields in the string
*
* @param string $string
*/
private static function protectFieldsPart(&$string)
{
self::protectFieldsTextAreas($string);
self::protectFieldsInputFields($string);
}
/**
* Protect the textarea fields in the string
*
* @param string $string
*/
private static function protectFieldsTextAreas(&$string)
{
if (strpos($string, '',
'<' . $temp_tag . '\1>\2' . $temp_tag . '>',
$string
);
self::protectByRegex(
$string,
'(?:'
. ''
. '\s*)+'
);
// Replace back the temporarily replaced empty textareas
$string = str_replace($temp_tag, 'textarea', $string);
}
/**
* Protect part of the AdminForm
*
* @param string $string
* @param array $tags
* @param array $protected_tags
*/
private static function protectFormPart(&$string, $tags = [], $protected_tags = [])
{
if (strpos($string, '') === false)
{
return;
}
// Protect entire form
if (empty($tags))
{
$form_parts = explode('', $string, 2);
$form_parts[0] = self::protectString($form_parts[0] . '');
$string = implode('', $form_parts);
return;
}
$regex_tags = RegEx::quote($tags);
if ( ! RegEx::match($regex_tags, $string))
{
return;
}
$form_parts = explode('', $string, 2);
// protect tags only inside form fields
RegEx::matchAll(
'(?: