Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

productview.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: productview.php 9895 2004-04-06 11:08:44Z br $
5 //
6 // Created on: <24-Sep-2000 12:20:32 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 // include_once( "classes/eztexttool.php" );
32
33 // include_once( "eztrade/classes/ezproduct.php" );
34 // include_once( "eztrade/classes/ezproductcategory.php" );
35 // include_once( "eztrade/classes/ezoption.php" );
36 // include_once( "eztrade/classes/ezpricegroup.php" );
37 // include_once( "eztrade/classes/ezproductcurrency.php" );
38 // include_once( "eztrade/classes/ezproductpermission.php" );
39 // include_once( "eztrade/classes/ezproductpricerange.php" );
40 // include_once( "ezuser/classes/ezuser.php" );
41
42 // include_once( "classes/ezmodulelink.php" );
43 // include_once( "classes/ezlinksection.php" );
44 // include_once( "classes/ezlinkitem.php" );
45
46 $ini =& eZINI::instance( 'site.ini' );
47
48 $Language = $ini->variable( "eZTradeMain", "Language" );
49 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
50 $RequireUserLogin = $ini->variable( "eZTradeMain", "RequireUserLogin" ) == "true";
51 $SimpleOptionHeaders = $ini->variable( "eZTradeMain", "SimpleOptionHeaders" ) == "true";
52 $ShowQuantity = $ini->variable( "eZTradeMain", "ShowQuantity" ) == "true";
53 $ShowNamedQuantity = $ini->variable( "eZTradeMain", "ShowNamedQuantity" ) == "true";
54 $RequireQuantity = $ini->variable( "eZTradeMain", "RequireQuantity" ) == "true" ;
55 $ShowOptionQuantity = $ini->variable( "eZTradeMain", "ShowOptionQuantity" ) == "true";
56 $PurchaseProduct = $ini->variable( "eZTradeMain", "PurchaseProduct" ) == "true" ? true : false;
57 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
58 $locale = new eZLocale( $Language );
59
60 $AdminSiteURL = $ini->variable( "site", "AdminSiteURL" );
61 $SiteURL = $ini->variable( "site", "UserSiteURL" );
62
63 if ( isset( $CategoryID ) )
64 $categoryID = $CategoryID;
65 else
66 $categoryID = 0;
67
68 $product = new eZProduct();
69
70 if ( isset( $ProductID ) && !$product->get( $ProductID, $categoryID ) )
71 {
72 if ( $product->get( $ProductID ) )
73 {
74 eZHTTPTool::header( "Location: /error/403/" );
75 }
76 else
77 {
78 eZHTTPTool::header( "Location: /error/404/" );
79 }
80 exit();
81 }
82
83 if ( !isset( $CategoryID ) )
84 {
85 $category = $product->categoryDefinition();
86 }
87 else
88 {
89 $category = new eZProductCategory();
90 $category->get( $CategoryID );
91 }
92
93 $CapitalizeHeadlines = $ini->variable( "eZArticleMain", "CapitalizeHeadlines" );
94
95 $MainImageWidth = $ini->variable( "eZTradeMain", "MainImageWidth" );
96 $MainImageHeight = $ini->variable( "eZTradeMain", "MainImageHeight" );
97
98 $SmallImageWidth = $ini->variable( "eZTradeMain", "SmallImageWidth" );
99 $SmallImageHeight = $ini->variable( "eZTradeMain", "SmallImageHeight" );
100
101
102 // sections
103 // include_once( "ezsitemanager/classes/ezsection.php" );
104
105 $GlobalSectionID = eZProductCategory::sectionIDStatic( $category->id() );
106
107 // init the section
108 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
109 $sectionObject->setOverrideVariables();
110
111
112 $user =& eZUser::currentUser();
113
114
115 if ( !eZObjectPermission::hasPermission( $category->id(), "trade_category", "r", $user ) )
116 {
117 eZHTTPTool::header( "Location: /trade/productlist/0/" );
118 exit();
119 }
120
121 if ( !isset( $IntlDir ) )
122 $IntlDir = "kernel/eztrade/user/intl";
123 if ( !isset( $IniFile ) )
124 $IniFile = "productview.php";
125
126 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ),
127 $IntlDir, $Language, $IniFile );
128
129 $t->setAllStrings();
130
131 if ( !isset( $productview ) )
132 $productview = "productview.tpl";
133
134 if ( isset( $template_array ) and isset( $variable_array ) and
135 is_array( $template_array ) and is_array( $variable_array ) )
136 {
137 $standard_array = array( "product_view_tpl" => $productview );
138 $temp_arr = array_merge( $standard_array, $template_array );
139 $t->set_file( $temp_arr );
140 $t->set_file_block( $template_array );
141 if ( isset( $block_array ) and is_array( $block_array ) )
142 $t->set_block( $block_array );
143 $t->parse( $variable_array );
144 }
145 else
146 {
147 $t->set_var( "extra_product_info", "" );
148 $t->set_file( "product_view_tpl", $productview );
149 }
150
151 // begin inline edit mod RBS
152
153 $t->set_block( "product_view_tpl", "user_login_tpl", "user_login" );
154
155 $t->set_var( "admin_site", "http://$AdminSiteURL" );
156
157 if ( $user && ( eZPermission::checkPermission( $user, "eZTrade", "WriteToRoot" ) ) )
158 {
159 $t->parse( "user_login", "user_login_tpl" );
160 }
161 else
162 {
163 $t->set_var( "user_login", "" );
164 }
165 //end inline edit mod RBS
166
167 // $t->set_file( array(
168 // "product_view_tpl" => "productview.tpl"
169 // ) );
170
171 $t->set_block( "product_view_tpl", "shipping_message_tpl", "shipping_message" );
172 $t->set_block( "shipping_message_tpl", "free_ups_tpl", "free_ups" );
173 $t->set_block( "shipping_message_tpl", "free_usps_tpl", "free_usps" );
174 $t->set_block( "shipping_message_tpl", "flat_ups_tpl", "flat_ups" );
175 $t->set_block( "shipping_message_tpl", "flat_usps_tpl", "flat_usps" );
176 $t->set_block( "shipping_message_tpl", "flat_ups_combine_tpl", "flat_ups_combine" );
177 $t->set_block( "shipping_message_tpl", "flat_usps_combine_tpl", "flat_usps_combine" );
178
179 $t->set_block( "product_view_tpl", "product_number_item_tpl", "product_number_item" );
180 $t->set_block( "product_view_tpl", "price_tpl", "price" );
181 $t->set_block( "product_view_tpl", "list_price_tpl", "list_price" );
182
183 $t->set_block( "product_view_tpl", "price_to_high_tpl", "price_to_high" );
184 $t->set_block( "product_view_tpl", "price_to_low_tpl", "price_to_low" );
185
186 $t->set_block( "product_view_tpl", "attached_file_list_tpl", "attached_file_list" );
187 $t->set_block( "attached_file_list_tpl", "attached_file_tpl", "attached_file" );
188
189 $t->set_block( "product_view_tpl", "price_range_tpl", "price_range" );
190 $t->set_block( "product_view_tpl", "mail_method_tpl", "mail_method" );
191 $t->set_block( "price_range_tpl", "price_range_min_unlimited_tpl", "price_range_min_unlimited" );
192 $t->set_block( "price_range_tpl", "price_range_min_limited_tpl", "price_range_min_limited" );
193 $t->set_block( "price_range_tpl", "price_range_max_unlimited_tpl", "price_range_max_unlimited" );
194 $t->set_block( "price_range_tpl", "price_range_max_limited_tpl", "price_range_max_limited" );
195
196 $t->set_block( "price_tpl", "alternative_currency_list_tpl", "alternative_currency_list" );
197 $t->set_block( "alternative_currency_list_tpl", "alternative_currency_tpl", "alternative_currency" );
198
199 $t->set_block( "product_view_tpl", "quantity_item_tpl", "quantity_item" );
200 $t->set_block( "product_view_tpl", "date_available_tpl", "date_available" );
201 $t->set_block( "product_view_tpl", "add_to_cart_tpl", "add_to_cart" );
202 $t->set_block( "product_view_tpl", "voucher_buttons_tpl", "voucher_buttons" );
203 $t->set_block( "product_view_tpl", "path_tpl", "path" );
204 $t->set_block( "product_view_tpl", "image_list_tpl", "image_list" );
205
206 $t->set_block( "image_list_tpl", "image_tpl", "image" );
207 $t->set_block( "product_view_tpl", "main_image_tpl", "main_image" );
208 $t->set_block( "product_view_tpl", "option_tpl", "option" );
209 $t->set_block( "option_tpl", "value_price_header_tpl", "value_price_header" );
210 $t->set_block( "option_tpl", "value_tpl", "value" );
211
212 $t->set_block( "value_price_header_tpl", "value_description_header_tpl", "value_description_header" );
213 $t->set_block( "value_price_header_tpl", "value_price_header_item_tpl", "value_price_header_item" );
214 $t->set_block( "value_price_header_tpl", "value_currency_header_item_tpl", "value_currency_header_item" );
215
216 $t->set_block( "value_tpl", "value_description_tpl", "value_description" );
217 $t->set_block( "value_tpl", "value_price_item_tpl", "value_price_item" );
218 $t->set_block( "value_tpl", "value_availability_item_tpl", "value_availability_item" );
219 $t->set_block( "value_tpl", "value_price_currency_list_tpl", "value_price_currency_list" );
220
221 $t->set_block( "value_price_currency_list_tpl", "value_price_currency_item_tpl", "value_price_currency_item" );
222 $t->set_block( "product_view_tpl", "external_link_tpl", "external_link" );
223 $t->set_block( "product_view_tpl", "attribute_list_tpl", "attribute_list" );
224
225 $t->set_block( "attribute_list_tpl", "attribute_tpl", "attribute" );
226 $t->set_block( "attribute_list_tpl", "attribute_value_tpl", "attribute_value" );
227 $t->set_block( "attribute_list_tpl", "attribute_header_tpl", "attribute_header" );
228
229 $t->set_block( "product_view_tpl", "numbered_page_link_tpl", "numbered_page_link" );
230 $t->set_block( "product_view_tpl", "print_page_link_tpl", "print_page_link" );
231 $t->set_block( "product_view_tpl", "section_item_tpl", "section_item" );
232
233 $t->set_block( "section_item_tpl", "link_item_tpl", "link_item" );
234
235 if ( !isset( $ModuleName ) )
236 $ModuleName = "trade";
237 if ( !isset( $ModuleList ) )
238 $ModuleList = "productlist";
239 if ( !isset( $ModuleView ) )
240 $ModuleView = "productview";
241 if ( !isset( $ModulePrint ) )
242 $ModulePrint = "productprint";
243
244 // Add Product Information into Site / Page Title
245 // escape product names with quotes (kicks new error) re: htmlspecialchars are not search engine friendly
246 $SiteTitleAppend = $product->name();
247 $SiteTitleAppend .= " - ". $product->productNumber();
248
249 $t->set_var( "module", $ModuleName );
250 $t->set_var( "module_list", $ModuleList );
251 $t->set_var( "module_view", $ModuleView );
252 $t->set_var( "module_print", $ModulePrint );
253 $t->set_var( "product_category_id", $categoryID );
254 $t->set_var( "attribute_header", "" );
255 $t->set_var( "attribute_value", "" );
256 $t->set_var( "price_range", "" );
257 $t->set_var( "price_to_high", "" );
258 $t->set_var( "price_to_low", "" );
259
260 $MailMethod = 1;
261
262 if ($product->flatUSPS() != 'off') {
263 if (0 == $product->flatUSPS()) {
264 $t->set_var( "flat_usps_combine", "");
265 $t->set_var( "flat_usps", "");
266 $t->parse("free_usps", "free_usps_tpl");
267 } elseif ($product->flatCombine()) {
268 $t->set_var("free_usps", "");
269 $t->set_var("flat_usps", "");
270 $t->set_var ("flat_usps_price", $product->flatUSPS() );
271 $t->parse("flat_usps_combine", "flat_usps_combine_tpl");
272 } else {
273 $t->set_var("free_usps", "");
274 $t->set_var("flat_usps_combine", "");
275 $t->set_var ("flat_usps_price", $product->flatUSPS() );
276 $t->parse("flat_usps", "flat_usps_tpl");
277 }
278 } else {
279 $t->set_var("free_usps", "");
280 $t->set_var("flat_usps", "");
281 $t->set_var("flat_usps_combine", "");
282 }
283 if ($product->flatUPS() != 'off') {
284 if (0 == $product->flatUPS()) {
285 $t->set_var( "flat_ups_combine", "");
286 $t->set_var( "flat_ups", "");
287 $t->parse("free_ups", "free_ups_tpl");
288 } elseif ($product->flatCombine()) {
289 $t->set_var( "free_ups", "");
290 $t->set_var( "flat_ups", "");
291 $t->set_var ("flat_ups_price", $product->flatUPS() );
292 $t->parse("flat_ups_combine", "flat_ups_combine_tpl");
293 } else {
294 $t->set_var( "free_ups", "");
295 $t->set_var( "flat_ups_combine", "");
296 $t->set_var ("flat_ups_price", $product->flatUPS() );
297 $t->parse("flat_ups", "flat_ups_tpl");
298 }
299 } else {
300 $t->set_var("free_ups", "");
301 $t->set_var("flat_ups", "");
302 $t->set_var("flat_ups_combine", "");
303 }
304
305
306 if ($product->flatUPS() != 'off' || $product->flatUSPS() != 'off')
307 {
308 $t->parse("shipping_message", "shipping_message_tpl");
309 } else {
310 $t->set_var("shipping_message", "");
311 }
312
313 if ( !$product->showProduct() )
314 {
315 eZHTTPTool::header( "Location: /error/404/" );
316 echo "Sorry, this product is not currently available.";
317 exit();
318 }
319
320 if ( isset ( $Voucher ) )
321 {
322 $range = $product->priceRange();
323
324 if ( isset( $_REQUEST['PriceRange'] ) )
325 $PriceRange = $_REQUEST['PriceRange'];
326 else
327 $PriceRange = $range->min();
328
329 $error = false;
330 if ( ( $range->min() != 0 ) && ( $range->min() > $PriceRange ) )
331 {
332 $error = true;
333 $t->parse( "price_to_low", "price_to_low_tpl" );
334 }
335 if ( ( $range->max() != 0 ) && ( $range->max() < $PriceRange ) )
336 {
337 $error = true;
338 $t->parse( "price_to_high", "price_to_high_tpl" );
339 }
340
341 if ( !$error )
342 {
343 eZHTTPTool::header( "Location: /trade/voucherinformation/$ProductID/$PriceRange/$MailMethod/" );
344 exit();
345 }
346 }
347 else
348 $session->setVariable( "VoucherInformationID", 0 );
349
350 $pathArray =& $category->path();
351
352 $t->set_var( "path", "" );
353 foreach ( $pathArray as $path )
354 {
355 $t->set_var( "category_id", $path[0] );
356 $t->set_var( "category_name", $path[1] );
357
358 $t->parse( "path", "path_tpl", true );
359 }
360
361 $mainImage = $product->mainImage();
362 $mainImageID = false;
363
364 if ( $mainImage )
365 {
366 $variation = $mainImage->requestImageVariation( $MainImageWidth, $MainImageHeight );
367
368 $t->set_var( "main_image_id", $mainImage->id() );
369 $t->set_var( "main_image_uri", "/" . $variation->imagePath() );
370 $t->set_var( "main_image_width", $variation->width() );
371 $t->set_var( "main_image_height", $variation->height() );
372 $t->set_var( "main_image_caption", $mainImage->caption() );
373
374 if ( $mainImage->caption() != "" )
375 {
376 $t->set_var( "main_image_caption", $mainImage->caption() );
377 } else {
378 $t->set_var( "main_image_caption", "&nbsp;" );
379 }
380 $mainImageID = $mainImage->id();
381
382 $t->parse( "main_image", "main_image_tpl" );
383 }
384 else
385 {
386 $t->set_var( "main_image", "" );
387 }
388
389 if ( $CapitalizeHeadlines == "enabled" )
390 {
391 // include_once( "classes/eztexttool.php" );
392 $t->set_var( "title_text", eZTextTool::capitalize( $product->name() ) );
393 }
394 else
395 {
396 $t->set_var( "title_text", $product->name() );
397 }
398 $t->set_var( "intro_text", $product->brief() );
399 $t->set_var( "description_text", $product->description() );
400
401 if ( $product->productType() == 2 )
402 {
403 $useVoucher = true;
404 $t->set_var( "action_url", "productview" );
405 }
406 else
407 {
408 $useVoucher = false;
409 $t->set_var( "action_url", "cart/add" );
410 }
411
412 $images = $product->images();
413
414 $i = 0;
415 $t->set_var( "image", "" );
416 $t->set_var( "image_list", "" );
417 $image_count = 0;
418
419 foreach ( $images as $imageArray )
420 {
421 $image = $imageArray["Image"];
422 if ( $image->id() != $mainImageID )
423 {
424
425 if ( ( $i % 2 ) == 0 )
426 {
427 $t->set_var( "td_class", "bglight" );
428 }
429 else
430 {
431 $t->set_var( "td_class", "bgdark" );
432 }
433
434 $t->set_var( "image_name", $image->name() );
435
436 $t->set_var( "image_title", $image->name() );
437 $t->set_var( "image_caption", eZTextTool::nl2br( $image->caption() ) );
438 $t->set_var( "image_id", $image->id() );
439 $t->set_var( "product_id", $ProductID );
440
441 $variation = $image->requestImageVariation( $SmallImageWidth, $SmallImageHeight );
442
443 $t->set_var( "image_url", "/" .$variation->imagePath() );
444 $t->set_var( "image_width", $variation->width() );
445 $t->set_var( "image_height", $variation->height() );
446
447 $t->parse( "image", "image_tpl", true );
448
449 $image_count++;
450 $i++;
451 }
452 }
453
454 if ( $image_count > 0 )
455 $t->parse( "image_list", "image_list_tpl" );
456
457 $options = $product->options();
458 $t->set_var( "option", "" );
459
460 $t->set_var( "value_price_header", "" );
461 if ( $ShowPrice and $product->showPrice() == true )
462 $t->parse( "value_price_header", "value_price_header_tpl" );
463
464 // show alternative currencies
465 $currency = new eZProductCurrency( );
466 $currencies =& $currency->getAll();
467 $t->set_var( "currency_count", count( $currencies ) );
468 $t->set_var( "value_price_header_item", "" );
469 $t->set_var( "value_currency_header_item", "" );
470 if ( !$RequireUserLogin or is_a( $user, "eZUser" ) )
471 {
472 $t->parse( "value_price_header_item", "value_price_header_item_tpl" );
473 if ( count( $currencies ) > 0 )
474 $t->parse( "value_currency_header_item", "value_currency_header_item_tpl" );
475 }
476
477 $can_checkout = true;
478
479 $currency_locale = new eZLocale( $Language );
480 foreach ( $options as $option )
481 {
482 $values = $option->values();
483
484 $t->set_var( "value", "" );
485 $i = 0;
486 $headers = $option->descriptionHeaders();
487 $t->set_var( "value_description_header", "" );
488 if ( $SimpleOptionHeaders )
489 {
490 $t->set_var( "description_header", $headers[0] );
491 $t->parse( "value_description_header", "value_description_header_tpl" );
492 }
493 else
494 {
495 foreach ( $headers as $header )
496 {
497 $t->set_var( "description_header", $header );
498 $t->parse( "value_description_header", "value_description_header_tpl", true );
499 }
500 }
501
502 foreach ( $values as $value )
503 {
504 $value_quantity = $value->totalQuantity();
505 if ( $ShowOptionQuantity or ( is_bool( $value_quantity ) and !$value_quantity ) or
506 !$RequireQuantity or ( $RequireQuantity and $value_quantity > 0 ) )
507 {
508 if ( !$value->hasQuantity( $RequireQuantity ) )
509 $can_checkout = false;
510 $t->set_var( "value_td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
511 $id = $value->id();
512
513 $descriptions = $value->descriptions();
514 $t->set_var( "value_description", "" );
515 if ( $SimpleOptionHeaders )
516 {
517 $t->set_var( "value_id", $value->id() );
518
519 $t->set_var( "value_name", $descriptions[0] );
520 $t->parse( "value_description", "value_description_tpl" );
521 }
522 else
523 {
524 foreach ( $descriptions as $description )
525 {
526 $t->set_var( "value_name", $description );
527 $t->parse( "value_description", "value_description_tpl", true );
528 }
529 }
530
531 $t->set_var( "value_price", "" );
532 $t->set_var( "value_price_item", "" );
533 $t->set_var( "value_price_currency_list", "" );
534 if ( $ShowPrice and $product->showPrice() == true )
535 {
536 $price = new eZCurrency( $value->correctPrice( $PricesIncludeVAT, $product ) );
537 if ( $value->price() != 0 )
538 $t->set_var( "value_price", "+".$value->localePrice( $PricesIncludeVAT, $product ) );
539 else
540 $t->set_var( "value_price", "" );
541
542 $t->parse( "value_price_item", "value_price_item_tpl" );
543
544 $t->set_var( "value_price_currency_item", "" );
545 foreach ( $currencies as $currency )
546 {
547 $altPrice = $price;
548 $altPrice->setValue( $price->value() * $currency->value() );
549
550 $currency_locale->setSymbol( $currency->sign() );
551 $currency_locale->setPrefixSymbol( $currency->prefixSign() );
552
553 $t->set_var( "alt_value_price", $currency_locale->format( $altPrice ) );
554 $t->parse( "value_price_currency_item", "value_price_currency_item_tpl", true );
555 }
556
557 $t->set_var( "value_price_currency_list", "" );
558 if ( count( $currencies ) > 0 )
559 $t->parse( "value_price_currency_list", "value_price_currency_list_tpl" );
560 }
561
562 $t->set_var( "value_availability_item", "" );
563 if ( !( is_bool( $value_quantity ) and !$value_quantity ) )
564 {
565 $named_quantity = $value_quantity;
566 if ( $ShowNamedQuantity )
567 $named_quantity = eZProduct::namedQuantity( $value_quantity );
568 $t->set_var( "value_availability", $named_quantity );
569 $t->parse( "value_availability_item", "value_availability_item_tpl" );
570 }
571
572 $t->parse( "value", "value_tpl", true );
573 $i++;
574 }
575 }
576
577 if ( $i > 0 )
578 {
579 $t->set_var( "option_name", $option->name() );
580 $t->set_var( "option_description", $option->description() );
581 $t->set_var( "option_id", $option->id() );
582 $t->set_var( "product_id", $ProductID );
583
584 $t->parse( "option", "option_tpl", true );
585 }
586 }
587
588 if ( !$product->hasQuantity( $RequireQuantity ) )
589 $can_checkout = false;
590
591 // $can_checkout = $product->showPrice();
592
593 // link list
594 $module_link = new eZModuleLink( "eZTrade", "Product", $product->id() );
595 $sections =& $module_link->sections();
596 $t->set_var( "section_item", "" );
597 foreach ( $sections as $section )
598 {
599 $t->set_var( "link_item", "" );
600 $t->set_var( "section_name", $section->name() );
601 $t->set_var( "section_id", $section->id() );
602 $links =& $section->links();
603 $i = 0;
604 foreach ( $links as $link )
605 {
606 $t->set_var( "td_class", ($i % 2) == 0 ? "bglight" : "bgdark" );
607 $t->set_var( "link_name", $link->name() );
608 $t->set_var( "link_url", $link->url() );
609 $t->set_var( "link_id", $link->id() );
610 $t->parse( "link_item", "link_item_tpl", true );
611 ++$i;
612 }
613 $t->parse( "section_item", "section_item_tpl", true );
614 }
615
616 // attribute list
617 $type = $product->type();
618 if ( $type )
619 {
620 $attributes = $type->attributes();
621 for ( $i = 0; $i < count( $attributes ); $i++ )
622 {
623 if ( ( $i % 2 ) == 0 )
624 {
625 $t->set_var( "begin_tr", "<tr>" );
626 $t->set_var( "end_tr", "" );
627 }
628 else
629 {
630 $t->set_var( "begin_tr", "" );
631 $t->set_var( "end_tr", "</tr>" );
632 }
633
634 $value =& $attributes[$i]->value( $product );
635 $t->set_var( "attribute_id", $attributes[$i]->id( ) );
636 $t->set_var( "attribute_name", $attributes[$i]->name( ) );
637 $t->set_var( "attribute_unit", $attributes[$i]->unit( ) );
638 $t->set_var( "attribute_value_var", $value );
639
640 if ( $attributes[$i]->attributeType() == 1 )
641 {
642 // don''t who empty attributes or attributes == 0.0
643 if ( ( is_numeric( $value ) and ( $value > 0 ) ) || ( !is_numeric( $value ) and $value != "" ) )
644 {
645 $t->parse( "attribute", "attribute_value_tpl", true );
646 }
647 }
648 else if ( $attributes[$i]->attributeType() == 2 )
649 {
650 $j = $i;
651 $header = false;
652 for ( $j++; $j < count( $attributes ); $j++ )
653 {
654 if ( $attributes[$j]->attributeType() == 2 )
655 break;
656 $value =& $attributes[$j]->value( $product );
657 if ( ( is_numeric( $value ) and ( $value > 0 ) ) || ( !is_numeric( $value ) and $value != "" ) )
658 {
659 $t->parse( "attribute", "attribute_header_tpl", true );
660 break;
661 }
662 }
663 }
664 }
665 }
666
667 if ( isset( $attributes ) && count( $attributes ) > 0 )
668 {
669 $t->parse( "attribute_list", "attribute_list_tpl" );
670 }
671 else
672 {
673 $t->set_var( "attribute_list", "" );
674 }
675
676
677 $t->set_var( "product_id", $product->id() );
678
679 if ( trim( $product->externalLink() ) != "" )
680 {
681 $t->set_var( "external_link_url", "http://" . $product->externalLink() );
682 $t->parse( "external_link", "external_link_tpl" );
683 }
684 else
685 {
686 $t->set_var( "external_link", "" );
687 $t->set_var( "external_link_url", "" );
688 $t->parse( "external_link", "external_link_tpl" );
689 }
690
691 $t->set_var( "product_number_item", "" );
692 if ( $product->productNumber() != "" )
693 {
694 $t->set_var( "product_number", $product->productNumber() );
695 $t->parse( "product_number_item", "product_number_item_tpl" );
696 }
697
698 $t->set_var( "product_catalog_number_item", "" );
699 if ( $product->catalogNumber() != "" )
700 {
701 $t->set_var( "product_catalog_number", $product->catalogNumber() );
702 $t->parse( "product_catalog_number_item", "product_catalog_number_item_tpl" );
703 }
704
705
706 $Quantity = $product->totalQuantity();
707 if ( is_bool( $Quantity ) and !$Quantity )
708 $ShowQuantity = false;
709 $t->set_var( "quantity_item", "" );
710
711 if ( $ShowQuantity and $product->hasPrice() )
712 {
713 $NamedQuantity = $Quantity;
714 if ( $ShowNamedQuantity )
715 {
716 $NamedQuantity = eZProduct::namedQuantity( $Quantity );
717 }
718 $t->set_var( "product_quantity", $NamedQuantity );
719 $t->parse( "quantity_item", "quantity_item_tpl" );
720 }
721
722 $t->set_var( "date_available", "" );
723
724 if ( $product->stockDate() && $NamedQuantity == 0 )
725 {
726 $Stock = new eZDate();
727 $Stock->setTimeStamp( $product->stockDate() );
728 $t->set_var( "date_available", $locale->format( $Stock ) );
729 $t->parse( "date_available", "date_available_tpl" );
730 }
731
732 $t->set_var( "price", "" );
733 $t->set_var( "list_price", "" );
734 $t->set_var( "product_list_price", "" );
735 $t->set_var( "add_to_cart", "" );
736 $t->set_var( "voucher_buttons", "" );
737
738 if ( $product->listPrice() && $product->listPrice() > 0 )
739 {
740 $currency = new eZCurrency();
741 $currency->setValue( $product->listPrice() );
742 $t->set_var( "product_list_price", $locale->format( $currency ) );
743 $t->parse( "list_price", "list_price_tpl", true );
744 }
745
746 if ( $ShowPrice and $product->showPrice() == true and $product->hasPrice() )
747 {
748 $currency = new eZCurrency();
749 $currency->setValue( $product->correctPrice( $PricesIncludeVAT ) );
750 $t->set_var( "product_price", $locale->format( $currency ) );
751
752 // $t->set_var( "product_price", $product->localePrice( $PricesIncludeVAT ) );
753
754 $price = new eZCurrency( $product->correctPrice( $PricesIncludeVAT ) );
755
756 // show alternative currencies
757
758 $currency = new eZProductCurrency( );
759 $currencies =& $currency->getAll();
760
761 if ( $product->hasOptions() )
762 {
763 $priceRange = $product->correctPriceRange( $PricesIncludeVAT );
764
765 foreach ( $currencies as $currency )
766 {
767 $altMinPrice = $price;
768 $altMaxPrice = $price;
769
770 $altMinPrice->setValue( $priceRange["min"] * $currency->value() );
771 $altMaxPrice->setValue( $priceRange["max"] * $currency->value() );
772
773 $locale->setSymbol( $currency->sign() );
774
775 if ( $currency->prefixSign() )
776 {
777 $locale->setPrefixSymbol( true );
778 }
779 else
780 {
781 $locale->setPrefixSymbol( false );
782 }
783
784 $t->set_var( "alt_price", $locale->format( $altMinPrice ) . " - " . $locale->format( $altMaxPrice ) );
785 $t->parse( "alternative_currency", "alternative_currency_tpl", true );
786 }
787 }
788 else
789 {
790 foreach ( $currencies as $currency )
791 {
792 $altPrice = $price;
793 $altPrice->setValue( $price->value() * $currency->value() );
794
795 $locale->setSymbol( $currency->sign() );
796
797 if ( $currency->prefixSign() )
798 {
799 $locale->setPrefixSymbol( true );
800 }
801 else
802 {
803 $locale->setPrefixSymbol( false );
804 }
805
806 $t->set_var( "alt_price", $locale->format( $altPrice ) );
807
808 $t->parse( "alternative_currency", "alternative_currency_tpl", true );
809 }
810 }
811
812 if ( count( $currencies ) > 0 )
813 {
814 $t->parse( "alternative_currency_list", "alternative_currency_list_tpl" );
815 }
816 else
817 {
818 $t->set_var( "alternative_currency_list", "" );
819 }
820
821 $t->set_var( "price_range", "" );
822 $t->set_var( "mail_method", "" );
823 $t->parse( "price", "price_tpl" );
824 }
825 else
826 {
827 $t->set_var( "price_range", "" );
828 $t->set_var( "mail_method", "" );
829
830 $priceRange =& $product->priceRange();
831 $currency = new eZCurrency( );
832
833 if ( ( is_a ( $priceRange, "eZProductPriceRange" ) ) && is_numeric ( $priceRange->id() ) )
834 {
835 $min = $priceRange->min();
836 $max = $priceRange->max();
837 if ( $min )
838 {
839 $currency->setValue( $min );
840 $t->set_var( "price_min", $locale->format( $currency ) );
841 $t->set_var( "price_range_min_unlimited", "" );
842 $t->parse( "price_range_min_limited", "price_range_min_limited_tpl" );
843 }
844 else
845 {
846 $t->set_var( "price_range_min_limited", "" );
847 $t->parse( "price_range_min_unlimited", "price_range_min_unlimited_tpl" );
848 }
849 if ( $max )
850 {
851 $currency->setValue( $max );
852 $t->set_var( "price_max", $locale->format( $currency ) );
853 $t->set_var( "price_range_max_unlimited", "" );
854 $t->parse( "price_range_max_limited", "price_range_max_limited_tpl" );
855 }
856 else
857 {
858 $t->set_var( "price_range_max_limited", "" );
859 $t->parse( "price_range_max_unlimited", "price_range_max_unlimited_tpl" );
860 }
861
862 $t->parse( "mail_method", "mail_method_tpl" );
863 $t->parse( "price_range", "price_range_tpl" );
864 }
865 }
866
867 if ( ( $PurchaseProduct and !$product->discontinued() and $can_checkout ) and !$useVoucher )
868 $t->parse( "add_to_cart", "add_to_cart_tpl" );
869 if ( ( $PurchaseProduct and !$product->discontinued() and $can_checkout ) and $useVoucher )
870 $t->parse( "voucher_buttons", "voucher_buttons_tpl" );
871 if ( isset( $PrintableVersion ) && $PrintableVersion == "enabled" )
872 {
873 $t->parse( "numbered_page_link", "numbered_page_link_tpl" );
874 $t->set_var( "print_page_link", "" );
875 }
876 else
877 {
878 $t->set_var( "print_page_link", "" );
879 // $t->parse( "print_page_link", "print_page_link_tpl" );
880 $t->set_var( "numbered_page_link", "" );
881 }
882
883 if ( isset( $func_array ) and is_array( $func_array ) )
884 {
885 foreach ( $func_array as $func )
886 {
887 $func( $t, $ProductID );
888 }
889 }
890
891 // files
892 $files = $product->files();
893
894 if ( count( $files ) > 0 )
895 {
896 $i=0;
897 foreach ( $files as $file )
898 {
899 if ( ( $i % 2 ) == 0 )
900 {
901 $t->set_var( "td_class", "bglight" );
902 }
903 else
904 {
905 $t->set_var( "td_class", "bgdark" );
906 }
907
908
909 $t->set_var( "site_protocol", "http://" );
910 $t->set_var( "site_host", $SiteURL );
911
912
913 $t->set_var( "file_id", $file->id() );
914 $t->set_var( "original_file_name", $file->fileName() );
915 $t->set_var( "file_name", $file->name() );
916 $t->set_var( "file_url", $file->name() );
917 $t->set_var( "file_description", $file->description() );
918
919 $size = $file->siFileSize();
920 $t->set_var( "file_size", $size["size-string"] );
921 $t->set_var( "file_unit", $size["unit"] );
922
923
924 $i++;
925 $t->parse( "attached_file", "attached_file_tpl", true );
926 }
927
928 $t->parse( "attached_file_list", "attached_file_list_tpl" );
929 }
930 else
931 $t->set_var( "attached_file_list", "" );
932
933
934 $SiteTitleAppend = $product->name();
935 $SiteDescriptionOverride = str_replace( "\"", "", strip_tags( $product->brief() ) );
936 $SiteKeywordsOverride = str_replace( "\"", "", strip_tags( $product->keywords() ) );
937
938 if ( isset( $GenerateStaticPage ) && $GenerateStaticPage == "true" && !$useVoucher )
939 {
940
941 $title_check_single = strstr( $SiteTitleAppend, "'" );
942 $title_check_double = strstr( $SiteTitleAppend, '"' );
943
944 $template_var = "product_view_tpl";
945
946 // add PHP code in the cache file to store variables
947 $output = "<?php\n";
948 $output .= "\$GlobalSectionID=\"$GlobalSectionID\";\n";
949
950 if ( $title_check_double && !$title_check_single )
951 {
952 $output .= "\$SiteTitleAppend='". $SiteTitleAppend ."';" ."\n";
953 } elseif ( $title_check_single && !$title_check_double ) {
954 $output .= "\$SiteTitleAppend=\"". $SiteTitleAppend ."\";" ."\n";
955 // print ( '$SiteTitleAppend="1-'. $SiteTitleAppend .'";' ."\n" );
956 } else {
957 $output .= "\$SiteTitleAppend='". $SiteTitleAppend ."';" ."\n";
958 // print ( '$SiteTitleAppend="1-'. $SiteTitleAppend .'";' ."\n" );
959 }
960
961 $output .= "\$SiteDescriptionOverride=\"$SiteDescriptionOverride\";\n";
962 $output .= "\$SiteKeywordsOverride=\"$SiteKeywordsOverride\";\n";
963 $output .= "?>\n";
964
965
966 $output .= $t->parse("output", $template_var );
967 // print the output the first time while printing the cache file.
968 print( $output );
969 $CacheFile->store( $output );
970 }
971 else
972 {
973 $t->pparse( "output", "product_view_tpl" );
974 }
975
976 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$session
$session
Definition: admin/articlelist.php:44
eZCurrency
Definition: ezcurrency.php:46
eZDate
Definition: ezdate.php:46
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZLocale
Definition: ezlocale.php:119
eZModuleLink
Definition: ezmodulelink.php:65
eZObjectPermission\hasPermission
static hasPermission( $objectID, $moduleTable, $permission, $user=false)
Definition: ezobjectpermission.php:76
eZPermission\checkPermission
static checkPermission( $user, $moduleName, $permissionName)
Definition: ezpermission.php:430
eZProductCategory
Definition: ezproductcategory.php:90
eZProductCategory\sectionIDStatic
static sectionIDStatic( $categoryID)
Definition: ezproductcategory.php:394
eZProductCurrency
Definition: ezproductcurrency.php:40
eZProduct
Definition: ezproduct.php:71
eZProduct\namedQuantity
static namedQuantity( $quantity)
Definition: ezproduct.php:1037
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZTemplate
Definition: eztemplate.php:107
eZTextTool\capitalize
static capitalize( $string, $bigClass="h1bigger")
Definition: eztexttool.php:105
eZTextTool\nl2br
static nl2br( $string, $xhtml=true)
Definition: eztexttool.php:65
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$id
$id
Definition: companytypelist.php:193
$block_array
$block_array
Definition: countryedit.php:44
$template_array
$template_array
Definition: countryedit.php:43
$variable_array
$variable_array
Definition: countrylist.php:39
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$ModuleName
$ModuleName
Definition: ezarticle/user/searchsupplier.php:30
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$j
$j
Definition: ezimagecatalogue/admin/imagelist.php:345
$section
$section
Definition: ezimagecatalogue/user/categoryedit.php:393
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$link
$link
Definition: ezlink/admin/attributeedit.php:49
$values
$values
Definition: fixedvalues.php:103
exit
exit
Definition: folder.php:81
$output
$output
Definition: formpreview.php:81
$ModuleList
$ModuleList
Definition: hotdealslist.php:87
$header
$header
Definition: paypalnotify.php:141
$price
$price
Definition: pricegroupedit.php:39
$ShowPrice
$ShowPrice
Definition: productpreview.php:48
$image_count
$image_count
Definition: productview.php:417
$options
$options
Definition: productview.php:457
$AdminSiteURL
$AdminSiteURL
Definition: productview.php:60
$can_checkout
if(! $RequireUserLogin or is_a( $user, "eZUser")) $can_checkout
Definition: productview.php:477
$mainImage
foreach( $pathArray as $path) $mainImage
Definition: productview.php:361
$MainImageWidth
$MainImageWidth
Definition: productview.php:95
$SmallImageHeight
$SmallImageHeight
Definition: productview.php:99
$ShowOptionQuantity
$ShowOptionQuantity
Definition: productview.php:55
$currency_locale
$currency_locale
Definition: productview.php:479
$SiteURL
$SiteURL
Definition: productview.php:61
$SiteKeywordsOverride
$SiteKeywordsOverride
Definition: productview.php:936
$MainImageHeight
$MainImageHeight
Definition: productview.php:96
$module_link
$module_link
Definition: productview.php:594
$currency
$currency
Definition: productview.php:465
$locale
$locale
Definition: productview.php:58
$t
$t
Definition: productview.php:126
$Quantity
if( $product->catalogNumber() !="") $Quantity
Definition: productview.php:706
$SiteTitleAppend
$SiteTitleAppend
Definition: productview.php:246
$mainImageID
$mainImageID
Definition: productview.php:362
$user
$user
Definition: productview.php:112
$GlobalSectionID
$GlobalSectionID
Definition: productview.php:105
$PricesIncludeVAT
$PricesIncludeVAT
Definition: productview.php:57
$pathArray
$pathArray
Definition: productview.php:350
$sectionObject
$sectionObject
Definition: productview.php:108
$product
$product
Definition: productview.php:68
$priceRange
$priceRange
Definition: productview.php:830
$currencies
$currencies
Definition: productview.php:466
$i
$i
Definition: productview.php:414
$PurchaseProduct
$PurchaseProduct
Definition: productview.php:56
$Language
$Language
Definition: productview.php:48
$ini
$ini
Definition: productview.php:46
$MailMethod
$MailMethod
Definition: productview.php:260
$categoryID
else $categoryID
Definition: productview.php:66
$ShowPriceGroups
$ShowPriceGroups
Definition: productview.php:49
$images
$images
Definition: productview.php:412
$ShowNamedQuantity
$ShowNamedQuantity
Definition: productview.php:53
$CapitalizeHeadlines
$CapitalizeHeadlines
Definition: productview.php:93
$SmallImageWidth
$SmallImageWidth
Definition: productview.php:98
$SimpleOptionHeaders
$SimpleOptionHeaders
Definition: productview.php:51
$sections
$sections
Definition: productview.php:595
$type
foreach( $sections as $section) $type
Definition: productview.php:617
$ShowQuantity
$ShowQuantity
Definition: productview.php:52
$files
if(isset( $func_array) and is_array( $func_array)) $files
Definition: productview.php:892
$RequireQuantity
$RequireQuantity
Definition: productview.php:54
$SiteDescriptionOverride
$SiteDescriptionOverride
Definition: productview.php:935
$RequireUserLogin
$RequireUserLogin
Definition: productview.php:50
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$headers
$headers
Definition: requestpagelist.php:61
$image
$image
Definition: user/articlelist.php:242
$links
$links
Definition: user/linkcategorylist.php:181
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.