Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

productgallery.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: productgallery.php,v 1.1.2.1 2002/05/14 13:02:54 kracker Exp $
5 //
6 // Created on: <24-Feb-2002 17:53:20 ghb>
7 //
8 // This source file is part of XP publish, based on Exponential Basic.
9 //
10 // Copyright (C) 2001-2002 Brookins Consulting. 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 // include_once( "classes/eztexttool.php" );
32 // include_once( "classes/ezcachefile.php" );
33 // include_once( "classes/ezlist.php" );
34
35 // include_once( "eztrade/classes/ezproduct.php" );
36 // include_once( "eztrade/classes/ezproductcategory.php" );
37 // include_once( "eztrade/classes/ezpricegroup.php" );
38
39 // // sections
40 // include_once( "ezsitemanager/classes/ezsection.php" );
41
42
43 if ( $CategoryID != 0 )
44 {
45 $GlobalSectionID = eZProductCategory::sectionIDStatic( $CategoryID );
46 }
47
48 // init the section
49 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
50 $sectionObject->setOverrideVariables();
51
52
53 $ini =& eZINI::instance( 'site.ini' );
54
55 $Language = $ini->variable( "eZTradeMain", "Language" );
56 $Limit = $ini->variable( "eZTradeMain", "ProductGalleryLimit" );
57 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
58 $RequireUserLogin = $ini->variable( "eZTradeMain", "RequireUserLogin" ) == "true";
59 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
60
61 $CapitalizeHeadlines = $ini->variable( "eZArticleMain", "CapitalizeHeadlines" );
62
63 $ThumbnailImageWidth = $ini->variable( "eZTradeMain", "ThumbnailImageWidth" );
64 $ThumbnailImageHeight = $ini->variable( "eZTradeMain", "ThumbnailImageHeight" );
65
66
67 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
68 "kernel/eztrade/user/intl/", $Language, "productgallery.php" );
69
70 $t->set_file( "product_gallery_page_tpl", "productgallery.tpl" );
71
72 //$t->set_block( "product_gallery_page_tpl", "product_catalog_number_tpl", "product_catalog_number" );
73 //$t->set_block( "product_tpl", "product_catalog_number_tpl", "product_catalog_number" );
74
75 $t->set_block( "product_gallery_page_tpl", "price_tpl", "price" );
76 $t->set_block( "product_gallery_page_tpl", "add_to_cart_tpl", "add_to_cart" );
77
78 $t->set_block( "product_gallery_page_tpl", "path_tpl", "path" );
79 $t->set_block( "product_gallery_page_tpl", "product_gallery_tpl", "product_gallery" );
80
81 $t->set_block( "product_gallery_tpl", "product_tpl", "product" );
82 $t->set_block( "product_tpl", "product_image_tpl", "product_image" );
83
84 $t->set_block( "product_tpl", "product_group_begin_tpl", "product_group_begin" );
85 $t->set_block( "product_tpl", "product_group_end_tpl", "product_group_end" );
86
87 $t->set_block( "product_gallery_page_tpl", "category_list_tpl", "category_list" );
88 $t->set_block( "category_list_tpl", "category_tpl", "category" );
89
90 if ( !isSet( $ModuleName ) )
91 $ModuleName = "trade";
92 if ( !isSet( $ModuleList ) )
93 $ModuleList = "productgallery";
94 if ( !isSet( $ModuleView ) )
95 $ModuleView = "productview";
96
97 // makes the section ID available in articleview template
98 $t->set_var( "section_id", $GlobalSectionID );
99
100 $t->set_var( "module", $ModuleName );
101 $t->set_var( "module_list", $ModuleList );
102 $t->set_var( "module_view", $ModuleView );
103
104 $t->setAllStrings();
105
106 $category = new eZProductCategory();
107 $category->get( $CategoryID );
108
109 // path
110 $pathArray = $category->path();
111
112 $t->set_var( "path", "" );
113 foreach ( $pathArray as $path )
114 {
115 $t->set_var( "category_id", $path[0] );
116 $t->set_var( "category_name", $path[1] );
117 $t->parse( "path", "path_tpl", true );
118
119 $SiteTitleAppend .= $path[1] . " - ";
120 }
121
122 $categoryList =& $category->getByParent( $category );
123
124 // categories
125 $i = 0;
126
127 foreach ( $categoryList as $categoryItem )
128 {
129 $t->set_var( "category_id", $categoryItem->id() );
130 $t->set_var( "category_name", $categoryItem->name() );
131 $t->set_var( "category_description", $categoryItem->description() );
132
133 $parent = $categoryItem->parent();
134
135 if ( $categoryItem->parent() != 0 )
136 {
137 $parent = $categoryItem->parent();
138 $t->set_var( "category_parent", $parent->name() );
139 }
140 else
141 {
142 $t->set_var( "category_parent", "&nbsp;" );
143 }
144
145 if ( ( $i % 2 ) == 0 )
146 {
147 $t->set_var( "td_class", "bglight" );
148 }
149 else
150 {
151 $t->set_var( "td_class", "bgdark" );
152 }
153
154 $t->parse( "category", "category_tpl", true );
155 $i++;
156 }
157
158 if ( count( $categoryList ) == 0 )
159 {
160 $t->set_var( "category_list", "" );
161 }
162 else
163 {
164 $t->parse( "category_list", "category_list_tpl" );
165 }
166
167 if ( !isSet( $Limit ) or !is_numeric( $Limit ) )
168 $Limit = 10;
169 if ( !isSet( $Offset ) or !is_numeric( $Offset ) )
170 $Offset = 0;
171
172 // products
173 //$category->setSortMode(2);
174 $category->setSortMode(5);
175 $TotalTypes =& $category->productCount( $category->sortMode(), false );
176 //$productgallery =& $category->activeProducts( $category->sortMode(), $Offset, $Limit );
177 $productgallery =& $category->activeProducts( "alphanumeric_asc", $Offset, $Limit, $category->id() );
178
179 $locale = new eZLocale( $Language );
180 $i = 0;
181 $groupi = 0;
182
183 foreach ( $productgallery as $product )
184 {
185 $t->set_var( "product_id", $product->id() );
186
187 // preview image
188 $thumbnailImage = $product->thumbnailImage();
189
190 if ( $thumbnailImage )
191 {
192 $variation =& $thumbnailImage->requestImageVariation( $ThumbnailImageWidth, $ThumbnailImageHeight );
193
194 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
195 $t->set_var( "thumbnail_image_width", $variation->width() );
196 $t->set_var( "thumbnail_image_height", $variation->height() );
197 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
198
199 $t->parse( "product_image", "product_image_tpl" );
200 }
201 else
202 {
203 $t->set_var( "product_image", "" );
204 }
205
206 $SiteDescriptionOverride .= $product->name() . " ";
207
208 $t->set_var( "product_name", $product->name() );
209
210 $t->set_var( "product_number", "" );
211
212 if ( $product->productNumber() != "" )
213 {
214 $t->set_var( "product_number", $product->productNumber() );
215 // $t->parse( "product_number", "product_number_item_tpl" );
216 }
217
218 $t->set_var( "catalog_number", "" );
219 $t->set_var( "product_catalog_number", "" );
220
221 if ( $product->catalogNumber() != "" )
222 {
223 $t->set_var( "catalog_number", $product->catalogNumber() );
224 $t->parse( "product_catalog_number", "product_catalog_number_tpl" );
225 }
226
227 $t->set_var( "product_intro_text", eZTextTool::nl2br( $product->brief() ) );
228
229 if ( $ShowPrice and $product->showPrice() == true and $product->hasPrice() )
230 {
231 $t->set_var( "product_price", $product->localePrice( $PricesIncludeVAT ) );
232 $priceRange = $product->correctPriceRange( $PricesIncludeVAT );
233
234 if ( ( empty( $priceRange["min"] ) and empty( $priceRange["max"] ) ) and !($product->correctPrice( $PricesIncludeVAT ) > 0) )
235 {
236 $t->set_var( "product_price", "" );
237 }
238 $t->parse( "price", "price_tpl" );
239 }
240 elseif( $product->showPrice() == false )
241 {
242 $t->set_var( "product_price", "" );
243 $t->parse( "price", "price_tpl" );
244 }
245 else
246 {
247 $priceArray = "";
248 $options =& $product->options();
249 if ( count( $options ) == 1 )
250 {
251 $option = $options[0];
252 if ( get_class( $option ) == "ezoption" )
253 {
254 $optionValues =& $option->values();
255 if ( count( $optionValues ) > 1 )
256 {
257 $i=0;
258 foreach ( $optionValues as $optionValue )
259 {
260 $priceArray[$i] = $optionValue->localePrice( $PricesIncludeVAT, $product );
261 $i++;
262 }
263 $high = max( $priceArray );
264 $low = min( $priceArray );
265
266 $t->set_var( "product_price", $low . " - " . $high );
267
268 $t->parse( "price", "price_tpl" );
269
270 }
271 }
272 }
273 else
274 $t->set_var( "price", "" );
275 }
276
277 $t->set_var( "category_id", $category->id() );
278
279 $galleryarraysize = sizeof($productgallery) - 1;
280 $groupi_size = $groupi; // - 1;
281 $groupitemnumber = 3;
282 $groupitempreceeding = $groupitemnumber - 1;
283
284 if ( $i == 0 )
285 {
286 $t->parse( "product_group_begin", "product_group_begin_tpl" );
287 $t->set_var( "product_group_end", "" );
288 }
289 elseif ( $i == $galleryarraysize ) {
290 $t->parse( "product_group_end", "product_group_end_tpl" );
291 $t->set_var( "product_group_begin", "" );
292 }
293 elseif ( $groupi_size == $groupitempreceeding ) {
294 $t->parse( "product_group_end", "product_group_end_tpl" );
295 $t->set_var( "product_group_begin", "" );
296 }
297 elseif ( $groupi_size == $groupitemnumber ) {
298 $groupi = 0;
299 $t->parse( "product_group_begin", "product_group_begin_tpl" );
300 $t->set_var( "product_group_end", "" );
301 }
302 else
303 {
304 /* Debug */
305 /*
306 $t->set_var( "product_group_begin", "$i / $groupi<br />" );
307 $t->set_var( "product_group_end", "$i / $groupi<br />" );
308 */
309 $t->set_var( "product_group_begin", "" );
310 $t->set_var( "product_group_end", "" );
311 }
312
313 if ( ( $i % 2 ) == 0 )
314 {
315 $t->set_var( "td_class", "bglight" );
316 }
317 else
318 {
319 $t->set_var( "td_class", "bgdark" );
320 }
321
322 $t->set_var( "action_url", "cart/add" );
323 $t->parse( "add_to_cart", "add_to_cart_tpl" );
324
325 $t->parse( "product", "product_tpl", true );
326 $i++;
327 $groupi++;
328 }
329
330 if ( count( $productgallery ) > 0 )
331 {
332 $t->parse( "product_gallery", "product_gallery_tpl" );
333 }
334 else
335 {
336 $t->set_var( "product_gallery", "<div>No Products</div>" );
337 }
338
339 eZList::drawNavigator( $t, $TotalTypes, $Limit, $Offset, "product_gallery_page_tpl" );
340
341
342 if ( $GenerateStaticPage == true )
343 {
344 if ( $user )
345 $CategoryArray =& $user->groups( false );
346 $cache = new eZCacheFile( "kernel/eztrade/cache/", array( "productgallery", $CategoryArray, $Offset, $PriceGroup ),
347 "cache", "," );
348
349 // add PHP code in the cache file to store variables
350 $output = "<?php\n";
351 $output .= "\$GlobalSectionID=\"$GlobalSectionID\";\n";
352 $output .= "\$SiteTitleAppend=\"$SiteTitleAppend\";\n";
353 $output .= "\$SiteDescriptionOverride=\"$SiteDescriptionOverride\";\n";
354 $output .= "?>\n";
355
356 $output = $t->parse( "output", "product_gallery_page_tpl" );
357 print( $output );
358 $CacheFile->store( $output );
359 }
360 else
361 {
362 $t->pparse( "output", "product_gallery_page_tpl" );
363 }
364
365 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZProductCategory
Definition: ezproductcategory.php:90
eZProductCategory\sectionIDStatic
static sectionIDStatic( $categoryID)
Definition: ezproductcategory.php:394
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZTemplate
Definition: eztemplate.php:107
eZTextTool\nl2br
static nl2br( $string, $xhtml=true)
Definition: eztexttool.php:65
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$ModuleName
$ModuleName
Definition: ezarticle/user/searchsupplier.php:30
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$priceRange
$priceRange
Definition: eztrade/user/extendedsearch.php:85
$output
$output
Definition: formpreview.php:81
$product
$product
Definition: homepage.php:202
$ModuleList
$ModuleList
Definition: hotdealslist.php:87
$options
$options
Definition: optionlist.php:56
$PriceGroup
$PriceGroup
Definition: productedit.php:1073
$productgallery
$productgallery
Definition: productgallery.php:177
$ThumbnailImageHeight
$ThumbnailImageHeight
Definition: productgallery.php:64
$Limit
$Limit
Definition: productgallery.php:56
$category
$category
Definition: productgallery.php:106
$groupi
$groupi
Definition: productgallery.php:181
$locale
$locale
Definition: productgallery.php:179
$t
$t
Definition: productgallery.php:67
$sectionObject
if( $CategoryID !=0) $sectionObject
Definition: productgallery.php:49
$TotalTypes
$TotalTypes
Definition: productgallery.php:175
$PricesIncludeVAT
$PricesIncludeVAT
Definition: productgallery.php:59
$pathArray
$pathArray
Definition: productgallery.php:110
$i
$i
Definition: productgallery.php:125
$Language
$Language
Definition: productgallery.php:55
$ini
$ini
Definition: productgallery.php:53
$ShowPriceGroups
$ShowPriceGroups
Definition: productgallery.php:57
$categoryList
foreach( $pathArray as $path) $categoryList
Definition: productgallery.php:122
$CapitalizeHeadlines
$CapitalizeHeadlines
Definition: productgallery.php:61
$ThumbnailImageWidth
$ThumbnailImageWidth
Definition: productgallery.php:63
$RequireUserLogin
$RequireUserLogin
Definition: productgallery.php:58
$ShowPrice
$ShowPrice
Definition: productpreview.php:48
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$user
$user
Definition: user/adlist.php:39
$SiteTitleAppend
$SiteTitleAppend
Definition: user/articlelist.php:212
$SiteDescriptionOverride
$SiteDescriptionOverride
Definition: user/articlelist.php:383
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.