Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

votebox.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: votebox.php 6376 2001-08-03 12:49:23Z master $
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 // include_once( "classes/ezhttptool.php" );
30
31 $ini =& eZINI::instance( 'site.ini' );
32 $Language = $ini->variable( "eZPollMain", "Language" );
33 $PageCaching = $ini->variable( "eZPollMain", "PageCaching" );
34 $errorIni = new eZINI( "kernel/ezpoll/user/intl/" . $Language . "/votebox.php.ini", false );
35
36 $noItem = $errorIni->variable( "strings", "noitem" );
37
38 unset( $menuCachedFile );
39 // do the caching
40 if ( $PageCaching == "enabled" )
41 {
42 $menuCachedFile = "kernel/ezpoll/cache/menubox,". $GlobalSiteDesign .".cache";
43
44 if ( file_exists( $menuCachedFile ) )
45 {
46 include( $menuCachedFile );
47 }
48 else
49 {
50 createPollMenu( true, $menuCachedFile, $ini, $GlobalSiteDesign, $PollID, $noItem );
51 }
52 }
53 else
54 {
55 createPollMenu(false, false, $ini, $GlobalSiteDesign, $PollID, $noItem );
56 }
57
58 function createPollMenu( $generateStaticPage = false, $menuCachedFile = false, $ini = null, $GlobalSiteDesign = null,
59 $PollID = null, $noItem = null )
60 {
61 // global $ini;
62 // global $menuCachedFile;
63 // global $noItem;
64 // global $GlobalSiteDesign;
65 // global $PollID;
66
67 $Language = $ini->variable( "eZPollMain", "Language" );
68
69 // include_once( "ezpoll/classes/ezpoll.php" );
70 // include_once( "ezpoll/classes/ezpollchoice.php" );
71
72 $t = new eZTemplate( "kernel/ezpoll/user/" . $ini->variable( "eZPollMain", "TemplateDir" ),
73 "kernel/ezpoll/user/intl/", $Language, "votebox.php" );
74
75 $t->setAllStrings();
76
77 $poll = new eZPoll( $PollID );
78 $poll = $poll->mainPoll();
79
80 $t->set_file( array(
81 "vote_box" => "votebox.tpl"
82 ) );
83
84 $t->set_block( "vote_box", "vote_item_tpl", "vote_item" );
85 $t->set_block( "vote_box", "novote_item_tpl", "novote_item" );
86
87 $t->set_var( "vote_item", "" );
88 $t->set_var( "novote_item", "" );
89 $t->set_var( "head_line", "" );
90 $t->set_var( "sitedesign", $GlobalSiteDesign );
91
92 if ( $poll )
93 {
94 if (! $PollID)
95 {
96 $PollID = $poll->id();
97 }
98 $poll = new eZPoll( $PollID );
99
100
101 if ( $poll->isClosed() )
102 {
103 eZHTTPTool::header( "Location: /poll/result/$PollID" );
104 exit();
105 }
106
107 $choice = new eZPollChoice();
108
109 $choiceList = $choice->getAll( $PollID );
110
111 if ( !$choiceList )
112 {
113 $t->set_var( "vote_item", "" );
114 $t->set_var( "novote_item", $noItem );
115 $t->parse( "novote_item", "novote_item_tpl" );
116 }
117 else
118 {
119 foreach( $choiceList as $choiceItem )
120 {
121 $t->set_var( "choice_name", $choiceItem->name() );
122 $t->set_var( "choice_id", $choiceItem->id() );
123
124 $t->set_var( "novote_item", "" );
125 $t->parse( "vote_item", "vote_item_tpl", true );
126 }
127 }
128
129 $poll = new eZPoll();
130 $poll->get( $PollID );
131 $t->set_var( "head_line", $poll->name() );
132 $t->set_var( "poll_id", $PollID );
133
134 }
135 if ( $generateStaticPage == true )
136 {
137 $fp = eZPBFile::fopen( $menuCachedFile, "w+");
138
139 $output = $t->parse( "output", "vote_box" );
140 // print the output the first time while printing the cache file.
141
142 print( $output );
143 fwrite ( $fp, $output );
144 fclose( $fp );
145 }
146 else
147 {
148 $t->pparse( "output", "vote_box" );
149 }
150
151 }
152
153 ?>
$poll
$poll
Definition: admin/pollist.php:114
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZINI
Reads and writes .ini style configuration files.
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZPollChoice
Definition: ezpollchoice.php:45
eZPoll
Definition: ezpoll.php:64
eZTemplate
Definition: eztemplate.php:107
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$fp
$fp
Definition: export.php:97
exit
exit
Definition: folder.php:81
$output
$output
Definition: formpreview.php:81
$GlobalSiteDesign
global $GlobalSiteDesign
Definition: latestmessages.php:52
$errorIni
$errorIni
Definition: votebox.php:34
$Language
$Language
Definition: votebox.php:32
$ini
$ini
Definition: votebox.php:31
createPollMenu
createPollMenu( $generateStaticPage=false, $menuCachedFile=false, $ini=null, $GlobalSiteDesign=null, $PollID=null, $noItem=null)
Definition: votebox.php:58
$noItem
$noItem
Definition: votebox.php:36
$PageCaching
$PageCaching
Definition: votebox.php:33
$choice
$choice
Definition: votepage.php:58
$choiceList
$choiceList
Definition: votepage.php:60
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.