Templating

This commit is contained in:
Dennis Eichhorn 2016-02-11 21:10:18 +01:00
parent ec41bc8cc2
commit f3311a5e06
3 changed files with 52 additions and 44 deletions

View File

@ -15,8 +15,7 @@
*/
namespace Modules\Profile;
use Modules\Navigation\Models\Navigation;
use Modules\Navigation\Views\NavigationView;
use Modules\Admin\Models\AccountMapper;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\RequestDestination;
@ -98,7 +97,8 @@ class Controller extends ModuleAbstract implements WebInterface
* @since 1.0.0
*/
protected static $routes = [
'^.*/backend/profile/list.*$' => [['dest' => '\Modules\Profile\Controller:viewProfileList', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
'^.*/backend/profile/list.*$' => [['dest' => '\Modules\Profile\Controller:viewProfileList', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
'^.*/backend/profile/single.*$' => [['dest' => '\Modules\Profile\Controller:viewProfileSingle', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
];
/**
@ -116,7 +116,33 @@ class Controller extends ModuleAbstract implements WebInterface
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Profile/Theme/Backend/profile-list');
$accountMapper = new AccountMapper($this->app->dbPool->get());
$view->setData('accounts', $accountMapper->getNewest(25));
return $view;
}
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function viewProfileSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Profile/Theme/Backend/profile-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000301001, $request, $response));
$accountMapper = new AccountMapper($this->app->dbPool->get());
$view->setData('account', $accountMapper->get($request->getData('id')));
return $view;
}
}

View File

@ -21,7 +21,10 @@ $footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
$accounts = $this->getData('accounts');
?>
<section class="box">
<table class="table">
<caption><?= $this->l11n->lang['Profile']['Profiles']; ?></caption>
@ -34,7 +37,12 @@ $footerView->setPage(1);
<tr>
<td colspan="3"><?= $footerView->render(); ?>
<tbody>
<?php $count = 0; foreach([] as $key => $value) : $count++; ?>
<?php $count = 0; foreach($accounts as $key => $account) : $count++;
$url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/profile/single?id=' . $account->getId()); ?>
<tr>
<td><a href="<?= $url; ?>"><?= $account->getId(); ?></a>
<td><a href="<?= $url; ?>"><?= $account->getName3() . ' ' . $account->getName2() . ' ' . $account->getName1(); ?></a>
<td><a href="<?= $url; ?>"><?= $account->getLastActive()->format('Y-m-d'); ?></a>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="3" class="empty"><?= $this->l11n->lang[0]['Empty']; ?>

View File

@ -15,43 +15,19 @@
*/
/**
* @var \phpOMS\Views\View $this
* @var \Modules\Tasks\Models\Task[] $tasks
*/
$nav = new \Modules\Navigation\Views\NavigationView($this->app, $this->request, $this->response);
$nav->setTemplate('/Modules/Navigation/Theme/Backend/mid');
$nav->setNav($this->getData('nav'));
$nav->setLanguage($this->l11n->language);
$nav->setParent(1000301001);
$sidenav = new \Modules\Navigation\Views\NavigationView($this->app, $this->request, $this->response);
$sidenav->setTemplate('/Modules/Navigation/Theme/Backend/mid-side');
$sidenav->setNav($this->getData('nav'));
$sidenav->setLanguage($this->l11n->language);
$sidenav->setParent(1000301001);
$account = $this->getData('account');
echo $this->getData('nav')->render();
?>
<?= $nav->render(); ?>
<div itemscope itemtype="http://schema.org/Person">
<div class="b-7" id="i3-2-1">
<div class="b-5" id="i3-2-4">
<div class="bc-1">
<img src="/Modules/Profile/Theme/Backend/img/profile-default-small.jpg" itemprop="image">
</div>
</div>
<?= $sidenav->render(); ?>
</div>
<div class="b-6" id="i3-2-2">
<div class="b b-2 c3-2 c3" id="i3-2-3">
<h1>
<?= $this->l11n->lang['Profile']['Profile']; ?>
<i class="fa fa-minus min"></i>
<i class="fa fa-plus max vh"></i>
</h1>
<div class="bc-1">
<!-- @formatter:off -->
<table class="tc-1">
<section itemscope itemtype="http://schema.org/Person" class="box w-33">
<h1><?= $this->l11n->lang['Profile']['Profile']; ?></h1>
<div class="inner">
<!-- @formatter:off -->
<table class="list">
<tr>
<th><?= $this->l11n->lang['Profile']['Name']; ?>
<td><span itemprop="familyName">Duck</span>, <span itemprop="givenName">Donald</span>
<td><span itemprop="familyName"><?= $account->getName3(); ?></span>, <span itemprop="givenName"><?= $account->getName1(); ?></span>
<tr>
<th><?= $this->l11n->lang['Profile']['Occupation']; ?>
<td itemprop="jobTitle">Sailor
@ -63,7 +39,7 @@ $sidenav->setParent(1000301001);
<td itemprop="memberOf">Gosling
<tr>
<th><?= $this->l11n->lang['Profile']['Email']; ?>
<td itemprop="email"><a href="mailto:>donald.duck@email.com<">donald.duck[at]email.com</a>
<td itemprop="email"><a href="mailto:>donald.duck@email.com<"><?= $account->getEmail(); ?></a>
<tr>
<th>Address
<td>
@ -87,16 +63,14 @@ $sidenav->setParent(1000301001);
<td itemprop="telephone">+01 12345-4567
<tr>
<th><?= $this->l11n->lang['Profile']['Registered']; ?>
<td>09.06.1934
<td><?= $account->getCreatedAt()->format('Y-m-d'); ?>
<tr>
<th><?= $this->l11n->lang['Profile']['LastLogin']; ?>
<td>01.04.2015
<td><?= $account->getLastActive()->format('Y-m-d'); ?>
<tr>
<th><?= $this->l11n->lang['Profile']['Status']; ?>
<td><span class="green">Active</span>
<td><span class="tag green"><?= $account->getStatus(); ?></span>
</table>
<!-- @formatter:on -->
</div>
</div>
</div>
</div>
</section>