Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
services
t3o sites
voting.typo3.org
extensions
election
Commits
bb9b6be3
Commit
bb9b6be3
authored
Mar 15, 2019
by
Stefan Busemann
Browse files
[FEATURE] Show election status (planned)
parent
2774100f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Classes/Domain/Model/Election.php
View file @
bb9b6be3
<?php
namespace
TYPO3\Election\Domain\Model
;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class Election
...
...
@@ -198,8 +199,23 @@ class Election extends AbstractEntity
if
(
$this
->
getEndDate
()
->
getTimestamp
()
<
time
())
{
return
true
;
}
return
false
;
}
//
// /** @return bool
// */
// public function isElectionPlanned()
// {
// if ($this->getStartDate() === null) {
// return true;
// }
// if ($this->getStartDate()->getTimestamp() > time()) {
// return true;
// }
//
// return false;
// }
/**
* @return array
...
...
@@ -216,6 +232,7 @@ class Election extends AbstractEntity
}
}
}
return
$votingElectors
;
}
...
...
@@ -234,6 +251,7 @@ class Election extends AbstractEntity
}
}
}
return
$votingElectors
;
}
...
...
@@ -250,6 +268,7 @@ class Election extends AbstractEntity
$uninvitedElectors
[]
=
$elector
;
}
}
return
$uninvitedElectors
;
}
...
...
@@ -269,9 +288,9 @@ class Election extends AbstractEntity
$nominees
[
$uid
][
'votes'
]
=
1
;
$nominees
[
$uid
][
'nominee'
]
=
$nominee
;
}
if
(
$this
->
getElectionVotes
()
>
0
){
if
(
$this
->
getElectionVotes
()
>
0
)
{
$nominees
[
$uid
][
'relativevotes'
]
=
round
(
$nominees
[
$uid
][
'votes'
]
/
count
(
$this
->
getElectionVotes
())
*
100
,
2
);
round
(
$nominees
[
$uid
][
'votes'
]
/
count
(
$this
->
getElectionVotes
())
*
100
,
2
);
}
}
uasort
(
...
...
@@ -283,9 +302,11 @@ class Election extends AbstractEntity
if
(
$a
[
'votes'
]
<
$b
[
'votes'
])
{
return
1
;
}
return
0
;
}
);
return
$nominees
;
}
}
Resources/Private/Language/locallang.xlf
View file @
bb9b6be3
...
...
@@ -478,6 +478,9 @@
<trans-unit
id=
"view.fe.election.show.active"
>
<source>
Voting in Progress
</source>
</trans-unit>
<trans-unit
id=
"view.fe.election.show.active"
>
<source>
Voting planned
</source>
</trans-unit>
<trans-unit
id=
"view.fe.election.show.nominee"
>
<source>
Nominee
</source>
</trans-unit>
...
...
Resources/Private/Templates/FeElection/Show.html
View file @
bb9b6be3
...
...
@@ -4,15 +4,22 @@
<h1>
{election.title}
</h1>
<div>
This election starts at
<f:format.date>
{election.StartDate}
</f:format.date>
and ends at
<f:format.date>
{election.EndDate}
</f:format.date>
.
<br>
</div>
<div>
{election.description}
</div>
<f:if
condition=
"!{election.ElectionFinished}"
>
<f:then>
<h2>
Current Voting
</h2>
<h2>
Nominees
</h2>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
<f:translate
key=
"model.nominee.field.image"
>
Image
</f:translate>
</th>
<th>
<f:translate
key=
"view.fe.election.show.nominee"
/>
</th>
...
...
@@ -24,11 +31,30 @@
<tbody>
<f:for
each=
"{election.nominees}"
as=
"nominee"
>
<tr>
<td>
<f:if
condition=
"{nominee.image}"
>
<f:then>
<f:image
image=
"{nominee.image}"
width=
"50c"
height=
"50c"
/>
</f:then>
<f:else>
<f:image
src=
"EXT:core/Resources/Public/Icons/T3Icons/avatar/avatar-default.svg"
width=
"50c"
height=
"50c"
/>
</f:else>
</f:if>
</td>
<td>
{nominee.lastName}, {nominee.firstName} {nominee.MiddleName}
</td>
<td>
<f:translate
key=
"view.fe.election.show.active"
/>
<f:if
condition=
"{election.ElectionPlanned}"
>
<f:then>
<f:translate
key=
"view.fe.election.show.planned"
/>
</f:then>
<f:else>
<f:translate
key=
"view.fe.election.show.active"
/>
</f:else>
</f:if>
</td>
</tr>
</f:for>
...
...
@@ -43,6 +69,9 @@
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
<f:translate
key=
"model.nominee.field.image"
>
Image
</f:translate>
</th>
<th>
<f:translate
key=
"view.fe.election.show.nominee"
/>
</th>
...
...
@@ -54,6 +83,17 @@
<tbody>
<f:for
each=
"{results}"
as=
"result"
>
<tr>
<td>
<f:if
condition=
"{nominee.image}"
>
<f:then>
<f:image
image=
"{nominee.image}"
width=
"50c"
height=
"50c"
/>
</f:then>
<f:else>
<f:image
src=
"EXT:core/Resources/Public/Icons/T3Icons/avatar/avatar-default.svg"
width=
"50c"
height=
"50c"
/>
</f:else>
</f:if>
</td>
<td>
{result.nominee.lastName}, {result.nominee.firstName} {result.nominee.MiddleName}
</td>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment