Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

homepage.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: listtable.php,v 1.2 2001/07/19 12:48:35 jakobn Exp $
5 //
6 // Created on: <22-Jun-2001 13:12:22 br>
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 the class files.
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "ezexample/classes/ezexample.php" );
31 // include_once( "ezuser/classes/ezuser.php" );
32 // include_once( "ezuser/classes/ezpermission.php" );
33 // include_once( "ezuser/classes/ezobjectpermission.php" );
34 // include_once( "eztrade/classes/ezproductcategory.php" );
35 // include_once( "ezimagecatalogue/classes/ezimagecategory.php" );
36 // include_once( "ezimagecatalogue/classes/ezimage.php" );
37 // include_once( "ezarticle/classes/ezarticlecategory.php" );
38 // include_once( "ezarticle/classes/ezarticlerenderer.php" );
39 // include_once( "ezforum/classes/ezforummessage.php" );
40 // include_once( "eztrade/classes/ezproduct.php" );
41 // include_once( "classes/ezcurrency.php" );
42 // include_once( "classes/ezlocale.php" );
43 // include_once( "classes/ezdatetime.php" );
44
45 $ini =& eZINI::instance( 'site.ini' );
46
47 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" ) == "enabled" ? true : false;
48 $Dealer = $ini->variable( "homepage", "DealerDescription" );
49 $Distributor = $ini->variable( "homepage", "DistributorDescription" );
50 $DistProdCats = $ini->variable( "homepage", "DistProdCats" );
51 $DistThumbWidth = $ini->variable( "homepage", "DistThumbWidth" );
52 $DistThumbHeight = $ini->variable( "homepage", "DistThumbHeight" );
53 $DealerProdCats = $ini->variable( "homepage", "DealerProdCats" );
54 $DealerThumbWidth = $ini->variable( "homepage", "DealerThumbWidth" );
55 $DealerThumbHeight = $ini->variable( "homepage", "DealerThumbHeight" );
56 $ArticleLimit = $ini->variable( "homepage", "ArticleLimit" );
57 $ArticleThumbWidth = $ini->variable( "homepage", "ArticleThumbWidth" );
58 $ArticleThumbHeight = $ini->variable( "homepage", "ArticleThumbHeight" );
59 $HotDealsLimit = $ini->variable( "homepage", "HotDealsLimit" );
60 $HotDealsThumbWidth = $ini->variable( "homepage", "HotDealsThumbWidth" );
61 $HotDealsThumbHeight = $ini->variable( "homepage", "HotDealsThumbHeight" );
62 $GalleryLimit = $ini->variable( "homepage", "GalleryLimit" );
63 $CommentLimit = $ini->variable( "homepage", "CommentLimit" );
64 $CommentLetterLimit = $ini->variable( "homepage", "CommentLetterLimit" );
65 $Anonymous = $ini->variable( "eZForumMain", "AnonymousPoster" );
66 $GalleryThumbWidth = $ini->variable( "homepage", "GalleryThumbWidth" );
67 $GalleryThumbHeight = $ini->variable( "homepage", "GalleryThumbHeight" );
68 $Language = $ini->variable( "eZUserMain", "Language" );
69
70 $locale = new eZLocale( $Language );
71
72 $t = new eZTemplate( "kernel/ezarticle/user/" . $ini->variable( "eZArticleMain", "TemplateDir" ),
73 "kernel/ezarticle/user/intl", $Language, "homepage.php" );
74 $t->setAllStrings();
75
76 // get all fields from the database.
77
78 // $field = new eZExample( );
79 // $fieldArray =& $field->getAll();
80
81 // parse the template.
82
83 $t->set_file( "homepage_tpl", "homepage.tpl" );
84 //$t->set_block( "listtable_tpl", "row_tpl", "row" );
85 //$t->set_var( "row", "" );
86 $t->set_block( "homepage_tpl", "distributor_image_box_tpl", "distributor_image_box" );
87 $t->set_block( "distributor_image_box_tpl", "distributor_image_item_tpl", "distributor_image_item" );
88 $t->set_block( "distributor_image_item_tpl", "distributor_image_tpl", "distributor_image" );
89 $t->set_block( "homepage_tpl", "dealer_image_box_tpl", "dealer_image_box" );
90 $t->set_block( "dealer_image_box_tpl", "dealer_image_item_tpl", "dealer_image_item" );
91 $t->set_block( "dealer_image_item_tpl", "dealer_image_tpl", "dealer_image" );
92 $t->set_block( "homepage_tpl", "product_list_tpl", "product_list" );
93 $t->set_block( "product_list_tpl", "product_list_item_tpl", "product_list_item" );
94 $t->set_block( "product_list_item_tpl", "price_tpl", "price" );
95 $t->set_block( "product_list_item_tpl", "product_message_count_tpl", "product_message_count" );
96 $t->set_block( "homepage_tpl", "image_list_tpl", "image_list" );
97 $t->set_block( "image_list_tpl", "image_list_item_tpl", "image_list_item" );
98 $t->set_block( "homepage_tpl", "message_list_tpl", "message_list" );
99 $t->set_block( "message_list_tpl", "message_list_item_tpl", "message_list_item" );
100 $t->set_block( "homepage_tpl", "article_list_tpl", "article_list" );
101 $t->set_block( "article_list_tpl", "article_item_tpl", "article_item" );
102 $t->set_block( "article_item_tpl", "article_image_tpl", "article_image" );
103 $t->set_block( "article_item_tpl", "message_count_tpl", "message_count" );
104
105 $t->set_var( "distributor_image_box", "" );
106 $t->set_var( "dealer_image_box", "" );
107 $t->set_var( "product_list", "" );
108 $t->set_var( "image_list", "" );
109 $t->set_var( "message_list", "" );
110 $t->set_var( "message_count", "" );
111 $t->set_var( "article_list", "" );
112
113 /*
114 for( $i=0; $i< count($fieldArray); $i++ )
115 {
116 if ( $fieldArray[$i]->Text() != "" )
117 $t->set_var( "row_text", $fieldArray[$i]->Text() );
118 else
119 $t->set_var( "row_text", "&nbsp;" );
120 $t->parse( "row", "row_tpl", true );
121 }
122 $t->pparse( "output", "listtable_tpl" );
123 */
124
125
126 $distProdArray = explode(';', $DistProdCats);
127 //print_r($distProdArray);
128 $dealerProdArray = explode(';', $DealerProdCats);
129 //print_r($dealerProdArray);
130
131 $user =& eZUser::currentUser();
132 $fei = 0;
133
134 foreach ($distProdArray as $distProdCatID )
135 {
136 $fei++;
137 $t->set_var("import_row_open", "");
138 $t->set_var("import_row_close", "");
139 if ($fei == 1 || is_integer(($fei-1) / 4)) { // for some reason modulus ( % ) wasn't working for me ( I suspect a personal grudge )
140 $t->set_var("import_row_open", "<tr>");
141 }
142 if ( is_integer( $fei / 4 ) )
143 {
144 $t->set_var("import_row_close", "</tr>");
145 }
146 $distCategory = new eZProductCategory( $distProdCatID );
147 // print_r($distCategory);
148 $t->set_var( "category_id", $distCategory->id() );
149 $t->set_var( "category_description", $distCategory->description() );
150 $t->set_var( "category_name", $distCategory->name() );
151
152 $t->set_var( "distributor_image", "" );
153 $image = $distCategory->image();
154 if ( $image->id() != 0 )
155 {
156 $variation = $image->requestImageVariation( $DistThumbWidth, $DistThumbHeight );
157 $t->set_var( "thumbnail_image_uri", $variation->imagePath() );
158 $t->set_var( "thumbnail_image_width", $variation->width() );
159 $t->set_var( "thumbnail_image_height", $variation->height() );
160 $t->parse( "distributor_image", "distributor_image_tpl", true );
161 }
162 $t->parse( "distributor_image_item", "distributor_image_item_tpl", true );
163 }
164
165 $t->parse( "distributor_image_box", "distributor_image_box_tpl", true );
166 $dei = 0;
167 foreach ($dealerProdArray as $dealerProdCatID )
168 {
169 $dei++;
170 $t->set_var("dealer_row_open", "");
171 $t->set_var("dealer_row_close", "");
172 if ($dei == 1 || is_integer(($dei-1) / 4)) {
173 $t->set_var("dealer_row_open", "<tr>");
174 }
175 if ( is_integer( $fei / 4 ) )
176 {
177 $t->set_var("dealer_row_close", "</tr>");
178 }
179 $t->set_var( "dealer", $Dealer );
180 $t->set_var( "distributor", $Distributor );
181
182 $dealerCategory = new eZProductCategory( $dealerProdCatID );
183 $t->set_var( "category_id", $dealerCategory->id() );
184 $t->set_var( "category_description", $dealerCategory->description() );
185 $t->set_var( "category_name", $dealerCategory->name() );
186
187 $t->set_var( "dealer_image", "" );
188 $image = $dealerCategory->image();
189 if ( $image->id() != 0 )
190 {
191 $variation = $image->requestImageVariation( $DealerThumbWidth, $DealerThumbHeight );
192 $t->set_var( "thumbnail_image_uri", $variation->imagePath() );
193 $t->set_var( "thumbnail_image_width", $variation->width() );
194 $t->set_var( "thumbnail_image_height", $variation->height() );
195 $t->parse( "dealer_image", "dealer_image_tpl", true );
196 }
197 $t->parse( "dealer_image_item", "dealer_image_item_tpl", true );
198 }
199 $t->parse( "dealer_image_box", "dealer_image_box_tpl", true );
200
201 // products
202 $product = new eZProduct();
203 $productList =& $product->hotDealProducts( $HotDealsLimit );
204
205 $i = 0;
206 foreach ($productList as $product)
207 {
208 if ($i < $HotDealsLimit )
209 {
210 $t->set_var( "product_id", $product->id() );
211 // prevent html from being excaped ! render that html!
212 // $t->set_var( "product_intro_text", htmlspecialchars( $product->brief() ) );
213 $t->set_var( "product_intro_text", $product->brief() );
214 $t->set_var( "product_name", $product->name() );
215
216 if ( $product->showPrice() == true )
217 {
218 $currency = new eZCurrency();
219 $currency->setValue( $product->correctPrice( $PricesIncludeVAT ) );
220 $t->set_var( "product_price", $locale->format( $currency ) );
221 $t->parse( "price", "price_tpl" );
222 }
223 else
224 $t->set_var( "price", "" );
225
226 if ( $product->forum() )
227 {
228 $forum = $product->forum();
229 $MessageCount = $forum->messageCount( false, true );
230 if ( $MessageCount > 0 )
231 {
232 if ( $MessageCount == 1)
233 $messageText = $t->get_var("intl-message");
234 else
235 $messageText = $t->get_var("intl-messages");
236
237 $t->set_var( "messages", $MessageCount."&nbsp;".$messageText );
238 $t->parse( "product_message_count", "product_message_count_tpl" );
239 }
240 else
241 $t->set_var( "product_message_count", "" );
242 }
243 else
244 $t->set_var( "product_message_count", "" );
245
246 $image = $product->thumbnailImage();
247 if( is_object( $image ) )
248 {
249 $t->set_var( "image_caption", $image->caption() );
250 $variation = $image->requestImageVariation( $HotDealsThumbWidth, $HotDealsThumbHeight );
251 $t->set_var( "product_image_path", $variation->imagePath() );
252 $t->set_var( "product_image_width", $variation->width() );
253 $t->set_var( "product_image_height", $variation->height() );
254 $t->parse( "product_list_item", "product_list_item_tpl", true );
255 }
256 }
257 $i++;
258 }
259 $t->parse( "product_list", "product_list_tpl", true );
260
261 $i = 0;
262 if ( $i < $GalleryLimit )
263 {
264 $imageCategories =& eZImageCategory::getAll($GalleryLimit);
265 foreach ($imageCategories as $category)
266 {
267 $images = $category->images( "time", 0, 1 );
268 if (count( $images ) < 1)
269 {
270 $GalleryLimit++;
271 }
272 }
273 $i++;
274 }
275
276 $imageCategories =& eZImageCategory::getAll($GalleryLimit);
277 $iei=0;
278 foreach ($imageCategories as $category)
279 {
280 $iei++;
281 // echo($iei);
282 $t->set_var("image_row_open", "");
283 $t->set_var("image_row_close", "");
284 // if ($iei == 1 || is_integer(($iei-1) / 5) )
285 // if ($iei == 1 || is_integer(($iei-1) / 3) )
286 // if ($iei == 1 || is_integer(($iei-1) / 3) )
287 if ( $iei % 9 == 0 )
288 {
289 $t->set_var("image_row_open", "<tr>");
290 }
291
292 if ( ($iei + 1) % 9 == 0 )
293 {
294 $t->set_var("image_row_close", "</tr>");
295 }
296 $images = $category->images( "time", 0, 1 );
297 $t->set_var( "category_id", $category->id() );
298 if ( strlen( $category->name() ) > ($GalleryThumbWidth/10) )
299 $name = substr($category->name(), 0, $GalleryThumbWidth/10);
300 else
301 $name = $category->name();
302 $t->set_var( "category_name", stripslashes($name) );
303
304 if ( $category->description() != "" )
305 $t->set_var( "category_description", $category->description() );
306 else
307 $t->set_var( "category_description", stripslashes( $category->name() ) );
308 // print_r( $images[0]->requestImageVariation( $GalleryThumbWidth, $GalleryThumbHeight ) ); exit();
309 // $image = new eZImage( $images[0]->id() );
310 if ( isset( $images[0] ) )
311 {
312 $variation = $images[0]->requestImageVariation( $GalleryThumbWidth, $GalleryThumbHeight );
313 $t->set_var( "thumbnail_image_uri", $variation->imagePath() );
314 $t->set_var( "thumbnail_image_width", $variation->width() );
315 $t->set_var( "thumbnail_image_height", $variation->height() );
316 $t->parse( "image_list_item", "image_list_item_tpl", true );
317 }
318 // echo "<img src=\"http://" . $HTTP_HOST . $ini->WWWDir . "/" . $variation->imagePath() .
319 // "\" height=\"".$variation->height()."\" width=\"".
320 // $variation->width()."\" /><br />";
321
322 }
323
324 $t->parse( "image_list", "image_list_tpl", true );
325
326
327 $time = new eZDateTime();
328 $messages =& eZForumMessage::lastMessages( $CommentLimit );
329
330 foreach ($messages as $message)
331 {
332 $t->set_var( "message_id", $message['ID'] );
333 $time->setTimeStamp( $message['PostingTime'] );
334 $t->set_var( "date_posted", $locale->format( $time ) );
335 $t->set_var( "message_topic", stripslashes($message['Topic']) );
336 if ( $message['UserID'] == 0 )
337 $messageAuthorName = $Anonymous;
338 else
339 {
340 $messageAuthor = new eZUser( $message['UserID'] );
341 $messageAuthorName = $messageAuthor->firstName() . " " . $messageAuthor->lastName();
342 }
343
344 $t->set_var( "author", $messageAuthorName );
345
346 if( isset( $message['Body'] ) )
347 {
348 $messageHeader = substr($message['Body'], 0, $CommentLetterLimit );
349 $t->set_var( "message_header", stripslashes($messageHeader)."..." );
350 }
351
352 $t->parse( "message_list_item", "message_list_item_tpl", true );
353 // print_r( stripslashes($message['Topic']) );
354 // echo "\n";
355 }
356
357 if ( count($messages) > 0 )
358 $t->parse( "message_list", "message_list_tpl", true );
359 else
360 $t->set_var( "message_list", "" );
361
362 $article = new eZArticle();
363 $articleList =& $article->articles( "time", false, 0, $ArticleLimit );
364
365 foreach($articleList as $article)
366 {
367 $t->set_var( "article_id", $article->id() );
368 $t->set_var( "category_id", $article->categoryDefinition( false ) );
369 $t->set_var( "title", $article->name() );
370
371 $thumbnailImage =& $article->thumbnailImage();
372 if ( $thumbnailImage )
373 {
374 $variation =& $thumbnailImage->requestImageVariation( $ArticleThumbWidth, $ArticleThumbHeight );
375 $t->set_var( "thumbnail_image_uri", $variation->imagePath() );
376 $t->set_var( "thumbnail_image_width", $variation->width() );
377 $t->set_var( "thumbnail_image_height", $variation->height() );
378 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
379 $t->parse( "article_image", "article_image_tpl" );
380 }
381 else
382 $t->set_var( "article_image", "" );
383
384 $renderer = new eZArticleRenderer( $article );
385 $t->set_var( "article_intro", $renderer->renderIntro( ) );
386
387 $published =& $article->published();
388 $publishedDateValue =& $published->date();
389 $publishedTimeValue =& $published->time();
390
391 $t->set_var( "article_published", $locale->format( $publishedDateValue )."&nbsp;".$locale->format( $publishedTimeValue ) );
392
393 $t->set_var( "messages", "" );
394 if ( $article->forum() )
395 {
396 $forum = $article->forum();
397 $MessageCount = $forum->messageCount( false, true );
398 if ( $MessageCount > 0 )
399 {
400 if ( $MessageCount == 1)
401 $messageText = $t->get_var("intl-message");
402 else
403 $messageText = $t->get_var("intl-messages");
404
405 $t->set_var( "messages", $MessageCount."&nbsp;".$messageText );
406 $t->parse( "message_count", "message_count_tpl" );
407 }
408 else
409 $t->set_var( "message_count", "" );
410 }
411 else
412 $t->set_var( "message_count", "" );
413 $t->parse( "article_item", "article_item_tpl", true );
414 // print_r($article->name());
415 // echo "\n";
416 }
417 $t->parse( "article_list", "article_list_tpl", true );
418
419 //echo "</pre>";
420
421
422 if ( isset( $GenerateStaticPage ) and $GenerateStaticPage == "true" and $cachedFile != "" )
423 {
424 $fp = eZPBFile::fopen( $cachedFile, "w+");
425
426 // add PHP code in the cache file to store variables
427 $output = "<?php\n";
428 $output .= "\$GlobalSectionID=\"$GlobalSectionID\";\n";
429 // $output .= "\$SiteTitleAppend=\"$SiteTitleAppend\";\n";
430 // $output .= "\$SiteDescriptionOverride=\"$SiteDescriptionOverride\";\n";
431 // $output .= "\$eZLanguageOverride=\"$eZLanguageOverride\";\n";
432 $output .= "?>\n";
433
434 $output .= $t->parse( "output", "homepage_tpl" );
435
436 // print the output the first time while printing the cache file.
437 print( $output );
438 fwrite ( $fp, $output );
439 fclose( $fp );
440 }
441 else
442 {
443 $t->pparse( "output", "homepage_tpl" );
444 }
445
446 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$forum
$forum
Definition: admin/forumlist.php:50
$message
$message
Definition: admin/message.php:51
$images
$images
Definition: articlepreview.php:146
$renderer
if(! $article->get( $ArticleID)) $renderer
Definition: articlepreview.php:76
eZArticleRenderer
Definition: ezarticlerenderer.php:36
eZArticle
Definition: ezarticle.php:82
eZCurrency
Definition: ezcurrency.php:46
eZDateTime
Definition: ezdatetime.php:55
eZForumMessage\lastMessages
static & lastMessages( $limit, $user=false, $userid=false)
Definition: ezforummessage.php:892
eZImageCategory\getAll
static getAll( $limit=false, $offset=0)
Definition: ezimagecategory.php:237
eZLocale
Definition: ezlocale.php:119
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZProductCategory
Definition: ezproductcategory.php:90
eZProduct
Definition: ezproduct.php:71
eZTemplate
Definition: eztemplate.php:107
eZUser
Definition: ezuser.php:76
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$name
$name
Definition: companytypelist.php:194
$currency
$currency
Definition: companyview.php:529
$fp
$fp
Definition: export.php:97
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$cachedFile
$cachedFile
Definition: eznewsfeed/user/headlines.php:109
$output
$output
Definition: formpreview.php:81
$dealerProdArray
$dealerProdArray
Definition: homepage.php:128
$Anonymous
$Anonymous
Definition: homepage.php:65
$ArticleThumbHeight
$ArticleThumbHeight
Definition: homepage.php:58
$articleList
$articleList
Definition: homepage.php:363
$fei
$fei
Definition: homepage.php:132
$messages
$messages
Definition: homepage.php:328
$CommentLetterLimit
$CommentLetterLimit
Definition: homepage.php:64
$locale
$locale
Definition: homepage.php:70
$t
$t
Definition: homepage.php:72
$distProdArray
$distProdArray
Definition: homepage.php:126
$Distributor
$Distributor
Definition: homepage.php:49
$article
$article
Definition: homepage.php:362
$CommentLimit
$CommentLimit
Definition: homepage.php:63
$user
$user
Definition: homepage.php:131
$PricesIncludeVAT
$PricesIncludeVAT
Definition: homepage.php:47
$GalleryThumbHeight
$GalleryThumbHeight
Definition: homepage.php:67
$imageCategories
if( $i< $GalleryLimit) $imageCategories
Definition: homepage.php:276
$product
$product
Definition: homepage.php:202
$ArticleLimit
$ArticleLimit
Definition: homepage.php:56
$dei
$dei
Definition: homepage.php:166
$time
$time
Definition: homepage.php:327
$HotDealsLimit
$HotDealsLimit
Definition: homepage.php:59
$DistThumbHeight
$DistThumbHeight
Definition: homepage.php:52
$i
$i
Definition: homepage.php:205
$DistProdCats
$DistProdCats
Definition: homepage.php:50
$Language
$Language
Definition: homepage.php:68
$GalleryLimit
$GalleryLimit
Definition: homepage.php:62
$Dealer
$Dealer
Definition: homepage.php:48
$DistThumbWidth
$DistThumbWidth
Definition: homepage.php:51
$iei
$iei
Definition: homepage.php:277
$ini
$ini
Definition: homepage.php:45
$DealerThumbWidth
$DealerThumbWidth
Definition: homepage.php:54
$DealerProdCats
$DealerProdCats
Definition: homepage.php:53
$HotDealsThumbWidth
$HotDealsThumbWidth
Definition: homepage.php:60
$DealerThumbHeight
$DealerThumbHeight
Definition: homepage.php:55
$GalleryThumbWidth
$GalleryThumbWidth
Definition: homepage.php:66
$HotDealsThumbHeight
$HotDealsThumbHeight
Definition: homepage.php:61
$ArticleThumbWidth
$ArticleThumbWidth
Definition: homepage.php:57
$productList
$productList
Definition: homepage.php:203
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.