tpl fixes, dont use printHtml for none-string types

This commit is contained in:
Dennis Eichhorn 2020-12-06 11:13:19 +01:00
parent cb8c1fa8ef
commit a162214ef6
4 changed files with 24 additions and 15 deletions

View File

@ -38,6 +38,14 @@ class BaseView extends View
*/
protected string $id = '';
/**
* Form id
*
* @var string
* @since 1.0.0
*/
protected string $form = '';
/**
* Virtual path of the media file
*
@ -76,10 +84,11 @@ class BaseView extends View
*/
public function render(...$data) : string
{
$this->id = $data[0];
$this->name = $data[1];
$this->virtualPath = $data[2] ?? '/';
$this->isRequired = $data[3] ?? false;
$this->form = $data[0];
$this->id = $data[1];
$this->name = $data[2];
$this->virtualPath = $data[3] ?? '/';
$this->isRequired = $data[4] ?? false;
return parent::render();
}

View File

@ -1,10 +1,10 @@
<div class="ipt-wrap">
<div class="ipt-first">
<span class="input">
<button type="button" id="<?= $this->printHtml($this->getId()); ?>-book-button" data-action='[
<button type="button" id="<?= $this->getId(); ?>-book-button" data-action='[
{
"key": 1, "listener": "click", "action": [
{"key": 1, "type": "dom.popup", "selector": "#acc-grp-tpl", "aniIn": "fadeIn", "id": "<?= $this->printHtml($this->getId()); ?>"},
{"key": 1, "type": "dom.popup", "selector": "#acc-grp-tpl", "aniIn": "fadeIn", "id": "<?= $this->getId(); ?>"},
{"key": 2, "type": "message.request", "uri": "<?= \phpOMS\Uri\UriFactory::build('{/prefix}admin/account?filter=some&limit=10'); ?>", "method": "GET", "request_type": "json"},
{"key": 3, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1},
{"key": 4, "type": "message.request", "uri": "<?= \phpOMS\Uri\UriFactory::build('{/prefix}admin/account?filter=some&limit=10'); ?>", "method": "GET", "request_type": "json"},
@ -12,12 +12,12 @@
]
}
]' formaction=""><i class="fa fa-book"></i></button>
<div class="advancedInput wf-100" id="<?= $this->printHtml($this->getId()); ?>">
<input autocomplete="off" class="input" type="text" id="i<?= $this->printHtml($this->getId()); ?>"
<div class="advancedInput wf-100" id="<?= $this->getId(); ?>">
<input autocomplete="off" class="input" type="text" id="i<?= $this->getId(); ?>"
data-emptyAfter="true"
data-autocomplete="off"
data-src="api/media/find?search={!#mediaInput}">
<div id="<?= $this->printHtml($this->getId()); ?>-dropdown" class="dropdown" data-active="true">
<div id="<?= $this->getId(); ?>-dropdown" class="dropdown" data-active="true">
<table class="default">
<thead>
<tr>
@ -25,7 +25,7 @@
<td>Name<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td>Extension<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<template id="<?= $this->printHtml($this->getId()); ?>-rowElement" class="rowTemplate">
<template id="<?= $this->getId(); ?>-rowElement" class="rowTemplate">
<tr tabindex="-1">
<td data-tpl-text="/id" data-tpl-value="/id" data-value=""></td>
<td data-tpl-text="/name" data-tpl-value="/name" data-value=""></td>
@ -40,8 +40,8 @@
</div>
<div class="ipt-second"><button><?= $this->getHtml('Select', 'Media'); ?></button></div>
</div>
<div class="box" id="<?= $this->printHtml($this->getId()); ?>-tags" data-limit="0" data-active="true">
<template id="<?= $this->printHtml($this->getId()); ?>-tagTemplate">
<div class="box" id="<?= $this->getId(); ?>-tags" data-limit="0" data-active="true">
<template id="<?= $this->getId(); ?>-tagTemplate">
<span class="tag red" data-tpl-value="/id" data-value="" data-uuid="" data-name="<?= $this->printHtml($this->name); ?>">
<i class="fa fa-times"></i>
<span style="display: none;" data-name="type_prefix" data-tpl-value="/type_prefix" data-value=""></span>

View File

@ -27,7 +27,7 @@ include __DIR__ . '/../../template-functions.php';
<td data-label="<?= $this->getHtml('Type'); ?>"><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td data-label="<?= $this->getHtml('Extension'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->extension); ?></a>
<td data-label="<?= $this->getHtml('Size'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->size); ?></a>
<td data-label="<?= $this->getHtml('Size'); ?>"><a href="<?= $url; ?>"><?= $value->size; ?></a>
<td data-label="<?= $this->getHtml('Creator'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
<td data-label="<?= $this->getHtml('Created'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d H:i:s')); ?></a>
<?php endforeach; ?>

View File

@ -44,7 +44,7 @@ echo $this->getData('nav')->render();
<table class="list w-100">
<tbody>
<tr><td><?= $this->getHtml('Name'); ?><td class="wf-100"><?= $this->printHtml($media->name); ?>
<tr><td><?= $this->getHtml('Size'); ?><td class="wf-100"><?= $this->printHtml($media->size); ?>
<tr><td><?= $this->getHtml('Size'); ?><td class="wf-100"><?= $media->size; ?>
<tr><td><?= $this->getHtml('Created'); ?><td><?= $this->printHtml($media->createdAt->format('Y-m-d')); ?>
<tr><td><?= $this->getHtml('Creator'); ?><td><a href="<?= UriFactory::build('{/prefix}profile/single?for=' . $media->createdBy->getId()); ?>"><?= $this->printHtml(
\ltrim($media->createdBy->name2 . ', ' . $media->createdBy->name1, ', ')
@ -99,7 +99,7 @@ echo $this->getData('nav')->render();
<td><a href="<?= $url; ?>"><i class="fa fa-<?= $this->printHtml($icon); ?>"></i></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->name); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->extension); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->size); ?></a>
<td><a href="<?= $url; ?>"><?= $value->size; ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdBy->name1); ?></a>
<td><a href="<?= $url; ?>"><?= $this->printHtml($value->createdAt->format('Y-m-d H:i:s')); ?></a>
<?php endforeach; else : $path = $this->dirPathFunction($media, $this->request->getData('sub') ?? ''); ?>