Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

menuarticleview.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: menuarticleview.php 7204 2001-09-14 08:29:00Z ce $
5 //
6 // Created on: <18-Oct-2000 16:34:51 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/ezhttptool.php" );
28 // include_once( "classes/INIFile.php" );
29 // include_once( "classes/eztemplate.php" );
30 // include_once( "classes/ezlocale.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( "ezmail/classes/ezmail.php" );
36
37 if ( !isset( $CategoryID ) )
38 $CategoryID = eZArticle::categoryDefinitionStatic( $ArticleID );
39
40 $GlobalSectionID = eZArticleCategory::sectionIDStatic( $CategoryID );
41
42
43 $ini =& eZINI::instance( 'site.ini' );
44
45 $Language = $ini->variable( "eZArticleMain", "Language" );
46 $ForceCategoryDefinition = $ini->variable( "eZArticleMain", "ForceCategoryDefinition" );
47 $CapitalizeHeadlines = $ini->variable( "eZArticleMain", "CapitalizeHeadlines" );
48 $TemplateDir = $ini->variable( "eZArticleMain", "TemplateDir" );
49
50 if ( $ForceCategoryDefinition == "enabled" )
51 {
52 $CategoryID = eZArticle::categoryDefinitionStatic( $ArticleID );
53 }
54
55 $t = new eZTemplate( "kernel/ezarticle/user/" . $TemplateDir,
56 "kernel/ezarticle/user/intl/", $Language, "articleview.php" );
57
58 $t->setAllStrings();
59
60 $StaticPage = false;
61 if ( $url_array[2] == "static" || $url_array[2] == "articlestatic" )
62 {
63 $StaticPage = true;
64 }
65
66
67 // override template for the current category
68 $override = "_override_$CategoryID";
69
70 if ( $StaticPage == true )
71 {
72 if ( file_exists( "kernel/ezarticle/user/$TemplateDir/articlestatic" . $override . ".tpl" ) )
73 $t->set_file( "article_view_page_tpl", "articlestatic" . $override . ".tpl" );
74 else
75 $t->set_file( "article_view_page_tpl", "articlestatic.tpl" );
76 }
77 else
78 {
79 if ( isset( $PrintableVersion ) and $PrintableVersion == "enabled" )
80 {
81 $t->set_file( "article_view_page_tpl", "articleprint.tpl" );
82 }
83 else
84 {
85 if ( file_exists( "kernel/ezarticle/user/$TemplateDir/articleview" . $override . ".tpl" ) )
86 $t->set_file( "article_view_page_tpl", "articleview" . $override . ".tpl" );
87 else
88 $t->set_file( "article_view_page_tpl", "menuarticleview.tpl" );
89 }
90 }
91
92 // path
93 $t->set_block( "article_view_page_tpl", "path_item_tpl", "path_item" );
94
95 $t->set_block( "article_view_page_tpl", "article_url_item_tpl", "article_url_item" );
96
97 $t->set_block( "article_view_page_tpl", "article_header_tpl", "article_header" );
98 $t->set_block( "article_view_page_tpl", "article_intro_tpl", "article_intro" );
99
100 $t->set_block( "article_view_page_tpl", "attached_file_list_tpl", "attached_file_list" );
101 $t->set_block( "attached_file_list_tpl", "attached_file_tpl", "attached_file" );
102
103 $t->set_block( "article_view_page_tpl", "image_list_tpl", "image_list" );
104 $t->set_block( "image_list_tpl", "image_tpl", "image" );
105
106 $t->set_block( "article_view_page_tpl", "page_link_tpl", "page_link" );
107 $t->set_block( "article_view_page_tpl", "current_page_link_tpl", "current_page_link" );
108 $t->set_block( "article_view_page_tpl", "next_page_link_tpl", "next_page_link" );
109 $t->set_block( "article_view_page_tpl", "prev_page_link_tpl", "prev_page_link" );
110 $t->set_block( "article_view_page_tpl", "numbered_page_link_tpl", "numbered_page_link" );
111 $t->set_block( "article_view_page_tpl", "print_page_link_tpl", "print_page_link" );
112
113 $t->set_block( "article_view_page_tpl", "mail_to_tpl", "mail_to" );
114 $t->set_block( "article_view_page_tpl", "attribute_list_tpl", "attribute_list" );
115 $t->set_block( "attribute_list_tpl", "type_item_tpl", "type_item" );
116 $t->set_block( "type_item_tpl", "attribute_item_tpl", "attribute_item" );
117
118
119 if ( $StaticRendering == true )
120 {
121 $t->set_var( "article_header", "" );
122 }
123 else
124 {
125 $t->parse( "article_header", "article_header_tpl" );
126 }
127
128 $SiteURL = $ini->variable( "site", "UserSiteURL" );
129
130 $t->set_var( "article_url", $SiteURL . $REQUEST_URI );
131 $t->set_var( "article_url_item", "" );
132 if ( isset( $PrintableVersion ) and $PrintableVersion == "enabled" )
133 $t->parse( "article_url_item", "article_url_item_tpl" );
134
135
136 $article = new eZArticle( );
137
138 // check if the article exists
139 if ( $article->get( $ArticleID ) )
140 {
141 if ( $article->isPublished() )
142 {
143 // published article.
144 }
145 else
146 {
147 eZHTTPTool::header( "Location: /error/404" );
148 exit();
149 }
150
151 $categories =& $article->categories( false );
152
153 // path
154 if ( !in_array( $CategoryID, $categories ) )
155 {
156 $category = $article->categoryDefinition();
157 }
158 else
159 {
160 $category = new eZArticleCategory( $CategoryID );
161 }
162
163 $pathArray =& $category->path();
164
165 $t->set_var( "path_item", "" );
166 foreach ( $pathArray as $path )
167 {
168 $t->set_var( "category_id", $path[0] );
169
170 if ( $CapitalizeHeadlines == "enabled" )
171 {
172 // include_once( "classes/eztexttool.php" );
173 $t->set_var( "category_name", eZTextTool::capitalize( $path[1] ) );
174 }
175 else
176 {
177 $t->set_var( "category_name", $path[1] );
178 }
179
180 $t->parse( "path_item", "path_item_tpl", true );
181 }
182
183
184 // override the article tags:
185 $template = "menu";
186 $renderer = new eZArticleRenderer( $article, $template );
187
188 if ( $CapitalizeHeadlines == "enabled" )
189 {
190 // include_once( "classes/eztexttool.php" );
191 $t->set_var( "article_name", eZTextTool::capitalize( $article->name() ) );
192 }
193 else
194 {
195 $t->set_var( "article_name", $article->name() );
196 }
197
198 if ( eZMail::validate( $article->authorEmail() ) && $article->authorEmail() )
199 {
200 $t->set_var( "author_email", $article->authorEmail() );
201 }
202 else
203 {
204 $author = $article->author();
205 $t->set_var( "author_email", $author->email() );
206 }
207
208 $t->set_var( "author_text", $article->authorText() );
209
210 $t->set_var( "author_id", $article->contentsWriter( false ) );
211
212 $categoryDef =& $article->categoryDefinition();
213
214 $t->set_var( "category_definition_name", $categoryDef->name() );
215
216 $pageCount = $article->pageCount();
217 if ( $PageNumber > $pageCount )
218 $PageNumber = $pageCount;
219
220 if ( $PageNumber == -1 )
221 $articleContents = $renderer->renderPage( -1 );
222 else
223 $articleContents = $renderer->renderPage( $PageNumber -1 );
224
225 $t->set_var( "article_intro", $articleContents[0] );
226
227 if ( $PageNumber == 1 )
228 $t->parse( "article_intro", "article_intro_tpl" );
229 else
230 $t->set_var( "article_intro", "" );
231
232 $t->set_var( "article_body", $articleContents[1] );
233
234 $t->set_var( "link_text", $article->linkText() );
235
236 $t->set_var( "article_id", $article->id() );
237
238 $locale = new eZLocale();
239 $published = $article->published();
240
241 $t->set_var( "article_created", $locale->format( $published ) );
242
243 // image list
244
245 $usedImages = $renderer->usedImageList();
246
247 $images =& $article->images();
248
249
250 {
251 $imageNumber = 1;
252 $i=0;
253 foreach ( $images as $image )
254 {
255 if ( is_array( $usedImages ) && !in_array( $imageNumber, $usedImages ) )
256 {
257 if ( ( $i % 2 ) == 0 )
258 {
259 $t->set_var( "td_class", "bglight" );
260 }
261 else
262 {
263 $t->set_var( "td_class", "bgdark" );
264 }
265
266 if ( $image->caption() == "" )
267 $t->set_var( "image_caption", "&nbsp;" );
268 else
269 $t->set_var( "image_caption", $image->caption() );
270
271
272 $t->set_var( "image_id", $image->id() );
273 $t->set_var( "article_id", $ArticleID );
274
275 $variation =& $image->requestImageVariation( 150, 150 );
276
277 $t->set_var( "image_url", "/" .$variation->imagePath() );
278 $t->set_var( "image_width", $variation->width() );
279 $t->set_var( "image_height",$variation->height() );
280
281 $t->parse( "image", "image_tpl", true );
282 $i++;
283 }
284 $imageNumber++;
285 }
286
287 $t->parse( "image_list", "image_list_tpl", true );
288 }
289 if ( $i == 0 )
290 $t->set_var( "image_list", "" );
291
292
293
294 }
295
296 // set the variables in the mail_to form
297 if ( !isset( $SendTo ) )
298 $SendTo = "";
299 $t->set_var( "send_to", $SendTo );
300 if ( !isset( $From ) )
301 $From = "";
302 $t->set_var( "from", $From );
303
304 $types = $article->types();
305
306 $typeCount = count( $types );
307
308 $t->set_var( "attribute_item", "" );
309 $t->set_var( "type_item", "" );
310 $t->set_var( "attribute_list", "" );
311
312 if( $typeCount > 0 )
313 {
314 foreach( $types as $type )
315 {
316 $attributes = array();
317 $attributes = $type->attributes();
318 $attributeCount = count( $attributes );
319
320 if( $attributeCount > 0 )
321 {
322 $t->set_var( "type_id", $type->id() );
323 $t->set_var( "type_name", $type->name() );
324 $t->set_var( "attribute_item", "" );
325 foreach( $attributes as $attribute )
326 {
327 $t->set_var( "attribute_id", $attribute->id() );
328 $t->set_var( "attribute_name", $attribute->name() );
329 $t->set_var( "attribute_value", nl2br( $attribute->value( $article ) ) );
330 $t->parse( "attribute_item", "attribute_item_tpl", true );
331 }
332 $t->parse( "type_item", "type_item_tpl", true );
333 }
334 }
335
336 $t->parse( "attribute_list", "attribute_list_tpl" );
337 }
338
339
340
341 // files
342 $files = $article->files();
343
344 if ( count( $files ) > 0 )
345 {
346 $i=0;
347 foreach ( $files as $file )
348 {
349 if ( ( $i % 2 ) == 0 )
350 {
351 $t->set_var( "td_class", "bglight" );
352 }
353 else
354 {
355 $t->set_var( "td_class", "bgdark" );
356 }
357
358 $t->set_var( "file_id", $file->id() );
359 $t->set_var( "original_file_name", $file->originalFileName() );
360 $t->set_var( "file_name", $file->name() );
361 $t->set_var( "file_url", $file->name() );
362 $t->set_var( "file_description", $file->description() );
363
364 $size = $file->siFileSize();
365 $t->set_var( "file_size", $size["size-string"] );
366 $t->set_var( "file_unit", $size["unit"] );
367
368
369 $i++;
370 $t->parse( "attached_file", "attached_file_tpl", true );
371 }
372
373 $t->parse( "attached_file_list", "attached_file_list_tpl" );
374 }
375 else
376 {
377 $t->set_var( "attached_file_list", "" );
378 }
379
380
381 $t->set_var( "current_page_link", "" );
382
383 // page links
384 if ( $pageCount > 1 && $PageNumber != -1 && ( $PrintableVersion != "enabled" ) )
385 {
386 for ( $i=0; $i<$pageCount; $i++ )
387 {
388 $t->set_var( "article_id", $article->id() );
389 $t->set_var( "page_number", $i+1 );
390 $t->set_var( "category_id", $CategoryID );
391
392 if ( ( $i + 1 ) == $PageNumber )
393 {
394 $t->parse( "page_link", "current_page_link_tpl", true );
395 }
396 else
397 {
398 $t->parse( "page_link", "page_link_tpl", true );
399 }
400 }
401 }
402 else
403 {
404 $t->set_var( "page_link", "" );
405
406 }
407
408
409 // non-printable version link
410 if ( ( $PageNumber == -1 ) && ( $PrintableVersion == "enabled" ) )
411 {
412 $t->parse( "numbered_page_link", "numbered_page_link_tpl" );
413 }
414 else
415 {
416 $t->set_var( "numbered_page_link", "" );
417 }
418
419 // printable version link
420 if ( ( $PrintableVersion != "enabled" ) && ( $StaticRendering != true ) )
421 {
422 $t->parse( "print_page_link", "print_page_link_tpl" );
423 }
424 else
425 {
426 $t->set_var( "print_page_link", "" );
427 }
428
429 // previous page link
430 if ( ( $PageNumber > 1 ) && ( $PrintableVersion != "enabled" ) )
431 {
432 $t->set_var( "prev_page_number", $PageNumber - 1 );
433 $t->parse( "prev_page_link", "prev_page_link_tpl" );
434 }
435 else
436 {
437 $t->set_var( "prev_page_link", "" );
438 }
439
440 // next page link
441 if ( $PageNumber < $pageCount && $PageNumber != -1 && ( $PrintableVersion != "enabled" ) )
442 {
443 $t->set_var( "next_page_number", $PageNumber + 1 );
444 $t->parse( "next_page_link", "next_page_link_tpl" );
445 }
446 else
447 {
448 $t->set_var( "next_page_link", "" );
449 }
450
451
452 // set variables for meta information
453 $SiteTitleAppend = $article->name();
454 $SiteDescriptionOverride = str_replace( "\"", "", strip_tags( $articleContents[0] ) );
455
456 if ( isset( $GenerateStaticPage ) && $GenerateStaticPage == "true" )
457 {
458 $fp = eZPBFile::fopen( $cachedFile, "w+");
459
460 // add PHP code in the cache file to store variables
461 $output = "<?php\n";
462 $output .= "\$GlobalSectionID=\"$GlobalSectionID\";\n";
463 $output .= "\$SiteTitleAppend=\"$SiteTitleAppend\";\n";
464 $output .= "\$SiteDescriptionOverride=\"$SiteDescriptionOverride\";\n";
465 $output .= "?>\n";
466
467 $output .= $t->parse( "output", "article_view_page_tpl" );
468
469 // print the output the first time while printing the cache file.
470 print( $output );
471 fwrite ( $fp, $output );
472 fclose( $fp );
473 }
474 else
475 {
476 $t->pparse( "output", "article_view_page_tpl" );
477 }
478
479 ?>
$category
if( $Action=="Edit") $category
Definition: adedit.php:378
$locale
$locale
Definition: admin/adlist.php:127
$pathArray
$pathArray
Definition: admin/adlist.php:74
$i
$i
Definition: admin/adlist.php:91
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$author
$author
Definition: admin/articleedit.php:834
$articleContents
$articleContents
Definition: articlepreview.php:81
$imageNumber
$imageNumber
Definition: articlepreview.php:147
$pageCount
$pageCount
Definition: articlepreview.php:195
$images
$images
Definition: articlepreview.php:146
$renderer
if(! $article->get( $ArticleID)) $renderer
Definition: articlepreview.php:76
$usedImages
if( $typeCount > 0) $usedImages
Definition: articlepreview.php:145
eZArticleCategory
Definition: ezarticlecategory.php:45
eZArticleCategory\sectionIDStatic
static sectionIDStatic($categoryID)
Definition: ezarticlecategory.php:662
eZArticleRenderer
Definition: ezarticlerenderer.php:36
eZArticle
Definition: ezarticle.php:82
eZArticle\categoryDefinitionStatic
static categoryDefinitionStatic( $id)
Definition: ezarticle.php:2541
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZLocale
Definition: ezlocale.php:119
eZMail\validate
static validate( $address)
Definition: ezmail.php:599
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZTemplate
Definition: eztemplate.php:107
eZTextTool\capitalize
static capitalize( $string, $bigClass="h1bigger")
Definition: eztexttool.php:105
$type
$type
Definition: classes/admin/linkselect.php:220
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$fp
$fp
Definition: export.php:97
$ArticleID
$ArticleID
Definition: export.php:48
$url_array
$url_array
Definition: ezaddress/admin/datasupplier.php:34
$categories
$categories
Definition: ezarticle/admin/categoryedit.php:636
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$cachedFile
$cachedFile
Definition: eznewsfeed/user/headlines.php:109
exit
exit
Definition: folder.php:81
$output
$output
Definition: formpreview.php:81
$SiteURL
$SiteURL
Definition: menuarticleview.php:128
$SiteTitleAppend
$SiteTitleAppend
Definition: menuarticleview.php:453
$TemplateDir
$TemplateDir
Definition: menuarticleview.php:48
$article
$article
Definition: menuarticleview.php:136
$t
if( $ForceCategoryDefinition=="enabled") $t
Definition: menuarticleview.php:55
$GlobalSectionID
$GlobalSectionID
Definition: menuarticleview.php:40
$files
if( $typeCount > 0) $files
Definition: menuarticleview.php:342
$ForceCategoryDefinition
$ForceCategoryDefinition
Definition: menuarticleview.php:46
$StaticPage
$StaticPage
Definition: menuarticleview.php:60
$Language
$Language
Definition: menuarticleview.php:45
$ini
$ini
Definition: menuarticleview.php:43
$types
$types
Definition: menuarticleview.php:304
$typeCount
$typeCount
Definition: menuarticleview.php:306
$CapitalizeHeadlines
$CapitalizeHeadlines
Definition: menuarticleview.php:47
$override
if( $url_array[2]=="static"|| $url_array[2]=="articlestatic") $override
Definition: menuarticleview.php:68
$SiteDescriptionOverride
$SiteDescriptionOverride
Definition: menuarticleview.php:454
$GenerateStaticPage
$GenerateStaticPage
Definition: quizscores.php:95
$REQUEST_URI
$REQUEST_URI
Definition: storestats.php:32
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.