Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

hotdealslist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: hotdealslist.php 7382 2001-09-21 14:28:49Z jhe $
5 //
6 // Created on: <12-Nov-2000 19:34:40 bf>
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/ezlocale.php" );
30 // include_once( "classes/ezcurrency.php" );
31
32 $ini =& eZINI::instance( 'site.ini' );
33
34 $Language = $ini->variable( "eZTradeMain", "Language" );
35 $hotDealColumns = $ini->variable( "eZTradeMain", "HotDealColumns" );
36 $hotDealImageWidth = $ini->variable( "eZTradeMain", "HotDealImageWidth" );
37 $hotDealImageHeight = $ini->variable( "eZTradeMain", "HotDealImageHeight" );
38 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
39 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
40
41 // include_once( "eztrade/classes/ezproduct.php" );
42 // include_once( "eztrade/classes/ezproductcategory.php" );
43
44 // include_once( "ezuser/classes/ezuser.php" );
45 // include_once( "eztrade/classes/ezpricegroup.php" );
46
47 $user =& eZUser::currentUser();
48
49 $RequireUser = $ini->variable( "eZTradeMain", "RequireUserLogin" ) == "enabled" ? true : false;
50 $ShowPrice = $RequireUser ? is_a( $user, "eZUser" ) : true;
51
52 $PriceGroup = 0;
53 if ( is_a( $user, "eZUser" ) )
54 {
55 $PriceGroup = eZPriceGroup::correctPriceGroup( $user->groups( false ) );
56 }
57 if ( !$ShowPrice )
58 $PriceGroup = -1;
59
60 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
61 "kernel/eztrade/user/intl/", $Language, "hotdealslist.php" );
62
63 if ( isset( $HotDealsPage ) )
64 {
65 $t->set_file( "hdl_product_list_page_tpl", "hotdealspage.tpl" );
66 }
67 else
68 {
69 if ( !isset( $HotDealsTemplate ) )
70 $HotDealsTemplate = "hotdealslist.tpl";
71 $t->set_file( "hdl_product_list_page_tpl", $HotDealsTemplate );
72 }
73
74 $t->set_block( "hdl_product_list_page_tpl", "hdl_header_tpl", "header" );
75 $t->set_block( "hdl_product_list_page_tpl", "hdl_product_list_tpl", "hdl_product_list" );
76 $t->set_block( "hdl_product_list_tpl", "hdl_product_tpl", "hdl_product" );
77 $t->set_block( "hdl_product_tpl", "hdl_product_image_tpl", "hdl_product_image" );
78 $t->set_block( "hdl_product_tpl", "hdl_price_tpl", "hdl_price" );
79
80 $t->set_block( "product_gallary_page_tpl", "add_to_cart_tpl", "add_to_cart" );
81
82 if ( !isset( $ModuleName ) )
83 $ModuleName = "trade";
84 if ( !isset( $ModuleView ) )
85 $ModuleView = "productview";
86
87 $ModuleList = "productgallary";
88
89 $t->set_var( "module", $ModuleName );
90 $t->set_var( "module_view", $ModuleView );
91 $t->set_var( "module_list", $ModuleList );
92
93
94 $t->setAllStrings();
95
96 $product = new eZProduct( );
97
98 $HotDealColumns = 2;
99
100 if ( !isset( $MaxHotDeals ) )
101 $MaxHotDeals = false;
102 if ( isset( $HotDealColumns ) )
103 $hotDealListColumns = $HotDealColumns;
104
105 $t->set_var( "hotdeal_columns", $hotDealListColumns );
106
107 // products
108 $productList =& $product->hotDealProducts( $MaxHotDeals );
109
110 $locale = new eZLocale( $Language );
111 $i=0;
112 $groupi = 0;
113 $hotDealListColumns = 1;
114 $trEnded = false;
115
116 foreach ( $productList as $product )
117 {
118 $gallaryarraysize = sizeof($productList) - 1;
119 $groupi_size = $groupi; // - 1;
120 $groupitemnumber = $hotDealListColumns;
121 $groupitempreceeding = $groupitemnumber - 1;
122
123 if ( $i == 0 )
124 {
125 $t->set_var( "begin_tr", "<tr>" );
126 $t->set_var( "end_tr", "" );
127 }
128 elseif ( $i == $gallaryarraysize )
129 {
130 $t->set_var( "begin_tr", "" );
131 $t->set_var( "end_tr", "</tr>" );
132 }
133 elseif ( $groupi_size == $groupitempreceeding )
134 {
135 $t->set_var( "begin_tr", "" );
136 $t->set_var( "end_tr", "</tr>" );
137 }
138 elseif ( $groupi_size == $groupitemnumber )
139 {
140 $t->set_var( "begin_tr", "<tr>" );
141 $t->set_var( "end_tr", "" );
142 $groupi = 0;
143 }
144 else
145 {
146 $t->set_var( "begin_tr", "" );
147 $t->set_var( "end_tr", "" );
148 }
149
150 $t->set_var( "product_id", $product->id() );
151 $t->set_var( "product_name", $product->name() );
152 $t->set_var( "product_intro_text", htmlspecialchars( $product->brief() ) );
153
154 $image = $product->thumbnailImage();
155
156 if ( $image )
157 {
158 $thumbnail =& $image->requestImageVariation( $hotDealImageWidth, $hotDealImageHeight );
159 // $thumbnail =& $image->requestImageVariation( 109, 109 );
160
161 if ( $thumbnail )
162 {
163 if ( !isset( $HotDealsPage ) )
164 {
165 $t->set_var( "product_image_path", "/" . $thumbnail->imagePath() );
166 $t->set_var( "product_image_width", $thumbnail->width() );
167 $t->set_var( "product_image_height", $thumbnail->height() );
168 $t->set_var( "product_image_caption", $image->caption() );
169 }
170 else
171 {
172 $t->set_var( "thumbnail_image_uri", "/" . $thumbnail->imagePath() );
173 $t->set_var( "thumbnail_image_width", $thumbnail->width() );
174 $t->set_var( "thumbnail_image_height", $thumbnail->height() );
175 $t->set_var( "thumbnail_image_caption", $image->caption() );
176 }
177 $t->parse( "hdl_product_image", "hdl_product_image_tpl" );
178 }
179 else
180 {
181 $t->set_var( "product_image", "" );
182 }
183
184
185 }
186 else
187 {
188 $t->set_var( "hdl_product_image", "" );
189 }
190
191 if ( ( !$RequireUser || is_a( $user, "eZUser") ) &&
192 ( $ShowPrice && $product->showPrice() ) )
193 {
194 $t->set_var( "product_price", $product->localePrice( $PricesIncludeVAT ) );
195 $priceRange = $product->correctPriceRange( $PricesIncludeVAT );
196
197 if ( ( empty( $priceRange["min"] ) and empty( $priceRange["max"] ) )
198 and !($product->correctPrice( $PricesIncludeVAT ) > 0) )
199 {
200 $t->set_var( "product_price", "" );
201 }
202
203 $t->parse( "hdl_price", "hdl_price_tpl" );
204 }
205 else
206 {
207 $t->set_var( "hdl_price", "" );
208 }
209
210 $defCat = $product->categoryDefinition();
211 if ( $defCat )
212 {
213 $t->set_var( "category_id", $defCat->id() );
214 }
215
216 $t->set_var( "action_url", "cart/add" );
217 $t->parse( "add_to_cart", "add_to_cart_tpl" );
218
219 $t->parse( "hdl_product", "hdl_product_tpl", true );
220 $i++;
221 }
222
223 if ( count( $productList ) > 0 )
224 {
225 $t->parse( "hdl_product_list", "hdl_product_list_tpl" );
226 }
227 else
228 {
229 $t->set_var( "hdl_product_list", "" );
230 }
231
232
233
234 if ( $GenerateStaticPage == "true" )
235 {
236 // include_once( "classes/ezcachefile.php" );
237 $CacheFile = new eZCacheFile( "kernel/eztrade/cache/",
238 array( "hotdealslist", $PriceGroup ),
239 "cache", "," );
240 $output = $t->parse( "output", "product_list_page_tpl" );
241 // print the output the first time while printing the cache file.
242 print( $output );
243 $CacheFile->store( $output );
244 }
245 else
246 {
247 $t->pparse( "output", "hdl_product_list_page_tpl" );
248 }
249
250 ?>
eZLocale
Definition: ezlocale.php:119
eZPriceGroup\correctPriceGroup
static correctPriceGroup( $group_id, $debug=false)
Definition: ezpricegroup.php:240
eZProduct
Definition: ezproduct.php:71
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$thumbnail
$thumbnail
Definition: ezarticle/admin/imagelist.php:59
$ModuleName
$ModuleName
Definition: ezarticle/user/searchsupplier.php:30
$priceRange
$priceRange
Definition: eztrade/user/extendedsearch.php:85
$output
$output
Definition: formpreview.php:81
$hotDealListColumns
$hotDealListColumns
Definition: hotdealslist.php:113
$ModuleList
$ModuleList
Definition: hotdealslist.php:87
$groupi
$groupi
Definition: hotdealslist.php:112
$HotDealColumns
$HotDealColumns
Definition: hotdealslist.php:98
$locale
$locale
Definition: hotdealslist.php:110
$t
$t
Definition: hotdealslist.php:60
$hotDealColumns
$hotDealColumns
Definition: hotdealslist.php:35
$user
$user
Definition: hotdealslist.php:47
$PricesIncludeVAT
$PricesIncludeVAT
Definition: hotdealslist.php:39
$product
$product
Definition: hotdealslist.php:96
$RequireUser
$RequireUser
Definition: hotdealslist.php:49
$i
$i
Definition: hotdealslist.php:111
$Language
$Language
Definition: hotdealslist.php:34
$ini
$ini
Definition: hotdealslist.php:32
$hotDealImageHeight
$hotDealImageHeight
Definition: hotdealslist.php:37
$PriceGroup
$PriceGroup
Definition: hotdealslist.php:52
$ShowPriceGroups
$ShowPriceGroups
Definition: hotdealslist.php:38
$ShowPrice
$ShowPrice
Definition: hotdealslist.php:50
$trEnded
$trEnded
Definition: hotdealslist.php:114
$hotDealImageWidth
$hotDealImageWidth
Definition: hotdealslist.php:36
$productList
$productList
Definition: hotdealslist.php:108
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.