mirror of
https://github.com/friendica/friendica
synced 2025-04-24 03:10:11 +00:00
Merge pull request #11531 from annando/display-polls
Improved poll texts for different conditions
This commit is contained in:
commit
b18880221a
2 changed files with 38 additions and 8 deletions
|
@ -3201,13 +3201,28 @@ class Item
|
|||
$percent = $question['voters'] ? ($option['replies'] / $question['voters'] * 100) : 0;
|
||||
|
||||
$options[$key]['percent'] = $percent;
|
||||
$options[$key]['vote'] = DI::l10n()->t('%s (%d%s, %d votes)', $option['name'], round($percent, 1), '%', $option['replies']);
|
||||
|
||||
if ($question['voters'] > 0) {
|
||||
$options[$key]['vote'] = DI::l10n()->t('%s (%d%s, %d votes)', $option['name'], round($percent, 1), '%', $option['replies']);
|
||||
} else {
|
||||
$options[$key]['vote'] = DI::l10n()->t('%s (%d votes)', $option['name'], $option['replies']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($question['voters']) && !empty($question['endtime'])) {
|
||||
$summary = DI::l10n()->t('%d voters. Poll end: %s', $question['voters'], Temporal::getRelativeDate($question['endtime']));
|
||||
} elseif (!empty($question['voters'])) {
|
||||
$summary = DI::l10n()->t('%d voters.', $question['voters']);
|
||||
} elseif (!empty($question['endtime'])) {
|
||||
$summary = DI::l10n()->t('Poll end: %s', Temporal::getRelativeDate($question['endtime']));
|
||||
} else {
|
||||
$summary = '';
|
||||
}
|
||||
|
||||
$content .= Renderer::replaceMacros(Renderer::getMarkupTemplate('content/question.tpl'), [
|
||||
'$question' => $question,
|
||||
'$options' => $options,
|
||||
'$summary' => DI::l10n()->t('%d voters. Poll end: %s', $question['voters'], Temporal::getRelativeDate($question['endtime'])),
|
||||
'$summary' => $summary,
|
||||
]);
|
||||
}
|
||||
DI::profiler()->stopRecording();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue