Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

articlepreview.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: articlepreview.php 8216 2001-11-01 19:12:53Z bf $
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
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
36 $ini =& eZINI::instance( 'site.ini' );
37
38 $Language = $ini->variable( "eZArticleMain", "Language" );
39
40 $t = new eZTemplate( "kernel/ezarticle/admin/" . $ini->variable( "eZArticleMain", "AdminTemplateDir" ),
41 "kernel/ezarticle/admin/intl/", $Language, "articlepreview.php" );
42
43 $t->setAllStrings();
44
45 $t->set_file( array(
46 "article_preview_page_tpl" => "articlepreview.tpl"
47 ) );
48
49 $t->set_block( "article_preview_page_tpl", "page_menu_separator_tpl", "page_menu_separator" );
50
51 $t->set_block( "article_preview_page_tpl", "attached_file_list_tpl", "attached_file_list" );
52 $t->set_block( "attached_file_list_tpl", "attached_file_tpl", "attached_file" );
53
54
55 $t->set_block( "article_preview_page_tpl", "page_link_tpl", "page_link" );
56 $t->set_block( "article_preview_page_tpl", "next_page_link_tpl", "next_page_link" );
57 $t->set_block( "article_preview_page_tpl", "prev_page_link_tpl", "prev_page_link" );
58
59 $t->set_block( "article_preview_page_tpl", "attribute_list_tpl", "attribute_list" );
60 $t->set_block( "attribute_list_tpl", "type_item_tpl", "type_item" );
61 $t->set_block( "type_item_tpl", "attribute_item_tpl", "attribute_item" );
62
63 $t->set_block( "article_preview_page_tpl", "image_list_tpl", "image_list" );
64 $t->set_block( "image_list_tpl", "image_tpl", "image" );
65
66
67 $article = new eZArticle( );
68
69 if ( !$article->get( $ArticleID ) )
70 {
71 eZHTTPTool::header( "Location: /error/404/" );
72 exit();
73 }
74
75
76 $renderer = new eZArticleRenderer( $article );
77
78 $t->set_var( "article_name", $article->name() );
79 $t->set_var( "author_text", $article->authorText() );
80
81 $articleContents =& $renderer->renderPage( $PageNumber -1 );
82
83 $t->set_var( "article_intro", $articleContents[0] );
84 $t->set_var( "article_body", $articleContents[1] );
85
86
87 $t->set_var( "link_text", $article->linkText() );
88 $t->set_var( "article_id", $article->id() );
89
90
91 $files = $article->files();
92
93 if ( count( $files ) > 0 )
94 {
95 foreach ( $files as $file )
96 {
97 $t->set_var( "file_name", $file->name() );
98 $t->parse( "attached_file", "attached_file_tpl", true );
99 }
100
101 $t->parse( "attached_file_list", "attached_file_list_tpl" );
102 }
103 else
104 {
105 $t->set_var( "attached_file_list", "" );
106 }
107
108 $types = $article->types();
109
110 $typeCount = count( $types );
111
112 $t->set_var( "attribute_item", "" );
113 $t->set_var( "type_item", "" );
114 $t->set_var( "attribute_list", "" );
115
116 if( $typeCount > 0 )
117 {
118 foreach( $types as $type )
119 {
120 $attributes = array();
121 $attributes = $type->attributes();
122 $attributeCount = count( $attributes );
123
124 if( $attributeCount > 0 )
125 {
126 $t->set_var( "type_id", $type->id() );
127 $t->set_var( "type_name", $type->name() );
128 $t->set_var( "attribute_item", "" );
129 foreach( $attributes as $attribute )
130 {
131 $t->set_var( "attribute_id", $attribute->id() );
132 $t->set_var( "attribute_name", $attribute->name() );
133 $t->set_var( "attribute_value", nl2br( $attribute->value( $article ) ) );
134 $t->parse( "attribute_item", "attribute_item_tpl", true );
135 }
136 $t->parse( "type_item", "type_item_tpl", true );
137 }
138 }
139
140 $t->parse( "attribute_list", "attribute_list_tpl" );
141 }
142
143 // image list
144
145 $usedImages = $renderer->usedImageList();
146 $images =& $article->images();
147 $imageNumber = 0;
148 $i=0;
149 foreach ( $images as $imageArray ) {
150 $image = $imageArray["Image"];
151 $placement = $imageArray["Placement"];
152
153 $showImage = true;
154
155 if ( is_array( $usedImages ) ) {
156 if ( in_array( $placement, $usedImages ) ) {
157 $showImage = false;
158 }
159 }
160
161 if ( $showImage ) {
162 if ( ( $i % 2 ) == 0 ) {
163 $t->set_var( "td_class", "bglight" );
164 } else {
165 $t->set_var( "td_class", "bgdark" );
166 }
167
168 if ( $image->caption() == "" )
169 $t->set_var( "image_caption", "&nbsp;" );
170 else
171 $t->set_var( "image_caption", $image->caption() );
172
173
174 $t->set_var( "image_id", $image->id() );
175 $t->set_var( "article_id", $ArticleID );
176
177 $variation =& $image->requestImageVariation( 150, 150 );
178
179 $t->set_var( "image_url", "/" . $variation->imagePath() );
180 $t->set_var( "image_width", $variation->width() );
181 $t->set_var( "image_height",$variation->height() );
182
183 $t->parse( "image", "image_tpl", true );
184 $i++;
185 }
186 $imageNumber++;
187 }
188
189 $t->parse( "image_list", "image_list_tpl", true );
190
191 if ( $i == 0 )
192 $t->set_var( "image_list", "" );
193
194
195 $pageCount = $article->pageCount();
196
197 if ( $pageCount > 1 )
198 {
199 for ( $i=0; $i<$pageCount; $i++ )
200 {
201 $t->set_var( "article_id", $article->id() );
202 $t->set_var( "page_number", $i+1 );
203
204 $t->parse( "page_link", "page_link_tpl", true );
205 }
206
207 $t->parse( "page_menu_separator", "page_menu_separator_tpl" );
208 }
209 else
210 {
211 $t->set_var( "page_link", "" );
212 $t->set_var( "page_menu_separator", "" );
213 }
214
215 if ( $PageNumber > 1 )
216 {
217 $t->set_var( "prev_page_number", $PageNumber - 1 );
218 $t->parse( "prev_page_link", "prev_page_link_tpl" );
219 }
220 else
221 {
222 $t->set_var( "prev_page_link", "" );
223 }
224
225 if ( $PageNumber < $pageCount )
226 {
227 $t->set_var( "next_page_number", $PageNumber + 1 );
228 $t->parse( "next_page_link", "next_page_link_tpl" );
229 }
230 else
231 {
232 $t->set_var( "next_page_link", "" );
233 }
234
235
236
237 $t->pparse( "output", "article_preview_page_tpl" );
238
239 ?>
$articleContents
$articleContents
Definition: articlepreview.php:81
$t
$t
Definition: articlepreview.php:40
$article
$article
Definition: articlepreview.php:67
$imageNumber
$imageNumber
Definition: articlepreview.php:147
$i
$i
Definition: articlepreview.php:148
$Language
$Language
Definition: articlepreview.php:38
$ini
$ini
Definition: articlepreview.php:36
$types
$types
Definition: articlepreview.php:108
$files
$files
Definition: articlepreview.php:91
$pageCount
$pageCount
Definition: articlepreview.php:195
$images
$images
Definition: articlepreview.php:146
$renderer
if(! $article->get( $ArticleID)) $renderer
Definition: articlepreview.php:76
$typeCount
$typeCount
Definition: articlepreview.php:110
$usedImages
if( $typeCount > 0) $usedImages
Definition: articlepreview.php:145
eZArticleRenderer
Definition: ezarticlerenderer.php:36
eZArticle
Definition: ezarticle.php:82
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZTemplate
Definition: eztemplate.php:107
$type
$type
Definition: classes/admin/linkselect.php:220
$ArticleID
$ArticleID
Definition: export.php:48
$file
$file
Definition: ezfilemanager/user/filedownload.php:35
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
exit
exit
Definition: folder.php:81
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.