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)); $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; return $view;
} }
@ -122,6 +127,11 @@ final class BackendController extends Controller
$media = MediaMapper::getFor((int) $profile->account->getId(), 'createdBy'); $media = MediaMapper::getFor((int) $profile->account->getId(), 'createdBy');
$view->setData('media', $media instanceof NullMedia ? [] : (!\is_array($media) ? [$media] : $media)); $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; return $view;
} }

View File

@ -1,54 +1,56 @@
<div class="ipt-wrap wf-100"> <div>
<div class="ipt-first"> <div class="ipt-wrap wf-100">
<span class="input"> <div class="ipt-first">
<button type="button" id="<?= $this->getId(); ?>-book-button" data-action='[ <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": 1, "listener": "click", "action": [
{"key": 2, "type": "message.request", "uri": "<?= \phpOMS\Uri\UriFactory::build('{/prefix}admin/account?filter=some&limit=10'); ?>", "method": "GET", "request_type": "json"}, {"key": 1, "type": "dom.popup", "selector": "#acc-grp-tpl", "aniIn": "fadeIn", "id": "<?= $this->getId(); ?>"},
{"key": 3, "type": "dom.table.append", "id": "acc-table", "aniIn": "fadeIn", "data": [], "bindings": {"id": "id", "name": "name/0"}, "position": -1}, {"key": 2, "type": "message.request", "uri": "<?= \phpOMS\Uri\UriFactory::build('{/prefix}admin/account?filter=some&limit=10'); ?>", "method": "GET", "request_type": "json"},
{"key": 4, "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": 5, "type": "dom.table.append", "id": "grp-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(); ?>"> ]' formaction=""><i class="fa fa-book"></i></button>
<input autocomplete="off" spellcheck="false" class="input" type="text" id="i<?= $this->getId(); ?>" placeholder="&#xf007; Guest" <div class="advancedInput wf-100" id="<?= $this->getId(); ?>">
data-emptyAfter="true" <input autocomplete="off" spellcheck="false" class="input" type="text" id="i<?= $this->getId(); ?>" placeholder="&#xf007; Guest"
data-autocomplete="off" data-emptyAfter="true"
data-src="api/admin/find/accgrp?search={!#i<?= $this->getId(); ?>}"> data-autocomplete="off"
<div id="<?= $this->getId(); ?>-popup" class="popup" data-active="true"> data-src="api/admin/find/accgrp?search={!#i<?= $this->getId(); ?>}">
<table class="default"> <div id="<?= $this->getId(); ?>-popup" class="popup" data-active="true">
<thead> <table class="default">
<tr> <thead>
<td>Type<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <tr>
<td>ID<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i> <td>Type<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>ID<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> <td>Name<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<tbody> <td>Email<i class="sort-asc fa fa-chevron-up"></i><i class="sort-desc fa fa-chevron-down"></i>
<template id="<?= $this->getId(); ?>-rowElement" class="rowTemplate"> <tbody>
<tr tabindex="-1"> <template id="<?= $this->getId(); ?>-rowElement" class="rowTemplate">
<td data-tpl-text="/type_name" data-tpl-value="/type_prefix" data-value=""> <tr tabindex="-1">
<td data-tpl-text="/id" data-tpl-value="/id" data-value=""></td> <td data-tpl-text="/type_name" data-tpl-value="/type_prefix" data-value="">
<td data-tpl-text="/name/0" data-tpl-value="/name/0" data-value=""></td> <td data-tpl-text="/id" data-tpl-value="/id" data-value=""></td>
<td data-tpl-text="/email" data-tpl-value="/email" data-value=""></td> <td data-tpl-text="/name/0" data-tpl-value="/name/0" data-value=""></td>
</tr> <td data-tpl-text="/email" data-tpl-value="/email" data-value=""></td>
</template> </tr>
</tbody> </template>
</table> </tbody>
</table>
</div>
</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>
<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>

View File

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

View File

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

View File

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