prepare localization for profile

This commit is contained in:
Dennis Eichhorn 2020-02-03 17:52:38 +01:00
parent 0c3c479696
commit e98cef8827
7 changed files with 106 additions and 29 deletions

View File

@ -15,7 +15,7 @@ declare(strict_types=1);
namespace Modules\Profile\Models;
/**
* Account class.
* Contact element class.
*
* @package Modules\Profile\Models
* @license OMS License 1.0
@ -35,12 +35,12 @@ class ContactElement
private int $type = 0;
/**
* Description.
* Content.
*
* @var string
* @since 1.0.0
*/
private string $description = '';
private string $content = '';
/**
* Get id.
@ -81,28 +81,28 @@ class ContactElement
}
/**
* Get description
* Get content
*
* @return string
*
* @since 1.0.0
*/
public function getDescription() : string
public function getContent() : string
{
return $this->description;
return $this->content;
}
/**
* Set description
* Set content
*
* @param string $description Description
* @param string $content Content
*
* @return void
*
* @since 1.0.0
*/
public function setDescription(string $description) : void
public function setContent(string $content) : void
{
$this->description = $description;
$this->content = $content;
}
}

View File

@ -33,7 +33,7 @@ final class ContactElementMapper extends DataMapperAbstract
* @since 1.0.0
*/
protected static array $columns = [
'profile_contact_id' => ['name' => 'profile_contact_id', 'type' => 'int', 'internal' => 'id'],
'profile_contactelement_id' => ['name' => 'profile_contactelement_id', 'type' => 'int', 'internal' => 'id'],
];
/**
@ -42,7 +42,7 @@ final class ContactElementMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $table = 'profile_contact';
protected static string $table = 'profile_contactelement';
/**
* Primary field name.
@ -50,5 +50,5 @@ final class ContactElementMapper extends DataMapperAbstract
* @var string
* @since 1.0.0
*/
protected static string $primaryField = 'profile_contact_id';
protected static string $primaryField = 'profile_contactelement_id';
}

View File

@ -0,0 +1,27 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Profile\Models
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Profile\Models;
/**
* Contact element class.
*
* @package Modules\Profile\Models
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class NullContactElement implements ContactElement
{
}

View File

@ -71,6 +71,14 @@ class Profile implements \JsonSerializable
*/
protected array $location = [];
/**
* Contact data.
*
* @var ContactElements[]
* @since 1.0.0
*/
protected array $contactElements = [];
/**
* Constructor.
*
@ -123,6 +131,32 @@ class Profile implements \JsonSerializable
$this->location[] = $location;
}
/**
* Get account contact element.
*
* @return Location[]
*
* @since 1.0.0
*/
public function getContactElements() : array
{
return $this->contactElements;
}
/**
* Add contact element.
*
* @param ContactElements $contactElements Contact Element
*
* @return void
*
* @since 1.0.0
*/
public function addContactElements(Location $contactElements) : void
{
$this->contactElements[] = $contactElements;
}
/**
* Get account image.
*

View File

@ -72,6 +72,12 @@ final class ProfileMapper extends DataMapperAbstract
'dst' => 'profile_address_address',
'src' => 'profile_address_profile',
],
'contactElements' => [
'mapper' => ContactElementMapper::class,
'table' => 'profile_contactelement',
'src' => null,
'dst' => 'profile_contactelement_contact',
],
];
/**

View File

@ -21,6 +21,7 @@ return ['Profile' => [
'Birthday' => 'Birthday',
'City' => 'City',
'Community' => 'Community',
'Contact' => 'Contact',
'ContactInformation' => 'Contact Information',
'Country' => 'Country',
'CreateProfile' => 'Create Profile',

View File

@ -17,6 +17,7 @@ use phpOMS\Uri\UriFactory;
/**
* @var \phpOMS\Views\View $this
* @var \Modules\Profile\Models\Profile $account
*/
$account = $this->getData('account');
$settings = $this->getData('settings') ?? [];
@ -79,34 +80,42 @@ echo $this->getData('nav')->render();
<td itemprop="jobTitle">Sailor
<tr>
<th><?= $this->getHtml('Birthday') ?>
<td itemprop="birthDate" itemprop="foundingDate">06.09.1934
<tr>
<th><?= $this->getHtml('Ranks') ?>
<td itemprop="memberOf">Gosling
<td itemprop="birthDate" itemprop="foundingDate"><?= $account->getBirthday()->format('Y-m-d'); ?>
<tr>
<th><?= $this->getHtml('Email') ?>
<td itemprop="email"><a href="mailto:>donald.duck@email.com<"><?= $this->printHtml($account->getAccount()->getEmail()); ?></a>
<tr>
<th>Address
<th><?= $this->getHtml('Address') ?>
<td>
<?php
$locations = $account->getLocation();
if (empty($locations)) :
?>
<tr>
<th>
<td>No address specified
<?php endif; ?>
<?php foreach ($locations as $location) : ?>
<tr>
<th class="vT">Private
<td itemprop="address">SMALLSYS INC<br>795 E DRAGRAM<br>TUCSON AZ 85705<br>USA
<?php endforeach; ?>
<tr>
<th class="vT">Work
<td itemprop="address">SMALLSYS INC<br>795 E DRAGRAM<br>TUCSON AZ 85705<br>USA
<tr>
<th><?= $this->getHtml('Phone') ?>
<th><?= $this->getHtml('Contact') ?>
<td>
<?php
$contacts = $account->getContactElements();
if (empty($contacts)) :
?>
<tr>
<th>
<td>No contact specified
<?php endif; ?>
<?php foreach ($contacts as $location) : ?>
<tr>
<th>Private
<td itemprop="telephone">+01 12345-4567
<tr>
<th>Mobile
<td itemprop="telephone">+01 12345-4567
<tr>
<th>Work
<td itemprop="telephone">+01 12345-4567
<?php endforeach; ?>
<tr>
<th><?= $this->getHtml('Registered') ?>
<td><?= $this->printHtml($account->getAccount()->getCreatedAt()->format('Y-m-d')); ?>
@ -115,7 +124,7 @@ echo $this->getData('nav')->render();
<td><?= $this->printHtml($account->getAccount()->getLastActive()->format('Y-m-d')); ?>
<tr>
<th><?= $this->getHtml('Status') ?>
<td><span class="tag green"><?= $this->printHtml($account->getAccount()->getStatus()); ?></span>
<td><span class="tag green"><?= $this->getHtml(':s' . $account->getAccount()->getStatus(), 'Admin'); ?></span>
</table>
<!-- @formatter:on -->
</div>