create default profile image

This commit is contained in:
Dennis Eichhorn 2021-08-06 19:29:11 +02:00
parent 4c28981f1f
commit 08d382cfce
5 changed files with 79 additions and 64 deletions

View File

@ -77,6 +77,11 @@ final class BackendController extends Controller
$view->setData('accounts', ProfileMapper::getAfterPivot(0, null, 25));
}
$profileImage = $this->app->appSettings->get(null, 'default_profile_image', 'Profile');
$image = MediaMapper::get((int) $profileImage['content']);
$view->setData('defaultImage', $image);
return $view;
}
@ -122,6 +127,11 @@ final class BackendController extends Controller
$media = MediaMapper::getFor((int) $profile->account->getId(), 'createdBy');
$view->setData('media', $media instanceof NullMedia ? [] : (!\is_array($media) ? [$media] : $media));
$profileImage = $this->app->appSettings->get(null, 'default_profile_image', 'Profile');
$image = MediaMapper::get((int) $profileImage['content']);
$view->setData('defaultImage', $image);
return $view;
}

View File

@ -1,54 +1,56 @@
<div class="ipt-wrap wf-100">
<div class="ipt-first">
<span class="input">
<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->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"},
{"key": 5, "type": "dom.table.append", "id": "grp-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' formaction=""><i class="fa fa-book"></i></button>
<div class="advancedInput wf-100" id="<?= $this->getId(); ?>">
<input autocomplete="off" spellcheck="false" class="input" type="text" id="i<?= $this->getId(); ?>" placeholder="&#xf007; Guest"
data-emptyAfter="true"
data-autocomplete="off"
data-src="api/admin/find/accgrp?search={!#i<?= $this->getId(); ?>}">
<div id="<?= $this->getId(); ?>-popup" class="popup" data-active="true">
<table class="default">
<thead>
<tr>
<td>Type<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td>ID<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td>Name<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td>Email<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<template id="<?= $this->getId(); ?>-rowElement" class="rowTemplate">
<tr tabindex="-1">
<td data-tpl-text="/type_name" data-tpl-value="/type_prefix" data-value="">
<td data-tpl-text="/id" data-tpl-value="/id" data-value=""></td>
<td data-tpl-text="/name/0" data-tpl-value="/name/0" data-value=""></td>
<td data-tpl-text="/email" data-tpl-value="/email" data-value=""></td>
</tr>
</template>
</tbody>
</table>
<div>
<div class="ipt-wrap wf-100">
<div class="ipt-first">
<span class="input">
<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->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"},
{"key": 5, "type": "dom.table.append", "id": "grp-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}
]
}
]' formaction=""><i class="fa fa-book"></i></button>
<div class="advancedInput wf-100" id="<?= $this->getId(); ?>">
<input autocomplete="off" spellcheck="false" class="input" type="text" id="i<?= $this->getId(); ?>" placeholder="&#xf007; Guest"
data-emptyAfter="true"
data-autocomplete="off"
data-src="api/admin/find/accgrp?search={!#i<?= $this->getId(); ?>}">
<div id="<?= $this->getId(); ?>-popup" class="popup" data-active="true">
<table class="default">
<thead>
<tr>
<td>Type<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td>ID<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td>Name<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<td>Email<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody>
<template id="<?= $this->getId(); ?>-rowElement" class="rowTemplate">
<tr tabindex="-1">
<td data-tpl-text="/type_name" data-tpl-value="/type_prefix" data-value="">
<td data-tpl-text="/id" data-tpl-value="/id" data-value=""></td>
<td data-tpl-text="/name/0" data-tpl-value="/name/0" data-value=""></td>
<td data-tpl-text="/email" data-tpl-value="/email" data-value=""></td>
</tr>
</template>
</tbody>
</table>
</div>
</div>
</div>
</span>
</span>
</div>
<div class="ipt-second"><button><?= $this->getHtml('Select', '0', '0'); ?></button></div>
</div>
<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>
<span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span>
<span data-tpl-text="/name/0" data-tpl-value="/name/0" data-value=""></span>
</span>
</template>
</div>
<div class="ipt-second"><button><?= $this->getHtml('Select', '0', '0'); ?></button></div>
</div>
<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>
<span data-tpl-text="/id" data-name="id" data-tpl-value="/id" data-value=""></span>
<span data-tpl-text="/name/0" data-tpl-value="/name/0" data-value=""></span>
</span>
</template>
</div>

View File

@ -57,19 +57,21 @@ $next = empty($accounts) ? '{/prefix}profile/list' : '{/prefix}profile/list?
<i class="filter fa fa-filter"></i>
</label>
<tbody>
<?php $count = 0; foreach ($accounts as $key => $account) : ++$count;
$url = UriFactory::build('{/prefix}profile/single?{?}&id=' . $account->getId()); ?>
<?php $count = 0;
foreach ($accounts as $key => $account) : ++$count;
$url = UriFactory::build('{/prefix}profile/single?{?}&id=' . $account->getId());
?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><a href="<?= $url; ?>"><img width="30" loading="lazy" class="profile-image"
src="<?=
$account->image instanceof NullMedia ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/prefix}' . $account->image->getPath()); ?>"></a>
$account->image instanceof NullMedia
? UriFactory::build('{/prefix}' . $this->getData('defaultImage')->getPath())
: UriFactory::build('{/prefix}' . $account->image->getPath()); ?>"></a>
<td data-label="<?= $this->getHtml('Name'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->account->name3 . ' ' . $account->account->name2 . ' ' . $account->account->name1); ?></a>
<td data-label="<?= $this->getHtml('Activity'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->account->getLastActive()->format('Y-m-d')); ?></a>
<td data-label="<?= $this->getHtml('Activity'); ?>"><a href="<?= $url; ?>"><?= $this->printHtml($account->account->getLastActive()->format('Y-m-d')); ?></a>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<tr><td colspan="3" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
<div class="portlet-foot">

View File

@ -71,9 +71,9 @@ echo $this->getData('nav')->render();
alt="<?= $this->getHtml('ProfileImage'); ?>"
itemprop="logo" loading="lazy"
src="<?=
$profile->image instanceof NullMedia ?
UriFactory::build('Web/Backend/img/user_default_' . \mt_rand(1, 6) .'.png') :
UriFactory::build('{/prefix}' . $profile->image->getPath()); ?>"
$profile->image instanceof NullMedia
? UriFactory::build('{/prefix}' . $this->getData('defaultImage')->getPath())
: UriFactory::build('{/prefix}' . $profile->image->getPath()); ?>"
width="100px"></div>
<?php if ($this->request->header->account === $account->getId()) : ?>
<div><a id="iProfileUploadButton" href="#upload" data-action='[

View File

@ -18,12 +18,13 @@
"directory": "Profile",
"dependencies": {
"Admin": "1.0.0",
"Media": "1.0.0",
"Home": "1.0.0",
"Contact": "1.0.0",
"Media": "1.0.0"
"Contact": "1.0.0"
},
"providing": {
"Navigation": "*"
"Navigation": "*",
"Media": "1.0.0"
},
"load": [
{