Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezpoll/user/result.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: result.php 7833 2001-10-14 21:33:08Z fh $
5 //
6 // Created on: <20-Sep-2000 13:32:11 ce>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29
30 $ini =& eZINI::instance( 'site.ini' );
31
32 $Language = $ini->variable( "eZPollMain", "Language" );
33
34 // include_once( "ezpoll/classes/ezpoll.php" );
35 // include_once( "ezpoll/classes/ezvote.php" );
36 // include_once( "ezpoll/classes/ezpollchoice.php" );
37
38
39 $t = new eZTemplate( "kernel/ezpoll/user/" . $ini->variable( "eZPollMain", "TemplateDir" ),
40 "kernel/ezpoll/user/intl/", $Language, "result.php" );
41
42 $t->setAllStrings();
43
44 $t->set_file( array(
45 "result" => "result.tpl"
46 ) );
47
48 $t->set_block( "result", "result_list_tpl", "result_list" );
49 $t->set_block( "result_list_tpl", "result_item_tpl", "result_item" );
50
51 $poll = new eZPoll();
52 if ( isset($Show) && $Show == "all" )
53 {
54 $pollArray = $poll->getAll();
55 }
56 else
57 {
58 $poll->get( $PollID );
59 $pollArray[] = $poll;
60 }
61
62 foreach ( $pollArray as $poll )
63 {
64 $t->set_var( "poll_name", $poll->name() );
65 $t->set_var( "description", $poll->description() );
66
67 $pollchoice = new eZPollChoice();
68 $choiceList = $pollchoice->getAll( $poll->id() );
69
70 $vote = new eZVote();
71 $total = 0;
72 $total = $poll->totalVotes();
73
74 setType( $total, "double" );
75
76 $i=1;
77
78 if ( $poll->showResult() )
79 {
80 $t->set_var( "result_item", "" );
81 foreach( $choiceList as $choiceItem )
82 {
83 $value = 0;
84 $t->set_var( "choice_name", $choiceItem->name() );
85 $t->set_var( "choice_id", $choiceItem->id() );
86
87 $t->set_var( "choice_vote", $choiceItem->voteCount() );
88 $t->set_var( "choice_number", $i );
89
90 if ( $total != 0 )
91 {
92 $percent = ( ( $choiceItem->voteCount() / $total ) * 100 );
93 $percent = round( $percent );
94 // we can still have errors, if two numbers come up with a ,5 result there will be a percent to much.
95 // consider the case
96 // a - 1 vote
97 // b - 3 votes
98 // c - 4 votes
99 setType( $percent, "integer" );
100 $t->set_var( "choice_percent", $percent );
101 $t->set_var( "choice_inverted_percent", 100 - $percent );
102
103 }
104 else
105 {
106 $t->set_var( "choice_percent", 0 );
107 $t->set_var( "choice_inverted_percent", 100 );
108 }
109
110 $value = $choiceItem->voteCount();
111
112 setType( $value, "double" );
113 setType( $total, "double" );
114
115 $t->parse( "result_item", "result_item_tpl", true );
116 $i++;
117 }
118
119 $t->set_var( "total_votes", $poll->totalVotes() );
120
121 $t->parse( "result_list", "result_list_tpl", true );
122 }
123 else
124 {
125 $languageIni = new eZINI( "kernel/ezpoll/user/intl/" . $Language . "/result.php.ini", false );
126 $result = $languageIni->variable( "strings", "no_result" );
127
128 $t->set_var( "result_list", $result );
129 }
130 }
131
132 $t->pparse( "output", "result" );
133
134 ?>
$i
$i
Definition: admin/adlist.php:91
$total
else $total["inctax"]
Definition: checkout.php:1359
eZINI
Reads and writes .ini style configuration files.
eZPollChoice
Definition: ezpollchoice.php:45
eZPoll
Definition: ezpoll.php:64
eZTemplate
Definition: eztemplate.php:107
eZVote
Definition: ezvote.php:46
$result
$result
Definition: companysearch.php:94
$t
$t
Definition: ezpoll/user/result.php:39
$pollArray
$pollArray[]
Definition: ezpoll/user/result.php:59
$poll
$poll
Definition: ezpoll/user/result.php:51
$Language
$Language
Definition: ezpoll/user/result.php:32
$ini
$ini
Definition: ezpoll/user/result.php:30
$languageIni
$languageIni
Definition: pendinglist.php:43
$choiceList
$choiceList
Definition: votepage.php:60
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.