Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

frontpage.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: frontpage.php 9900 2004-07-08 13:48:56Z br $
5 //
6 // Created on: <30-May-2001 14:06:59 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/ezlist.php" );
31
32 // include_once( "ezarticle/classes/ezarticlecategory.php" );
33 // include_once( "ezarticle/classes/ezarticle.php" );
34 // include_once( "ezarticle/classes/ezarticlerenderer.php" );
35 // include_once( "ezuser/classes/ezobjectpermission.php" );
36 // include_once( "ezsitemanager/classes/ezsection.php" );
37
38 // include_once( "ezad/classes/ezadcategory.php" );
39 // include_once( "ezad/classes/ezad.php" );
40
41 // $CategoryID = $url_array[3];
42 global $CategoryID;
43
44 $ini =& eZINI::instance( 'site.ini' );
45
46 $Language = $ini->variable( "eZArticleMain", "Language" );
47 $ImageDir = $ini->variable( "eZArticleMain", "ImageDir" );
48 $CapitalizeHeadlines = $ini->variable( "eZArticleMain", "CapitalizeHeadlines" );
49 $DefaultLinkText = $ini->variable( "eZArticleMain", "DefaultLinkText" );
50 $GrayScaleImageList = $ini->variable( "eZArticleMain", "GrayScaleImageList" );
51
52 $sectionObject =& eZSection::globalSectionObject( $GlobalSectionID );
53 $sectionObject->setOverrideVariables();
54
55 $t = new eZTemplate( "kernel/ezarticle/user/" . $ini->variable( "eZArticleMain", "TemplateDir" ),
56 "kernel/ezarticle/user/intl/", $Language, "frontpage.php" );
57
58 $t->setAllStrings();
59
60 $t->set_file( "article_list_page_tpl", "frontpage.tpl" );
61
62 $t->set_block( "article_list_page_tpl", "header_item_tpl", "header_item" );
63
64
65 // one column article
66 $t->set_block( "article_list_page_tpl", "element_list_tpl", "element_list" );
67 $t->set_block( "article_list_page_tpl", "one_column_article_tpl", "one_column_article" );
68 $t->set_block( "one_column_article_tpl", "one_column_article_image_tpl", "one_column_article_image" );
69 $t->set_block( "one_column_article_tpl", "one_column_read_more_tpl", "one_column_read_more" );
70 $t->set_block( "one_column_article_tpl", "message_count_tpl", "message_count" );
71
72 // one column product
73 $t->set_block( "article_list_page_tpl", "one_column_product_tpl", "one_column_product" );
74 $t->set_block( "one_column_product_tpl", "product_image_tpl", "product_image" );
75 $t->set_block( "one_column_product_tpl", "price_tpl", "price" );
76
77 // two column product
78 $t->set_block( "article_list_page_tpl", "two_column_product_tpl", "two_column_product" );
79 $t->set_block( "two_column_product_tpl", "left_product_tpl", "left_product" );
80 $t->set_block( "left_product_tpl", "left_product_image_tpl", "left_product_image" );
81 $t->set_block( "left_product_tpl", "left_price_tpl", "left_price" );
82
83 $t->set_block( "two_column_product_tpl", "right_product_tpl", "right_product" );
84 $t->set_block( "right_product_tpl", "right_product_image_tpl", "right_product_image" );
85 $t->set_block( "right_product_tpl", "right_price_tpl", "right_price" );
86
87 // two column article
88 $t->set_block( "article_list_page_tpl", "two_column_article_tpl", "two_column_article" );
89 $t->set_block( "two_column_article_tpl", "left_article_tpl", "left_article" );
90 $t->set_block( "left_article_tpl", "left_article_image_tpl", "left_article_image" );
91 $t->set_block( "left_article_tpl", "left_read_more_tpl", "left_read_more" );
92 $t->set_block( "left_article_tpl", "left_message_count_tpl", "left_message_count" );
93
94 $t->set_block( "two_column_article_tpl", "right_article_tpl", "right_article" );
95 $t->set_block( "right_article_tpl", "right_article_image_tpl", "right_article_image" );
96 $t->set_block( "right_article_tpl", "right_read_more_tpl", "right_read_more" );
97 $t->set_block( "right_article_tpl", "right_message_count_tpl", "right_message_count" );
98
99 // short single article
100 $t->set_block( "article_list_page_tpl", "one_short_article_tpl", "one_short_article" );
101 $t->set_block( "one_short_article_tpl", "short_read_more_tpl", "short_read_more" );
102
103 // banner ad
104 $t->set_block( "article_list_page_tpl", "ad_column_tpl", "ad_column" );
105 $t->set_block( "ad_column_tpl", "standard_ad_tpl", "standard_ad" );
106 $t->set_block( "ad_column_tpl", "html_ad_tpl", "html_ad" );
107
108 $t->set_var( "element_list", "" );
109
110 $t->set_var( "one_column_article", "" );
111 $t->set_var( "two_column_article", "" );
112 $t->set_var( "two_column_product", "" );
113 $t->set_var( "one_short_article", "" );
114 $t->set_var( "ad_column", "" );
115 $t->set_var( "one_column_product", "" );
116
117
118 // image dir
119 $t->set_var( "image_dir", $ImageDir );
120
121 $articleCount = 0;
122 $productCount = 0;
123 $adCount = 0;
124
125 // section
126 $t->set_var( "section_id", $GlobalSectionID );
127
128 $rows =& $sectionObject->frontPageRows();
129
130 $page_element = array();
131 $offsetArticleArray = array();
132 $offsetProductArray = array();
133
134 $tempArticle = new eZArticle();
135 $articleList = array();
136
137 if ( is_array ( $rows ) and count ( $rows ) > 0 )
138 {
139 foreach ( $rows as $row )
140 {
141 $value = $row->settingByID( $row->settingID() );
142 if (!isset($offsetArticleArray[$row->categoryID()]))
143 {
144 $offsetArticleArray[$row->categoryID()] = 0;
145 }
146 if ( $value == "2column" )
147 {
148 $category = new eZArticleCategory( $row->categoryID() );
149 if ( $category->id() == "0" )
150 {
151 $articleList = @array_merge( $articleList, $tempArticle->articles( "time", false, $offsetArticleArray[$row->categoryID()], 2 ) );
152 }
153 else
154 {
155 $articleList = @array_merge( $articleList, (new eZArticleCategory())->articles( $category->sortMode(), false, true, $offsetArticleArray[$row->categoryID()], 2, $row->categoryID() ) );
156 }
157
158 $offsetArticleArray[$row->categoryID()] = $offsetArticleArray[$row->categoryID()] + 2;
159 }
160 if ( $value == "1column" || $value == "1short" )
161 {
162 $category = new eZArticleCategory( $row->categoryID() );
163 if ( $category->id() == "0" )
164 {
165 $articleList = @array_merge( $articleList, $tempArticle->articles( "time", false, $offsetArticleArray[$row->categoryID()], 1 ) );
166 }
167 else
168 {
169 $articleList = @array_merge( $articleList, (new eZArticleCategory())->articles( $category->sortMode(), false, true, $offsetArticleArray[$row->categoryID()], 1, $row->categoryID() ) );
170 }
171 $offsetArticleArray[$row->categoryID()] = $offsetArticleArray[$row->categoryID()] + 1;
172 }
173 if ( $value == "ad" )
174 {
175 $adList = array();
176 $offsetAdArray = array();
177 $category = new eZAdCategory( $row->categoryID() );
178 if( isset( $offsetAdArray[ $row->categoryID() ] ) )
179 {
180 $offsetAdCategoryID = $offsetAdArray[ $row->categoryID() ];
181 }
182 else
183 {
184 $offsetAdCategoryID = 0;
185 }
186 $adList =& array_merge( $adList, $category->ads( "count", false, $offsetAdCategoryID, 1 ) );
187 $offsetAdArray[$row->categoryID()] = $offsetAdCategoryID + 1;
188 }
189 if ( $value == "1columnProduct" )
190 {
191 $category = new eZProductCategory( $row->categoryID() );
192 if (!isset($offsetProductArray[$row->categoryID()]))
193 {
194 $offsetProductArray[$row->categoryID()] = 0;
195 }
196 if (isset($productList))
197 {
198 $productList = array_merge( $productList, eZProductCategory::products( $category->sortMode(), false, $offsetProductArray[$row->categoryID()], 1, false, $row->categoryID() ) );
199 }
200 else
201 {
202 $productList = eZProductCategory::products( $category->sortMode(), false, $offsetProductArray[$row->categoryID()], 1, false, $row->categoryID() );
203 }
204 $offsetProductArray[$row->categoryID()] = $offsetProductArray[$row->categoryID()] + 1;
205 }
206 if ( $value == "2columnProduct" )
207 {
208 $productList = array();
209 $offsetProductArray = array();
210 if( isset( $offsetProductArray[ $row->categoryID() ] ) )
211 {
212 $offsetProductCategoryID = $offsetProductArray[ $row->categoryID() ];
213 }
214 else
215 {
216 $offsetProductCategoryID = 0;
217 }
218 $category = new eZProductCategory( $row->categoryID() );
219 $productList =& array_merge( $productList, eZProductCategory::products( $category->sortMode(), false, $offsetProductCategoryID, 2, false, $row->categoryID() ) );
220 $offsetProductArray[$row->categoryID()] = $offsetProductCategoryID + 2;
221 }
222 $page_elements[] = $value;
223 }
224 }
225
226 $user =& eZUser::currentUser();
227
228 //$sectionObject->setOverrideVariables();
229
230 if ( $adCount > 0 )
231 {
232 // include_once( "ezad/classes/ezadcategory.php" );
233 // include_once( "ezad/classes/ezad.php" );
234
235 $adCategory = new eZAdCategory( $FrontPageAdCategory );
236
237 $adList =& $adCategory->ads( "count", false, 0, $adCount );
238 }
239
240 $t->set_var( "category_current_id", $CategoryID);
241
242 $locale = new eZLocale( $Language );
243 $i=0;
244
245 $articleOffset = 0;
246 $productOffset = 0;
247 $adOffset = 0;
248 $pageContents = "";
249 $counter = -1;
250 // render the page elements
251 if ( isset( $page_elements ) && count( $page_elements ) > 0 )
252 foreach ( $page_elements as $element )
253 {
254 $counter++;
255
256 switch ( $element )
257 {
258 case "1column":
259 {
260 $article =& $articleList[$articleOffset];
261
262 if ( is_a( $article, "eZArticle" ) )
263 $pageContents .= renderFrontpageArticle( $t, $locale, $article, $ini, $counter, $rows, $GrayScaleImageList );
264
265 $articleOffset++;
266 }break;
267
268 case "2column":
269 {
270 $article1 =& $articleList[$articleOffset];
271 $articleOffset++;
272 $article2 =& $articleList[$articleOffset];
273
274 if ( is_a( $article1, "eZArticle" ) && is_a( $article2, "eZArticle" ) )
275 $pageContents .= renderFrontpageArticleDouble( $t, $locale, $article1, $article2, $ini, $counter, $rows, $GrayScaleImageList );
276
277 $articleOffset++;
278 }break;
279
280 case "1short":
281 {
282 $article =& $articleList[$articleOffset];
283
284 if ( is_a( $article, "eZArticle" ) )
285 $pageContents .= renderShortSingleArticle( $t, $locale, $article, $ini, $counter, $rows, $GrayScaleImageList );
286
287 $articleOffset++;
288 }break;
289
290 case "ad":
291 {
292 $ad =& $adList[$adOffset];
293 if ( is_a( $ad, "eZAd" ) )
294 $pageContents .= renderAd( $t, $locale, $ad, $ini, $counter, $rows, $GrayScaleImageList );
295
296 $adOffset++;
297 }break;
298
299 case "1columnProduct":
300 {
301 $product =& $productList[$productOffset];
302 if ( is_a( $product, "eZProduct" ) )
303 $pageContents .= renderFrontpageProduct( $t, $locale, $product, $ini, $counter, $rows, $GrayScaleImageList );
304
305 $productOffset++;
306 }break;
307
308 case "2columnProduct":
309 {
310 $product1 =& $productList[$productOffset];
311 $productOffset++;
312 $product2 =& $productList[$productOffset];
313
314 if ( is_a( $product1, "eZProduct" ) && is_a( $product2, "eZProduct" ) )
315 $pageContents .= renderFrontpageProductDouble( $t, $locale, $product1, $product2, $ini, $counter, $rows, $GrayScaleImageList );
316
317 $productOffset++;
318 }break;
319
320
321 }
322 }
323 $t->set_var( "element_list", $pageContents );
324
325
326 function &renderFrontpageArticle( &$t, &$locale, &$article, &$ini = null, $counter = 0, $rows = null, $GrayScaleImageList = null )
327 {
328 // global $ini, $counter, $rows, $GrayScaleImageList;
329
330 $DefaultLinkText = $ini->variable( "eZArticleMain", "DefaultLinkText" );
331
332 $aid = $article->id();
333
334 $CategoryID = $rows[$counter]->CategoryID;
335
336 if ( $CategoryID == 0 )
337 {
338 $category =& $article->categoryDefinition();
339 $CategoryID = $category->id();
340 }
341
342 $t->set_var( "category_id", $CategoryID );
343
344 $t->set_var( "article_id", $article->id() );
345 $t->set_var( "article_name", $article->name() );
346
347 $t->set_var( "author_text", $article->authorText() );
348
349 $categoryDef =& $article->categoryDefinition();
350
351 $t->set_var( "category_def_name", $categoryDef->name() );
352 $t->set_var( "category_def_id", $categoryDef->id() );
353
354 // preview image
355 $thumbnailImage =& $article->thumbnailImage();
356 if ( $thumbnailImage )
357 {
358 if ( $GrayScaleImageList == "enabled" )
359 $convertToGray = true;
360 else
361 $convertToGray = false;
362
363 $variation =& $thumbnailImage->requestImageVariation( $ini->variable( "eZArticleMain", "ThumbnailImageWidth" ),
364 $ini->variable( "eZArticleMain", "ThumbnailImageHeight" ), $convertToGray );
365
366 // $t->set_var( "thumbnail_image_uri", $variation->imagePath() );
367
368 if( is_object( $variation ) )
369 {
370 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
371 $t->set_var( "thumbnail_image_width", $variation->width() );
372 $t->set_var( "thumbnail_image_height", $variation->height() );
373 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
374 }
375
376 $t->parse( "one_column_article_image", "one_column_article_image_tpl" );
377 }
378 else
379 {
380 $t->set_var( "one_column_article_image", "" );
381 }
382
383 $published = $article->published();
384
385 $publishedDateValue =& $published->date();
386 $publishedTimeValue =& $published->time();
387
388 $t->set_var( "article_datevalue", $locale->format( $publishedDateValue ) );
389 $t->set_var( "article_timevalue", $locale->format( $publishedTimeValue ) );
390
391
392 $t->set_var( "article_published", $locale->format( $published ) );
393
394
395 $renderer = new eZArticleRenderer( $article );
396 $t->set_var( "article_intro", $renderer->renderIntro( ) );
397
398 $t->set_var( "messages", "" );
399 if ( $article->forum() )
400 {
401 $forum = $article->forum();
402 $MessageCount = $forum->messageCount( false, true );
403 if ( $MessageCount > 0 )
404 {
405 $t->set_var( "messages", $MessageCount );
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
414 if ( $article->linkText() != "" )
415 {
416 $t->set_var( "article_link_text", $article->linkText() );
417 }
418 else
419 {
420 $t->set_var( "article_link_text", $DefaultLinkText );
421 }
422
423 // check if the article contains more than intro
424 $contents =& $renderer->renderPage();
425
426 if ( trim( $contents[1] ) == "" )
427 {
428 $t->set_var( "one_column_read_more", "" );
429 }
430 else
431 {
432 $t->parse( "one_column_read_more", "one_column_read_more_tpl" );
433 }
434
435
436 return $t->parse( "output", "one_column_article_tpl" );
437 }
438
439 function &renderFrontpageArticleDouble( &$t, &$locale, &$article1, &$article2, &$ini = null, $counter = 0, $rows = null, $GrayScaleImageList = null )
440 {
441 // global $ini, $counter, $rows, $GrayScaleImageList;
442 $aid = $article1->id();
443
444 $DefaultLinkText = $ini->variable( "eZArticleMain", "DefaultLinkText" );
445
446 $CategoryID = $rows[$counter]->CategoryID;
447
448 if ( $CategoryID == 0 )
449 {
450 $category =& $article1->categoryDefinition();
451 $CategoryID = $category->id();
452 }
453
454 $t->set_var( "category_id", $CategoryID );
455
456 $t->set_var( "article_id", $article1->id() );
457 $t->set_var( "article_name", $article1->name() );
458 $t->set_var( "author_text", $article1->authorText() );
459
460 $categoryDef =& $article1->categoryDefinition();
461 $t->set_var( "category_def_name", $categoryDef->name() );
462 $t->set_var( "category_def_id", $categoryDef->id() );
463
464 // preview image
465 $thumbnailImage =& $article1->thumbnailImage();
466 if ( $thumbnailImage )
467 {
468 if ( $GrayScaleImageList == "enabled" )
469 $convertToGray = true;
470 else
471 $convertToGray = false;
472
473 $variation =& $thumbnailImage->requestImageVariation( $ini->variable( "eZArticleMain", "ThumbnailImageWidth" ),
474 $ini->variable( "eZArticleMain", "ThumbnailImageHeight" ), $convertToGray );
475
476 if( is_object( $variation ) ) {
477 $t->set_var("thumbnail_image_uri", "/" . $variation->imagePath());
478 $t->set_var("thumbnail_image_width", $variation->width());
479 $t->set_var("thumbnail_image_height", $variation->height());
480 }
481 $t->set_var("thumbnail_image_caption", $thumbnailImage->caption());
482
483 $t->parse( "left_article_image", "left_article_image_tpl" );
484 }
485 else
486 {
487 $t->set_var( "left_article_image", "" );
488 }
489
490 $published = $article1->published();
491
492 $publishedDateValue =& $published->date();
493 $publishedTimeValue =& $published->time();
494
495 $t->set_var( "article_datevalue", $locale->format( $publishedDateValue ) );
496 $t->set_var( "article_timevalue", $locale->format( $publishedTimeValue ) );
497
498
499 $t->set_var( "article_published", $locale->format( $published ) );
500
501
502 $renderer = new eZArticleRenderer( $article1 );
503 $t->set_var( "article_intro", $renderer->renderIntro( ) );
504
505 $t->set_var( "messages", "" );
506 if ( $article1->forum() )
507 {
508 $forum = $article1->forum();
509 $MessageCount = $forum->messageCount( false, true );
510 if ( $MessageCount > 0 )
511 {
512 $t->set_var( "messages", $MessageCount );
513 $t->parse( "left_message_count", "left_message_count_tpl" );
514 }
515 else
516 $t->set_var( "left_message_count", "" );
517 }
518 else
519 $t->set_var( "left_message_count", "" );
520
521 if ( $article1->linkText() != "" )
522 {
523 $t->set_var( "article_link_text", $article1->linkText() );
524 }
525 else
526 {
527 $t->set_var( "article_link_text", $DefaultLinkText );
528 }
529
530 // check if the article contains more than intro
531 $contents =& $renderer->renderPage();
532
533 if ( trim( $contents[1] ) == "" )
534 {
535 $t->set_var( "left_read_more", "" );
536 }
537 else
538 {
539 $t->parse( "left_read_more", "left_read_more_tpl" );
540 }
541
542 $t->parse( "left_article", "left_article_tpl" );
543 $aid = $article2->id();
544
545 // if ( $CategoryID == 0 )
546 // {
547 // $category =& $article2->categoryDefinition();
548 // $CategoryID = $category->id();
549 // }
550 // $category =& $article2->categoryDefinition();
551 // $CategoryID = $category->id();
552
553 $t->set_var( "category_id", $CategoryID );
554
555 $t->set_var( "article_id", $article2->id() );
556 $t->set_var( "article_name", $article2->name() );
557 $t->set_var( "author_text", $article2->authorText() );
558
559 $categoryDef =& $article2->categoryDefinition();
560 $t->set_var( "category_def_name", $categoryDef->name() );
561 $t->set_var( "category_def_id", $categoryDef->id() );
562
563 // preview image
564 $thumbnailImage =& $article2->thumbnailImage();
565 if ( $thumbnailImage )
566 {
567 if ( $GrayScaleImageList == "enabled" )
568 $convertToGray = true;
569 else
570 $convertToGray = false;
571
572 $variation =& $thumbnailImage->requestImageVariation( $ini->variable( "eZArticleMain", "ThumbnailImageWidth" ),
573 $ini->variable( "eZArticleMain", "ThumbnailImageHeight" ), $convertToGray );
574
575 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
576 $t->set_var( "thumbnail_image_width", $variation->width() );
577 $t->set_var( "thumbnail_image_height", $variation->height() );
578 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
579
580 $t->parse( "right_article_image", "right_article_image_tpl" );
581 }
582 else
583 {
584 $t->set_var( "right_article_image", "" );
585 }
586
587 $published = $article2->published();
588
589 $publishedDateValue =& $published->date();
590 $publishedTimeValue =& $published->time();
591
592 $t->set_var( "article_datevalue", $locale->format( $publishedDateValue ) );
593 $t->set_var( "article_timevalue", $locale->format( $publishedTimeValue ) );
594
595
596 $t->set_var( "article_published", $locale->format( $published ) );
597
598
599 $renderer = new eZArticleRenderer( $article2 );
600 $t->set_var( "article_intro", $renderer->renderIntro( ) );
601
602 $t->set_var( "messages", "" );
603 if ( $article2->forum() )
604 {
605 $forum = $article2->forum();
606 $MessageCount = $forum->messageCount( false, true );
607 if ( $MessageCount > 0 )
608 {
609 $t->set_var( "messages", $MessageCount );
610 $t->parse( "right_message_count", "right_message_count_tpl" );
611 }
612 else
613 $t->set_var( "right_message_count", "" );
614 }
615 else
616 $t->set_var( "right_message_count", "" );
617
618 if ( $article2->linkText() != "" )
619 {
620 $t->set_var( "article_link_text", $article2->linkText() );
621 }
622 else
623 {
624 $t->set_var( "article_link_text", $DefaultLinkText );
625 }
626
627 // check if the article contains more than intro
628 $contents =& $renderer->renderPage();
629
630 if ( trim( $contents[1] ) == "" )
631 {
632 $t->set_var( "right_read_more", "" );
633 }
634 else
635 {
636 $t->parse( "right_read_more", "right_read_more_tpl" );
637 }
638
639 $t->parse( "right_article", "right_article_tpl" );
640
641 return $t->parse( "output", "two_column_article_tpl" );
642 }
643
644 function &renderShortSingleArticle( &$t, &$locale, &$article, &$ini = null, $counter = 0, $rows = null, $GrayScaleImageList = null )
645 {
646 // global $ini, $counter, $rows, $GrayScaleImageList;
647
648 $aid = $article->id();
649
650 $DefaultLinkText = $ini->variable( "eZArticleMain", "DefaultLinkText" );
651
652 $CategoryID = $rows[$counter]->CategoryID;
653
654 if ( $CategoryID == 0 )
655 {
656 $category =& $article->categoryDefinition();
657 $CategoryID = $category->id();
658 }
659
660 $t->set_var( "category_id", $CategoryID );
661
662 $t->set_var( "article_id", $article->id() );
663 $t->set_var( "article_name", $article->name() );
664
665 $t->set_var( "author_text", $article->authorText() );
666
667 $categoryDef =& $article->categoryDefinition();
668
669 $t->set_var( "category_def_name", $categoryDef->name() );
670 $t->set_var( "category_def_id", $categoryDef->id() );
671
672 $published = $article->published();
673
674 $publishedDateValue =& $published->date();
675 $publishedTimeValue =& $published->time();
676
677 $t->set_var( "article_datevalue", $locale->format( $publishedDateValue ) );
678 $t->set_var( "article_timevalue", $locale->format( $publishedTimeValue ) );
679
680 $t->set_var( "article_published", $locale->format( $published ) );
681
682
683 if ( $article->linkText() != "" )
684 {
685 $t->set_var( "article_link_text", $article->linkText() );
686 }
687 else
688 {
689 $t->set_var( "article_link_text", $DefaultLinkText );
690 }
691
692
693 return $t->parse( "output", "one_short_article_tpl" );
694 }
695
696 function &renderAd( &$t, &$locale, &$ad, &$ini = null )
697 {
698 // global $ini;
699
700 if ( $ad->useHTML() )
701 {
702 $t->set_var( "standard_ad", "" );
703
704 $t->set_var( "html_ad_contents", $ad->htmlBanner() );
705 $t->parse( "html_ad", "html_ad_tpl" );
706 }
707 else
708 {
709 $t->set_var( "html_ad", "" );
710 $image =& $ad->image();
711
712 if ( $image )
713 {
714 $imgSRC =& $image->filePath();
715 $imgWidth =& $image->width();
716 $imgHeight =& $image->height();
717 }
718
719 $t->set_var( "ad_id", $ad->id() );
720 $t->set_var( "image_src", $imgSRC );
721 $t->set_var( "image_width", $imgWidth );
722 $t->set_var( "image_height", $imgHeight );
723 $t->parse( "standard_ad", "standard_ad_tpl" );
724 }
725
726 $ad->addPageView();
727
728 return $t->parse( "output", "ad_column_tpl" );
729 }
730
731
732 function &renderFrontpageProduct( &$t, &$locale, &$product, &$ini = null )
733 {
734 // global $ini;
735 $i=0;
736 $pid = $product->id();
737
738 $ThumbnailImageWidth = $ini->variable( "eZTradeMain", "ThumbnailImageWidth" );
739 $ThumbnailImageHeight = $ini->variable( "eZTradeMain", "ThumbnailImageHeight" );
740
741 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" );
742
743 // preview image
744 $thumbnailImage = $product->thumbnailImage();
745 $t->set_var( "product_id", $product->id() );
746
747 if ( $thumbnailImage )
748 {
749 $variation =& $thumbnailImage->requestImageVariation( $ThumbnailImageWidth, $ThumbnailImageHeight );
750
751 $t->set_var( "product1_thumbnail_image_uri", "/" . $variation->imagePath() );
752 $t->set_var( "product1_thumbnail_image_width", $variation->width() );
753 $t->set_var( "product1_thumbnail_image_height", $variation->height() );
754 $t->set_var( "product1_thumbnail_image_caption", $thumbnailImage->caption() );
755
756 $t->parse( "product_image", "product_image_tpl" );
757 }
758 else
759 {
760 $t->set_var( "product_image", "" );
761 }
762
763 $t->set_var( "product_name", $product->name() );
764
765 // $t->set_var( "product_intro_text", eZTextTool::nl2br( $product->brief() ) );
766 $t->set_var( "product_intro_text", $product->brief() );
767
768 $categoryDefinition = $product->categoryDefinition();
769 $t->set_var( "category_id", $categoryDefinition->id() );
770
771 if ( $product->showPrice() == true and $product->hasPrice() )
772 {
773 $t->set_var( "product_price", $product->localePrice( $PricesIncludeVAT ) );
774 $priceRange = $product->correctPriceRange( $PricesIncludeVAT );
775
776 if ( ( empty( $priceRange["min"] ) and empty( $priceRange["max"] ) ) and !($product->correctPrice( $PricesIncludeVAT ) > 0) )
777 {
778 $t->set_var( "product_price", "" );
779 }
780 $t->parse( "price", "price_tpl" );
781 }
782 elseif( $product->showPrice() == false )
783 {
784 $t->set_var( "product_price", "" );
785 $t->parse( "price", "price_tpl" );
786 }
787 else
788 {
789 $priceArray = "";
790 $options =& $product->options();
791 if ( count( $options ) == 1 )
792 {
793 $option = $options[0];
794 if ( is_a( $option, "eZOption" ) )
795 {
796 $optionValues =& $option->values();
797 if ( count( $optionValues ) > 1 )
798 {
799 $i=0;
800 foreach ( $optionValues as $optionValue )
801 {
802 $priceArray[$i] = $optionValue->localePrice( $PricesIncludeVAT, $product );
803 $i++;
804 }
805 $high = max( $priceArray );
806 $low = min( $priceArray );
807
808 $t->set_var( "product_price", $low . " - " . $high );
809
810 $t->parse( "price", "price_tpl" );
811 }
812 }
813 }
814 else
815 $t->set_var( "price", "" );
816 }
817
818
819 if ( ( $i % 2 ) == 0 )
820 {
821 $t->set_var( "td_class", "bglight" );
822 }
823 else
824 {
825 $t->set_var( "td_class", "bgdark" );
826 }
827
828 return $t->parse( "output", "one_column_product_tpl" );
829 }
830
831
832 function &renderFrontpageProductDouble( &$t, &$locale, &$product1, &$product2, &$ini = null )
833 {
834 // global $ini;
835 $pid = $product1->id();
836
837 $PricesIncludeVAT = $ini->variable( "eZTradeMain", "PricesIncludeVAT" );
838
839 $ThumbnailImageWidth = $ini->variable( "eZTradeMain", "ThumbnailImageWidth" );
840 $ThumbnailImageHeight = $ini->variable( "eZTradeMain", "ThumbnailImageHeight" );
841
842 // preview image
843 $thumbnailImage = $product1->thumbnailImage();
844
845 if ( $thumbnailImage )
846 {
847 $variation =& $thumbnailImage->requestImageVariation( $ThumbnailImageWidth, $ThumbnailImageHeight );
848
849 $t->set_var( "product1_thumbnail_image_uri", "/" . $variation->imagePath() );
850 $t->set_var( "product1_thumbnail_image_width", $variation->width() );
851 $t->set_var( "product1_thumbnail_image_height", $variation->height() );
852 $t->set_var( "product1_thumbnail_image_caption", $thumbnailImage->caption() );
853
854 $t->parse( "left_product_image", "left_product_image_tpl" );
855 }
856 else
857 {
858 $t->set_var( "left_product_image", "" );
859 }
860
861 $t->set_var( "product1_name", $product1->name() );
862 $t->set_var( "product1_id", $product1->id() );
863
864 // $t->set_var( "product_intro_text", eZTextTool::nl2br( $product1->brief() ) );
865 $t->set_var( "product1_intro_text", $product1->brief() );
866
867
868 $categoryDefinition = $product1->categoryDefinition();
869 $t->set_var( "product1_category_id", $categoryDefinition->id() );
870
871 if ( $product1->showPrice() == true and $product1->hasPrice() )
872 {
873 $t->set_var( "product1_price", $product1->localePrice( $PricesIncludeVAT ) );
874 $priceRange = $product1->correctPriceRange( $PricesIncludeVAT );
875
876 if ( ( empty( $priceRange["min"] ) and empty( $priceRange["max"] ) ) and !($product1->correctPrice( $PricesIncludeVAT ) > 0) )
877 {
878 $t->set_var( "product1_price", "" );
879 }
880 $t->parse( "left_price", "left_price_tpl" );
881 }
882 elseif( $product1->showPrice() == false )
883 {
884 $t->set_var( "product1_price", "" );
885 $t->parse( "left_price", "left_price_tpl" );
886 }
887 else
888 {
889 $priceArray = "";
890 $options =& $product1->options();
891 if ( count( $options ) == 1 )
892 {
893 $option = $options[0];
894 if ( is_a( $option, "eZOption" ) )
895 {
896 $optionValues =& $option->values();
897 if ( count( $optionValues ) > 1 )
898 {
899 $i=0;
900 foreach ( $optionValues as $optionValue )
901 {
902 $priceArray[$i] = $optionValue->localePrice( $PricesIncludeVAT, $product1 );
903 $i++;
904 }
905 $high = max( $priceArray );
906 $low = min( $priceArray );
907
908 $t->set_var( "product1_price", $low . " - " . $high );
909
910 $t->parse( "left_price", "left_price_tpl" );
911 }
912 }
913 }
914 else
915 $t->set_var( "left_price", "" );
916 }
917
918
919 if ( isset( $i ) && ( $i % 2 ) == 0 )
920 {
921 $t->set_var( "td_class", "bglight" );
922 }
923 else
924 {
925 $t->set_var( "td_class", "bgdark" );
926 }
927
928 $t->parse( "left_product", "left_product_tpl" );
929
930 $pid = $product2->id();
931
932 // preview image
933 $thumbnailImage = $product2->thumbnailImage();
934
935 $t->set_var( "product_id", $product2->id() );
936
937 if ( $thumbnailImage )
938 {
939 $variation =& $thumbnailImage->requestImageVariation( $ThumbnailImageWidth, $ThumbnailImageHeight );
940
941 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
942 $t->set_var( "thumbnail_image_width", $variation->width() );
943 $t->set_var( "thumbnail_image_height", $variation->height() );
944 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
945
946 $t->parse( "left_product_image", "left_product_image_tpl" );
947 }
948 else
949 {
950 $t->set_var( "left_product_image", "" );
951 }
952
953 $t->parse( "left_product", "left_product_tpl" );
954
955 $pid = $product2->id();
956
957 $t->set_var( "product_name", $product2->name() );
958
959
960 $categoryDefinition = $product2->categoryDefinition();
961 $t->set_var( "category_id", $categoryDefinition->id() );
962
963 // $t->set_var( "product_intro_text", eZTextTool::nl2br( $product2->brief() ) );
964 $t->set_var( "product_intro_text", $product2->brief() );
965
966 if ( $product2->showPrice() == true and $product2->hasPrice() )
967 {
968 $t->set_var( "product_price", $product2->localePrice( $PricesIncludeVAT ) );
969 $priceRange = $product2->correctPriceRange( $PricesIncludeVAT );
970
971 if ( ( empty( $priceRange["min"] ) and empty( $priceRange["max"] ) ) and !($product2->correctPrice( $PricesIncludeVAT ) > 0) )
972 {
973 $t->set_var( "product_price", "" );
974 }
975 $t->parse( "right_price", "right_price_tpl" );
976 }
977 elseif( $product2->showPrice() == false )
978 {
979 $t->set_var( "product_price", "" );
980 $t->parse( "right_price", "right_price_tpl" );
981 }
982 else
983 {
984 $priceArray = "";
985 $options =& $product2->options();
986 if ( count( $options ) == 1 )
987 {
988 $option = $options[0];
989 if ( is_a( $option, "eZOption" ) )
990 {
991 $optionValues =& $option->values();
992 if ( count( $optionValues ) > 1 )
993 {
994 $i=0;
995 foreach ( $optionValues as $optionValue )
996 {
997 $priceArray[$i] = $optionValue->localePrice( $PricesIncludeVAT, $product2 );
998 $i++;
999 }
1000 $high = max( $priceArray );
1001 $low = min( $priceArray );
1002
1003 $t->set_var( "product_price", $low . " - " . $high );
1004
1005 $t->parse( "right_price", "right_price_tpl" );
1006 }
1007 }
1008 }
1009 else
1010 $t->set_var( "right_price", "" );
1011 }
1012
1013
1014 if ( isset( $i ) && ( $i % 2 ) == 0 )
1015 {
1016 $t->set_var( "td_class", "bglight" );
1017 }
1018 else
1019 {
1020 $t->set_var( "td_class", "bgdark" );
1021 }
1022
1023
1024 // preview image
1025 $thumbnailImage = $product2->thumbnailImage();
1026
1027 $t->set_var( "product_id", $product2->id() );
1028
1029 if ( $thumbnailImage )
1030 {
1031 $variation =& $thumbnailImage->requestImageVariation( $ThumbnailImageWidth, $ThumbnailImageHeight );
1032
1033 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
1034 $t->set_var( "thumbnail_image_width", $variation->width() );
1035 $t->set_var( "thumbnail_image_height", $variation->height() );
1036 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
1037
1038 $t->parse( "right_product_image", "right_product_image_tpl" );
1039 }
1040 else
1041 {
1042 $t->set_var( "right_product_image", "" );
1043 }
1044
1045 $t->parse( "right_product", "right_product_tpl" );
1046
1047 return $t->parse( "output", "two_column_product_tpl" );
1048 }
1049
1050
1051
1052 $t->pparse( "output", "article_list_page_tpl" );
1053
1054 // set variables for meta information
1055 // $SiteTitleAppend = $category->name();
1056 $SiteTitleAppend = '';
1057 $SiteDescriptionOverride = '';
1058 $eZLanguageOverride = '';
1059
1060 if ( isset( $GenerateStaticPage ) && $GenerateStaticPage == "true" )
1061 {
1062 $fp = eZPBFile::fopen( $cachedFile, "w+");
1063
1064 // add PHP code in the cache file to store variables
1065 $output = "<?php\n";
1066 $output .= "\$GlobalSectionID=\"$GlobalSectionID\";\n";
1067 $output .= "\$SiteTitleAppend=\"$SiteTitleAppend\";\n";
1068 $output .= "\$SiteDescriptionOverride=\"$SiteDescriptionOverride\";\n";
1069 $output .= "\$eZLanguageOverride=\"$eZLanguageOverride\";\n";
1070 $output .= "?>\n";
1071
1072 $output .= ob_get_contents();
1073
1074 // print the output the first time while printing the cache file.
1075 fwrite ( $fp, $output );
1076 fclose( $fp );
1077 }
1078
1079 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$adList
$adList
Definition: admin/adlist.php:125
$forum
$forum
Definition: admin/forumlist.php:50
$ad
$ad
Definition: adstatistics.php:56
$article
$article
Definition: articlelog.php:45
$renderer
if(! $article->get( $ArticleID)) $renderer
Definition: articlepreview.php:76
eZAdCategory
Definition: ezadcategory.php:44
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleRenderer
Definition: ezarticlerenderer.php:36
eZArticle
Definition: ezarticle.php:82
eZLocale
Definition: ezlocale.php:119
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZProductCategory
Definition: ezproductcategory.php:90
eZProductCategory\products
static & products( $sortMode="time", $fetchNonActive=false, $offset=0, $limit=50, $fetchDiscontinued=false, $categoryID=0)
Definition: ezproductcategory.php:688
eZSection\globalSectionObject
static & globalSectionObject( $sectionID)
Definition: ezsection.php:366
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$fp
$fp
Definition: export.php:97
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$productList
$productList
Definition: ezarticle/admin/categorylist.php:248
$contents
$contents
Definition: ezarticle/user/extendedsearch.php:52
$row
$row
Definition: ezcalendar/user/dayview.php:403
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$cachedFile
$cachedFile
Definition: eznewsfeed/user/headlines.php:109
$priceRange
$priceRange
Definition: eztrade/user/extendedsearch.php:85
$element
if(! $parent) $element
Definition: folder.php:64
$output
$output
Definition: formpreview.php:81
$articleList
$articleList
Definition: frontpage.php:135
$eZLanguageOverride
$eZLanguageOverride
Definition: frontpage.php:1058
renderShortSingleArticle
& renderShortSingleArticle(&$t, &$locale, &$article, &$ini=null, $counter=0, $rows=null, $GrayScaleImageList=null)
Definition: frontpage.php:644
$ImageDir
$ImageDir
Definition: frontpage.php:47
$offsetArticleArray
$offsetArticleArray
Definition: frontpage.php:131
$locale
$locale
Definition: frontpage.php:242
$t
$t
Definition: frontpage.php:55
$SiteTitleAppend
$SiteTitleAppend
Definition: frontpage.php:1056
$page_element
$page_element
Definition: frontpage.php:130
$sectionObject
$sectionObject
Definition: frontpage.php:52
$articleOffset
$articleOffset
Definition: frontpage.php:245
$adCount
$adCount
Definition: frontpage.php:123
$i
$i
Definition: frontpage.php:243
$adOffset
$adOffset
Definition: frontpage.php:247
$Language
$Language
Definition: frontpage.php:46
renderFrontpageArticle
& renderFrontpageArticle(&$t, &$locale, &$article, &$ini=null, $counter=0, $rows=null, $GrayScaleImageList=null)
Definition: frontpage.php:326
$ini
$ini
Definition: frontpage.php:44
renderFrontpageArticleDouble
& renderFrontpageArticleDouble(&$t, &$locale, &$article1, &$article2, &$ini=null, $counter=0, $rows=null, $GrayScaleImageList=null)
Definition: frontpage.php:439
renderFrontpageProductDouble
& renderFrontpageProductDouble(&$t, &$locale, &$product1, &$product2, &$ini=null)
Definition: frontpage.php:832
$tempArticle
$tempArticle
Definition: frontpage.php:134
$offsetProductArray
$offsetProductArray
Definition: frontpage.php:132
$pageContents
$pageContents
Definition: frontpage.php:248
$DefaultLinkText
$DefaultLinkText
Definition: frontpage.php:49
$CapitalizeHeadlines
$CapitalizeHeadlines
Definition: frontpage.php:48
$productCount
$productCount
Definition: frontpage.php:122
$productOffset
$productOffset
Definition: frontpage.php:246
$rows
$rows
Definition: frontpage.php:128
$articleCount
$articleCount
Definition: frontpage.php:121
$CategoryID
global $CategoryID
Definition: frontpage.php:42
$counter
$counter
Definition: frontpage.php:249
renderAd
& renderAd(&$t, &$locale, &$ad, &$ini=null)
Definition: frontpage.php:696
renderFrontpageProduct
& renderFrontpageProduct(&$t, &$locale, &$product, &$ini=null)
Definition: frontpage.php:732
$GrayScaleImageList
$GrayScaleImageList
Definition: frontpage.php:50
$SiteDescriptionOverride
$SiteDescriptionOverride
Definition: frontpage.php:1057
$user
if(is_array( $rows) and count( $rows) > 0) $user
Definition: frontpage.php:226
$PricesIncludeVAT
$PricesIncludeVAT
Definition: homepage.php:47
$product
$product
Definition: homepage.php:202
$options
$options
Definition: optionlist.php:56
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$ThumbnailImageHeight
$ThumbnailImageHeight
Definition: user/articlelist.php:153
$image
$image
Definition: user/articlelist.php:242
$ThumbnailImageWidth
$ThumbnailImageWidth
Definition: user/articlelist.php:152
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.