Commit 4c5df323 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

[FEATURE] Add voting results page

parent fac5a29f
Pipeline #20763 passed with stages
in 5 minutes and 58 seconds
......@@ -175,6 +175,22 @@ class NominationController extends ActionController
$this->redirect('listAllNominations');
}
public function listResultsAction()
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_terfe2_domain_model_documentationvoting');
$results = $queryBuilder
->select('e.ext_key')
->from('tx_terfe2_domain_model_documentationvoting', 'd')
->join('d', 'tx_terfe2_domain_model_extension', 'e', 'e.uid = d.extension')
->groupBy('d.extension')
->orderBy('result', 'desc')
->add('select', 'SUM(d.voting) AS result', true)
->execute()
->fetchAll();
$this->view->assign('results', $results);
}
private function vote(Extension $extension, FrontendUser $user, int $voting): bool
{
return (bool)GeneralUtility::makeInstance(ConnectionPool::class)
......
......@@ -92,6 +92,12 @@
'Nomination voting list',
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'ter_fe2',
'Results',
'Voting results',
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem(
'tt_content',
'CType',
......
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<f:section name="main">
<h1>Voting result</h1>
<table class="table table-striped">
<thead>
<tr>
<th>Position</th>
<th>Extension</th>
<th>Voting</th>
</tr>
</thead>
<tbody>
<f:for each="{results}" as="result" iteration="it">
<tr>
<td>
{it.cycle}.
</td>
<td>
{result.ext_key}
</td>
<td>
{result.result}
</td>
</tr>
</f:for>
</tbody>
</table>
</f:section>
</html>
......@@ -56,6 +56,14 @@ if (!defined('TYPO3_MODE')) {
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'ter_fe2',
'Results',
[
\T3o\TerFe2\Controller\NominationController::class => 'listResults'
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'ter_fe2',
'AccessToken',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment