Skip to content

Commit

Permalink
if voting period + additional time, there is no sorted issue #3
Browse files Browse the repository at this point in the history
Change Font Awesome icons
if voting period + additional time, there is no sorted issue #3 ( #3 )
  • Loading branch information
Dennis Reilard committed Aug 8, 2020
1 parent 68f9e04 commit c978a96
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 31 deletions.
12 changes: 10 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Config extends \Ilch\Config\Install
{
public $config = [
'key' => 'radiohoerercharts',
'version' => '1.5.0',
'version' => '1.5.1',
'icon_small' => 'fa-list-ol',
'author' => 'Reilard, Dennis alias hhunderter ',
'link' => '',
Expand Down Expand Up @@ -203,8 +203,16 @@ public function getUpdate($installedVersion)
$this->db()->query('UPDATE `[prefix]_radio_hoerercharts` SET `datecreate` = "'.$datecreate.'" WHERE `datecreate` = "0000-00-00 00:00:00"');
case "1.4.4": //update zu 1.5.0
/*
Admin View Sort #2 (https://github.com/hhunderter/radiohoerercharts/issues/2)
Admin View Sort #2 ( https://github.com/hhunderter/radiohoerercharts/issues/2 )
*/
case "1.5.0": //update zu 1.5.1
/*
Change Font Awesome icons
if voting period + additional time, there is no sorted issue #3 ( https://github.com/hhunderter/radiohoerercharts/issues/3 )
*/
$databaseConfig = new \Ilch\Config\Database($this->db());
$databaseConfig->set('radio_hoerercharts_Program_sec_duration', '7200'); //2h
case "1.5.1": //update zu ?
}
return 'Update function executed.';
}
Expand Down
9 changes: 7 additions & 2 deletions controllers/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public function indexAction()
if ($this->getConfig()->get('radio_hoerercharts_End_Datetime')) $end_datetime = new \Ilch\Date($this->getConfig()->get('radio_hoerercharts_End_Datetime'));
$formatdatetime = 'd.m.Y H:i';

$hoererchartsconfig = array('allsecvote'=>$this->getConfig()->get('radio_hoerercharts_all_sec_vote'),
$hoererchartsconfig = array('program_secduration'=>$this->getConfig()->get('radio_hoerercharts_Program_sec_duration'),
'allsecvote'=>$this->getConfig()->get('radio_hoerercharts_all_sec_vote'),
'guestallow'=>$this->getConfig()->get('radio_hoerercharts_Guest_Allow'),
'start_datetime'=>$start_datetime,
'allowsuggestion'=>$this->getConfig()->get('radio_hoerercharts_allow_suggestion'),
Expand All @@ -55,10 +56,14 @@ public function indexAction()
if ($hoererchartsMapper->checkDB()) {
$vote_allowed = $hoererchartsMapper->vote_allowed($hoererchartsconfig['start_datetime'], $hoererchartsconfig['end_datetime']);
$this->getView()->set('vote_allowed', $vote_allowed);
$show_sortedlist = $hoererchartsMapper->is_showsortedlist($hoererchartsconfig['end_datetime'], $hoererchartsconfig['program_secduration']);
$this->getView()->set('show_sortedlist', $show_sortedlist);

if ($hoererchartsuservotesMapper->is_voted($this->getUser(), $hoererchartsconfig['guestallow'], $hoererchartsconfig['allsecvote']) or !$vote_allowed) {
$this->getView()->set('voted', true);
$this->getView()->set('entries', $hoererchartsMapper->getEntriesBy(['setfree' => 1], ['votes' => 'DESC','id' => 'DESC']));

if ($show_sortedlist) $this->getView()->set('entries', $hoererchartsMapper->getEntriesBy(['setfree' => 1], ['votes' => 'DESC','id' => 'DESC']));
else $this->getView()->set('entries', $hoererchartsMapper->getEntriesBy(['setfree' => 1], ['datecreate' => 'ASC','id' => 'DESC']));
} else {
if ($this->getRequest()->getPost('saveHoererCharts')) {
$validation_indb = Validation::create($this->getRequest()->getPost(), ['hoerercharts-d' => 'required|unique:radio_hoerercharts,id']);
Expand Down
21 changes: 12 additions & 9 deletions controllers/admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,22 @@ public function indexAction()
if ($hoererchartsMapper->checkDB()) {
if ($this->getRequest()->isPost()) {
$validation = Validation::create($this->getRequest()->getPost(), [
'Program_Name' => 'required',
'allsecvote' => 'required|numeric',
'guestallow' => 'required|numeric|min:0|max:1',
'showstars' => 'required|numeric|min:0|max:1',
'Star1' => 'required|numeric|min:1',
'Star2' => 'required|numeric|min:1',
'Star3' => 'required|numeric|min:1',
'Star4' => 'required|numeric|min:1',
'Star5' => 'required|numeric|min:1',
'Program_Name' => 'required',
'allsecvote' => 'required|numeric',
'program_secduration' => 'required|numeric',
'guestallow' => 'required|numeric|min:0|max:1',
'showstars' => 'required|numeric|min:0|max:1',
'Star1' => 'required|numeric|min:1',
'Star2' => 'required|numeric|min:1',
'Star3' => 'required|numeric|min:1',
'Star4' => 'required|numeric|min:1',
'Star5' => 'required|numeric|min:1',
]);

if ($validation->isValid()) {
$this->getConfig()->set('radio_hoerercharts_Program_Name', $this->getRequest()->getPost('Program_Name'))
->set('radio_hoerercharts_all_sec_vote', $this->getRequest()->getPost('allsecvote'))
->set('radio_hoerercharts_Program_sec_duration', $this->getRequest()->getPost('program_secduration'))
->set('radio_hoerercharts_Guest_Allow', $this->getRequest()->getPost('guestallow'))
->set('radio_hoerercharts_showstars', $this->getRequest()->getPost('showstars'))
->set('radio_hoerercharts_Star1', $this->getRequest()->getPost('Star1'))
Expand All @@ -88,6 +90,7 @@ public function indexAction()

$this->getView()->set('Program_Name', $this->getConfig()->get('radio_hoerercharts_Program_Name'))
->set('allsecvote', $this->getConfig()->get('radio_hoerercharts_all_sec_vote'))
->set('program_secduration', $this->getConfig()->get('radio_hoerercharts_Program_sec_duration'))
->set('guestallow', $this->getConfig()->get('radio_hoerercharts_Guest_Allow'))
->set('showstars', $this->getConfig()->get('radio_hoerercharts_showstars'))
->set('Star1', $this->getConfig()->get('radio_hoerercharts_Star1'))
Expand Down
20 changes: 20 additions & 0 deletions mappers/HoererCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,24 @@ public function vote_allowed($start_datetime = null, $end_datetime = null)
}
}

/**
* Checks if Time to show the Filal list.
*
* @param null|\Ilch\Date $end_datetime
* @param null|integer $program_secduration
* @return boolean
*/
public function is_showsortedlist($end_datetime = null, $program_secduration = null)
{
$date = new \Ilch\Date();

$datenow = new \Ilch\Date($date->format("Y-m-d H:i:s",true));

if ((!$end_datetime and !$program_secduration) or $program_secduration <= 0){
return true;
}else{
return (($datenow->getTimestamp() >= ($end_datetime->getTimestamp()+$program_secduration)) ? true : false);
}
}

}
2 changes: 2 additions & 0 deletions translations/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
'setfree' => 'Anzeigen',
'Allsecvote' => 'Abstimmung Sperre',
'AllsecvoteText' => 'Gibt in Sekunden an, ab wann der Benutzer / Gast erneut abstimmen kann.<br>Wenn der Wert "0" ist, können Benutzer / Gäste nur einmal abstimmen.',
'Program_secduration' => 'Zusätzliche Endzeit',
'Program_secdurationText' => '(Sendezeit)<br>Gibt in Sekunden die zusätzliche Zeit nach dem Ende an, um die sortierte Liste anzuzeigen.',
'datecreate' => 'Erstell Datum',
'new' => 'neu',
'enable' => 'Freischalten',
Expand Down
2 changes: 2 additions & 0 deletions translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
'setfree' => 'Show',
'Allsecvote' => 'Vote lock',
'AllsecvoteText' => 'Specifies in seconds, from when the user / guest can vote again.<br>If the value is "0", users / guests can vote only once.',
'Program_secduration' => 'Additional End Time',
'Program_secdurationText' => '(Broadcasting time)<br>Specifies in seconds, the additional Time after end Time to show the Sorted List.',
'datecreate' => 'Erstell Datum',
'new' => 'neu',
'enable' => 'Freischalten',
Expand Down
18 changes: 9 additions & 9 deletions views/admin/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<?php if (!$this->get('suggestion')): ?>

<div class="col-lg-6">
<?=$this->get('votedatetime') ?> <a href="javascript:votedatetime()" title="<?=$this->getTrans('edit') ?>"><span class="fa fa-edit text-success"></span></a>
<?=$this->get('votedatetime') ?> <a href="javascript:votedatetime()" title="<?=$this->getTrans('edit') ?>"><span class="fas fa-edit text-success"></span></a>
</div>
<?php else: ?>
<div class="col-lg-6">
Expand Down Expand Up @@ -67,33 +67,33 @@
<th>
<a href="<?=$this->getUrl(array_merge(['column' => 'interpret'], $urladd)) ?>" title="<?=$this->getTrans('interpret') ?>">
<?=$this->getTrans('interpret') ?>
<i class="fa fa-sort<?php echo $this->get('sort_column') == 'interpret' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
<i class="fas fa-sort<?php echo $this->get('sort_column') == 'interpret' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
</a>
</th>
<th>
<a href="<?=$this->getUrl(array_merge(['column' => 'songtitel'], $urladd)) ?>" title="<?=$this->getTrans('songtitel') ?>">
<?=$this->getTrans('songtitel') ?>
<i class="fa fa-sort<?php echo $this->get('sort_column') == 'songtitel' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
<i class="fas fa-sort<?php echo $this->get('sort_column') == 'songtitel' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
</a>
</th>
<?php if (!$this->get('suggestion')): ?>
<th>
<a href="<?=$this->getUrl(array_merge(['column' => 'votes'], $urladd)) ?>" title="<?=$this->getTrans('vote') ?>">
<?=$this->getTrans('vote') ?>
<i class="fa fa-sort<?php echo $this->get('sort_column') == 'votes' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
<i class="fas fa-sort<?php echo $this->get('sort_column') == 'votes' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
</a>
</th>
<?php endif; ?>
<th>
<a href="<?=$this->getUrl(array_merge(['column' => 'datecreate'], $urladd)) ?>" title="<?=$this->getTrans('datecreate') ?>">
<?=$this->getTrans('datecreate') ?>
<i class="fa fa-sort<?php echo $this->get('sort_column') == 'datecreate' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
<i class="fas fa-sort<?php echo $this->get('sort_column') == 'datecreate' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
</a>
</th>
<th>
<a href="<?=$this->getUrl(array_merge(['column' => 'user'], $urladd)) ?>" title="<?=$this->getTrans('user') ?>">
<?=$this->getTrans('user') ?>
<i class="fa fa-sort<?php echo $this->get('sort_column') == 'user' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
<i class="fas fa-sort<?php echo $this->get('sort_column') == 'user' ? '-' . str_replace(array('ASC','DESC'), array('up','down'), $this->get('sort_order')) : ''; ?>"></i>
</a>
</th>
</tr>
Expand All @@ -108,16 +108,16 @@
<?php if (!$this->get('suggestion')): ?>
<?php if ($entry->getSetFree() == 1): ?>
<a href="<?=$this->getUrl(['action' => 'update', 'id' => $entry->getId(), 'status_man' => -1], null, true) ?>">
<span class="fa fa-check-square-o text-info"></span>
<span class="fas fa-check-square text-info"></span>
</a>
<?php else: ?>
<a href="<?=$this->getUrl(['action' => 'update', 'id' => $entry->getId(), 'status_man' => -1], null, true) ?>">
<span class="fa fa-square-o text-info"></span>
<span class="fas fa-square text-info"></span>
</a>
<?php endif; ?>
<?php else: ?>
<a href="<?=$this->getUrl(['action' => 'suggestionenable', 'id' => $entry->getId()], null, true) ?>">
<span class="fa fa-reply text-info"></span>
<span class="fas fa-reply text-info"></span>
</a>
<?php endif; ?>
</td>
Expand Down
15 changes: 15 additions & 0 deletions views/admin/settings/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ class="form-control"
required />
</div>
</div>
<h1><?=$this->getTrans('Program_secduration') ?></h1>
<div class="form-group <?=$this->validation()->hasError('program_secduration') ? 'has-error' : '' ?>">
<label for="program_secduration" class="col-lg-2 control-label">
<?=$this->getTrans('Program_secdurationText') ?>:
</label>
<div class="col-lg-4">
<input type="number"
class="form-control"
id="program_secduration"
name="program_secduration"
min="0"
value="<?=$this->get('program_secduration') ?>"
required />
</div>
</div>
<h1><?=$this->getTrans('guestallow') ?></h1>
<div class="form-group <?=$this->validation()->hasError('guestallow') ? 'has-error' : '' ?>">
<label for="guestallow" class="col-lg-2 control-label">
Expand Down
4 changes: 2 additions & 2 deletions views/admin/settings/votedatetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class="form-control"
name="start_datetime"
value="<?=$this->get('start_datetime') ?>" />
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
<span class="fas fa-calendar"></span>
</span>
</div>
</div>
Expand All @@ -30,7 +30,7 @@ class="form-control"
name="end_datetime"
value="<?=$this->get('end_datetime') ?>" />
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
<span class="fas fa-calendar"></span>
</span>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions views/index/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
?>
<table class="table table-hover table-striped">
<colgroup>
<col class="icon_width">
<?php if ($this->get('show_sortedlist')): ?><col class="icon_width"><?php endif; ?>
<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>
<?php if ($this->get('show_sortedlist')): ?><th><?=$this->getTrans('place') ?></th><?php endif; ?>
<th><?=$this->getTrans('interpret') ?></th>
<th><?=$this->getTrans('songtitel') ?></th>
<th><?=$this->getTrans('vote') ?></th>
Expand All @@ -47,12 +47,12 @@
<tbody>
<?php foreach ($this->get('entries') as $entry): ?>
<tr>
<td><?=$platz ?></td>
<?php if ($this->get('show_sortedlist')): ?><td><?=$platz ?></td><?php endif; ?>
<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>
<td><span class="fas 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 Down Expand Up @@ -97,7 +97,7 @@
<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>
<td><span class="fas 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 Down
3 changes: 1 addition & 2 deletions views/index/treat.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
value="<?php if ($this->getRequest()->getPost('songtitel') != '') { echo $this->escape($this->getRequest()->getPost('songtitel')); } ?>" />
</div>
</div>

<?php if ($this->get('captchaNeeded')) : ?>
<div class="form-group <?=$this->validation()->hasError('captcha') ? 'has-error' : '' ?>">
<label class="col-lg-2 control-label">
Expand All @@ -48,7 +47,7 @@ class="form-control"
document.getElementById('captcha').src='<?=$this->getUrl() ?>/application/libraries/Captcha/Captcha.php?'+Math.random();
document.getElementById('captcha-form').focus();"
id="change-image">
<i class="fa fa-refresh"></i>
<i class="fas fa-sync"></i>
</a>
</span>
</div>
Expand Down

0 comments on commit c978a96

Please sign in to comment.