Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztechrenderer.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: eztechrenderer.php 9256 2002-02-21 10:43:48Z br $
5 //
6 // Definition of eZTechRenderer class
7 //
8 // Created on: <18-Oct-2000 17:45:32 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
123 // include_once( "classes/eztexttool.php" );
124 // include_once( "classes/ezlog.php" );
125
126 class eZTechRenderer
127 {
131 function __construct( &$article )
132 {
133 $this->Article = $article;
134 }
135
139 function &renderIntro()
140 {
141 // print( "<pre>" );
142
143 $xml = xmltree( $this->Article->contents() );
144
145 // print_r( $xml );
146
147 // $xml =& qdom_tree( $this->Article->contents() );
148
149 // print_r( $xml );
150
151 // print( "</pre>" );
152
153 if ( !$xml )
154 {
155 print( "<br /><b>Error: eZTechRenderer::docodeXML() could not decode XML</b><br />" );
156 }
157 else
158 {
159 $intro = "";
160 $body = "";
161
162 $articleImages = $this->Article->images();
163 $articleID = $this->Article->id();
164
165 $i=0;
166 $this->PrevTag = "";
167 foreach ( $xml->children as $child )
168 {
169 if ( $child->name == "article" )
170 {
171 foreach ( $child->children as $article )
172 {
173 if ( $article->name == "intro" )
174 {
175 if ( count( $article->children ) > 0 )
176 {
177 foreach ( $article->children as $paragraph )
178 {
179 $intro = $this->renderPlain( $intro, $paragraph );
180
181 $intro = $this->renderCode( $intro, $paragraph );
182
183 $intro = $this->renderStandards( $intro, $paragraph );
184
185 $intro = $this->renderLink( $intro, $paragraph );
186
187 $intro = $this->renderModule( $intro, $paragraph );
188
189 $intro = $this->renderImage( $intro, $paragraph, $articleImages );
190
191 $this->PrevTag = $paragraph->name;
192 }
193 }
194 }
195 }
196 }
197 }
198
199 // $newArticle = eZTextTool::nl2br( $intro );
200 $newArticle = $intro;
201 }
202
203 return $newArticle;
204 }
205
211 function &renderPage( $pageNumber=0 )
212 {
213 $xml =& xmltree( $this->Article->contents() );
214
215 // $xml =& qdom_tree( $this->Article->contents() );
216
217 $returnArray = array( );
218
219 if ( !$xml )
220 {
221 print( "<br /><b>Error: eZTechRenderer::docodeXML() could not decode XML</b><br />" );
222 }
223 else
224 {
225 $intro = "";
226 $body = array();
227
228 $this->PrevTag = "";
229 $articleImages =& $this->Article->images();
230 $articleID = $this->Article->id();
231
232 foreach ( $xml->children as $child )
233 {
234 if ( $child->name == "article" )
235 {
236 foreach ( $child->children as $article )
237 {
238 if ( $article->name == "intro" )
239 {
240 if ( count( $article->children ) > 0 )
241 foreach ( $article->children as $paragraph )
242 {
243 $intro = $this->renderPlain( $intro, $paragraph );
244
245 $intro = $this->renderCode( $intro, $paragraph );
246
247 $intro = $this->renderStandards( $intro, $paragraph );
248
249 $intro = $this->renderLink( $intro, $paragraph );
250
251 $intro = $this->renderModule( $intro, $paragraph );
252
253 $intro = $this->renderImage( $intro, $paragraph, $articleImages );
254
255 $this->PrevTag = $paragraph->name;
256 }
257 }
258
259 if ( $article->name == "body" )
260 {
261 $body = $article->children;
262 }
263 }
264 }
265 }
266
267 $pageArray = array();
268 // loop on the pages
269 if ( count( $body ) > 0 )
270 foreach ( $body as $page )
271 {
272 if ( $page->name == "page" )
273 {
274 $pageContent = "";
275 $this->PrevTag = "";
276 // loop on the contents of the pages
277 if ( count( $page->children ) > 0 )
278 foreach ( $page->children as $paragraph )
279 {
280 $pageContent = $this->renderPlain( $pageContent, $paragraph );
281
282 $pageContent = $this->renderCode( $pageContent, $paragraph );
283
284 $pageContent = $this->renderStandards( $pageContent, $paragraph );
285
286 $pageContent = $this->renderLink( $pageContent, $paragraph );
287
288 $pageContent = $this->renderModule( $pageContent, $paragraph );
289
290 $pageContent = $this->renderImage( $pageContent, $paragraph, $articleImages );
291
292 $this->PrevTag = $paragraph->name;
293 }
294 $pageArray[] = $pageContent;
295 }
296 }
297
298
299 $bodyContents = "";
300 if ( $pageNumber == -1 )
301 {
302 // $newArticle = "<span class=\"intro\">" . $intro . "</span>\n</p><p>\n";
303
304 if ( count( $pageArray ) > 0 )
305 foreach ( $pageArray as $page )
306 {
307 $bodyContents .= $page;
308 }
309 }
310 else if ( $pageNumber != 0 )
311 {
312 $bodyContents = $pageArray[$pageNumber];
313 }
314 else
315 {
316 // $newArticle = eZTextTool::nl2br( $intro ) . "</p><p>". $pageArray[$pageNumber];
317 // $newArticle = "<span class=\"intro\">" . $intro . "</span>\n</p><p>\n". $pageArray[$pageNumber];
318 $bodyContents = $pageArray[$pageNumber];
319 }
320
321 $returnArray[] =& $intro;
322 $returnArray[] =& $bodyContents;
323 }
324
325 return $returnArray;
326 }
327
328 function &renderPlain( $pageContent, $paragraph )
329 {
330 // ordinary text
331 if ( $paragraph->name == "#text" || $paragraph->name == "text" )
332 {
333 $paragraph_text = $paragraph->content;
334 if ( $paragraph_text[0] == "\n" )
335 {
336 if ( $this->PrevTag != "link" )
337 $paragraph_text[0] = " ";
338 }
339 $pageContent .= eZTextTool::nl2br( $paragraph_text );
340 }
341 return $pageContent;
342 }
343
344
345 function &renderLink( $pageContent, $paragraph )
346 {
347 global $GlobalSiteIni;
348
349 // link
350 if ( $paragraph->name == "link" )
351 {
352 foreach ( $paragraph->attributes as $imageItem )
353 {
354 switch ( $imageItem->name )
355 {
356
357 case "href" :
358 {
359 $href = $imageItem->children[0]->content;
360 }
361 break;
362
363 case "text" :
364 {
365 $text = $imageItem->children[0]->content;
366 }
367 break;
368 }
369 }
370
371 if ( !preg_match( "%^(([a-z]+://)|/|#)%", $href ) )
372 $href = "http://" . $href;
373 $pageContent .= "<a href=\"" . $GlobalSiteIni->WWWDir . $GlobalSiteIni->Index . $href . "\">" . $text . "</a>";
374 }
375
376 // link
377 if ( $paragraph->name == "iconlink" )
378 {
379 foreach ( $paragraph->attributes as $imageItem )
380 {
381 switch ( $imageItem->name )
382 {
383
384 case "href" :
385 {
386 $href = $imageItem->children[0]->content;
387 }
388 break;
389
390 case "text" :
391 {
392 $text = $imageItem->children[0]->content;
393 }
394 break;
395 }
396 }
397
398 if ( !preg_match( "%^(([a-z]+://)|/|#)%", $href ) )
399 $href = "http://" . $href;
400
401 $pageContent .= "<img align=\"baseline\" src=\"" . $GlobalSiteIni->WWWDir . "/images/bulletlink.gif\" width=\"50\" height=\"10\" border=\"0\" hspace=\"0\">&nbsp;<a class=\"path\" href=\"$href\">" . $text . "</a>";
402 }
403
404 // ez anchor
405 if ( $paragraph->name == "ezanchor" )
406 {
407 foreach ( $paragraph->attributes as $anchorItem )
408 {
409 switch ( $anchorItem->name )
410 {
411 case "href" :
412 {
413 $href = $anchorItem->children[0]->content;
414 }
415 break;
416 }
417 }
418
419 $pageContent .= "<a name=\"$href\"></a>";
420 }
421
422 // mail
423 if ( $paragraph->name == "mail" )
424 {
425 foreach ( $paragraph->attributes as $mailItem )
426 {
427 switch ( $mailItem->name )
428 {
429 case "to" :
430 {
431 $to = $mailItem->children[0]->content;
432 }
433 break;
434
435 case "subject" :
436 {
437 $subject = $mailItem->children[0]->content;
438 }
439 break;
440
441 case "text" :
442 {
443 $text = $mailItem->children[0]->content;
444 }
445 break;
446 }
447 }
448
449 $pageContent .= "<a href=\"mailto:$to?subject=$subject\">$text</a>";
450 }
451
452
453 return $pageContent;
454 }
455
459 function &renderModule( $pageContent, $paragraph )
460 {
461 // ordinary text
462 if ( $paragraph->name == "module" )
463 {
464 foreach ( $paragraph->attributes as $moduleItem )
465 {
466 switch ( $moduleItem->name )
467 {
468 case "name" :
469 {
470 $name = $moduleItem->children[0]->content;
471 }
472 break;
473 }
474 }
475
476 $localModuleFile = "modules/" . $name . ".php";
477
478 if ( file_exists( $localModuleFile ) )
479 {
480 $moduleFile = $localModuleFile;
481 }
482 else
483 {
484 $moduleFile = "ezarticle/modules/" . $name . ".php";
485 }
486
487 if ( file_exists( $moduleFile ) )
488 {
489 // save the buffer contents
490 $buffer =& ob_get_contents();
491 ob_end_clean();
492
493 // fetch the module printout
494 ob_start();
495 include( $moduleFile );
496 $moduleContents .= ob_get_contents();
497 ob_end_clean();
498
499 // fill the buffer with the old values
500 ob_start();
501 print( $buffer );
502
503 $pageContent .= "$moduleContents";
504 }
505 else
506 {
507 $pageContent .= "<b>Error</b>: module $name, not found. Looking in: $moduleFile";
508 }
509 }
510 return $pageContent;
511 }
512
513
514 function &renderImage( $pageContent, $paragraph, $articleImages )
515 {
516 global $GlobalSiteIni;
517
518 $articleID = $this->Article->id();
519 // image
520 if ( $paragraph->name == "image" )
521 {
522 foreach ( $paragraph->attributes as $imageItem )
523 {
524 switch ( $imageItem->name )
525 {
526
527 case "id" :
528 {
529 $imageID = $imageItem->children[0]->content;
530 }
531 break;
532
533 case "align" :
534 {
535 $imageAlignment = $imageItem->children[0]->content;
536 }
537 break;
538
539 case "size" :
540 {
541 $imageSize = $imageItem->children[0]->content;
542 }
543 break;
544
545 }
546 }
547
548 // $imageID = $paragraph->children[0]->content;
549 setType( $imageID, "integer" );
550
551 foreach ( $articleImages as $imageArray )
552 {
553 if ( $imageArray["Placement"] == $imageID )
554 $image = $imageArray["Image"];
555 }
556
557 // add image if a valid image was found, else report an error in the log.
558 if ( is_a( $image, "eZImage" ) )
559 {
560 $ini =& eZINI::instance( 'site.ini' );
561
562 // store the relative ID to the image
563 $this->UsedImageList[] = $imageID;
564
565 switch ( $imageSize )
566 {
567 case "small" :
568 {
569 $variation =& $image->requestImageVariation( $ini->variable( "eZArticleMain", "SmallImageWidth" ),
570 $ini->variable( "eZArticleMain", "SmallImageHeight" ) );
571 }
572 break;
573 case "medium" :
574 {
575 $variation =& $image->requestImageVariation( $ini->variable( "eZArticleMain", "MediumImageWidth" ),
576 $ini->variable( "eZArticleMain", "MediumImageHeight" ) );
577 }
578 break;
579 case "large" :
580 {
581 $variation =& $image->requestImageVariation( $ini->variable( "eZArticleMain", "LargeImageWidth" ),
582 $ini->variable( "eZArticleMain", "LargeImageHeight" ) );
583 }
584 break;
585
586 case "original" :
587 {
588 $variation =& $image;
589 }
590 break;
591
592 default :
593 {
594 $variation =& $image->requestImageVariation( $ini->variable( "eZArticleMain", "MediumImageWidth" ),
595 $ini->variable( "eZArticleMain", "MediumImageHeight" ) );
596 }
597 }
598
599 if ( is_a( $variation, "eZImage" ) )
600 {
601 $imageURL = $variation->filePath();
602 }
603 else
604 {
605 $imageURL = "/" . $variation->imagePath();
606 }
607
608 $imageWidth = $variation->width();
609 $imageHeight = $variation->height();
610 $imageCaption = $image->caption();
611 $imageID = $image->id();
612
613 if ( isset( $GLOBALS["ViewMode"] ) )
614 $viewMode = $GLOBALS["ViewMode"];
615 else
616 $viewMode = "";
617
618 if ( $viewMode == "" )
619 {
620 $viewMode = "view";
621 }
622 if ( $imageAlignment != "float" )
623 {
624 $imageTags = "<br clear=\"all\"><table width=\"$imageWidth\" align=\"$imageAlignment\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">
625 <tr>
626 <td>
627 <a href=\"" . $GlobalSiteIni->WWWDir . $GlobalSiteIni->Index . "/imagecatalogue/imageview/$imageID/?RefererURL=/article/$viewMode/$articleID/\">
628 <img src=\"" . $GlobalSiteIni->WWWDir . "$imageURL\" border=\"0\" width=\"$imageWidth\" height=\"$imageHeight\" alt=\"\" />
629 </a>
630 </td>
631 </tr>
632 <tr>
633 <td class=\"pictext\">
634 $imageCaption
635 </td>
636 </tr>
637 </table>";
638 }
639 else
640 {
641 $imageTags = "<a href=\"" . $GlobalSiteIni->WWWDir . $GlobalSiteIni->Index . "/imagecatalogue/imageview/$imageID/?RefererURL=/article/$viewMode/$articleID/\"><img src=\"" . $GlobalSiteIni->WWWDir . "$imageURL\" border=\"0\" width=\"$imageWidth\" height=\"$imageHeight\" alt=\"\" /></a>";
642 }
643 $pageContent .= $imageTags;
644 }
645 else
646 {
647 eZPBLog::writeError( "Image nr: $imageID not found in article: $articleID from IP: $REMOTE_ADDR" );
648 }
649 }
650 return $pageContent;
651 }
652
653 function &renderCode( $pageContent, $paragraph )
654 {
655 // php code
656 if ( $paragraph->name == "php" )
657 {
658 $pageContent .= $this->phpHighlight( trim( $paragraph->children[0]->content ) );
659 }
660
661 // java code
662 if ( $paragraph->name == "java" )
663 {
664 $pageContent .= $this->javaHighlight( trim( $paragraph->children[0]->content ) );
665 }
666
667 // html code
668 if ( $paragraph->name == "ezhtml" )
669 {
670 $pageContent .= $this->htmlHighlight( trim( $paragraph->children[0]->content ) );
671 }
672
673 // html code
674 if ( $paragraph->name == "html" )
675 {
676 $pageContent .= trim( $paragraph->children[0]->content );
677 }
678
679 // sql code
680 if ( $paragraph->name == "sql" )
681 {
682 $pageContent .= $this->sqlHighlight( $paragraph->children[0]->content );
683 }
684
685 // c++ code
686 if ( $paragraph->name == "cpp" )
687 {
688 $pageContent .= $this->cppHighlight( $paragraph->children[0]->content );
689 }
690
691 // shell code
692 if ( $paragraph->name == "shell" )
693 {
694 $pageContent .= $this->shellHighlight( $paragraph->children[0]->content );
695 }
696
697 // perl code
698 if ( $paragraph->name == "perl" )
699 {
700 $pageContent .= $this->perlHighlight( $paragraph->children[0]->content );
701 }
702
703 // lisp code
704 if ( $paragraph->name == "lisp" )
705 {
706 $pageContent .= $this->lispHighlight( $paragraph->children[0]->content );
707 }
708 return $pageContent;
709 }
710
711 function &renderStandards( $pageContent, $paragraph )
712 {
713 // header
714 if ( $paragraph->name == "header" )
715 {
716 $pageContent .= "\n<h2>". $paragraph->children[0]->content . "</h2>\n";
717 }
718
719 // bold text
720 if ( $paragraph->name == "bold" )
721 {
722 $pageContent .= "<b>" . $paragraph->children[0]->content . "</b>";
723 }
724
725 // italic text
726 if ( $paragraph->name == "italic" )
727 {
728 $pageContent .= "<i>" . $paragraph->children[0]->content . "</i>";
729 }
730
731 // underline text
732 if ( $paragraph->name == "underline" )
733 {
734 $pageContent .= "<u>" . $paragraph->children[0]->content . "</u>";
735 }
736
737 // strike text
738 if ( $paragraph->name == "strike" )
739 {
740 $pageContent .= "<s>" . $paragraph->children[0]->content . "</s>";
741 }
742
743 // pre text
744 if ( ( $paragraph->name == "pre" ) || ( $paragraph->name == "verbatim" ) )
745 {
746 $pageContent .= "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
747 $paragraph->children[0]->content . "</pre></td></tr></table></p>";
748 }
749
750 // bullet list
751 if ( $paragraph->name == "bullet" )
752 {
753 $tmpContent =& trim( $paragraph->children[0]->content );
754
755 $tmpContent =& preg_replace( "#^(.*)$#m", "<li>\\1</li>", $tmpContent );
756
757 $pageContent .= "<ul>" . $tmpContent . "</ul>";
758 }
759
760 return $pageContent;
761 }
762
763
768 function &phpHighlight( $string )
769 {
770 $string = preg_replace ( "/(<)/", "&lt;", $string );
771 $string = preg_replace ( "/(>)/", "&gt;", $string );
772
773 // some special characters
774 $string = preg_replace ( "/([(){}+-]|=|\[|\])/", "<font color=\"red\">\\1</font>", $string );
775
776 // reserved words
777 // $string = preg_replace ( "/(foreach|function|for|while|switch|as)/", "<font color=\"blue\">\\1</font>", $string );
778
779 // comments
780 $string = preg_replace ( "/(\/\/[^\n]+)/", "<font color=\"orange\">\\1</font>", $string );
781
782 $string = preg_replace ( "#(/\*.+?\*/)#ms", "<font color=\"orange\">\\1</font>", $string );
783
784
785
786 $reservedWords = array( "/(function)/",
787 "/( as )/",
788 "/(class )/",
789 "/(var )/",
790 "/(^var )/",
791 "/(for )/"
792 );
793
794 $string = preg_replace( $reservedWords, "<font color=\"blue\">\\1</font>", $string );
795
796 $string = preg_replace( "/( [0-9]+)/", "<font color=\"green\">\\1</font>", $string );
797
798 $string = preg_replace( "#(\\$[a-zA-Z0-9]+)#", "<font color=\"#00aaaa\">\\1</font>", $string );
799
800 // $string = preg_replace ( "#(\\$.+?)[\s|\;]#", "<font color=\"#00aaaa\">\\1</font>", $string );
801
802 // indenting
803
804 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
805 $string . "</pre></td></tr></table></p>";
806
807 return $string;
808 }
809
814 function &sqlHighlight( $string )
815 {
816
817 // some special characters
818 $string = preg_replace ( "/([(){},+-;]|=|\[|\])/", "<font color=\"green\">\\1</font>", $string );
819
820 $string = preg_replace ( "#('.*?')#", "<font color=\"red\">\\1</font>", $string );
821
822 $string = preg_replace( "/(\‍([0-9]+\‍))/", "<font color=\"green\">\\1</font>", $string );
823 $string = preg_replace( "/('[0-9]+')/", "<font color=\"red\">\\1</font>", $string );
824
825 $reservedWords = array( "/(DROP )/i",
826 "/(CREATE )/i",
827 "/(TABLE )/i",
828 "/(DELETE )/i",
829 "/(DROP )/i",
830 "/(IF )/i",
831 "/(EXISTS )/i",
832 "/(DEFAULT )/i",
833 "/(AUTO_INCREMENT)/i",
834 "/(PRIMARY )/i",
835 "/(KEY )/i",
836 "/(NULL )/i",
837 "/(NULL,)/i",
838 "/(INSERT )/i",
839 "/(INTO )/i",
840 "/(VALUES )/i",
841 "/(UNIQUE )/i",
842 "/(INT )/i",
843 "/(INT,)/i",
844 "/(CHAR )/i",
845 "/( TEXT,)/i",
846 "/( TEXT )/i",
847 "/(TIMESTAMP)/i",
848 "/(VARCHAR)/i",
849 "/( NOT )/i",
850 "/( AND )/i"
851 );
852
853
854
855 $string = preg_replace( $reservedWords, "<font color=\"blue\">\\1</font>", $string );
856
857
858
859 // some special characters
860 $string = preg_replace ( "/([;,])/", "<font color=\"red\">\\1</font>", $string );
861
862 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
863 $string . "</pre></td></tr></table></p>";
864
865 return $string;
866 }
867
872 function &cppHighlight( $string )
873 {
874 $string = preg_replace ( "/(<)/", "&lt;", $string );
875 $string = preg_replace ( "/(>)/", "&gt;", $string );
876
877 // some special characters
878 $string = preg_replace ( "/([(){}+-]|=|\[|\])/", "<font color=\"red\">\\1</font>", $string );
879
880 // comments
881 $string = preg_replace ( "/(//[^\n]+)/", "<font color=\"orange\">\\1</font>", $string );
882 $string = preg_replace ( "/(/\*[^\*]+\*/)/", "<font color=\"orange\">\\1</font>", $string );
883
884 // reserved words
885 $reservedWords = array( "/(function)/",
886 "/( as )/",
887 "/(void )/",
888 "/(class )/",
889 "/(var )/",
890 "/(int )/",
891 "/( for)/"
892 );
893
894 $string = preg_replace( $reservedWords, "<font color=\"blue\">\\1</font>", $string );
895
896
897 $string = preg_replace( "/( [0-9]+)/", "<font color=\"green\">\\1</font>", $string );
898
899
900 $string = preg_replace( "/(\$[a-zA-Z0-9]+)/", "<font color=\"#00ffff\">\\1</font>", $string );
901
902 // newlines
903 // $string = preg_replace ( "/\n/", "<br />\n newline", $string );
904
905 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
906 $string . "</pre></td></tr></table></p>";
907
908 return $string;
909 }
910
915 function &shellHighlight( $string )
916 {
917 $reservedWords = array( "/(IF )/i",
918 "/(FI )/i",
919 "/(FI\n)/i",
920 "/( THEN)/i"
921 );
922
923 $string = preg_replace( $reservedWords, "<font color=\"blue\">\\1</font>", $string );
924
925
926 // comment
927 $string = preg_replace ( "/(\#[^\n]+)/", "<font color=\"orange\">\\1</font>", $string );
928
929 // some special characters
930 $string = preg_replace ( "/([;,]|\]|\[)/", "<font color=\"red\">\\1</font>", $string );
931
932
933 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
934 $string . "</pre></td></tr></table></p>";
935
936 return $string;
937 }
938
943 function &perlHighlight( $string )
944 {
945 $string = preg_replace ( "/(<)/", "&lt;", $string );
946 $string = preg_replace ( "/(>)/", "&gt;", $string );
947
948 // some special characters
949 $string = preg_replace ( "/([(){}+-]|=|\[|\])/", "<font color=\"red\">\\1</font>", $string );
950
951 // reserved words
952 // $string = preg_replace ( "/(foreach|function|for|while|switch|as)/", "<font color=\"blue\">\\1</font>", $string );
953
954 // comments
955 $string = preg_replace ( "/(#[^\n]+)/", "<font color=\"orange\">\\1</font>", $string );
956
957 $reservedWords = array( "/(function)/",
958 "/( as )/",
959 "/(class )/",
960 "/(var )/",
961 "/( for)/"
962 );
963
964 $string = preg_replace( $reservedWords, "<font color=\"blue\">\\1</font>", $string );
965
966
967 $string = preg_replace( "/( [0-9]+)/", "<font color=\"green\">\\1</font>", $string );
968
969 $string = preg_replace( "/(\$[a-zA-Z0-9]+)/", "<font color=\"#00ffff\">\\1</font>", $string );
970
971 // indenting
972 $string = preg_replace( "/^( )+/m", "&nbsp;", $string );
973
974 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
975 $string . "</pre></td></tr></table></p>";
976
977 return $string;
978 }
979
980
985 function &lispHighlight( $string )
986 {
987 $len = strlen( $string );
988 $index = 0;
989 $tmpstring = "";
990
991 while ( $index < $len )
992 {
993 $char = $string[$index];
994 if ( $char == ';' )
995 {
996 $end = strpos( $string, "\n", $index );
997 if ( $end === false )
998 {
999 $tmpstring .= "<font color=\"orange\">" . $this->sptobsp( substr( $string, $index ) ) . "</font>\n";
1000 $index = $len;
1001 }
1002 else
1003 {
1004 $tmpstring .= "<font color=\"orange\">" . $this->sptobsp( substr( $string, $index, $end - $index ) ) . "</font>\n";
1005 $index = $end + 1;
1006 }
1007 }
1008 else if ( $char == ' ' )
1009 {
1010 $tmpstring .= "&nbsp;";
1011 ++$index;
1012 }
1013 else if ( $char == '(' )
1014 {
1015 $end = strpos( $string, " ", $index + 1 );
1016 $end_paren = strpos( $string, ")", $index + 1 );
1017 if ( $end_paren < $end )
1018 $end = $end_paren;
1019 if ( $end === false )
1020 {
1021 $tmpstring .= "(";
1022 ++$index;
1023 }
1024 else
1025 {
1026 $tmpstring .= "<font color=\"red\">(</font>";
1027 $command = substr( $string, $index + 1, $end - $index - 1 );
1028 if ( preg_match( "/(let|if|while)/i", $command ) )
1029 {
1030 $tmpstring .= "<font color=\"blue\">" . $command . "</font>";
1031 }
1032 else if ( preg_match( "/(defun|defvar)/i", $command ) )
1033 {
1034 $name_end = strpos( $string, " ", $end + 1 );
1035 if ( $name_end === false )
1036 {
1037 $tmpstring .= "<font color=\"blue\">" . $command . "</font>";
1038 $end = $len;
1039 }
1040 else
1041 {
1042 $name = substr( $string, $end + 1, $name_end - $end - 1 );
1043 $tmpstring .= "<font color=\"blue\">" . $command . "</font>&nbsp;";
1044 $tmpstring .= "<font color=\"magenta\">" . $name . "</font>";
1045 $end = $name_end;
1046 }
1047 }
1048 else
1049 {
1050 $tmpstring .= $command;
1051 }
1052 $index = $end;
1053 }
1054 }
1055 else if ( $char == ')' )
1056 {
1057 $tmpstring .= "<font color=\"red\">)</font>";
1058 ++$index;
1059 }
1060 else if ( $char == '"' )
1061 {
1062 $end = strpos( $string, "\"", $index + 1 );
1063 if ( $end === false )
1064 {
1065 $tmpstring .= "<font color=\"green\">\"" . $this->sptobsp( substr( $string, $index + 1 ) ) . "</font>";
1066 $index = $len;
1067 }
1068 else
1069 {
1070 $tmpstring .= "<font color=\"green\">\"" . $this->sptobsp( substr( $string, $index + 1, $end - $index - 1 ) ) . "\"</font>";
1071 $index = $end + 1;
1072 }
1073 }
1074 else
1075 {
1076 $tmpstring .= $char;
1077 ++$index;
1078 }
1079 }
1080 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
1081 $tmpstring . "</pre></td></tr></table></p>";
1082
1083 return $string;
1084
1085 // $string = preg_replace ( "/(<)/", "&lt;", $string );
1086 // $string = preg_replace ( "/(>)/", "&gt;", $string );
1087
1088 // // comments
1089 // $string = preg_replace ( "#(;.*$)#m", "<font color=\"orange\">\\1</font>", $string );
1090
1091 // // indenting
1092 // $string = preg_replace( "/( )/m", "&nbsp;", $string );
1093
1094 // $string = preg_replace( "/(\"[^\"]*\")/", "<font color=\"green\">\\1</font>", $string );
1095
1096 // // some special characters
1097 // $string = preg_replace ( "/([(){}+-]|\[|\])/", "<font color=\"red\">\\1</font>", $string );
1098
1099 // $string = preg_replace( "/(defun|let|if|while)/", "<font color=\"blue\">\\1</font>", $string );
1100
1101 // // reserved words
1102 // // $string = preg_replace ( "/(foreach|function|for|while|switch|as)/", "<font color=\"blue\">\\1</font>", $string );
1103
1104
1105 // $string = preg_replace( "/( [0-9]+)/", "<font color=\"green\">\\1</font>", $string );
1106
1107 // $string = preg_replace( "/(\$[a-zA-Z0-9]+)/", "<font color=\"#00ffff\">\\1</font>", $string );
1108
1109 // $string = "<p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
1110 // $string . "</pre></td></tr></table></p>";
1111
1112 // return $string;
1113 }
1114
1115 function &sptobsp( $string )
1116 {
1117 preg_replace( "# #m", "&nbsp;", $string );
1118 return $string;
1119 }
1120
1125 function &javaHighlight( $string )
1126 {
1127 $string = preg_replace ( "/(<)/", "&lt;", $string );
1128 $string = preg_replace ( "/(>)/", "&gt;", $string );
1129
1130 // some special characters
1131 $string = preg_replace ( "/([(){},+-;]|=|\[|\])/", "<font color=\"red\">\\1</font>", $string );
1132
1133 // comments
1134 $string = preg_replace ( "/(\/\/[^\n]+)/", "<font color=\"orange\">\\1</font>", $string );
1135 $string = preg_replace ( "/(\/\*[^\*]+\*\/)/", "<font color=\"orange\">\\1</font>", $string );
1136
1137 // reserved words
1138 $reservedWords = array( "/(function)/",
1139 "/( as )/",
1140 "/(void )/",
1141 "/(class )/",
1142 "/(float )/",
1143 "/(doble )/",
1144 "/(int )/",
1145 "/(var )/",
1146 "/(private )/",
1147 "/(public )/",
1148 "/(int )/",
1149 "/( for)/"
1150 );
1151
1152 $string = preg_replace( $reservedWords, "<font color=\"blue\">\\1</font>", $string );
1153
1154 $string = preg_replace( "/( [0-9]+)/", "<font color=\"green\">\\1</font>", $string );
1155
1156 $string = preg_replace( "/(\$[a-zA-Z0-9]+)/", "<font color=\"#00ffff\">\\1</font>", $string );
1157
1158 // newlines
1159 // $string = preg_replace ( "/\n/", "<br />\n newline", $string );
1160
1161 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
1162 $string . "</pre></td></tr></table></p>";
1163
1164 return $string;
1165 }
1166
1171 function &htmlHighlight( $string )
1172 {
1173 $string =& htmlspecialchars( $string );
1174
1175 $string = preg_replace( "#(&lt;.*?&gt;)#", "<font color=\"blue\">\\1</font>", $string );
1176
1177 $string = "<br clear=\"all\"><p><table width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td bgcolor=\"#f0f0f0\"><pre>" .
1178 $string . "</pre></td></tr></table></p>";
1179
1180 return $string;
1181 }
1182
1186 function usedImageList()
1187 {
1188 return $this->UsedImageList;
1189 }
1190
1191
1192 var $UsedImageList;
1193
1194 var $Article;
1195 var $PrevTag;
1196 }
1197
1198 ?>
$i
$i
Definition: admin/adlist.php:91
$article
$article
Definition: articlelog.php:45
eZPBLog\writeError
writeError( $error)
Definition: ezpblog.php:188
eZTechRenderer
Definition: eztechrenderer.php:127
eZTechRenderer\renderCode
& renderCode( $pageContent, $paragraph)
Definition: eztechrenderer.php:653
eZTechRenderer\usedImageList
usedImageList()
Definition: eztechrenderer.php:1186
eZTechRenderer\$PrevTag
$PrevTag
Definition: eztechrenderer.php:1195
eZTechRenderer\renderIntro
& renderIntro()
Definition: eztechrenderer.php:139
eZTechRenderer\renderLink
& renderLink( $pageContent, $paragraph)
Definition: eztechrenderer.php:345
eZTechRenderer\renderPage
& renderPage( $pageNumber=0)
Definition: eztechrenderer.php:211
eZTechRenderer\renderStandards
& renderStandards( $pageContent, $paragraph)
Definition: eztechrenderer.php:711
eZTechRenderer\sptobsp
& sptobsp( $string)
Definition: eztechrenderer.php:1115
eZTechRenderer\cppHighlight
& cppHighlight( $string)
Definition: eztechrenderer.php:872
eZTechRenderer\sqlHighlight
& sqlHighlight( $string)
Definition: eztechrenderer.php:814
eZTechRenderer\$UsedImageList
$UsedImageList
Definition: eztechrenderer.php:1192
eZTechRenderer\htmlHighlight
& htmlHighlight( $string)
Definition: eztechrenderer.php:1171
eZTechRenderer\phpHighlight
& phpHighlight( $string)
Definition: eztechrenderer.php:768
eZTechRenderer\javaHighlight
& javaHighlight( $string)
Definition: eztechrenderer.php:1125
eZTechRenderer\renderImage
& renderImage( $pageContent, $paragraph, $articleImages)
Definition: eztechrenderer.php:514
eZTechRenderer\__construct
__construct(&$article)
Definition: eztechrenderer.php:131
eZTechRenderer\$Article
$Article
Definition: eztechrenderer.php:1194
eZTechRenderer\renderPlain
& renderPlain( $pageContent, $paragraph)
Definition: eztechrenderer.php:328
eZTechRenderer\renderModule
& renderModule( $pageContent, $paragraph)
Definition: eztechrenderer.php:459
eZTechRenderer\lispHighlight
& lispHighlight( $string)
Definition: eztechrenderer.php:985
eZTechRenderer\shellHighlight
& shellHighlight( $string)
Definition: eztechrenderer.php:915
eZTechRenderer\perlHighlight
& perlHighlight( $string)
Definition: eztechrenderer.php:943
eZTextTool\nl2br
static nl2br( $string, $xhtml=true)
Definition: eztexttool.php:65
$ini
$ini
Definition: classes/admin/linklist.php:64
$name
$name
Definition: companytypelist.php:194
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$page
$page
Definition: ezarticle/modules/content.php:28
$GlobalSiteIni
$GlobalSiteIni
Definition: ezarticle/xmlrpc/xmlrpcserver.php:33
$index
$index
Definition: ezforum/user/messageedit.php:36
$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+.