2020-05-29 13:41:58 +02:00
|
|
|
<?php
|
2020-12-07 17:17:11 +01:00
|
|
|
if (isset($field['raw'])) {
|
2020-09-28 01:25:07 +02:00
|
|
|
$string = $field['raw'];
|
|
|
|
} else {
|
2021-06-01 07:46:29 +02:00
|
|
|
$value = 1;
|
2020-09-28 01:25:07 +02:00
|
|
|
$value = Cake\Utility\Hash::extract($data, $field['path']);
|
|
|
|
$string = empty($value[0]) ? '' : $value[0];
|
|
|
|
}
|
2020-06-19 00:43:11 +02:00
|
|
|
if (!empty($field['url'])) {
|
|
|
|
if (!empty($field['url_vars'])) {
|
|
|
|
if (!is_array($field['url_vars'])) {
|
|
|
|
$field['url_vars'] = [$field['url_vars']];
|
|
|
|
}
|
|
|
|
foreach ($field['url_vars'] as $k => $path) {
|
|
|
|
$field['url'] = str_replace('{{' . $k . '}}', $this->Hash->extract($data, $path)[0], $field['url']);
|
|
|
|
}
|
|
|
|
}
|
2022-05-17 10:42:44 +02:00
|
|
|
if (substr($field['url'], 0, 4) === 'http') {
|
|
|
|
$baseurl = '';
|
|
|
|
}
|
2020-06-19 00:43:11 +02:00
|
|
|
$string = sprintf(
|
2021-02-09 22:10:26 +01:00
|
|
|
'<a href="%s%s">%s</a>',
|
|
|
|
$baseurl,
|
2020-06-19 00:43:11 +02:00
|
|
|
h($field['url']),
|
2022-09-18 18:27:39 +02:00
|
|
|
h($string)
|
2020-06-19 00:43:11 +02:00
|
|
|
);
|
2022-09-18 18:32:43 +02:00
|
|
|
} else if (empty($field['raw'])) {
|
2022-09-18 18:27:39 +02:00
|
|
|
$string = h($string);
|
2020-06-19 00:43:11 +02:00
|
|
|
}
|
2022-11-09 14:01:37 +01:00
|
|
|
foreach (['info', 'warning', 'danger'] as $message_type) {
|
|
|
|
if (!empty($field[$message_type])) {
|
|
|
|
$string .= sprintf(' (<span class="text-%s">%s</span>)', $message_type, $field[$message_type]);
|
|
|
|
}
|
|
|
|
}
|
2020-06-19 00:43:11 +02:00
|
|
|
echo $string;
|