Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezarticle/user/headlines.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: headlines.php 9827 2003-06-02 10:46:23Z jhe $
5 //
6 // Created on: <30-Nov-2000 14:35:24 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/ezcachefile.php" );
31
32 $ini =& eZINI::instance( 'site.ini' );
33 $Language = $ini->variable( "eZArticleMain", "Language" );
34 $ImageDir = $ini->variable( "eZArticleMain", "ImageDir" );
35
36 if ( !function_exists( "createHeadlinesMenu" ) )
37 {
38 function createHeadlinesMenu( $menuCacheFile=false, $ini = null, $Language = null, $GlobalSiteDesign = null,
39 $GlobalSectionID = null, $CategoryID = null, $Limit = null )
40 {
41 // global $ini;
42 // global $Language;
43 // global $GlobalSiteDesign;
44 // global $CategoryID;
45 // global $Limit;
46
47 $ImageDir = '';
48
49 // include_once( "ezarticle/classes/ezarticlecategory.php" );
50 // include_once( "ezarticle/classes/ezarticle.php" );
51 // include_once( "ezarticle/classes/ezarticlerenderer.php" );
52
53 $t = new eZTemplate( "kernel/ezarticle/user/" . $ini->variable( "eZArticleMain", "TemplateDir" ),
54 "kernel/ezarticle/user/intl/", $Language, "headlines.php" );
55
56 $t->setAllStrings();
57
58 $t->set_file( array(
59 "article_list_page_tpl" => "headlines.tpl"
60 ) );
61
62
63 // product
64 $t->set_block( "article_list_page_tpl", "article_list_tpl", "article_list" );
65 $t->set_block( "article_list_tpl", "article_item_tpl", "article_item" );
66 $t->set_block( "article_item_tpl", "current_image_item_tpl", "current_image_item" );
67
68
69 // image dir
70 $t->set_var( "image_dir", $ImageDir );
71
72 if ( !isset( $Limit ) )
73 {
74 $Limit = 10;
75 }
76
77 if ( !isset( $HeadlineOffset ) )
78 {
79 $HeadlineOffset = 0;
80 }
81
82 $category = new eZArticleCategory( $CategoryID );
83
84 if ( $CategoryID == 0 )
85 {
86 // do not set offset for the main page news
87 // always sort by publishing date is the merged category
88 $article = new eZArticle();
89 $articleList =& $article->articles( "time", false, $HeadlineOffset, $Limit );
90 $articleCount = $article->articleCount( false );
91 }
92 else
93 {
94 $articleList =& $category->articles( $category->sortMode(), false, true, $HeadlineOffset, $Limit );
95 $articleCount = $category->articleCount( false, true );
96 }
97
98
99 // should we allow currentuser to go get articles with permissions or should we not??
100 //$articleList = $category->articles( $SortMode, false, true, 0, 5 );
101
102 $locale = new eZLocale( $Language );
103 $i=0;
104 $t->set_var( "article_list", "" );
105 foreach ( $articleList as $article )
106 {
107 $t->set_var( "category_id", $CategoryID );
108
109 $t->set_var( "article_id", $article->id() );
110 $t->set_var( "article_name", $article->name() );
111
112 // category image/icon
113 $catDef = $article->categoryDefinition();
114
115 $image =& $catDef->image();
116
117 $t->set_var( "current_image_item", "" );
118
119 if ( ( is_a( $image, "eZImage" ) ) && ( $image->id() != 0 ) )
120 {
121 $imageWidth =& $ini->variable( "eZArticleMain", "CategoryImageWidth" );
122 $imageHeight =& $ini->variable( "eZArticleMain", "CategoryImageHeight" );
123
124 $variation =& $image;
125
126 $imageURL = $variation->filePath( );
127 // $imageWidth =& $variation->width();
128 // $imageHeight =& $variation->height();
129 $imageCaption =& $image->caption();
130
131 $t->set_var( "current_image_width", $imageWidth );
132 $t->set_var( "current_image_height", $imageHeight );
133 $t->set_var( "current_image_url", $imageURL );
134 $t->set_var( "current_image_caption", $imageCaption );
135 $t->parse( "current_image_item", "current_image_item_tpl" );
136 }
137 else
138 {
139 $t->set_var( "current_image_item", "" );
140 }
141
142 $published =& $article->published();
143 $date =& $published->date();
144
145 $t->set_var( "article_published", $locale->format( $date ) );
146
147 if ( ( $i % 2 ) == 0 )
148 {
149 $t->set_var( "td_class", "bglight" );
150 $t->set_var( "td_alt", "1" );
151 }
152 else
153 {
154 $t->set_var( "td_class", "bgdark" );
155 $t->set_var( "td_alt", "2" );
156 }
157
158 if ( $article->linkText() != "" )
159 {
160 $t->set_var( "article_link_text", $article->linkText() );
161 }
162 else
163 {
164 $t->set_var( "article_link_text", "more" );
165 }
166
167 $t->parse( "article_item", "article_item_tpl", true );
168 $i++;
169 }
170
171 if ( count( $articleList ) > 0 )
172 $t->parse( "article_list", "article_list_tpl" );
173 else
174 $t->set_var( "article_list", "" );
175
176 if ( is_a( $menuCacheFile, "eZCacheFile" ) )
177 {
178 $output =& $t->parse( "output", "article_list_page_tpl" );
179 $menuCacheFile->store( $output );
180 print( $output );
181 }
182 else
183 {
184 $t->pparse( "output", "article_list_page_tpl" );
185 }
186 }
187 }
188
189 unset( $menuCachedFile );
190 // do the caching
191 if ( $PageCaching == "enabled" )
192 {
193 $user =& eZUser::currentUser();
194 $groupstr = "";
195 if ( is_a( $user, "eZUser" ) )
196 {
197 $groupIDArray =& $user->groups( false );
198 sort( $groupIDArray );
199 $first = true;
200 foreach ( $groupIDArray as $groupID )
201 {
202 $first ? $groupstr .= "$groupID" : $groupstr .= "-$groupID";
203 $first = false;
204 }
205 }
206 else
207 $user = 0;
208
209 $menuCacheFile = new eZCacheFile( "kernel/ezarticle/cache",
210 array( "menubox_headlines", $GlobalSiteDesign, $CategoryID, $groupstr ),
211 "cache", "," );
212
213 if ( $menuCacheFile->exists() )
214 {
215 print( $menuCacheFile->contents() );
216 }
217 else
218 {
219 createHeadlinesMenu( $menuCacheFile, $ini, $Language, $GlobalSiteDesign, $GlobalSectionID, $CategoryID, $Limit );
220 }
221 }
222 else
223 {
224 createHeadlinesMenu(false, $ini, $Language, $GlobalSiteDesign, $GlobalSectionID, $CategoryID, $Limit );
225 }
226
227 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$locale
$locale
Definition: admin/adlist.php:127
$i
$i
Definition: admin/adlist.php:91
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$articleCount
$articleCount
Definition: admin/articlelist.php:456
$PageCaching
$PageCaching
Definition: articlelinks.php:32
$article
$article
Definition: articlelog.php:45
$date
$date
Definition: bugpreview.php:66
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticle
Definition: ezarticle.php:82
eZLocale
Definition: ezlocale.php:119
eZTemplate
Definition: eztemplate.php:107
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$t
foreach( $Modules as $module) if(isset( $ItemInsert)) $t
Definition: classes/admin/linklist.php:168
$GlobalSectionID
$GlobalSectionID
Definition: ezad/user/datasupplier.php:28
$Limit
$Limit
Definition: ezarticle/admin/categorylist.php:66
$ImageDir
$ImageDir
Definition: ezarticle/user/headlines.php:34
$Language
$Language
Definition: ezarticle/user/headlines.php:33
$ini
$ini
Definition: ezarticle/user/headlines.php:32
$groupID
$groupID
Definition: ezgroupeventcalendar/user/dayview.php:90
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$output
$output
Definition: formpreview.php:81
$GlobalSiteDesign
global $GlobalSiteDesign
Definition: latestmessages.php:52
$articleList
$articleList
Definition: pendinglist.php:112
$user
$user
Definition: user/adlist.php:39
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.