Skip to content

Commit

Permalink
Update: shows the Voted entries + shows the users / guests who submit…
Browse files Browse the repository at this point in the history
…ted the entry + small fixes
  • Loading branch information
hhunderter committed Jun 10, 2019
1 parent 53851e8 commit b1cfee4
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 5 deletions.
3 changes: 3 additions & 0 deletions controllers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Modules\RadioHoererCharts\Controllers;

use Modules\User\Mappers\User as UserMapper;
use Modules\RadioHoererCharts\Mappers\HoererCharts as HoererChartsMapper;
use Modules\RadioHoererCharts\Models\HoererCharts as HoererChartsModel;
use Modules\RadioHoererCharts\Mappers\HoererChartsSuggestion as HoererChartsSuggestionMapper;
Expand All @@ -19,6 +20,7 @@ public function indexAction()
{
$hoererchartsMapper = new HoererChartsMapper();
$hoererchartsuservotesMapper = new HoererChartsUserVotesMapper();
$userMapper = new UserMapper;

$this->getLayout()->getTitle()
->add($this->getTranslator()->trans('hoerercharts'));
Expand Down Expand Up @@ -47,6 +49,7 @@ public function indexAction()
'Star5'=>$this->getConfig()->get('radio_hoerercharts_Star5'),
'Program_Name'=>(($this->getConfig()->get('radio_hoerercharts_Program_Name'))?$this->getConfig()->get('radio_hoerercharts_Program_Name'):$this->getTranslator()->trans('notset')));
$this->getView()->set('config', $hoererchartsconfig);
$this->getView()->set('userMapper', $userMapper);

$this->getView()->set('votedatetime', ((!$hoererchartsconfig['start_datetime'] and !$hoererchartsconfig['end_datetime'])?'':$this->getTranslator()->trans('votedatetime').(($hoererchartsconfig['start_datetime'] and $hoererchartsconfig['end_datetime'])?call_user_func_array([$this->getTranslator(), 'trans'], array('fromto', $hoererchartsconfig['start_datetime']->format($formatdatetime),$hoererchartsconfig['end_datetime']->format($formatdatetime))):(($hoererchartsconfig['start_datetime'])?$this->getTranslator()->trans('from').' '.$hoererchartsconfig['start_datetime']->format($formatdatetime):$this->getTranslator()->trans('to').' '.$hoererchartsconfig['end_datetime']->format($formatdatetime)))."<br><br>"));
if ($hoererchartsMapper->checkDB()){
Expand Down
6 changes: 5 additions & 1 deletion controllers/admin/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ public function indexAction()
$this->redirect(['action' => 'index']);
}
}
$suggestionentries = $hoererchartssuggestionMapper->getEntries([]);

if ($this->getRequest()->getParam('suggestion')) $this->getView()->set('entries', $hoererchartssuggestionMapper->getEntries([]));
if ($this->getRequest()->getParam('suggestion')) $this->getView()->set('entries', $suggestionentries);
else $this->getView()->set('entries', $hoererchartsMapper->getEntries([]));
$this->getView()->set('badgeSuggestion', count($suggestionentries));
}
}

Expand Down Expand Up @@ -253,5 +255,7 @@ public function resetAction()
$this->redirect(['action' => 'index']);
}
}

$this->getView()->set('entries', $hoererchartsuservotesMapper->getEntries([]));
}
}
3 changes: 3 additions & 0 deletions translations/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@
'enable' => 'Freischalten',
'user' => 'Username',
'guest' => 'Gast',

'registered_by' => 'Eingetragen von',
'suggestionenable' => 'Vorschlag aktivieren',
];
3 changes: 3 additions & 0 deletions translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@
'enable' => 'Freischalten',
'user' => 'Username',
'guest' => 'Gast',

'registered_by' => 'Registered by',
'suggestionenable' => 'Suggestion enable',
];
2 changes: 1 addition & 1 deletion views/admin/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<a href="<?=$this->getUrl(['action' => 'index']) ?>"><?=$this->getTrans('index') ?></a>
</li>
<li class="<?=($this->get('suggestion')?'active':'') ?>">
<a href="<?=$this->getUrl(['action' => 'index', 'suggestion' => 'true']) ?>"><?=$this->getTrans('suggestion') ?></a>
<a href="<?=$this->getUrl(['action' => 'index', 'suggestion' => 'true']) ?>"><?=$this->getTrans('suggestion') ?> <span class="badge"><?=$this->get('badgeSuggestion') ?></span></a>
</li>
</ul>
</div>
Expand Down
39 changes: 39 additions & 0 deletions views/admin/index/reset.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,42 @@
<div class="form-group">
<a href="<?=$this->getUrl(['action' => 'reset', 'reset' => true], null, true) ?>" class="btn btn-danger btn-lg active delete_button" role="button" aria-pressed="true"><?=$this->getTrans('reset') ?></a>
</div>

<div class="table-responsive">
<table class="table table-hover table-striped">
<colgroup>
<col>
<col>
</colgroup>
<thead>
<tr>
<th><?=$this->getTrans('user') ?></th>
<th><?=$this->getTrans('datecreate') ?></th>
</tr>
</thead>
<?php foreach ($this->get('entries') as $entry): ?>
<tbody>
<tr>
<td>
<?php
$userMapper = new \Modules\User\Mappers\User();

$user_id = $entry->getUser_Id();
$user = $userMapper->getUserById($user_id);
if ($user)
echo $this->escape($user->getName());
else
echo $this->getTrans('guest');
?>
</td>
<td>
<?php
$datenow = new \Ilch\Date($entry->getLast_Activity());
echo $datenow->format('d.m.Y H:i');
?>
</td>
</tr>
</tbody>
<?php endforeach; ?>
</table>
</div>
18 changes: 15 additions & 3 deletions views/index/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
$hoererchartsconfig = $this->get('config');
$userMapper = $this->get('userMapper');
?>
<h1>
<?=$this->getTrans('hoerercharts').$this->get('gettext') ?>
Expand Down Expand Up @@ -31,14 +32,16 @@
<col class="icon_width">
<col class="col-lg-4">
<col class="col-lg-4">
<col class="col-lg-4">
<col class="col-lg-3">
<col class="icon_width">
</colgroup>
<thead>
<tr>
<th><?=$this->getTrans('place') ?></th>
<th><?=$this->getTrans('interpret') ?></th>
<th><?=$this->getTrans('songtitel') ?></th>
<th><?=$this->getTrans('vote') ?></th>
<th></th>
</tr>
</thead>
<tbody>
Expand All @@ -48,6 +51,8 @@
<td><?=$this->escape($entry->getInterpret()) ?></td>
<td><?=$this->escape($entry->getSongTitel()) ?></td>
<td><?=$this->get('hoererchartsMapper')->getStars($entry->getVotes(), $hoererchartsconfig) ?></td>
<?php $User = $userMapper->getUserById($entry->getUser_Id()); ?>
<td><span class="fa fa-info-circle text-info" data-toggle="tooltip" data-placement="left" title="<?=$this->getTrans('registered_by') ?>: <?=(!$User?$this->getTrans('guest'):$this->escape($User->getName())) ?>"></span></td>
</tr>
<?php
$platz++;
Expand All @@ -74,13 +79,15 @@
<colgroup>
<col class="icon_width">
<col class="col-lg-6">
<col class="col-lg-6">
<col class="col-lg-5">
<col class="icon_width">
</colgroup>
<thead>
<tr>
<th>&nbsp;</th>
<th><?=$this->getTrans('interpret') ?></th>
<th><?=$this->getTrans('songtitel') ?></th>
<th></th>
</tr>
</thead>
<tbody>
Expand All @@ -89,6 +96,8 @@
<td><input type="radio" name="hoerercharts-d" value="<?=$entry->getId() ?>"></td>
<td><?=$this->escape($entry->getInterpret()) ?></td>
<td><?=$this->escape($entry->getSongTitel()) ?></td>
<?php $User = $userMapper->getUserById($entry->getUser_Id()); ?>
<td><span class="fa fa-info-circle text-info" data-toggle="tooltip" data-placement="left" title="<?=$this->getTrans('registered_by') ?>: <?=(!$User?$this->getTrans('guest'):$this->escape($User->getName())) ?>"></span></td>
</tr>
<?php endforeach; ?>
</tbody>
Expand All @@ -107,4 +116,7 @@
<?php endif; ?>
<?php endif; ?>
</div>
</div>
</div>
<script>
$('[data-toggle="tooltip"]').tooltip()
</script>

0 comments on commit b1cfee4

Please sign in to comment.