Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

user/productsearch.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: productsearch.php 9805 2003-04-10 14:48:45Z br $
5 //
6 // Created on: <10-Oct-2000 17:49:05 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
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezlocale.php" );
31 // include_once( "classes/ezcurrency.php" );
32
33 $ini =& eZINI::instance( 'site.ini' );
34
35 $Language = $ini->variable( "eZTradeMain", "Language" );
36 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
37 $RequireUserLogin = $ini->variable( "eZTradeMain", "RequireUserLogin" ) == "true";
38 $MaxSearchForProducts = $ini->variable( "eZTradeMain", "MaxSearchForProducts" );
39 $SmallImageWidth = $ini->variable( "eZTradeMain", "SmallImageWidth" );
40 $SmallImageHeight = $ini->variable( "eZTradeMain", "SmallImageHeight" );
41 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
42
43 // include_once( "eztrade/classes/ezproduct.php" );
44 // include_once( "eztrade/classes/ezproductcategory.php" );
45 // include_once( "eztrade/classes/ezcartoptionvalue.php" );
46 // include_once( "ezuser/classes/ezuser.php" );
47 // include_once( "ezsession/classes/ezsession.php" );
48 // include_once( "ezimagecatalogue/classes/ezimage.php" );
49 // include_once( "classes/ezlist.php" );
50
51 $user =& eZUser::currentUser();
52
53 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ) ,
54 "kernel/eztrade/user/intl/", $Language, "productsearch.php" );
55
56 $t->setAllStrings();
57
58 $t->set_file( "product_search_tpl", "productsearch.tpl" );
59
60 $t->set_block( "product_search_tpl", "product_tpl", "product" );
61 //$t->set_block( "product_search_tpl", "error_max_search_for_products_tpl", "error_max_search_for_products" );
62
63 if ( !isset( $ModuleName ) )
64 $ModuleName = "trade";
65 if ( !isset( $ModuleList ) )
66 $ModuleList = "productlist";
67 if ( !isset( $ModuleView ) )
68 $ModuleView = "productview";
69 if ( !isset( $ModulePrint ) )
70 $ModulePrint = "productprint";
71
72 $t->set_var( "module", $ModuleName );
73 $t->set_var( "module_list", $ModuleList );
74 $t->set_var( "module_view", $ModuleView );
75 $t->set_var( "module_print", $ModulePrint );
76
77 $t->set_block( "product_tpl", "image_tpl", "image" );
78 $t->set_block( "product_tpl", "price_tpl", "price" );
79 $t->set_var( "image", "" );
80 $t->set_var( "price", "" );
81
82 $t->set_var( "next", "" );
83 $t->set_var( "previous", "" );
84 $t->set_var( "error_max_search_for_products", "" );
85
86 // products
87 $product = new eZProduct();
88
89 if ( !isset( $Limit ) )
90 $Limit = 10;
91 if ( !isset( $Offset ) )
92 $Offset = 0;
93
94
95 if ( isset( $URLQueryString ) )
96 {
97 $Query = $URLQueryString;
98 }
99
100 if ( isset( $Query ) && $Query )
101 {
102 $productList =& $product->activeProductSearch( $Query, $Offset, $Limit );
103 $total_count = $product->activeProductSearchCount( $Query );
104 }
105 else
106 {
107 $total_count = 0;
108 }
109
110 $t->set_var( "url_text", urlencode( $Query ) );
111
112 if ( isset( $total_count ) && ( $MaxSearchForProducts != 0 ) && ( $MaxSearchForProducts < $total_count ) )
113 {
114 $t->parse( "error_max_search_for_products", "error_max_search_for_products_tpl" );
115 $t->set_var( "product_search_list", "" );
116 $productList = array();
117 $total_count = 0;
118 }
119
120 $locale = new eZLocale( $Language );
121 $i=0;
122 $t->set_var( "product", "" );
123 if ( isset( $productList ) && isset( $Query ) && ( count ( $productList ) > 0 ) )
124 {
125 foreach ( $productList as $product )
126 {
127 $t->set_var( "product_id", $product->id() );
128
129 $defCat = $product->categoryDefinition();
130 $t->set_var( "category_id", $defCat->id() );
131
132 // preview image
133 $thumbnailImage = $product->thumbnailImage();
134 if ( $thumbnailImage )
135 {
136 $variation =& $thumbnailImage->requestImageVariation( $SmallImageWidth, $SmallImageHeight );
137
138 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
139 $t->set_var( "thumbnail_image_width", $variation->width() );
140 $t->set_var( "thumbnail_image_height", $variation->height() );
141 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
142
143 $t->parse( "image", "image_tpl" );
144 }
145 else
146 {
147 $t->set_var( "image", "" );
148 }
149
150 $t->set_var( "product_name", $product->name() );
151
152 $t->set_var( "description_text", $product->description() );
153
154 $t->set_var( "product_number", "" );
155
156 if ( $product->productNumber() != "" )
157 {
158 $t->set_var( "product_number", $product->productNumber() );
159 // $t->parse( "product_number", "product_number_item_tpl" );
160 }
161
162 $t->set_var( "catalog_number", "" );
163
164 if ( $product->catalogNumber() != "" )
165 {
166 $t->set_var( "catalog_number", $product->catalogNumber() );
167 // $t->parse( "product_number", "product_number_item_tpl" );
168 }else {
169 $t->set_var( "catalog_number", "N/A" );
170 }
171 if ( $ShowPrice and $product->showPrice() == true and $product->hasPrice() )
172 {
173 $t->set_var( "product_price", $product->localePrice( $PricesIncludeVAT ) );
174 $priceRange = $product->correctPriceRange( $PricesIncludeVAT );
175
176 if ( ( empty( $priceRange["min"] ) and empty( $priceRange["max"] ) ) and !($product->correctPrice( $PricesIncludeVAT ) > 0) )
177 {
178 $t->set_var( "product_price", "" );
179 }
180 $t->parse( "price", "price_tpl" );
181 }
182 else if( $product->showPrice() == false )
183 {
184 $t->set_var( "product_price", "" );
185 $t->parse( "price", "price_tpl" );
186 }
187 else
188 {
189 $priceArray = "";
190 $options =& $product->options();
191 if ( count( $options ) == 1 )
192 {
193 $option = $options[0];
194 if ( is_a( $option, "eZOption" ) )
195 {
196 $optionValues =& $option->values();
197 if ( count( $optionValues ) > 1 )
198 {
199 $i=0;
200 foreach ( $optionValues as $optionValue )
201 {
202 $priceArray[$i] = $optionValue->localePrice( $PricesIncludeVAT, $product );
203 $i++;
204 }
205 $high = max( $priceArray );
206 $low = min( $priceArray );
207
208 $t->set_var( "product_price", $low . " - " . $high );
209
210 $t->parse( "price", "price_tpl" );
211 }
212 }
213 }
214 else
215 $t->set_var( "price", "" );
216 }
217
218 $t->set_var( "product_intro_text", $product->brief() );
219 $t->set_var( "product_id", $product->id() );
220
221 $defCat = $product->categoryDefinition();
222 $t->set_var( "category_id", $defCat->id() );
223
224 if ( ( $i % 2 ) == 0 )
225 {
226 $t->set_var( "td_class", "bglight" );
227 }
228 else
229 {
230 $t->set_var( "td_class", "bgdark" );
231 }
232
233 $t->parse( "product", "product_tpl", true );
234 $i++;
235 }
236 }
237
238 eZList::drawNavigator( $t, $total_count, $Limit, $Offset, "product_search_tpl" );
239
240 $t->set_var( "url_query_string", htmlspecialchars( $Query ) );
241 $t->set_var( "query_string", htmlspecialchars( $Query ) );
242
243 $t->set_var( "query", $Query );
244 $t->set_var( "limit", $Limit );
245 $t->set_var( "product_start", $Offset + 1 );
246 $t->set_var( "product_end", min( $Offset + $Limit, $total_count ) );
247 $t->set_var( "product_total", $total_count );
248
249 $t->pparse( "output", "product_search_tpl" );
250 ?>
$total_count
$total_count
Definition: browserlist.php:54
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZProduct
Definition: ezproduct.php:71
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Limit
$Limit
Definition: ezarticle/admin/categorylist.php:66
$productList
$productList
Definition: ezarticle/admin/categorylist.php:248
$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
$ModuleList
$ModuleList
Definition: hotdealslist.php:87
$options
$options
Definition: optionlist.php:56
$ShowPrice
$ShowPrice
Definition: productpreview.php:48
$SmallImageHeight
$SmallImageHeight
Definition: user/productsearch.php:40
$MaxSearchForProducts
$MaxSearchForProducts
Definition: user/productsearch.php:38
$t
$t
Definition: user/productsearch.php:53
$user
$user
Definition: user/productsearch.php:51
$PricesIncludeVAT
$PricesIncludeVAT
Definition: user/productsearch.php:41
$product
$product
Definition: user/productsearch.php:87
$i
$i
Definition: user/productsearch.php:121
$Language
$Language
Definition: user/productsearch.php:35
$ini
$ini
Definition: user/productsearch.php:33
$ShowPriceGroups
$ShowPriceGroups
Definition: user/productsearch.php:36
$locale
if(isset( $total_count) &&( $MaxSearchForProducts !=0) &&( $MaxSearchForProducts< $total_count)) $locale
Definition: user/productsearch.php:120
$SmallImageWidth
$SmallImageWidth
Definition: user/productsearch.php:39
$RequireUserLogin
$RequireUserLogin
Definition: user/productsearch.php:37
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.