Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

newsgroup.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: newsgroup.php 7197 2001-09-13 14:45:41Z bf $
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
37 $ini =& eZINI::instance( 'site.ini' );
38
39 $Language = $ini->variable( "eZArticleMain", "Language" );
40 $ImageDir = $ini->variable( "eZArticleMain", "ImageDir" );
41 $CapitalizeHeadlines = $ini->variable( "eZArticleMain", "CapitalizeHeadlines" );
42 $DefaultLinkText = $ini->variable( "eZArticleMain", "DefaultLinkText" );
43 $GrayScaleImageList = $ini->variable( "eZArticleMain", "GrayScaleImageList" );
44
45 $TemplateDir = $ini->variable( "eZArticleMain", "TemplateDir" );
46
47 $t = new eZTemplate( "kernel/ezarticle/user/" . $TemplateDir,
48 "kernel/ezarticle/user/intl/", $Language, "newsgroup.php" );
49
50 $articleLimit = 2;
51
52 $t->setAllStrings();
53
54
55 $GlobalSectionID = eZArticleCategory::sectionIDStatic( $CategoryID );
56
57 // override template for the current category
58 $override = "_override_$CategoryID";
59
60 if ( file_exists( "kernel/ezarticle/user/$TemplateDir/newsgroup" . $override . ".tpl" ) )
61 {
62 $t->set_file( "news_group_tpl", "newsgroup" . $override . ".tpl" );
63 }
64 else
65 {
66 $t->set_file( "news_group_tpl", "newsgroup.tpl" );
67 }
68
69 $t->set_block( "news_group_tpl", "category_item_tpl", "category_item" );
70
71 $t->set_block( "category_item_tpl", "article_item_tpl", "article_item" );
72
73 $t->set_block( "category_item_tpl", "start_with_break_tpl", "start_with_break" );
74 $t->set_block( "category_item_tpl", "start_without_break_tpl", "start_without_break" );
75
76 $t->set_block( "category_item_tpl", "end_with_break_tpl", "end_with_break" );
77 $t->set_block( "category_item_tpl", "end_without_break_tpl", "end_without_break" );
78
79 $t->set_block( "article_item_tpl", "article_image_tpl", "article_image" );
80 $t->set_block( "article_item_tpl", "no_image_tpl", "no_image" );
81
82 // makes the section ID available in articleview template
83 $t->set_var( "section_id", $GlobalSectionID );
84
85 // image dir
86 $t->set_var( "image_dir", $ImageDir );
87
88 $category = new eZArticleCategory( $CategoryID );
89
90 $categoryList =& $category->getByParent( $category, true, "placement", 0, 4 );
91
92 $locale = new eZLocale( $Language );
93
94 $i = 0;
95 foreach( $categoryList as $category )
96 {
97 $t->set_var( "start_with_break", "" );
98 $t->set_var( "start_without_break", "" );
99 $t->set_var( "end_with_break", "" );
100 $t->set_var( "end_without_break", "" );
101
102 if ( $i%2 == 0 )
103 {
104 $t->parse( "start_with_break", "start_with_break_tpl");
105 $t->parse( "end_without_break", "end_without_break_tpl");
106 }
107 else
108 {
109 $t->parse( "end_with_break", "end_with_break_tpl");
110 $t->parse( "start_without_break", "start_without_break_tpl");
111 }
112
113 $t->set_var( "category_id", $category->id() );
114 $t->set_var( "category_name", $category->name() );
115
116 $articles =& $category->articles( "time", false, true, 0, $articleLimit );
117
118 $t->set_var( "article_item", "" );
119 $j=0;
120 foreach( $articles as $article )
121 {
122 $t->set_var( "article_name", $article->name() );
123 $t->set_var( "article_id", $article->id() );
124
125 $renderer = new eZArticleRenderer( $article );
126 $t->set_var( "article_intro", $renderer->renderIntro( ) );
127
128 $published =& $article->published();
129 $published =& $published->date();
130
131 $t->set_var( "article_published", $locale->format( $published ) );
132
133 $t->set_var( "article_image", "" );
134 $t->set_var( "no_image", "" );
135 if ( $j == 0 )
136 {
137 // preview image
138 $thumbnailImage =& $article->thumbnailImage();
139 if ( $thumbnailImage )
140 {
141 if ( $GrayScaleImageList == "enabled" )
142 $convertToGray = true;
143 else
144 $convertToGray = false;
145
146 $variation =& $thumbnailImage->requestImageVariation( $ini->variable( "eZArticleMain", "ThumbnailGroupImageWidth" ),
147 $ini->variable( "eZArticleMain", "ThumbnailGroupImageHeight" ), $convertToGray );
148
149 $t->set_var( "thumbnail_image_uri", "/" . $variation->imagePath() );
150 $t->set_var( "thumbnail_image_width", $variation->width() );
151 $t->set_var( "thumbnail_image_height", $variation->height() );
152 $t->set_var( "thumbnail_image_caption", $thumbnailImage->caption() );
153
154 $t->parse( "article_image", "article_image_tpl" );
155 }
156 else
157 {
158 $t->parse( "no_image", "no_image_tpl" );
159 }
160 }
161 else
162 {
163 $t->parse( "no_image", "no_image_tpl" );
164 }
165
166
167 $t->parse( "article_item", "article_item_tpl", true );
168 $j++;
169 }
170
171
172 $t->parse( "category_item", "category_item_tpl", true );
173 $i++;
174 }
175
176 if ( isset( $GenerateStaticPage ) and $GenerateStaticPage == "true" and $cachedFile != "" )
177 {
178 $fp = eZPBFile::fopen( $cachedFile, "w+");
179
180 $output = $t->parse( "output", "news_group_tpl" );
181
182 // print the output the first time while printing the cache file.
183 print( $output );
184 fwrite ( $fp, $output );
185 fclose( $fp );
186 }
187 else
188 {
189 $t->pparse( "output", "news_group_tpl" );
190 }
191
192 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$article
$article
Definition: articlelog.php:45
$renderer
if(! $article->get( $ArticleID)) $renderer
Definition: articlepreview.php:76
$articles
$articles
Definition: authorview.php:64
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleCategory\sectionIDStatic
static sectionIDStatic($categoryID)
Definition: ezarticlecategory.php:662
eZArticleRenderer
Definition: ezarticlerenderer.php:36
eZLocale
Definition: ezlocale.php:119
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZTemplate
Definition: eztemplate.php:107
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$fp
$fp
Definition: export.php:97
$j
$j
Definition: ezimagecatalogue/admin/imagelist.php:345
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$cachedFile
$cachedFile
Definition: eznewsfeed/user/headlines.php:109
$output
$output
Definition: formpreview.php:81
$category
$category
Definition: newsgroup.php:88
$ImageDir
$ImageDir
Definition: newsgroup.php:40
$locale
$locale
Definition: newsgroup.php:92
$t
$t
Definition: newsgroup.php:47
$TemplateDir
$TemplateDir
Definition: newsgroup.php:45
$articleLimit
$articleLimit
Definition: newsgroup.php:50
$GlobalSectionID
$GlobalSectionID
Definition: newsgroup.php:55
$i
$i
Definition: newsgroup.php:94
$Language
$Language
Definition: newsgroup.php:39
$ini
$ini
Definition: newsgroup.php:37
$override
$override
Definition: newsgroup.php:58
$categoryList
$categoryList
Definition: newsgroup.php:90
$DefaultLinkText
$DefaultLinkText
Definition: newsgroup.php:42
$CapitalizeHeadlines
$CapitalizeHeadlines
Definition: newsgroup.php:41
$GrayScaleImageList
$GrayScaleImageList
Definition: newsgroup.php:43
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.