Skip to content

Commit

Permalink
v1.3 Ausgabe Statistik
Browse files Browse the repository at this point in the history
  • Loading branch information
thielpeter committed May 16, 2018
1 parent 77a46ea commit d336c82
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 4 deletions.
25 changes: 25 additions & 0 deletions assets/rex-poll.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.rex-poll .progress-bar {
width: 0;
transition: 1s;
}
.rex-poll .poll {
padding:30px;
cursor:pointer;
}
.rex-poll .poll:hover{
background-color: #cfcfc4;
}
.rex-poll .poll-status-online,
.rex-poll .poll-status-offline {
border-radius:100%;
height:15px;
width:15px;
display: inline-block;
vertical-align: middle;
}
.rex-poll .poll-status-online {
background-color: #77dd77;
}
.rex-poll .poll-status-offline {
background-color: #ff6961;
}
5 changes: 5 additions & 0 deletions assets/rex-poll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$(document).on('rex:ready', function () {
$('.rex-poll .progress-bar').each(function(){
$(this).css('width',$(this).data('percent') + '%');
})
});
5 changes: 5 additions & 0 deletions boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@
rex_yform_manager_dataset::setModelClass('rex_poll', rex_poll::class);
rex_yform_manager_dataset::setModelClass('rex_poll_option', rex_poll_option::class);
rex_yform_manager_dataset::setModelClass('rex_poll_vote', rex_poll_vote::class);

if (rex::isBackend() && rex::getUser()) {
rex_view::addCssFile($this->getAssetsUrl('rex-poll.css'));
rex_view::addJsFile($this->getAssetsUrl('rex-poll.js'));
}
4 changes: 3 additions & 1 deletion lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ ip = IP
poll_module = Umfrage Modul

poll_validate_email = Bitte gib eine gültige E-Mail-Adresse an
poll_validate_option = Bitte wähle eine Option
poll_validate_option = Bitte wähle eine Option

statistics = Statistiken
2 changes: 1 addition & 1 deletion package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package: poll
version: '1.2'
version: '1.3'
author: Friends Of REDAXO
supportpage: www.github.org/friendsofredaxo/poll

Expand Down
34 changes: 32 additions & 2 deletions pages/statistic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,39 @@

echo rex_view::title($this->i18n('poll'));

$content = '';
$polls = '';
foreach (rex_poll::getAll() as $poll) {
$hits_all = $poll->getHits();

$results = '';
if ($hits_all > 0) {
foreach ($poll->getOptions() as $option) {
$hits = $option->getHits();

$percent = (int)($hits / $hits_all * 100);
$results .= '
<div class="progress bb-progress-thin">
<div class="progress-bar bb-blue-bg" role="progressbar" aria-valuenow="' . $percent . '" aria-valuemin="0" aria-valuemax="100" data-percent="' . $percent . '">
<span class="poll-vote-value">' . $percent . ' % [ ' . $option->getHits() . ' von ' . $hits_all . ' Stimmen ]</span> ' . $option->title . '</div>
</div>
';
}
} else {
$results .= '<p>Es liegen keine Abstimmungen vor.</p>';
}

$polls .= '
<div class="poll">
<p class="poll-title"><h3>Umfrage: ' . $poll->title . '</h3></p>
<p class="poll-info">Status: ' . ($poll->status == '1' ? '<span class="poll-status-online" title="online"></span>' : '<span class="poll-status-offline" title="offline"></span>') . ' Antworten: ' . $hits_all . '</p>
<div class="poll-results">' . $results . '</div>
</div>
';
}

$content = '<div class="rex-poll"><div class="polls">' . $polls . '</div></div>';

$fragment = new rex_fragment();
$fragment->setVar('title', $this->i18n('description'), false);
$fragment->setVar('title', $this->i18n('statistics'), false);
$fragment->setVar('body', $content, false);
echo $fragment->parse('core/page/section.php');

0 comments on commit d336c82

Please sign in to comment.