示例#1
0
// Copy & Past
// Parsing Vote
$election1->parseVotes("\n            Ligeti > Wiltod Lutoslawski > Olivier Messiaen = Debussy > Koechlin # A comment. A a line break for the next vote.\n            greatFrenchVote,chauvinismVote || Olivier Messiaen > Debussy = Caplet > Ligeti # Tags at first, vote at second, separated by '||'\n            strangeVote || Caplet > Koechlin * 8 # This vote and his tag will be register 8 times.\n        ");
// Adding some random to this election
$VoteModel = $myVote2->getRanking();
for ($i = 0; $i < 95; $i++) {
    shuffle($VoteModel);
    $election1->addVote($VoteModel);
}
// How Many Vote could I Have now ?
$election1->countVotes();
// Return 110 (int)
# -B- Manage Votes
# 1- Get vote list
// Get the vote list
$election1->getVotesList();
// Returns an array of all votes as object.
// How many Vote with tag "strangeVote" ?
$election1->countVotes('strangeVote');
// Return 10 (int)
// Or without
$election1->countVotes('strangeVote', false);
// Return 100 (int)
// Or with this tag OR this tag
$election1->countVotes(['greatFrenchVote', 'chauvinismVote']);
// Return 4 (int)
// Or without this tag AND this tag
$election1->countVotes(['greatFrenchVote', 'chauvinismVote'], false);
// Return 4 (int)
// Return this 10 votes !
$election1->getVotesList('strangeVote');
	</em>

	<h2>Candidates list :</h2>

	<ul>
	<?php 
foreach ($election->getCandidatesList() as $candidatName) {
    echo '<li>' . $candidatName . '</li>';
}
?>
	</ul>


	<h2>Registered votes details :</h2>
<?php 
foreach ($election->getVotesList() as $vote) {
    echo '<div class="votant">';
    echo '<strong style="color:green;">' . implode(' / ', $vote->getTags()) . '</strong><br>';
    echo "<ol>";
    foreach ($vote as $rank => $value) {
        if ($rank == 'tag') {
            continue;
        }
        ?>

			<li><?php 
        echo implode(',', $value);
        ?>
</li>

		<?php 
	</em>

	<h2>Candidates list :</h2>

	<ul>
	<?php 
foreach ($election->getCandidatesList() as $candidatName) {
    echo '<li>' . $candidatName . '</li>';
}
?>
	</ul>


	<h2>Registered votes details :</h2>
<?php 
foreach ($election->getVotesList() as $vote) {
    echo '<div class="votant">';
    echo '<strong style="color:green;">' . implode(' / ', $vote->getTags()) . '</strong><br>';
    echo "<ol>";
    foreach ($vote as $rank => $value) {
        if ($rank == 'tag') {
            continue;
        }
        ?>

			<li><?php 
        echo implode(',', $value);
        ?>
</li>

		<?php