correct description shorting for Seminaries and add values for XP progress bar

This commit is contained in:
coderkun 2014-04-28 23:16:36 +02:00
commit 6d17b7eaf1
2 changed files with 12 additions and 10 deletions

View file

@ -64,15 +64,15 @@
// Get additional data // Get additional data
foreach($seminaries as &$seminary) foreach($seminaries as &$seminary)
{ {
$seminary['description'] = \hhu\z\Utils::shortenString($seminary['description'], 100, 120).' …'; $description = \hhu\z\Utils::shortenString($seminary['description'], 100, 120);
$seminary['description'] = $description.(strlen($description) < strlen($seminary['description']) ? ' …' : null);
// Created user
$seminary['creator'] = $this->Users->getUserById($seminary['created_user_id']); $seminary['creator'] = $this->Users->getUserById($seminary['created_user_id']);
// Character of currently logged-in user // Character of currently logged-in user
try { try {
$seminary['usercharacter'] = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']); $seminary['usercharacter'] = $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']);
$seminary['usercharacter']['characterroles'] = $this->Characterroles->getCharacterrolesForCharacterById($seminary['usercharacter']['id']); $seminary['usercharacter']['characterroles'] = $this->Characterroles->getCharacterrolesForCharacterById($seminary['usercharacter']['id']);
$seminary['xps'] = $this->Seminaries->getTotalXPs($seminary['id']);
} }
catch(\nre\exceptions\IdNotFoundException $e) { catch(\nre\exceptions\IdNotFoundException $e) {
} }

View file

@ -15,18 +15,20 @@
<?php endif ?> <?php endif ?>
<section> <section>
<p class="fwb"> <p class="fwb">
<?php if(array_key_exists('usercharacter', $seminary) && count($seminary['usercharacter']['characterroles']) > 0) : ?> <?php if(array_key_exists('usercharacter', $seminary) && count($seminary['usercharacter']['characterroles']) > 0) : ?>
<a href="<?=$linker->link(array('seminary', $seminary['url']), 1)?>"><?=$seminary['title']?></a> <a href="<?=$linker->link(array('seminary', $seminary['url']), 1)?>"><?=$seminary['title']?></a>
<?php else : ?> <?php else : ?>
<?=$seminary['title']?> <?=$seminary['title']?>
<?php endif ?> <?php endif ?>
</p> </p>
<?php if(array_key_exists('usercharacter', $seminary)) : ?>
<div class="cf"> <div class="cf">
<div class="xpbar"> <div class="xpbar">
<span style="width:25%"></span> <span style="width:<?=round($seminary['usercharacter']['xps'] * 100 / $seminary['xps'])?>%"></span>
</div> </div>
<p class="xpnumeric">25 / 100 XP</p> <p class="xpnumeric"><?=$seminary['usercharacter']['xps']?> / <?=sprintf(_('%dXPs'), $seminary['xps'])?></p>
</div> </div>
<?php endif ?>
<p><small><?=sprintf(_('created by %s on %s'), $seminary['creator']['username'], $dateFormatter->format(new \DateTime($seminary['created'])))?></small></p> <p><small><?=sprintf(_('created by %s on %s'), $seminary['creator']['username'], $dateFormatter->format(new \DateTime($seminary['created'])))?></small></p>
<p><?=\hhu\z\Utils::t($seminary['description'])?></p> <p><?=\hhu\z\Utils::t($seminary['description'])?></p>
<?php if(!array_key_exists('usercharacter', $seminary)) : ?> <?php if(!array_key_exists('usercharacter', $seminary)) : ?>