Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztrade/user/extendedsearch.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: extendedsearch.php 6484 2001-08-17 13:36:01Z jhe $
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 // include_once( "classes/ezhttptool.php" );
33 // include_once( "classes/ezlist.php" );
34
35 $ini =& eZINI::instance( 'site.ini' );
36
37 $Language = $ini->variable( "eZTradeMain", "Language" );
38 $ShowPriceGroups = $ini->variable( "eZTradeMain", "PriceGroupsEnabled" ) == "true";
39 $RequireUserLogin = $ini->variable( "eZTradeMain", "RequireUserLogin" ) == "true";
40 $ExtendedSearchCategories = $ini->read_array( "eZTradeMain", "ExtendedSearchCategories" );
41 $MaxSearchForProducts = $ini->variable( "eZTradeMain", "MaxSearchForProducts" );
42
43 $SmallImageWidth = $ini->variable( "eZTradeMain", "SmallImageWidth" );
44 $SmallImageHeight = $ini->variable( "eZTradeMain", "SmallImageHeight" );
45
46 // include_once( "eztrade/classes/ezproduct.php" );
47 // include_once( "eztrade/classes/ezproductcategory.php" );
48 // include_once( "eztrade/classes/ezcartoptionvalue.php" );
49 // include_once( "ezuser/classes/ezuser.php" );
50 // include_once( "ezsession/classes/ezsession.php" );
51 // include_once( "ezimagecatalogue/classes/ezimage.php" );
52 // include_once( "classes/ezlist.php" );
53
54 if ( isset ( $SearchButton ) )
55 {
56 $Action = "SearchButton";
57 }
58
59 $user =& eZUser::currentUser();
60
61 $t = new eZTemplate( "kernel/eztrade/user/" . $ini->variable( "eZTradeMain", "TemplateDir" ) ,
62 "kernel/eztrade/user/intl/", $Language, "extendedsearch.php" );
63
64 $t->setAllStrings();
65
66 $t->set_file( "extended_search_tpl", "extendedsearch.tpl" );
67
68
69 $t->set_block( "extended_search_tpl", "extended_tpl", "product" );
70 $t->set_block( "extended_search_tpl", "product_search_list_tpl", "product_search_list" );
71 $t->set_block( "extended_search_tpl", "error_max_search_for_products_tpl", "error_max_search_for_products" );
72 $t->set_block( "extended_search_tpl", "category_list_tpl", "category_list" );
73 $t->set_block( "category_list_tpl", "category_item_tpl", "category_item" );
74
75 $t->set_block( "extended_search_tpl", "empty_search_tpl", "empty_search" );
76
77 $t->set_block( "product_search_list_tpl", "image_tpl", "image" );
78 $t->set_block( "product_search_list_tpl", "price_tpl", "price" );
79
80 $t->set_var( "price_lower", "" );
81 $t->set_var( "price_higher", "" );
82 $t->set_var( "text", "" );
83 $t->set_var( "error_max_search_for_products", "" );
84
85 $priceRange = explode( "-", $PriceRange );
86 // $PriceLower = !is_numeric( $priceRange[0] ) ? 0 : $priceRange[0];
87 // $PriceHigher = !is_numeric( $priceRange[1] ) ? 500 : $priceRange[1];
88 $PriceLower = $priceRange[0];
89 $PriceHigher = $priceRange[1];
90
91 // products
92 $product = new eZProduct();
93
94 if ( $Action == "SearchButton" )
95 {
96 if ( $Limit == "" )
97 $Limit = 10;
98 if ( $Offset == "" )
99 $Offset = 0;
100
101 $mainCategoryArray = explode( "-", $MainCategories );
102 if ( $Next || $Prev )
103 {
104 $lists = explode( ":", $CategoryArray );
105 $cats = array();
106 foreach( $lists as $list )
107 {
108 $cats[] = explode( "-", $list );
109 }
110 $mains = explode( "-", $MainCategories );
111
112 $catIDArray = array();
113 reset( $mains );
114 list($key,$main) = each( $mains );
115 foreach ( $cats as $cat )
116 {
117 $cat_array = array();
118 $cat_array["id"] = $main;
119 $cat_array["categories"] = $cat;
120 $catIDArray[] = $cat_array;
121 list($key,$main) = each( $mains );
122 }
123
124 $productList =& $product->extendedSearch( $PriceLower, $PriceHigher, $Text, $Offset, $Limit, $catIDArray );
125 $totalCount = $product->extendedSearchCount( $PriceLower, $PriceHigher, $Text, $catIDArray );
126 }
127 else
128 {
129 if ( $Limit == "" )
130 $Limit = 10;
131 if ( $Offset == "" )
132 $Offset = 0;
133
134 $catIDArray = array();
135
136 reset( $CategoryArrayID );
137 while ( list($main,$cats ) = each($CategoryArrayID) )
138 {
139 $cat_array = array();
140 $cat_array["id"] = $main;
141 $categories = array();
142 foreach( $cats as $cat )
143 {
144 $tree =& eZProductCategory::getTree( $cat == 0 ? $main : $cat );
145 foreach( $tree as $category_item )
146 {
147 $categories[] = $category_item[0]->id();
148 }
149 if ( $cat != 0 )
150 $categories[] = $cat;
151 }
152 $cat_array["categories"] = $categories;
153 $catIDArray[] = $cat_array;
154 }
155
156 $productList =& $product->extendedSearch( $PriceLower, $PriceHigher, $Text, $Offset, $Limit, $catIDArray );
157 $totalCount = $product->extendedSearchCount( $PriceLower, $PriceHigher, $Text, $catIDArray );
158 }
159
160 $t->set_var( "price_lower", $PriceLower );
161 $t->set_var( "price_higher", $PriceHigher );
162 $t->set_var( "text", $Text );
163
164 $t->set_var( "url_text", urlencode( $Text == "" ? " " : $Text ) );
165 $t->set_var( "url_range", urlencode( $PriceRange ) );
166
167 $urlCategory = "";
168 $i = 0;
169 foreach( $catIDArray as $catID )
170 {
171 $categories =& $catID["categories"];
172 $cat_list = "";
173 $j = 0;
174 foreach( $categories as $category )
175 {
176 if ( $j > 0 )
177 $cat_list .= "-";
178 $cat_list .= $category;
179 ++$j;
180 }
181 if ( $i > 0 )
182 $urlCategory .= ":";
183 $urlCategory .= $cat_list;
184 ++$i;
185 }
186
187 $t->set_var( "url_category", urlencode( $urlCategory ) );
188
189 $mainCategory = "";
190 $i = 0;
191 foreach( $catIDArray as $catID )
192 {
193 if ( $i > 0 )
194 $mainCategory .= "-";
195 $mainCategory .= $catID["id"];
196 ++$i;
197 }
198 $t->set_var( "url_main_categories", $mainCategory );
199 }
200
201 if ( ( $MaxSearchForProducts != 0 ) && ( $MaxSearchForProducts < $totalCount ) )
202 {
203 $t->parse( "error_max_search_for_products", "error_max_search_for_products_tpl" );
204 $t->set_var( "product_search_list", "" );
205 $productList = array();
206 $totalCount = 0;
207 }
208
209 $locale = new eZLocale( $Language );
210 $i=0;
211 $t->set_var( "product", "" );
212 $t->set_var( "empty_search", "" );
213 if ( count ( $productList ) > 0 )
214 {
215 foreach ( $productList as $product )
216 {
217 // preview image
218 $thumbnailImage = $product->thumbnailImage();
219 if ( $thumbnailImage )
220 {
221 $variation =& $thumbnailImage->requestImageVariation( $SmallImageWidth, $SmallImageHeight );
222
223 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
224 $t->set_var( "thumbnail_image_width", $variation->width() );
225 $t->set_var( "thumbnail_image_height", $variation->height() );
226 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
227
228 $t->parse( "image", "image_tpl" );
229 }
230 else
231 {
232 $t->set_var( "image", "" );
233 }
234
235 $t->set_var( "product_name", $product->name() );
236
237 if ( ( !$RequireUserLogin or is_a( $user, "eZUser" ) ) and
238 $ShowPrice and $product->showPrice() == true and $product->hasPrice() )
239 {
240 $found_price = false;
241 if ( $ShowPriceGroups and $PriceGroup > 0 )
242 {
243 $price = eZPriceGroup::correctPrice( $product->id(), $PriceGroup );
244 if ( $price )
245 {
246 $found_price = true;
247 $price = new eZCurrency( $price );
248 }
249 }
250 if ( !$found_price )
251 {
252 $price = new eZCurrency( $product->price() );
253 }
254 $t->set_var( "product_price", $locale->format( $price ) );
255 $t->parse( "price", "price_tpl" );
256 }
257 else
258 {
259 $t->set_var( "price", "" );
260 }
261
262 $t->set_var( "product_intro_text", $product->brief() );
263 $t->set_var( "product_id", $product->id() );
264
265 $defCat = $product->categoryDefinition();
266 $t->set_var( "category_id", $defCat->id() );
267
268 $t->set_var( "td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
269
270 $t->parse( "product_search_list", "product_search_list_tpl", true );
271 $i++;
272 }
273 }
274 else
275 {
276 $t->set_var( "product_search_list", "" );
277 if ( $Action == "SearchButton" )
278 $t->parse( "empty_search", "empty_search_tpl" );
279 }
280
281 eZList::drawNavigator( $t, $totalCount, $Limit, $Offset, "extended_search_tpl" );
282
283 $category = new eZProductCategory();
284
285 //$categoryList =& $category->getTree();
286 $categoryList = array();
287 foreach( $ExtendedSearchCategories as $category )
288 {
289 $cat = new eZProductCategory( $category );
290 $cats = $cat->getByParent( $cat );
291 $categoryList[] = array( "categories" => $cats,
292 "name" => $cat->name(),
293 "id" => $cat->id() );
294 }
295
296 $subCategories = "";
297 $t->set_var( "category_list", "" );
298 $t->set_var( "is_all_selected", "" );
299 if ( is_array( $CategoryArrayID ) )
300 {
301 reset( $CategoryArrayID );
302 list($key,$categoryArray) = each( $CategoryArrayID );
303 }
304 foreach( $categoryList as $categoryItem )
305 {
306 $t->set_var( "category_main_name", $categoryItem["name"] );
307 $t->set_var( "category_main_id", $categoryItem["id"] );
308 $cats =& $categoryItem["categories"];
309 $t->set_var( "category_item", "" );
310 foreach( $cats as $cat )
311 {
312 $t->set_var( "category_name", $cat->name() );
313 $t->set_var( "category_id", $cat->id() );
314 $t->set_var( "option_level", "" );
315
316 $t->set_var( "is_selected", "" );
317 if ( is_array ( $categoryArray ) )
318 {
319 foreach ( $categoryArray as $categoryID )
320 {
321 if ( $categoryID == $cat->id() )
322 $t->set_var( "is_selected", "selected" );
323 }
324 }
325
326 $t->parse( "category_item", "category_item_tpl", true );
327 $subCategories = "";
328 }
329 $t->parse( "category_list", "category_list_tpl", true );
330 if ( is_array( $CategoryArrayID ) )
331 {
332 list($key,$categoryArray) = each( $CategoryArrayID );
333 }
334 }
335
336 $t->set_var( "url_query_string", $Query );
337 $t->set_var( "query_string", $Query );
338
339 $t->set_var( "query", $Query );
340 $t->set_var( "limit", $Limit );
341 $prevOffs = $Offset - $Limit;
342 $nextOffs = $Offset + $Limit;
343
344 $t->set_var( "prev_offset", $prevOffs );
345 $t->set_var( "next_offset", $nextOffs );
346
347 $t->pparse( "output", "extended_search_tpl" );
348 ?>
$categoryArray
$categoryArray
Definition: adedit.php:379
eZCurrency
Definition: ezcurrency.php:46
eZList\drawNavigator
static drawNavigator(&$t, $total_types, $max_types, $index, $parent=false, $variables=false)
Definition: ezlist.php:401
eZLocale
Definition: ezlocale.php:119
eZPriceGroup\correctPrice
static correctPrice( $productid, $priceid, $optionid=0, $valueid=0)
Definition: ezpricegroup.php:414
eZProductCategory
Definition: ezproductcategory.php:90
eZProductCategory\getTree
static & getTree( $parentID=0, $level=0)
Definition: ezproductcategory.php:335
eZProduct
Definition: ezproduct.php:71
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$Action
$Action
Definition: companysearch.php:80
$tree
$tree
Definition: ezad/admin/categoryedit.php:172
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$Limit
$Limit
Definition: ezarticle/admin/categorylist.php:66
$productList
$productList
Definition: ezarticle/admin/categorylist.php:248
$totalCount
$totalCount
Definition: ezarticle/admin/formlist.php:73
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$cat
if(isset( $DeleteCategories)) $cat
Definition: ezforum/admin/categoryedit.php:49
$j
$j
Definition: ezimagecatalogue/admin/imagelist.php:345
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$main
$main
Definition: eztrade/admin/imagelist.php:62
$SmallImageHeight
$SmallImageHeight
Definition: eztrade/user/extendedsearch.php:44
$category
$category
Definition: eztrade/user/extendedsearch.php:283
$MaxSearchForProducts
$MaxSearchForProducts
Definition: eztrade/user/extendedsearch.php:41
$t
$t
Definition: eztrade/user/extendedsearch.php:61
$nextOffs
$nextOffs
Definition: eztrade/user/extendedsearch.php:342
$product
$product
Definition: eztrade/user/extendedsearch.php:92
$priceRange
$priceRange
Definition: eztrade/user/extendedsearch.php:85
$prevOffs
$prevOffs
Definition: eztrade/user/extendedsearch.php:341
$i
$i
Definition: eztrade/user/extendedsearch.php:210
$Language
$Language
Definition: eztrade/user/extendedsearch.php:37
$ini
$ini
Definition: eztrade/user/extendedsearch.php:35
$ShowPriceGroups
$ShowPriceGroups
Definition: eztrade/user/extendedsearch.php:38
$categoryList
$categoryList
Definition: eztrade/user/extendedsearch.php:286
$PriceLower
$PriceLower
Definition: eztrade/user/extendedsearch.php:88
$subCategories
foreach( $ExtendedSearchCategories as $category) $subCategories
Definition: eztrade/user/extendedsearch.php:296
$locale
if( $Action=="SearchButton") if(( $MaxSearchForProducts !=0) &&( $MaxSearchForProducts< $totalCount)) $locale
Definition: eztrade/user/extendedsearch.php:209
$ExtendedSearchCategories
$ExtendedSearchCategories
Definition: eztrade/user/extendedsearch.php:40
$SmallImageWidth
$SmallImageWidth
Definition: eztrade/user/extendedsearch.php:43
$user
if(isset( $SearchButton)) $user
Definition: eztrade/user/extendedsearch.php:59
$PriceHigher
$PriceHigher
Definition: eztrade/user/extendedsearch.php:89
$RequireUserLogin
$RequireUserLogin
Definition: eztrade/user/extendedsearch.php:39
$price
$price
Definition: pricegroupedit.php:39
$PriceGroup
$PriceGroup
Definition: productedit.php:1073
$ShowPrice
$ShowPrice
Definition: productpreview.php:48
$categoryID
else $categoryID
Definition: productview.php:66
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.