Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

simplecategorylist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: categorylist.php,v 1.32.2.2 2001/11/21 17:34:16 br Exp $
5 //
6 // Created on: <13-Sep-2000 14:56:11 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/ezcachefile.php" );
32 // include_once( "classes/ezlist.php" );
33
34 function deleteCache( $ProductID, $CategoryID, $CategoryArray )
35 {
36 if ( get_class( $ProductID ) == "ezproduct" )
37 {
38 $CategoryID =& $ProductID->categoryDefinition( false );
39 $CategoryArray =& $ProductID->categories( false );
40 $ProductID = $ProductID->id();
41 }
42
43 $files = eZCacheFile::files( "eztrade/cache/", array( "productlist",
44 array_merge( $CategoryID, $CategoryArray ) ),
45 "cache", "," );
46 foreach( $files as $file )
47 {
48 $file->delete();
49 }
50 $files = eZCacheFile::files( "eztrade/cache/", array( "hotdealslist" ),
51 "cache", "," );
52 foreach( $files as $file )
53 {
54 $file->delete();
55 }
56 }
57
58
59 $ini =& eZINI::instance( 'site.ini' );
60
61 $Language = $ini->variable( "eZTradeMain", "Language" );
62 $Limit = $ini->variable( "eZTradeMain", "ProductLimit" );
63
64 // include_once( "eztrade/classes/ezproductcategory.php" );
65 // include_once( "eztrade/classes/ezproduct.php" );
66
67 $t = new eZTemplate( "kernel/eztrade/admin/" . $ini->variable( "eZTradeMain", "AdminTemplateDir" ),
68 "kernel/eztrade/admin/intl/", $Language, "simplecategorylist.php" );
69
70 $t->setAllStrings();
71
72 $t->set_file( "category_list_page_tpl", "simplecategorylist.tpl" );
73
74 // path
75 $t->set_block( "category_list_page_tpl", "path_item_tpl", "path_item" );
76
77 // category
78 $t->set_block( "category_list_page_tpl", "category_list_tpl", "category_list" );
79 $t->set_block( "category_list_tpl", "category_item_tpl", "category_item" );
80
81 // product
82 $t->set_block( "category_list_page_tpl", "product_list_tpl", "product_list" );
83 $t->set_block( "product_list_tpl", "product_item_tpl", "product_item" );
84 $t->set_block( "product_item_tpl", "product_active_item_tpl", "product_active_item" );
85 $t->set_block( "product_item_tpl", "product_inactive_item_tpl", "product_inactive_item" );
86
87 $t->set_block( "product_item_tpl", "voucher_icon_tpl", "voucher_icon" );
88 $t->set_block( "product_item_tpl", "product_icon_tpl", "product_icon" );
89
90 $t->set_block( "product_item_tpl", "inc_vat_item_tpl", "inc_vat_item" );
91 $t->set_block( "product_item_tpl", "ex_vat_item_tpl", "ex_vat_item" );
92
93 // move up / down
94 $t->set_block( "product_list_tpl", "absolute_placement_header_tpl", "absolute_placement_header" );
95 $t->set_block( "product_item_tpl", "absolute_placement_item_tpl", "absolute_placement_item" );
96
97 $t->set_var( "site_style", $SiteDesign );
98
99 $category = new eZProductCategory( 1 );
100 // $category->copy( true );
101
102
103 $category = new eZProductCategory();
104
105 if( isset( $ParentID ) )
106 {
107 $category->get( $ParentID );
108 }
109 else
110 {
111 $category->get();
112 }
113
114 // move products up / down
115
116 if ( $category->sortMode() == "absolute_placement" )
117 {
118 if ( is_numeric( $MoveUp ) )
119 {
120 $category->moveUp( $MoveUp );
121 deleteCache( $MoveUp, false, false );
122 }
123 if ( is_numeric( $MoveDown ) )
124 {
125 $category->moveDown( $MoveDown );
126 deleteCache( $MoveDown, false, false );
127 }
128 }
129
130 // path
131 $pathArray =& $category->path();
132
133 $t->set_var( "path_item", "" );
134 foreach ( $pathArray as $path )
135 {
136 $t->set_var( "category_id", $path[0] );
137
138 $t->set_var( "category_name", $path[1] );
139
140 $t->parse( "path_item", "path_item_tpl", true );
141 }
142
143 $categoryList =& $category->getByParent( $category );
144
145 // categories
146 $i = 0;
147 $t->set_var( "category_list", "" );
148 foreach ( $categoryList as $categoryItem )
149 {
150 $t->set_var( "category_id", $categoryItem->id() );
151
152 $t->set_var( "category_name", $categoryItem->name() );
153
154 $parent = $categoryItem->parent();
155
156
157 if ( ( $i % 2 ) == 0 )
158 {
159 $t->set_var( "td_class", "bglight" );
160 }
161 else
162 {
163 $t->set_var( "td_class", "bgdark" );
164 }
165 $t->set_var( "category_description", $categoryItem->description() );
166
167 $t->parse( "category_item", "category_item_tpl", true );
168 $i++;
169 }
170
171 if ( count( $categoryList ) > 0 )
172 $t->set_var( "csv_dir", $ini->variable( "eZTradeMain", "CSVImportPath" ) );
173
174 if ( count( $categoryList ) > 0 )
175 $t->parse( "category_list", "category_list_tpl" );
176 else
177 $t->set_var( "category_list", "" );
178
179 if ( !isset( $Limit ) or !is_numeric( $Limit ) )
180 $Limit = 10;
181 if ( !isset( $Offset ) or !is_numeric( $Offset ) )
182 $Offset = 0;
183
184 // products
185 $TotalTypes =& $category->productCount( $category->sortMode(), true );
186 $productList =& $category->products( $category->sortMode(), true, $Offset, $Limit, true, $category->id() );
187
188 $locale = new eZLocale( $Language );
189 $i = 0;
190
191 $t->set_var( "product_list", "" );
192
193 if ( $category->sortMode() == "absolute_placement" )
194 {
195 $t->parse( "absolute_placement_header", "absolute_placement_header_tpl" );
196 }
197 else
198 {
199 $t->set_var( "absolute_placement_header", "" );
200 }
201
202 foreach ( $productList as $product )
203 {
204 $t->set_var( "td_class", ( $i % 2 ) == 0 ? "bglight" : "bgdark" );
205
206 $t->set_var( "product_name", $product->name() );
207
208 $t->set_var( "product_price", "" );
209 $t->set_var( "product_price_inc_vat", "" );
210 if ( $product->hasPrice() )
211 {
212 $price = new eZCurrency( $product->price() );
213
214 $t->set_var( "product_price", $locale->format( $price ) );
215 }
216
217
218 $priceArray = "";
219 $options =& $product->options();
220 $high = 0;
221 $low = 0;
222 foreach ( $options as $option )
223 {
224 if ( get_class( $option ) == "ezoption" )
225 {
226 $optionValues =& $option->values();
227 if ( count( $optionValues ) > 1 )
228 {
229 $i=0;
230 $priceArray = array();
231 foreach ( $optionValues as $optionValue )
232 {
233 $priceArray[$i] = $optionValue->price();
234 $i++;
235 }
236 $high += max( $priceArray );
237 $low += min( $priceArray );
238 }
239 }
240 }
241
242 /*
243 if ( count( $options ) > 0 )
244 {
245 $low = new eZCurrency( $low + $product->price() );
246 $high = new eZCurrency( $high + $product->price() );
247 if ( $low != $high )
248 $t->set_var( "product_price", $locale->format( $low ) . " - " . $locale->format( $high ) );
249 else
250 $t->set_var( "product_price", $locale->format( $low ) );
251 }
252
253 $range = $product->priceRange();
254 if ( $range )
255 {
256 $min = new eZCurrency( $range->min() );
257 $max = new eZCurrency( $range->max() );
258
259 $t->set_var( "product_price", $locale->format( $min ) . " - " . $locale->format( $max ) );
260 }
261 */
262
263 if( $product->includesVAT() == true )
264 {
265 $t->set_var( "ex_vat_item", "" );
266 $t->parse( "inc_vat_item", "inc_vat_item_tpl" );
267 }
268 else
269 {
270 $t->set_var( "inc_vat_item", "" );
271 $t->parse( "ex_vat_item", "ex_vat_item_tpl" );
272 }
273
274
275
276 $t->set_var( "product_active_item", "" );
277 $t->set_var( "product_inactive_item", "" );
278 if ( $product->showProduct() )
279 {
280 $t->parse( "product_active_item", "product_active_item_tpl" );
281 }
282 else
283 {
284 $t->parse( "product_inactive_item", "product_inactive_item_tpl" );
285 }
286 $t->set_var( "product_id", $product->id() );
287
288 $t->set_var( "category_id", $category->id() );
289
290 if ( $category->sortMode() == "absolute_placement" )
291 {
292 $t->parse( "absolute_placement_item", "absolute_placement_item_tpl" );
293 }
294 else
295 {
296 $t->set_var( "absolute_placement_item", "" );
297 }
298
299 $t->set_var( "product_icon", "" );
300 $t->set_var( "voucher_icon", "" );
301
302 // If product type == 1, render the product object as a product
303 // If product type == 1, render the product object as a voucher
304 if ( $product->productType() == 1 )
305 {
306 $t->set_var( "url_action", "productedit" );
307 $t->parse( "product_icon", "product_icon_tpl" );
308 }
309 if ( $product->productType() == 2 )
310 {
311 $t->set_var( "url_action", "voucher" );
312 $t->parse( "voucher_icon", "voucher_icon_tpl" );
313 }
314
315 $t->parse( "product_item", "product_item_tpl", true );
316 $i++;
317 }
318
319 $t->set_var( "offset", $Offset );
320
321 eZList::drawNavigator( $t, $TotalTypes, $Limit, $Offset, "product_list_tpl" );
322
323 if ( count( $productList ) > 0 )
324 $t->parse( "product_list", "product_list_tpl" );
325 else
326 $t->set_var( "product_list", "" );
327
328 $t->pparse( "output", "category_list_page_tpl" );
329
330 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$files
$files
Definition: articlepreview.php:91
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
eZProductCategory
Definition: ezproductcategory.php:90
eZTemplate
Definition: eztemplate.php:107
$Offset
$Offset
Definition: ezarticle/user/search.php:110
$SiteDesign
$SiteDesign
Definition: ezbulkmail/user/datasupplier.php:31
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$ParentID
$ParentID
Definition: eztrade/admin/categorylist.php:171
$product
$product
Definition: homepage.php:202
$options
$options
Definition: optionlist.php:56
$price
$price
Definition: pricegroupedit.php:39
$Limit
$Limit
Definition: simplecategorylist.php:62
$category
$category
Definition: simplecategorylist.php:99
$locale
$locale
Definition: simplecategorylist.php:188
$t
$t
Definition: simplecategorylist.php:67
$TotalTypes
$TotalTypes
Definition: simplecategorylist.php:185
$i
$i
Definition: simplecategorylist.php:146
$Language
$Language
Definition: simplecategorylist.php:61
$ini
$ini
Definition: simplecategorylist.php:59
$pathArray
if( $category->sortMode()=="absolute_placement") $pathArray
Definition: simplecategorylist.php:131
$categoryList
foreach( $pathArray as $path) $categoryList
Definition: simplecategorylist.php:143
deleteCache
deleteCache( $ProductID, $CategoryID, $CategoryArray)
Definition: simplecategorylist.php:34
$productList
$productList
Definition: simplecategorylist.php:186
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.