Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezezrenderer.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezezrenderer.php 7590 2001-09-29 12:35:15Z kaid $
5 //
6 // Definition of eZEzRenderer class
7 //
8 // Created on: <26-Oct-2000 13:46:30 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
80 // $tmpPage = preg_replace( "#<mail\s+?([^ ]*?)\s+?(.*?),\s+?([^>]*?)>#", "<mail to=\"\\1\" subject=\"\\2\" text=\"\\3\" />", $tmpPage );
81
82 // print( htmlspecialchars( $tmpPage ) );
83
84
85 // include_once( "classes/eztexttool.php" );
86 // include_once( "classes/ezlog.php" );
87
88 class eZEzRenderer
89 {
93 function __construct( &$article )
94 {
95 $this->Article = $article;
96 }
97
101 function &renderIntro()
102 {
103 $xml = xmltree( $this->Article->contents() );
104
105 if ( !$xml )
106 {
107 print( "<br /><b>Error: eZEzRenderer::docodeXML() could not decode XML</b><br />" );
108 }
109 else
110 {
111 $intro = "";
112 $body = "";
113
114 $i=0;
115 foreach ( $xml->root->children as $child )
116 {
117 if ( $child->name == "intro" )
118 {
119 $intro = $child->children[0]->content;
120 $intro = preg_replace( "#(http://.*?)(\s|\‍))#", "<a href=\"\\1\">\\1</a>", $intro );
121 }
122 }
123
124 $newArticle = eZTextTool::nl2br( $intro );
125 }
126
127 return $newArticle;
128 }
129
133 function &renderPage( $pageNumber=0 )
134 {
135 $xml = xmltree( $this->Article->contents() );
136
137 if ( !$xml )
138 {
139 print( "<br /><b>Error: eZEzRenderer::docodeXML() could not decode XML</b><br />" );
140 }
141 else
142 {
143 $intro = "";
144 $body = "";
145
146
147 foreach ( $xml->root->children as $child )
148 {
149 if ( $child->name == "intro" )
150 {
151 $intro = trim( $child->children[0]->content );
152 $intro = preg_replace( "#(http://.*?)(\s|\‍))#", "<a href=\"\\1\">\\1</a>", $intro );
153 }
154
155 if ( $child->name == "body" )
156 {
157 $body = $child->children;
158 }
159 }
160
161 $articleImages = $this->Article->images();
162 $articleID = $this->Article->id();
163 $pageArray = array();
164 // loop on the pages
165 foreach ( $body as $page )
166 {
167 $pageContent = "";
168 // loop on the contents of the pages
169 if ( count( $page->children ) > 0 )
170 foreach ( $page->children as $paragraph )
171 {
172 // ordinary text
173 if ( $paragraph->name == "text" )
174 {
175 $pageContent .= eZTextTool::nl2br($paragraph->content );
176 }
177
178 // header
179 if ( $paragraph->name == "header" )
180 {
181 $tmpText = "
182 <br clear=\"all\" />
183 <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">
184 <tr>
185 <td bgcolor=\"#c0c0c0\" width=\"100%\">
186
187 <div class=\"listheadline\"><img src=\"$GlobalSiteIni->WWWDir$GlobalSiteIni->Index/images/1x1.gif\" width=\"4\" height=\"1\" border=\"0\">"
188 .
189 $paragraph->children[0]->content
190 .
191 "
192 </div>
193 </td>
194 </tr>
195 </table>";
196
197 $pageContent .= $tmpText;
198 }
199
200 // bold text
201 if ( $paragraph->name == "bold" )
202 {
203 $pageContent .= "<b>" . $paragraph->children[0]->content . "</b>";
204 }
205
206 // italic text
207 if ( $paragraph->name == "italic" )
208 {
209 $pageContent .= "<i>" . $paragraph->children[0]->content . "</i>";
210 }
211
212 // underline text
213 if ( $paragraph->name == "underline" )
214 {
215 $pageContent .= "<u>" . $paragraph->children[0]->content . "</u>";
216 }
217
218 // strike text
219 if ( $paragraph->name == "strike" )
220 {
221 $pageContent .= "<s>" . $paragraph->children[0]->content . "</s>";
222 }
223
224 // pre text
225 if ( ( $paragraph->name == "pre" ) || ( $paragraph->name == "verbatim" ) )
226 {
227 $pageContent .= "<pre>" . $paragraph->children[0]->content . "</pre>";
228 }
229
230 // link
231 if ( $paragraph->name == "link" )
232 {
233 foreach ( $paragraph->attributes as $imageItem )
234 {
235 switch ( $imageItem->name )
236 {
237
238 case "href" :
239 {
240 $href = $imageItem->children[0]->content;
241 }
242 break;
243
244 case "text" :
245 {
246 $text = $imageItem->children[0]->content;
247 }
248 break;
249 }
250 }
251
252 if ( ( $href[0] == "/" ) || ( $href[0] == "#" ) )
253 {
254 $pageContent .= "<a href=\"$GlobalSiteIni->WWWDir$GlobalSiteIni->Index$href\">" . $text . "</a>";
255 }
256 else
257 {
258 $pageContent .= "<a href=\"http://$href\">" . $text . "</a>";
259 }
260 }
261
262 // mail
263 if ( $paragraph->name == "mail" )
264 {
265 foreach ( $paragraph->attributes as $mailItem )
266 {
267 switch ( $mailItem->name )
268 {
269 case "to" :
270 {
271 $to = $mailItem->children[0]->content;
272 }
273 break;
274
275 case "subject" :
276 {
277 $subject = $mailItem->children[0]->content;
278 }
279 break;
280
281 case "text" :
282 {
283 $text = $mailItem->children[0]->content;
284 }
285 break;
286 }
287 }
288
289 $pageContent .= "<a href=\"mailto:$to?subject=$subject\">$text</a>";
290 }
291
292
293 // ezlink
294 if ( $paragraph->name == "ezlink" )
295 {
296 foreach ( $paragraph->attributes as $imageItem )
297 {
298 switch ( $imageItem->name )
299 {
300
301 case "href" :
302 {
303 $href = $imageItem->children[0]->content;
304 }
305 break;
306
307 case "text" :
308 {
309 $text = $imageItem->children[0]->content;
310 }
311 break;
312 }
313 }
314
315 if ( ( $href[0] == "/" ) || ( $href[0] == "#" ) )
316 {
317 $pageContent .= "
318 <img align=\"baseline\" src=\"$GlobalSiteIni->WWWDir$GlobalSiteIni->Index/images/pil-space.gif\" width=\"50\" height=\"10\" border=\"0\" hspace=\"0\">&nbsp;<a class=\"path\" href=\"$GlobalSiteIni->WWWDir$GlobalSiteIni->Index$href\">"
319 . $text . "</a>";
320 }
321 else
322 {
323 $pageContent .= "
324 <img align=\"baseline\" src=\"$GlobalSiteIni->WWWDir$GlobalSiteIni->Index/images/pil-space.gif\" width=\"50\" height=\"10\" border=\"0\" hspace=\"0\">&nbsp;<a class=\"path\" href=\"http://$href\">"
325 . $text . "</a>";
326
327 }
328 }
329
330
331 // ez anchor
332 if ( $paragraph->name == "ezanchor" )
333 {
334 foreach ( $paragraph->attributes as $anchorItem )
335 {
336 switch ( $anchorItem->name )
337 {
338 case "href" :
339 {
340 $href = $anchorItem->children[0]->content;
341 }
342 break;
343 }
344 }
345
346 $pageContent .= "<a name=\"$href\"></a>";
347 }
348
349 // image
350 if ( $paragraph->name == "image" )
351 {
352 foreach ( $paragraph->attributes as $imageItem )
353 {
354 switch ( $imageItem->name )
355 {
356
357 case "id" :
358 {
359 $imageID = $imageItem->children[0]->content;
360 }
361 break;
362
363 case "align" :
364 {
365 $imageAlignment = $imageItem->children[0]->content;
366 }
367 break;
368
369 case "size" :
370 {
371 $imageSize = $imageItem->children[0]->content;
372 }
373 break;
374
375 }
376 }
377
378
379 setType( $imageID, "integer" );
380
381 $image = $articleImages[$imageID-1];
382
383 // add image if a valid image was found, else report an error in the log.
384 if ( is_a( $image, "eZImage" ) )
385 {
386 $ini =& eZINI::instance( 'site.ini' );
387
388 switch ( $imageSize )
389 {
390 case "small" :
391 {
392 $variation =& $image->requestImageVariation( $ini->variable( "eZArticleMain", "SmallImageWidth" ),
393 $ini->variable( "eZArticleMain", "SmallImageHeight" ) );
394 }
395 break;
396 case "medium" :
397 {
398 $variation =& $image->requestImageVariation( $ini->variable( "eZArticleMain", "MediumImageWidth" ),
399 $ini->variable( "eZArticleMain", "MediumImageHeight" ) );
400 }
401 break;
402 case "large" :
403 {
404 $variation =& $image->requestImageVariation( $ini->variable( "eZArticleMain", "LargeImageWidth" ),
405 $ini->variable( "eZArticleMain", "LargeImageHeight" ) );
406 }
407 break;
408 }
409
410 $imageURL = "/" . $variation->imagePath();
411 $imageWidth = $variation->width();
412 $imageHeight = $variation->height();
413 $imageCaption = $image->caption();
414
415 $imageTags = "<table width=\"$imageWidth\" align=\"$imageAlignment\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
416 <tr>
417 <td>
418 <img src=\"$GlobalSiteIni->WWWDir$GlobalSiteIni->Index$imageURL\" border=\"0\" width=\"$imageWidth\" height=\"$imageHeight\" />
419 </td>
420 </tr>
421 <tr>
422 <td class=\"pictext\">
423 $imageCaption
424 </td>
425 </tr>
426 </table>";
427 $pageContent .= $imageTags;
428 }
429 else
430 {
431 eZPBLog::writeError( "Image nr: $imageID not found in article: $articleID from IP: $REMOTE_ADDR" );
432 }
433 }
434 }
435
436
437 $pageArray[] = $pageContent;
438
439 }
440
441
442 if ( $pageNumber != 0 )
443 {
444 $newArticle = $pageArray[$pageNumber];
445 }
446 else
447 {
448 if ( $intro != "" )
449 {
450 $newArticle = "<p>" . eZTextTool::nl2br( $intro ) . "</p>". $pageArray[$pageNumber];
451 }
452 else
453 {
454 $newArticle = $pageArray[$pageNumber];
455 }
456 }
457
458 }
459
460 return $newArticle;
461 }
462
463
467 function &renderIntro()
468 {
469 $xml = xmltree( $this->Article->contents() );
470
471 if ( !$xml )
472 {
473 print( "<br /><b>Error: eZEzRenderer::docodeXML() could not decode XML</b><br />" );
474 }
475 else
476 {
477 $intro = "";
478 $body = "";
479
480 $i=0;
481 foreach ( $xml->root->children as $child )
482 {
483 if ( $child->name == "intro" )
484 {
485 $intro = $child->children[0]->content;
486 }
487 }
488
489 $newArticle = eZTextTool::nl2br( $intro );
490 }
491
492 return $newArticle;
493 }
494
495 var $Article;
496 }
497
498 ?>
$i
$i
Definition: admin/adlist.php:91
$article
$article
Definition: articlelog.php:45
eZEzRenderer
Definition: ezezrenderer.php:89
eZEzRenderer\renderIntro
& renderIntro()
Definition: ezezrenderer.php:101
eZEzRenderer\__construct
__construct(&$article)
Definition: ezezrenderer.php:93
eZEzRenderer\renderPage
& renderPage( $pageNumber=0)
Definition: ezezrenderer.php:133
eZEzRenderer\$Article
$Article
Definition: ezezrenderer.php:495
eZPBLog\writeError
writeError( $error)
Definition: ezpblog.php:188
eZTextTool\nl2br
static nl2br( $string, $xhtml=true)
Definition: eztexttool.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$page
$page
Definition: ezarticle/modules/content.php:28
$variation
$variation
Definition: ezimagecatalogue/user/menubox.php:55
$articleID
if( $Action=="New") $articleID
Definition: user/articleedit.php:269
$image
$image
Definition: user/articlelist.php:242
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.