Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezqdomgenerator.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezqdomgenerator.php 9869 2003-07-22 09:26:27Z br $
5 //
6 // Definition of eZQDomGenerator class
7 //
8 // Created on: <24-Mar-2001 13:10:33 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 //
30
39 // include_once( "ezxml/classes/ezxml.php" );
40
41 class eZQDomGenerator
42 {
46 function __construct( &$contents )
47 {
48 $this->Level = 0;
49 $this->PageCount = 0;
50 $this->Contents = $contents;
51
52 // user defined tags
53 $ini =& eZINI::instance( 'site.ini' );
54
55 $customTags = $ini->variable( "eZArticleMain", "CustomTags" );
56
57 $this->CustomTagsArray = explode( ";", $customTags );
58 }
59
63 function &generateXML()
64 {
65 // add the XML header.
66 $newContents = "<?xml version=\"1.0\"?>";
67
68 //add the generator, this is used for rendering.
69 $newContents .= "<article><generator>qdom</generator>\n";
70
71 //add the contents
72 $newContents .= "<intro>" . $this->generatePage( $this->Contents[0] ) . "</intro>";
73
74 // get every page in an array
75 $pages = preg_split( "/<page>/" , $this->Contents[1] );
76
77 $body = "";
78 foreach ( $pages as $page )
79 {
80 $tmpPage = $page;
81
82 $tmpPage =& $this->generatePage( $tmpPage );
83
84 $body .= "<page>" . $tmpPage . "</page>";
85 }
86
87 $this->PageCount = count( $pages );
88
89
90 $newContents .= "<body>" . $body . "</body></article>";
91
92 return $newContents;
93 }
94
99 function &generatePage( $tmpPage )
100 {
101 $tmpPage = $this->generateImage( $tmpPage );
102
103 $tmpPage = $this->generateMedia( $tmpPage );
104 $tmpPage = $this->generateFile( $tmpPage );
105
106 $tmpPage = $this->generateHeader( $tmpPage );
107
108 $tmpPage = $this->generateHr( $tmpPage );
109
110 $tmpPage = $this->generateTable( $tmpPage );
111
112 // replace & with &amp; to prevent killing the xml parser..
113 // is that a bug in the xmltree(); function ? answer to bf@ez.no
114 $tmpPage = preg_replace ( "/&/", "&amp;", $tmpPage );
115
116 $tmpPage = $this->generateUnknowns( $tmpPage );
117
118 $tmpPage = $this->generateLink( $tmpPage );
119
120 $tmpPage = $this->generateHTML( $tmpPage );
121
122 $tmpPage = $this->generateForm( $tmpPage );
123
124 $tmpPage = $this->generateRollOver( $tmpPage );
125
126 // $tmpPage = $this->generateModule( $tmpPage );
127
128
129 return $tmpPage;
130 }
131
136 function &generateUnknowns( $tmpPage )
137 {
138 $tmpPage =& preg_replace( "#< #", "&lt; ", $tmpPage );
139 // $tmpPage =& preg_replace( "# >#", " &gt;", $tmpPage );
140
141 // make unknown tags readable.. look-ahead assertion is used ( ?! )
142 // $tmpPage = preg_replace( "/<(?!(page|php|\/|image|cpp|shell|sql|hea|lin|iconlink|per|bol|ita|und|str|pre|ver|lis|ezhtml|html|java|ezanchor|mail|module|bullet))/", "&lt;", $tmpPage );
143
144 // look-behind assertion is used here (?<!)
145 // the expression must be fixed width eg just use the 3 last letters of the tag
146
147 // $tmpPage = preg_replace( "#(?<!(age|php|age|cpp|ell|sql|der|erl|old|lic|ine|ike|pre|tim|isp|tml|ava|let))>#", "&gt;", $tmpPage );
148 // make better..
149 // $tmpPage = preg_replace( "#/&gt;#", "/>", $tmpPage );
150
151 return $tmpPage;
152 }
153
158 function &generateImage( $tmpPage )
159 {
160 $tmpPage = preg_replace( "/(<image\s+([0-9]+)\s+([a-z]+)\s+([a-z]+?)\s*>)/", "<image id=\"\\2\" align=\"\\3\" size=\"\\4\" />", $tmpPage );
161
162 // parse the <image id align size link> tag and convert it
163 // link is optional
164 // to <image id="id" align="align" size="size" href="link" />
165 $tmpPage = preg_replace( "/(<image\s+([0-9]+)\s+([a-z]+)\s+([a-z]+)\s+([^ ]+?)\s*>)/", "<image id=\"\\2\" align=\"\\3\" size=\"\\4\" href=\"\\5\" />", $tmpPage );
166
167 // default image tag <image id>
168 $tmpPage = preg_replace( "/(<image\s+?([0-9]+?)\s*?>)/", "<image id=\"\\2\" align=\"center\" size=\"medium\" />", $tmpPage );
169
170 return $tmpPage;
171 }
172
177 function &generateRollOver( $tmpPage )
178 {
179 preg_match( "/<rollover\s+([0-9]+)\s+([0-9]+)\s+([^\s]+)\s+(.+)\s*>/i", $tmpPage, $matchArray );
180
181 $tmpPage = preg_replace( "/<rollover\s+([0-9]+)\s+([0-9]+)\s+([^\s]+)\s+(.+)\s*>/i",
182 "<rollover url=\"\\3\" imageone=\"\\1\" imagetwo=\"\\2\" description=\"\\4\" />", $tmpPage );
183
184 return $tmpPage;
185 }
186
187
192 function &generateMedia( $tmpPage )
193 {
194 // default image tag <media id>
195 $tmpPage = preg_replace( "/(<media\s+?([0-9]+?)\s*?>)/", "<media id=\"\\2\" />", $tmpPage );
196 return $tmpPage;
197 }
198
203 function &generateFile( $tmpPage )
204 {
205 // default image tag <file id text>
206 $tmpPage = preg_replace( "/(<file\s+?([0-9]+)\s*(.*?)>)/", "<file id=\"\\2\" text=\"\\3\" />", $tmpPage );
207 return $tmpPage;
208 }
209
210
211 function &generateHr( $tmpPage )
212 {
213 // default horizontal line tag <hr>
214 $tmpPage = preg_replace( "/(<hr\s*?>)/", "<hr />", $tmpPage );
215 return $tmpPage;
216 }
217
218
223 function &generateHeader( $tmpPage )
224 {
225 $tmpPage = preg_replace( "/(<header\s+?([^ ]+?)\s*?>)/", "<header level=\"\\2\">", $tmpPage );
226
227 $tmpPage = preg_replace( "/(<header\s*?>)/", "<header level=\"1\">", $tmpPage );
228
229 return $tmpPage;
230 }
231
235 function &generateTable( $tmpPage )
236 {
237
238 $tmpPage = preg_replace( "/(<table\s+([0-9]+[^ ]??)\s+([0-9]+?)\s*>)/", "<table width=\"\\2\" border=\"\\3\">", $tmpPage );
239 $tmpPage = preg_replace( "/(<table\s+([0-9]+[^ ]??)\s*>)/", "<table width=\"\\2\">", $tmpPage );
240
241 $tmpPage = preg_replace( "/(<td\s+([0-9]+[^ ]??)\s+?([0-9]+?)\s+([0-9]+?)\s*>)/", "<td width=\"\\2\" colspan=\"\\3\" rowspan=\"\\4\">", $tmpPage );
242 $tmpPage = preg_replace( "/(<td\s+([0-9]+[^ ]??)\s+?([0-9]+?)\s*>)/", "<td width=\"\\2\" colspan=\"\\3\">", $tmpPage );
243 $tmpPage = preg_replace( "/(<td\s+([0-9]+[^ ]??)\s*>)/", "<td width=\"\\2\">", $tmpPage );
244
245 return $tmpPage;
246 }
247
252 function &generateForm( $tmpPage )
253 {
254 $tmpPage = preg_replace( "/(<form\s*?>)/", "<form />", $tmpPage );
255
256 return $tmpPage;
257 }
258
263 function &generateLink( $tmpPage )
264 {
265 // convert <link ez.no ez systems> to valid xml
266 // $tmpPage = "<link ez.no ez systems> <link ez.no ez systems>";
267 $tmpPage = preg_replace( "#(<link\s+?([^ ]+)\s+?([^>]+)>)#", "<link href=\"\\2\" text=\"\\3\" />", $tmpPage );
268 $tmpPage = preg_replace( "#(<popuplink\s+?([^ ]+)\s+?([^>]+)>)#", "<link href=\"\\2\" text=\"\\3\" target=\"_blank\" />", $tmpPage );
269
270 $tmpPage = preg_replace( "#(<iconlink\s+?([^ ]+)\s+?([^>]+)>)#", "<iconlink href=\"\\2\" text=\"\\3\" />", $tmpPage );
271
272 // convert <ezanchor anchor> to <ezanchor href="anchor" />
273 $tmpPage = preg_replace( "#<ezanchor\s+?(.*?)>#", "<ezanchor href=\"\\1\" />", $tmpPage );
274
275 // convert <mail adresse@domain.tld subject line, link text>
276 // to valid xml
277 $tmpPage = preg_replace( "#<mail\s+?([^ ]*?)\s+?(.*?),\s+?([^>]*?)>#", "<mail to=\"\\1\" subject=\"\\2\" text=\"\\3\" />", $tmpPage );
278
279 // convert bf@nospam.ez.no to <mail to="bf@nospam.ez.no" subject="" text="bf@nospam.ez.no" />
280 $tmpPage = preg_replace( "#([\s\n]|^)(([a-zA-Z0-9_\-\.]+)@((([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}))([\s\n]|$)#",
281 "<mail to=\"\\2\" subject=\"\" text=\"\\2\" />", $tmpPage );
282
283 // convert <ezarticle id text> to valid xml
284 $tmpPage = preg_replace( "#(<ezarticle\s+?([^ ]+)\s+?([^>]+)>)#", "<ezarticle id=\"\\2\" text=\"\\3\" />", $tmpPage );
285
286 // convert <ezstatic id text> to valid xml
287 $tmpPage = preg_replace( "#(<ezstatic\s+?([^ ]+)\s+?([^>]+)>)#", "<ezstatic id=\"\\2\" text=\"\\3\" />", $tmpPage );
288
289 // convert <ezcategory id text> to valid xml
290 $tmpPage = preg_replace( "#(<ezcategory\s+?([^ ]+)\s+?([^>]+)>)#", "<ezcategory id=\"\\2\" text=\"\\3\" />", $tmpPage );
291
292 return $tmpPage;
293 }
294
295
299 function &generateHTML( $tmpPage )
300 {
301 // Begin html tag replacer
302 // replace all < and > between <html> and </html>
303 // and to the same for <pre> </pre>
304 // ok this is a bit slow code, but it works
305 $startHTMLTag = "<html>";
306 $endHTMLTag = "</html>";
307
308 $startPreTag = "<pre>";
309 $endPreTag = "</pre>";
310
311 $numberBeginHTML = substr_count( $tmpPage, $startHTMLTag );
312 $numEndHTML = substr_count( $tmpPage, $endHTMLTag );
313
314 if ( $numberBeginHTML != $numEndHTML )
315 {
316 print( "Unmatched html tags, check that you have end tags for all begin tags" );
317 }
318
319 $numberBeginPre = substr_count( $tmpPage, $startPreTag );
320 $numEndPre = substr_count( $tmpPage, $endPreTag );
321
322 if ( $numberBeginPre != $numEndPre )
323 {
324 print( "Unmatched Pre tags, check that you have end tags for all begin tags" );
325 }
326
327 if ( ( $numberBeginPre > 0 ) || ( $numberBeginHTML > 0 ) )
328 {
329 $resultPage = "";
330 $isInsideHTMLTag = false;
331 $isInsidePreTag = false;
332
333 for ( $i=0; $i<strlen( $tmpPage ); $i++ )
334 {
335 if ( substr( $tmpPage, $i - strlen( $startHTMLTag ), strlen( $startHTMLTag ) ) == $startHTMLTag )
336 {
337 $isInsideHTMLTag = true;
338 }
339
340 if ( substr( $tmpPage, $i, strlen( $endHTMLTag ) ) == $endHTMLTag )
341 {
342 $isInsideHTMLTag = false;
343 }
344
345 if ( substr( $tmpPage, $i - strlen( $startPreTag ), strlen( $startPreTag ) ) == $startPreTag )
346 {
347 $isInsidePreTag = true;
348 }
349
350 if ( substr( $tmpPage, $i, strlen( $endPreTag ) ) == $endPreTag )
351 {
352 $isInsidePreTag = false;
353 }
354
355 if ( ( $isInsideHTMLTag == true ) || ( $isInsidePreTag == true ) )
356 {
357 switch ( $tmpPage[$i] )
358 {
359 case "<" :
360 {
361 $resultPage .= "&lt;";
362 }
363 break;
364
365 case ">" :
366 {
367 $resultPage .= "&gt;";
368 }
369 break;
370
371 default:
372 {
373 $resultPage .= $tmpPage[$i];
374 }
375 }
376 }
377 else
378 {
379 $resultPage .= $tmpPage[$i];
380 }
381 }
382
383 $tmpPage = $resultPage;
384 }
385 return $tmpPage;
386 }
387
388
395 function &decodeXML( $htmlSpecialChars=false )
396 {
397 $contentsArray = array();
398
399 $xml =& eZXML::domTree( $this->Contents );
400
401 // $xml =& xmltree( $this->Contents );
402 // $xml =& qdom_tree( $this->Contents );
403
404 if ( !$xml )
405 {
406 print( "<br /><b>Error: eZQDomRenderer::docodeXML() could not decode XML</b><br />" );
407 }
408 else
409 {
410 $into = "";
411 $body = "";
412
413 foreach ( $xml->children as $child )
414 {
415 if ( $child->name == "article" )
416 {
417 foreach ( $child->children as $article )
418 {
419 if ( $article->name == "intro" )
420 {
421 $intro = $this->decodePage( $article );
422 }
423
424 if ( $article->name == "body" )
425 {
426 $body = $article->children;
427 }
428 }
429 }
430 }
431
432 $contentsArray[] = stripslashes($intro);
433
434 $bodyContents = "";
435 $i=0;
436 // loop on the pages
437 foreach ( $body as $page )
438 {
439 if ( $page->name == "page" )
440 {
441 $pageContent = "";
442
443 $pageContent = $this->decodePage( $page );
444
445 if ( $i > 0 )
446 $bodyContents .= "<page>" . $pageContent;
447 else
448 $bodyContents .= $pageContent;
449
450 $i++;
451 }
452 }
453
454 if ( $htmlSpecialChars == true ) {
455 $bodyContents = stripslashes($bodyContents);
456 $contentsArray[] = htmlspecialchars( $bodyContents );
457 }
458 else
459 $contentsArray[] = stripslashes($bodyContents);
460 }
461
462 return $contentsArray;
463 }
464
469 function decodePage( $page )
470 {
471 $value = "";
472 if ( count( $page->children ) > 0 )
473 {
474 foreach ( $page->children as $paragraph )
475 {
476 $value .= $this->decodeStandards( $paragraph );
477 $value .= $this->decodeHeader( $paragraph );
478 $value .= $this->decodeImage( $paragraph );
479 $value .= $this->decodeMedia( $paragraph );
480 $value .= $this->decodeFile( $paragraph );
481 $value .= $this->decodeLink( $paragraph );
482 $value .= $this->decodeHr( $paragraph );
483 $value .= $this->decodeTable( $paragraph );
484 $value .= $this->decodeCustom( $paragraph );
485 $value .= $this->decodeRollOver( $paragraph );
486 }
487 }
488
489 return $value;
490 }
491
495 function &decodeRollOver( $paragraph )
496 {
497 switch ( $paragraph->name )
498 {
499 case "rollover" :
500 {
501 if ( count( $paragraph->children ) > 0 )
502 {
503 foreach ( $paragraph->children as $child )
504 {
505 if ( $child->name == "#text" or $child->name == "text" )
506 {
507 $content = $child->content;
508 }
509 }
510 }
511
512 if ( count( $paragraph->attributes ) > 0 )
513 {
514 foreach ( $paragraph->attributes as $attr )
515 {
516 switch ( $attr->name )
517 {
518 case "url":
519 {
520 $url = $attr->children[0]->content;
521 }
522 break;
523
524 case "imageone":
525 {
526 $image1 = $attr->children[0]->content;
527 }
528 break;
529
530 case "imagetwo":
531 {
532 $image2 = $attr->children[0]->content;
533 }
534 break;
535
536 case "description":
537 {
538 $description = $attr->children[0]->content;
539 }
540 break;
541 }
542 }
543 }
544
545
546
547 $pageContent .= "<rollover $image1 $image2 $url $description>";
548 }
549 break;
550 }
551
552 return $pageContent;
553 }
554
558 function &decodeHeader( $paragraph )
559 {
560 $pageContent = '';
561
562 switch ( $paragraph->name )
563 {
564 case "header" :
565 {
566
567 foreach ( $paragraph->children as $child )
568 {
569 if ( $child->name == "#text" or $child->name == "text" )
570 {
571 $content = $child->content;
572 }
573 }
574
575 $level = 1;
576
577 if ( isset( $paragraph->attributes ) && count( $paragraph->attributes ) > 0 )
578 foreach ( $paragraph->attributes as $attr )
579 {
580 switch ( $attr->name )
581 {
582 case "level" :
583 {
584 $level = $attr->children[0]->content;
585 }
586 break;
587 }
588 }
589
590 $pageContent .= "<header $level>" . $content . "</header>";
591 }
592 break;
593 }
594
595 return $pageContent;
596 }
597
598
603 function &decodeImage( $paragraph )
604 {
605 $imageCaptionOverride = $imageID = $imageAlignment = $imageSize = $imageHref =
606 $imageTarget = '';
607 // image
608 if ( $paragraph->name == "image" ) {
609 foreach ( $paragraph->attributes as $imageItem ) {
610 switch ( $imageItem->name ) {
611 case "id" : {
612 $imageID = $imageItem->children[0]->content;
613 }
614 break;
615
616 case "align" : {
617 $imageAlignment = $imageItem->children[0]->content;
618 }
619 break;
620
621 case "size" : {
622 $imageSize = $imageItem->children[0]->content;
623 }
624 break;
625
626 case "href" : {
627 $imageHref = $imageItem->children[0]->content;
628 }
629 break;
630
631 case "caption" : {
632 $imageCaptionOverride = trim( $imageItem->children[0]->content );
633 }
634 break;
635
636 case "target" : {
637 $imageTarget = trim( $imageItem->children[0]->content );
638 }
639 break;
640 }
641 }
642
643 if ( !in_array($imageSize, array("small", "medium", "large", "original") ) ) {
644 $imageSize = "medium";
645 }
646
647 if ( $imageCaptionOverride != "" || $imageTarget != "" ) {
648 $captionText = "";
649 $targetText = "";
650
651 if ( $imageCaptionOverride != "" )
652 $captionText = "caption=\"$imageCaptionOverride\"";
653
654 if ( $imageTarget != "" )
655 $targetText = "target=\"$imageTarget\"";
656
657 if ( $imageHref != "" )
658 $hrefText = "href=\"$imageHref\"";
659
660 $pageContent = "<image id=\"$imageID\" align=\"$imageAlignment\" size=\"$imageSize\" $hrefText $captionText $targetText />";
661 }
662 else
663 {
664 $pageContent = "<image $imageID $imageAlignment $imageSize $imageHref>";
665 }
666 }
667 return $pageContent;
668 }
669
674 function &decodeMedia( $paragraph )
675 {
676 // media
677 if ( $paragraph->name == "media" )
678 {
679 foreach ( $paragraph->attributes as $mediaItem )
680 {
681 switch ( $mediaItem->name )
682 {
683 case "id" :
684 {
685 $mediaID = $mediaItem->children[0]->content;
686 }
687 break;
688 }
689 }
690
691 $pageContent = "<media $mediaID>";
692 }
693 return $pageContent;
694 }
695
696
701 function &decodeFile( $paragraph )
702 {
703 if ( $paragraph->name == "file" )
704 {
705 foreach ( $paragraph->attributes as $fileItem )
706 {
707 switch ( $fileItem->name )
708 {
709 case "id" :
710 {
711 $fileID = $fileItem->children[0]->content;
712 }
713 break;
714
715 case "text" :
716 {
717 $fileText = $fileItem->children[0]->content;
718 }
719 break;
720 }
721 }
722
723 $pageContent = "<file $fileID $fileText>";
724 }
725 return $pageContent;
726 }
727
728
729 function &decodeHr( $paragraph )
730 {
731 if ( $paragraph->name == "hr" )
732 {
733 $pageContent = "<hr>";
734 }
735 return $pageContent;
736 }
737
738
739
743 function &decodeLink( $paragraph )
744 {
745 $href = false;
746 $target = $pageContent = '';
747 // link
748 if ( $paragraph->name == "link" )
749 {
750 foreach ( $paragraph->attributes as $imageItem )
751 {
752 switch ( $imageItem->name )
753 {
754
755 case "href" :
756 {
757 $href = $imageItem->children[0]->content;
758 }
759 break;
760
761 case "text" :
762 {
763 $text = $imageItem->children[0]->content;
764 }
765 break;
766
767 case "target" :
768 {
769 $target = $imageItem->children[0]->content;
770 }
771 break;
772
773 }
774 }
775
776 if ( $target == "_blank" )
777 $pageContent .= "<popuplink $href $text>";
778 else
779 $pageContent .= "<link $href $text>";
780 }
781
782
783 // mail
784 if ( $paragraph->name == "mail" )
785 {
786 foreach ( $paragraph->attributes as $mailItem )
787 {
788 switch ( $mailItem->name )
789 {
790 case "to" :
791 {
792 $to = $mailItem->children[0]->content;
793 }
794 break;
795
796 case "subject" :
797 {
798 $subject = $mailItem->children[0]->content;
799 }
800 break;
801
802 case "text" :
803 {
804 $text = $mailItem->children[0]->content;
805 }
806 break;
807 }
808 }
809
810 $pageContent .= "<mail $to $subject, $text>";
811 }
812
813 // ez anchor
814 if ( $paragraph->name == "ezanchor" )
815 {
816 foreach ( $paragraph->attributes as $anchorItem )
817 {
818 switch ( $anchorItem->name )
819 {
820 case "href" :
821 {
822 $href = $anchorItem->children[0]->content;
823 }
824 break;
825 }
826 }
827
828 $pageContent .= "<ezanchor $href>";
829 }
830
831 // ezarticle
832 if ( $paragraph->name == "ezarticle" )
833 {
834 foreach ( $paragraph->attributes as $ezArticleItem )
835 {
836 switch ( $ezArticleItem->name )
837 {
838
839 case "id" :
840 {
841 $id = $ezArticleItem->children[0]->content;
842 }
843 break;
844
845 case "text" :
846 {
847 $text = $ezArticleItem->children[0]->content;
848 }
849 break;
850 }
851 }
852
853 $pageContent .= "<ezarticle $id $text>";
854 }
855
856 // ezstatic
857 if ( $paragraph->name == "ezstatic" )
858 {
859 foreach ( $paragraph->attributes as $ezArticleItem )
860 {
861 switch ( $ezArticleItem->name )
862 {
863
864 case "id" :
865 {
866 $id = $ezArticleItem->children[0]->content;
867 }
868 break;
869
870 case "text" :
871 {
872 $text = $ezArticleItem->children[0]->content;
873 }
874 break;
875 }
876 }
877
878 $pageContent .= "<ezstatic $id $text>";
879 }
880
881 // ezcategory
882 if ( $paragraph->name == "ezcategory" )
883 {
884 foreach ( $paragraph->attributes as $Item )
885 {
886 switch ( $Item->name )
887 {
888
889 case "id" :
890 {
891 $id = $Item->children[0]->content;
892 }
893 break;
894
895 case "text" :
896 {
897 $text = $Item->children[0]->content;
898 }
899 break;
900 }
901 }
902
903 $pageContent .= "<ezcategory $id $text>";
904 }
905 return $pageContent;
906 }
907
908
912 function &decodeTable( $paragraph )
913 {
914 if ( $paragraph->name == "table" )
915 {
916
917 if ( isset( $paragraph->attributes ) && count( $paragraph->attributes ) > 0 )
918 foreach ( $paragraph->attributes as $attr )
919 {
920 switch ( $attr->name )
921 {
922 case "width" :
923 {
924 $tableWidth = $attr->children[0]->content;
925 }
926 break;
927 case "border" :
928 {
929 $tableBorder = $attr->children[0]->content;
930 }
931 break;
932 }
933 }
934
935 $tmpContent = "";
936 foreach ( $paragraph->children as $row )
937 {
938 if ( $row->name == "tr" )
939 {
940 $tdContent = "";
941 foreach ( $row->children as $data )
942 {
943 if ( $data->name == "td" )
944 {
945
946 $tdWidth="";
947 $tdColspan="";
948 $tdRowspan="";
949 if ( isset( $paragraph->attributes ) && !is_null( $data->attributes ) && count( $data->attributes ) > 0 )
950 foreach ( $data->attributes as $attr )
951 {
952 switch ( $attr->name )
953 {
954 case "width" :
955 {
956 $tdWidth = $attr->children[0]->content;
957 }
958 break;
959 case "colspan" :
960 {
961 $tdColspan = $attr->children[0]->content;
962 }
963 break;
964 case "rowspan" :
965 {
966 $tdRowspan = $attr->children[0]->content;
967 }
968 break;
969 }
970 }
971
972 $tmpData = "";
973 if ( count( $data->children ) > 0 )
974 foreach ( $data->children as $contents )
975 {
976 if ( $contents->name == "#text" or $contents->name == "text" )
977 {
978 $tmpData .= $contents->content;
979 }
980 else
981 {
982 $tmpData .= $this->decodeStandards( $contents );
983 $tmpData .= $this->decodeHeader( $contents );
984 $tmpData .= $this->decodeImage( $contents );
985 $tmpData .= $this->decodeMedia( $contents );
986 $tmpData .= $this->decodeFile( $contents );
987 $tmpData .= $this->decodeLink( $contents );
988 $tmpData .= $this->decodeHr( $contents );
989 $tmpData .= $this->decodeCustom( $contents );
990 $tmpData .= $this->decodeTable( $contents );
991 $tmpData .= $this->decodeRollOver( $contents );
992 }
993 }
994 $tdContent .= "<td";
995 if ( $tdWidth!="" ) $tdContent .= " $tdWidth";
996 if ( $tdColspan!="" ) $tdContent .= " colspan=\"$tdColspan\"";
997 if ( $tdRowspan!="" ) $tdContent .= " rowspan=\"$tdRowspan\"";
998 $tdContent .= ">$tmpData</td>";
999
1000 }
1001 }
1002
1003 $tmpContent .= "<tr>\n$tdContent</tr>\n";
1004 }
1005 }
1006
1007 $pageContent = "<table";
1008 if ( $tableWidth != "" ) $pageContent .= " $tableWidth";
1009 if ( $tableBorder != "" ) $pageContent .= " $tableBorder";
1010 $pageContent .= ">\n$tmpContent</table>";
1011 }
1012
1013
1014 return $pageContent;
1015 }
1016
1021 function &decodeStandards( $paragraph )
1022 {
1023 $pageContent = "";
1024 $tmpContent = "";
1025
1026 if ( is_array( $paragraph->children ) )
1027 {
1028 foreach ( $paragraph->children as $child )
1029 {
1030 if ( $child->name == "#text" or $child->name == "text" )
1031 {
1032 $content = $child->content;
1033 }
1034 else
1035 {
1036 $content = $this->decodeStandards( $child );
1037 $content .= $this->decodeCustom( $child );
1038 $content .= $this->decodeLink( $child );
1039 $content .= $this->decodeImage( $child );
1040 $content .= $this->decodeTable( $child );
1041 $content .= $this->decodeMedia( $child );
1042 $content .= $this->decodeFile( $child );
1043 $content .= $this->decodeHeader( $child );
1044 $content .= $this->decodeRollOver( $child );
1045 }
1046
1047 $tmpContent .= $content;
1048 }
1049
1050 switch ( $paragraph->name )
1051 {
1052
1053 case "bold" :
1054 {
1055 $pageContent .= "<bold>" . $tmpContent . "</bold>";
1056 }
1057 break;
1058
1059 case "italic" :
1060 {
1061 $pageContent .= "<italic>" . $tmpContent . "</italic>";
1062 }
1063 break;
1064
1065 case "underline" :
1066 {
1067 $pageContent .= "<underline>" . $tmpContent . "</underline>";
1068 }
1069 break;
1070
1071 case "strike" :
1072 {
1073 $pageContent .= "<strike>" . $tmpContent . "</strike>";
1074 }
1075 break;
1076
1077 case "strong" :
1078 {
1079 $pageContent .= "<strong>" . $tmpContent . "</strong>";
1080 }
1081 break;
1082
1083 case "list" :
1084 case "bullet" :
1085 {
1086 $itemStr = "";
1087 foreach ( $paragraph->children as $child )
1088 {
1089 if ( $child->name == "li" )
1090 {
1091 $itemStr = "";
1092 foreach ( $child->children as $listItem )
1093 {
1094 if ( $listItem->name == "text" )
1095 {
1096 $itemStr .= $listItem->content;
1097 }
1098 else
1099 {
1100 $itemStr .= $this->decodeStandards( $listItem );
1101 $itemStr .= $this->decodeCustom( $listItem );
1102 $itemStr .= $this->decodeLink( $listItem );
1103 $itemStr .= $this->decodeImage( $listItem );
1104 $itemStr .= $this->decodeMedia( $listItem );
1105 $itemStr .= $this->decodeFile( $listItem );
1106 $itemStr .= $this->decodeHeader( $listItem );
1107 $itemStr .= $this->decodeRollOver( $listItem );
1108
1109 }
1110 }
1111 $tmpContent .= "<li>$itemStr</li>\n";
1112 }
1113 }
1114
1115 if ( $paragraph->name == "bullet" )
1116 $pageContent .= "<bullet>\n" . trim( $tmpContent ) . "</bullet>";
1117 else
1118 $pageContent .= "<list>\n" . trim( $tmpContent ) . "</list>";
1119 }
1120 break;
1121
1122
1123 case "factbox" :
1124 {
1125 $pageContent .= "<factbox>" . $tmpContent . "</factbox>";
1126 }
1127 break;
1128
1129 case "quote" :
1130 {
1131 $pageContent .= "<quote>" . $tmpContent . "</quote>";
1132 }
1133 break;
1134
1135 case "pre" :
1136 {
1137 $pageContent .= "<pre>" . $tmpContent . "</pre>";
1138 }
1139 break;
1140
1141 case "html" :
1142 {
1143 $pageContent .= "<html>" . $tmpContent . "</html>";
1144 }
1145 break;
1146
1147 }
1148
1149 }
1150 else
1151 {
1152 if ( $paragraph->name == "form" )
1153 {
1154 $pageContent .= "<form>";
1155 }
1156 else
1157 {
1158 $pageContent = $paragraph->content;
1159 }
1160
1161 }
1162
1163 return $pageContent;
1164 }
1165
1170 function &decodeCustom( $paragraph )
1171 {
1172 $pageContent = "";
1173 $tagName = $paragraph->name;
1174
1175 if ( in_array( $tagName, $this->CustomTagsArray ) )
1176 {
1177 $content = "";
1178 if ( count( $paragraph->children ) )
1179 {
1180 foreach ( $paragraph->children as $child )
1181 {
1182 if ( $child->name == "text" )
1183 {
1184 $content .= $child->content;
1185 }
1186 else
1187 {
1188 $content .= $this->decodeStandards( $child );
1189 $content .= $this->decodeCustom( $child );
1190 $content .= $this->decodeLink( $child );
1191 $content .= $this->decodeImage( $child );
1192 $content .= $this->decodeTable( $child );
1193 $content .= $this->decodeMedia( $child );
1194 $content .= $this->decodeFile( $child );
1195 $content .= $this->decodeHeader( $child );
1196 $content .= $this->decodeRollOver( $child );
1197 }
1198 }
1199 }
1200
1201 $pageContent = "<$tagName>" . $content ."</$tagName>";
1202 }
1203
1204 return $pageContent;
1205 }
1206
1210 function pageCount( )
1211 {
1212 return $this->PageCount;
1213 }
1214
1215 var $Contents;
1216 var $PageCount;
1217
1218 var $CustomTagsArray;
1219 var $Level;
1220 }
1221
1222 ?>
$i
$i
Definition: admin/adlist.php:91
$level
$level
Definition: admin/message.php:106
$article
$article
Definition: articlelog.php:45
eZQDomGenerator
Definition: ezqdomgenerator.php:42
eZQDomGenerator\$Contents
$Contents
Definition: ezqdomgenerator.php:1215
eZQDomGenerator\decodePage
decodePage( $page)
Definition: ezqdomgenerator.php:469
eZQDomGenerator\generateRollOver
& generateRollOver( $tmpPage)
Definition: ezqdomgenerator.php:177
eZQDomGenerator\generateHeader
& generateHeader( $tmpPage)
Definition: ezqdomgenerator.php:223
eZQDomGenerator\decodeImage
& decodeImage( $paragraph)
Definition: ezqdomgenerator.php:603
eZQDomGenerator\generatePage
& generatePage( $tmpPage)
Definition: ezqdomgenerator.php:99
eZQDomGenerator\generateXML
& generateXML()
Definition: ezqdomgenerator.php:63
eZQDomGenerator\generateFile
& generateFile( $tmpPage)
Definition: ezqdomgenerator.php:203
eZQDomGenerator\generateTable
& generateTable( $tmpPage)
Definition: ezqdomgenerator.php:235
eZQDomGenerator\decodeXML
& decodeXML( $htmlSpecialChars=false)
Definition: ezqdomgenerator.php:395
eZQDomGenerator\decodeLink
& decodeLink( $paragraph)
Definition: ezqdomgenerator.php:743
eZQDomGenerator\decodeStandards
& decodeStandards( $paragraph)
Definition: ezqdomgenerator.php:1021
eZQDomGenerator\decodeMedia
& decodeMedia( $paragraph)
Definition: ezqdomgenerator.php:674
eZQDomGenerator\decodeRollOver
& decodeRollOver( $paragraph)
Definition: ezqdomgenerator.php:495
eZQDomGenerator\generateForm
& generateForm( $tmpPage)
Definition: ezqdomgenerator.php:252
eZQDomGenerator\pageCount
pageCount()
Definition: ezqdomgenerator.php:1210
eZQDomGenerator\generateLink
& generateLink( $tmpPage)
Definition: ezqdomgenerator.php:263
eZQDomGenerator\decodeHr
& decodeHr( $paragraph)
Definition: ezqdomgenerator.php:729
eZQDomGenerator\decodeTable
& decodeTable( $paragraph)
Definition: ezqdomgenerator.php:912
eZQDomGenerator\__construct
__construct(&$contents)
Definition: ezqdomgenerator.php:46
eZQDomGenerator\decodeFile
& decodeFile( $paragraph)
Definition: ezqdomgenerator.php:701
eZQDomGenerator\generateImage
& generateImage( $tmpPage)
Definition: ezqdomgenerator.php:158
eZQDomGenerator\generateHTML
& generateHTML( $tmpPage)
Definition: ezqdomgenerator.php:299
eZQDomGenerator\generateHr
& generateHr( $tmpPage)
Definition: ezqdomgenerator.php:211
eZQDomGenerator\generateMedia
& generateMedia( $tmpPage)
Definition: ezqdomgenerator.php:192
eZQDomGenerator\decodeHeader
& decodeHeader( $paragraph)
Definition: ezqdomgenerator.php:558
eZQDomGenerator\$CustomTagsArray
$CustomTagsArray
Definition: ezqdomgenerator.php:1218
eZQDomGenerator\generateUnknowns
& generateUnknowns( $tmpPage)
Definition: ezqdomgenerator.php:136
eZQDomGenerator\$PageCount
$PageCount
Definition: ezqdomgenerator.php:1216
eZQDomGenerator\decodeCustom
& decodeCustom( $paragraph)
Definition: ezqdomgenerator.php:1170
eZQDomGenerator\$Level
$Level
Definition: ezqdomgenerator.php:1219
eZXML\domTree
static domTree( $xmlDoc, $params=array())
Definition: ezxml.php:60
$ini
$ini
Definition: classes/admin/linklist.php:64
$id
$id
Definition: companytypelist.php:193
$page
$page
Definition: ezarticle/modules/content.php:28
$contents
$contents
Definition: ezarticle/user/extendedsearch.php:52
$row
$row
Definition: ezcalendar/user/dayview.php:403
$content
$content
Definition: ezimagecatalogue/admin/filedownload.php:53
$url
$url
Definition: messagereviewlist.php:153
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.