Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

newslist.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: newslist.php 8504 2001-11-19 09:46:46Z jhe $
5 //
6 // Created on: <29-Nov-2000 11:35:19 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( "eznewsfeed/classes/eznews.php" );
28 // include_once( "eznewsfeed/classes/eznewscategory.php" );
29 // include_once( "eznewsfeed/classes/eznewsimporter.php" );
30
31 // include_once( "classes/ezdatetime.php" );
32 // include_once( "classes/ezlocale.php" );
33 // include_once( "classes/eztemplate.php" );
34
35 $ini = eZINI::instance( 'site.ini' );
36
37 $Language = $ini->variable( "eZNewsFeedMain", "Language" );
38
39 $t = new eZTemplate( "kernel/eznewsfeed/user/" . $ini->variable( "eZNewsFeedMain", "TemplateDir" ),
40 "kernel/eznewsfeed/user/intl/", $Language, "newslist.php" );
41
42 $t->setAllStrings();
43
44 $t->set_file( array(
45 "news_archive_page_tpl" => "newslist.tpl"
46 ) );
47
48 // news
49 $t->set_block( "news_archive_page_tpl", "news_list_tpl", "news_list" );
50 $t->set_block( "news_list_tpl", "news_item_tpl", "news_item" );
51 $t->set_block( "news_list_tpl", "short_news_item_tpl", "short_news_item" );
52
53 $category = new eZNewsCategory( $CategoryID );
54
55
56 // news
57
58 // fetch the first new item
59 $firstNewsList =& $category->newsList( "time", "no", 0, 1 );
60
61 // fetch the n next news items
62 $newsList =& $category->newsList( "time", "no", 1, 4 );
63
64 // fetch the news to be listed as small items at the bottom
65 $shortNewsList =& $category->newsList( "time", "no", 5, 10 );
66
67 $locale = new eZLocale( $Language );
68
69 $t->set_var( "news_list", "" );
70
71
72 // print out the first news
73 if ( count( $firstNewsList ) > 0 )
74 {
75 $t->set_var( "first_news_id", $firstNewsList[0]->id() );
76 $t->set_var( "first_news_name", $firstNewsList[0]->name() );
77 $t->set_var( "first_news_intro", $firstNewsList[0]->intro() );
78 $t->set_var( "first_news_url", $firstNewsList[0]->url() );
79 $t->set_var( "first_news_origin", $firstNewsList[0]->origin() );
80
81 $published = $firstNewsList[0]->originalPublishingDate();
82 $t->set_var( "first_news_date", $locale->format( $published ) );
83 }
84
85 $i=0;
86 foreach ( $newsList as $news )
87 {
88 if ( ( $i % 2 ) == 0 )
89 {
90 $t->set_var( "starttr", "<tr>" );
91 $t->set_var( "endtr", "" );
92 }
93 else
94 {
95 $t->set_var( "starttr", "" );
96 $t->set_var( "endtr", "</tr>" );
97 }
98
99
100 $t->set_var( "news_name", $news->name() );
101
102 $t->set_var( "news_intro", $news->intro() );
103 $t->set_var( "news_url", $news->url() );
104 $t->set_var( "news_origin", $news->origin() );
105
106 $published = $news->originalPublishingDate();
107
108 $t->set_var( "news_date", $locale->format( $published ) );
109
110
111 $t->set_var( "news_id", $news->id() );
112
113 $t->parse( "news_item", "news_item_tpl", true );
114 $i++;
115 }
116
117 foreach ( $shortNewsList as $news )
118 {
119 $t->set_var( "news_name", $news->name() );
120
121 $t->set_var( "news_url", $news->url() );
122 $t->set_var( "news_origin", $news->origin() );
123
124 $published = $news->originalPublishingDate();
125 $date = $published->date();
126 $t->set_var( "news_date", $locale->format( $date ) );
127
128 $t->set_var( "news_id", $news->id() );
129
130 $t->parse( "short_news_item", "short_news_item_tpl", true );
131 // $t->set_var( "short_news_item", "" ); // Her ogs�!
132 $i++;
133 }
134
135 if ( count( $newsList ) > 0 )
136 $t->parse( "news_list", "news_list_tpl" );
137 else
138 $t->set_var( "news_list", "" );
139
140 if ( $GenerateStaticPage == "true" )
141 {
142 $fp = eZPBFile::fopen( $cachedFile, "w+");
143
144 $output = $t->parse( "output", "news_archive_page_tpl" );
145
146 // print the output the first time while printing the cache file.
147 print( $output );
148 fwrite ( $fp, $output );
149 fclose( $fp );
150 }
151 else
152 {
153 $t->pparse( "output", "news_archive_page_tpl" );
154 }
155
156 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$date
$date
Definition: bugpreview.php:66
eZLocale
Definition: ezlocale.php:119
eZNewsCategory
Definition: eznewscategory.php:42
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZTemplate
Definition: eztemplate.php:107
$fp
$fp
Definition: export.php:97
$news
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") $news
Definition: eznewsfeed/admin/categoryedit.php:69
$cachedFile
$cachedFile
Definition: eznewsfeed/user/headlines.php:109
$output
$output
Definition: formpreview.php:81
$category
$category
Definition: newslist.php:53
$shortNewsList
$shortNewsList
Definition: newslist.php:65
$locale
$locale
Definition: newslist.php:67
$t
$t
Definition: newslist.php:39
$i
if(count( $firstNewsList) > 0) $i
Definition: newslist.php:85
$Language
$Language
Definition: newslist.php:37
$ini
$ini
Definition: newslist.php:35
$firstNewsList
$firstNewsList
Definition: newslist.php:59
$newsList
$newsList
Definition: newslist.php:62
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.