2020-05-29 13:41:58 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* echo $this->element('/genericElements/SingleViews/single_view', [
|
|
|
|
* 'title' => '' //page title,
|
|
|
|
* 'description' => '' //description,
|
|
|
|
* 'description_html' => '' //html description, unsanitised,
|
|
|
|
* 'data' => $data, // the raw data passed for display
|
|
|
|
* 'fields' => [
|
|
|
|
* elements passed as to be displayed in the <ul> element.
|
|
|
|
* format:
|
|
|
|
* [
|
|
|
|
'key' => '' // key to be displayed
|
|
|
|
* 'path' => '' // path for the value to be parsed
|
|
|
|
* 'type' => '' // generic assumed if not filled, uses SingleViews/Fields/* elements
|
|
|
|
* ]
|
|
|
|
* ],
|
|
|
|
* 'children' => [
|
|
|
|
* // Additional elements attached to the currently viewed object. index views will be appended via ajax calls below.
|
|
|
|
[
|
|
|
|
* 'title' => '',
|
|
|
|
* 'url' => '', //cakephp compatible url, can be actual url or array for the constructor
|
|
|
|
* 'collapsed' => 0|1 // defaults to 0, whether to display it by default or not
|
|
|
|
* 'loadOn' => 'ready|expand' // load the data directly or only when expanded from a collapsed state
|
|
|
|
*
|
|
|
|
* ],
|
|
|
|
* ]
|
|
|
|
* ]);
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
$listElements = '';
|
|
|
|
if (!empty($fields)) {
|
|
|
|
foreach ($fields as $field) {
|
|
|
|
if (empty($field['type'])) {
|
|
|
|
$field['type'] = 'generic';
|
|
|
|
}
|
|
|
|
$listElements .= sprintf(
|
|
|
|
'<tr class="row"><td class="col-sm-2 font-weight-bold">%s</td><td class="col-sm-10">%s</td></tr>',
|
|
|
|
h($field['key']),
|
|
|
|
$this->element(
|
|
|
|
'/genericElements/SingleViews/Fields/' . $field['type'] . 'Field',
|
|
|
|
['data' => $data, 'field' => $field]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-12-08 09:07:48 +01:00
|
|
|
$metaTemplateTabs = '';
|
|
|
|
if (!empty($data['metaTemplates'])) {
|
|
|
|
$tabData = [
|
|
|
|
'navs' => [],
|
|
|
|
'content' => []
|
|
|
|
];
|
|
|
|
foreach($data['metaTemplates'] as $metaTemplate) {
|
2020-12-08 15:05:53 +01:00
|
|
|
if (!empty($metaTemplate->meta_template_fields)) {
|
|
|
|
$tabData['navs'][] = $metaTemplate->name;
|
|
|
|
$fieldsHtml = '<table class="table table-striped">';
|
|
|
|
foreach ($metaTemplate->meta_template_fields as $metaTemplateField) {
|
|
|
|
$metaField = $metaTemplateField->meta_fields[0];
|
|
|
|
$fieldsHtml .= sprintf(
|
|
|
|
'<tr class="row"><td class="col-sm-2 font-weight-bold">%s</td><td class="col-sm-10">%s</td></tr>',
|
|
|
|
h($metaField->field),
|
|
|
|
$this->element(
|
|
|
|
'/genericElements/SingleViews/Fields/genericField',
|
|
|
|
[
|
|
|
|
'data' => $metaField->value,
|
|
|
|
'field' => [
|
|
|
|
'raw' => $metaField->value
|
|
|
|
]
|
2020-12-08 09:07:48 +01:00
|
|
|
]
|
2020-12-08 15:05:53 +01:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$fieldsHtml .= '</table>';
|
|
|
|
$tabData['content'][] = $fieldsHtml;
|
2020-12-08 09:07:48 +01:00
|
|
|
}
|
2020-09-28 01:25:07 +02:00
|
|
|
}
|
2020-12-08 15:05:53 +01:00
|
|
|
if (!empty($tabData['navs'])) {
|
|
|
|
$metaTemplateTabs = $this->Bootstrap->Tabs([
|
|
|
|
'pills' => true,
|
|
|
|
'card' => true,
|
|
|
|
'data' => $tabData
|
|
|
|
]);
|
|
|
|
}
|
2020-09-28 01:25:07 +02:00
|
|
|
}
|
2020-05-29 13:41:58 +02:00
|
|
|
$ajaxLists = '';
|
|
|
|
if (!empty($children)) {
|
|
|
|
foreach ($children as $child) {
|
2020-06-21 21:34:15 +02:00
|
|
|
$ajaxLists .= $this->element(
|
2020-05-29 13:41:58 +02:00
|
|
|
'/genericElements/SingleViews/child',
|
|
|
|
array(
|
2020-06-21 21:34:15 +02:00
|
|
|
'child' => $child,
|
|
|
|
'data' => $data
|
2020-05-29 13:41:58 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-06-19 00:43:11 +02:00
|
|
|
$title = empty($title) ?
|
|
|
|
__('{0} view', \Cake\Utility\Inflector::singularize(\Cake\Utility\Inflector::humanize($this->request->getParam('controller')))) :
|
|
|
|
$title;
|
2020-05-29 13:41:58 +02:00
|
|
|
echo sprintf(
|
2020-12-08 09:19:00 +01:00
|
|
|
'<div><h2>%s</h2>%s%s<div class="px-3"><table class="table table-striped col-sm-8">%s</table></div><div id="metaTemplates" class="col-lg-8 px-0">%s</div><div id="accordion">%s</div></div>',
|
2020-06-19 00:43:11 +02:00
|
|
|
h($title),
|
2020-05-29 13:41:58 +02:00
|
|
|
empty($description) ? '' : sprintf('<p>%s</p>', h($description)),
|
|
|
|
empty($description_html) ? '' : sprintf('<p>%s</p>', $description_html),
|
|
|
|
$listElements,
|
2020-12-08 09:07:48 +01:00
|
|
|
$metaTemplateTabs,
|
2020-05-29 13:41:58 +02:00
|
|
|
$ajaxLists
|
|
|
|
);
|
2020-06-21 21:34:15 +02:00
|
|
|
?>
|