TextRenderer.class.php

gehe zur Dokumentation dieser Datei
00001 <?php
00002 
00013 class TextRenderer
00014 {
00015      var $linkedObjectIds = array();
00016      
00022      var $footnotes       = array();
00023 
00024      
00031      function renderElement( $child )
00032      {
00033           global $conf;
00034           
00035                     $className = strtolower(get_class($child));
00036                     $val = '';
00037 
00038                     $length = @$conf['editor']['text']['linelength'];
00039                     if   ( intval($length) == 0 )
00040                          $length = 70;
00041 
00042                     switch( $className )
00043                     {
00044                          case 'footnoteelement':
00045                               
00046                               $nr = 1;
00047                               foreach( $this->footnotes as $fn )
00048                                    if ( strtolower(get_class($fn))=='linebreakelement')
00049                                         $nr++;
00050                                         
00051                               $val = $nr;
00052                               if   ( @$conf['editor']['footnote']['bracket'])
00053                                    $val = '('.$nr.')';
00054 
00055                               if   ( $nr == 1 )
00056                               {
00057                                    $this->footnotes[] = new RawElement("\n\n---\n");
00058                               }
00059                               $this->footnotes[] = new LineBreakElement();
00060                               $this->footnotes[] = new RawElement($val);
00061                               $this->footnotes[] = new RawElement(' ');
00062                               foreach( $child->children as $c )
00063                                    $this->footnotes[] = $c;
00064                               
00065                               $child->children = array();
00066 
00067                               break;
00068 
00069                          case 'headlineelement':
00070                               $val = "\n".wordwrap($child->text,$length);
00071                               $val .= str_repeat('-',min($length,strlen($val)));
00072                               break;
00073 
00074                          case 'paragraphelement':
00075                               $val = "\n\n";
00076                               break;
00077 
00078                          case 'strongelement':
00079                               
00080                               foreach( $child->children as $c )
00081                                    $val .= $this->renderElement($c);
00082                               $val = strtoupper($val);
00083 
00084                               $child->children = array();
00085 
00086                               break;
00087                               
00088                          case 'textelement':
00089                               $length = @$conf['editor']['text']['linelength'];
00090                               if   ( intval($length) == 0 )
00091                                    $length = 70;
00092                               $val .= wordwrap($child->text,$length);
00093                               break;
00094 
00095                          case 'linebreakelement':
00096                               $val .= "\n";
00097                               break;
00098                          default:
00099                     }
00100                     
00101                     foreach( $child->children as $c )
00102                     {
00103                          $val .= $this->renderElement( $c );
00104                     }
00105 
00106                     return $val;
00107                
00108 //                  die( 'unknown document type: '.$this->type );
00109           
00110      }
00111 
00112 
00113      
00119      function render()
00120      {
00121           $this->renderedText = '';
00122           $this->footnotes    = array();
00123           
00124           foreach( $this->children as $child )
00125                $this->renderedText .= $this->renderElement( $child );
00126 
00127           foreach( $this->footnotes as $child )
00128                $this->renderedText .= $this->renderElement( $child );
00129                
00130           return $this->renderedText;
00131      }
00132 }
00133 
00134 ?>

Erzeugt am Thu May 14 00:55:49 2009 für OpenRat von  doxygen 1.5.8