|
eZ Publish
[trunk]
|
00001 <?php 00002 /** 00003 * File containing the eZXHTMLXMLOutput class. 00004 * 00005 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. 00006 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 00007 * @version //autogentag// 00008 * @package kernel 00009 */ 00010 00011 class eZXHTMLXMLOutput extends eZXMLOutputHandler 00012 { 00013 00014 public $OutputTags = array( 00015 00016 'section' => array( 'quickRender' => true, 00017 'initHandler' => 'initHandlerSection', 00018 'renderHandler' => 'renderChildrenOnly' ), 00019 00020 'embed' => array( 'initHandler' => 'initHandlerEmbed', 00021 'renderHandler' => 'renderAll', 00022 'attrNamesTemplate' => array( 'class' => 'classification', 00023 'xhtml:id' => 'id', 00024 'object_id' => false, 00025 'node_id' => false, 00026 'show_path' => false ), 00027 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00028 00029 'embed-inline' => array( 'initHandler' => 'initHandlerEmbed', 00030 'renderHandler' => 'renderInline', 00031 'attrNamesTemplate' => array( 'class' => 'classification', 00032 'xhtml:id' => 'id', 00033 'object_id' => false, 00034 'node_id' => false, 00035 'show_path' => false ), 00036 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00037 00038 'table' => array( 'initHandler' => 'initHandlerTable', 00039 'leavingHandler' => 'leavingHandlerTable', 00040 'renderHandler' => 'renderAll', 00041 'contentVarName' => 'rows', 00042 'attrNamesTemplate' => array( 'class' => 'classification', 00043 'width' => 'width' ), 00044 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00045 00046 'tr' => array( //'quickRender' => array( 'tr', "\n" ), 00047 'initHandler' => 'initHandlerTr', 00048 'renderHandler' => 'renderAll', 00049 'attrNamesTemplate' => array( 'class' => 'classification' ), 00050 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00051 00052 'td' => array( 'initHandler' => 'initHandlerTd', 00053 'renderHandler' => 'renderAll', 00054 'attrNamesTemplate' => array( 'xhtml:width' => 'width', 00055 'xhtml:colspan' => 'colspan', 00056 'xhtml:rowspan' => 'rowspan', 00057 'class' => 'classification' ), 00058 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00059 00060 'th' => array( 'initHandler' => 'initHandlerTd', 00061 'renderHandler' => 'renderAll', 00062 'attrNamesTemplate' => array( 'xhtml:width' => 'width', 00063 'xhtml:colspan' => 'colspan', 00064 'xhtml:rowspan' => 'rowspan', 00065 'class' => 'classification' ), 00066 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00067 00068 'ol' => array( 'renderHandler' => 'renderAll', 00069 'attrNamesTemplate' => array( 'class' => 'classification' ), 00070 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00071 00072 'ul' => array( 'renderHandler' => 'renderAll', 00073 'attrNamesTemplate' => array( 'class' => 'classification' ), 00074 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00075 00076 'li' => array( 'renderHandler' => 'renderAll', 00077 'attrNamesTemplate' => array( 'class' => 'classification' ), 00078 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00079 00080 'header' => array( 'initHandler' => 'initHandlerHeader', 00081 'renderHandler' => 'renderAll', 00082 'attrNamesTemplate' => array( 'class' => 'classification' ), 00083 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00084 00085 'paragraph' => array( //'quickRender' => array( 'p', "\n" ), 00086 'renderHandler' => 'renderParagraph', 00087 'attrNamesTemplate' => array( 'class' => 'classification' ), 00088 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00089 00090 'line' => array( //'quickRender' => array( '', "<br/>" ), 00091 'renderHandler' => 'renderLine' ), 00092 00093 'literal' => array( 'renderHandler' => 'renderAll', 00094 'attrNamesTemplate' => array( 'class' => 'classification' ), 00095 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00096 00097 'strong' => array( 'renderHandler' => 'renderInline', 00098 'attrNamesTemplate' => array( 'class' => 'classification' ), 00099 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00100 00101 'emphasize' => array( 'renderHandler' => 'renderInline', 00102 'attrNamesTemplate' => array( 'class' => 'classification' ), 00103 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00104 00105 'link' => array( 'initHandler' => 'initHandlerLink', 00106 'renderHandler' => 'renderInline', 00107 'attrNamesTemplate' => array( 'xhtml:id' => 'id', 00108 'xhtml:title' => 'title', 00109 'url_id' => false, 00110 'object_id' => false, 00111 'node_id' => false, 00112 'show_path' => false, 00113 'ezurl_id' => false, 00114 'anchor_name' => false, 00115 'class' => 'classification' ), 00116 'attrDesignKeys' => array( 'class' => 'classification' ) ), 00117 00118 'anchor' => array( 'renderHandler' => 'renderInline' ), 00119 00120 'custom' => array( 'initHandler' => 'initHandlerCustom', 00121 'renderHandler' => 'renderCustom', 00122 'attrNamesTemplate' => array( 'name' => false ) ), 00123 00124 '#text' => array( 'quickRender' => true, 00125 'renderHandler' => 'renderText' ) 00126 ); 00127 00128 function eZXHTMLXMLOutput( &$xmlData, $aliasedType, $contentObjectAttribute = null ) 00129 { 00130 $this->eZXMLOutputHandler( $xmlData, $aliasedType, $contentObjectAttribute ); 00131 00132 $ini = eZINI::instance('ezxml.ini'); 00133 if ( $ini->variable( 'ezxhtml', 'RenderParagraphInTableCells' ) == 'disabled' ) 00134 $this->RenderParagraphInTableCells = false; 00135 } 00136 00137 function initHandlerSection( $element, &$attributes, &$siblingParams, &$parentParams ) 00138 { 00139 $ret = array(); 00140 if( !isset( $parentParams['section_level'] ) ) 00141 $parentParams['section_level'] = 0; 00142 else 00143 $parentParams['section_level']++; 00144 00145 // init header counter for current level and for the next level if needed 00146 $level = $parentParams['section_level']; 00147 if ( $level != 0 ) 00148 { 00149 if ( !isset( $this->HeaderCount[$level] ) ) 00150 $this->HeaderCount[$level] = 0; 00151 00152 if ( !isset( $this->HeaderCount[$level + 1] ) ) 00153 $this->HeaderCount[$level + 1] = 0; 00154 } 00155 00156 return $ret; 00157 } 00158 00159 function initHandlerHeader( $element, &$attributes, &$siblingParams, &$parentParams ) 00160 { 00161 $level = $parentParams['section_level']; 00162 $this->HeaderCount[$level]++; 00163 00164 // headers auto-numbering 00165 $i = 1; 00166 $headerAutoName = ''; 00167 while ( $i <= $level ) 00168 { 00169 if ( $i > 1 ) 00170 $headerAutoName .= "_"; 00171 00172 $headerAutoName .= $this->HeaderCount[$i]; 00173 $i++; 00174 } 00175 $levelNumber = str_replace( "_", ".", $headerAutoName ); 00176 00177 if ( $this->ObjectAttributeID ) 00178 $headerAutoName = $this->ObjectAttributeID . '_' . $headerAutoName; 00179 00180 $ret = array( 'tpl_vars' => array( 'level' => $level, 00181 'header_number' => $levelNumber, 00182 'toc_anchor_name' => $headerAutoName ) ); 00183 00184 return $ret; 00185 } 00186 00187 function initHandlerLink( $element, &$attributes, &$siblingParams, &$parentParams ) 00188 { 00189 $ret = array(); 00190 00191 // Set link parameters for rendering children of link tag 00192 $href=''; 00193 if ( $element->getAttribute( 'url_id' ) != null ) 00194 { 00195 $linkID = $element->getAttribute( 'url_id' ); 00196 if ( isset( $this->LinkArray[$linkID] ) ) 00197 $href = $this->LinkArray[$linkID]; 00198 } 00199 elseif ( $element->getAttribute( 'node_id' ) != null ) 00200 { 00201 $nodeID = $element->getAttribute( 'node_id' ); 00202 $node = isset( $this->NodeArray[$nodeID] ) ? $this->NodeArray[$nodeID] : null; 00203 00204 if ( $node != null ) 00205 { 00206 $view = $element->getAttribute( 'view' ); 00207 if ( $view ) 00208 $href = 'content/view/' . $view . '/' . $nodeID; 00209 else 00210 $href = $node->attribute( 'url_alias' ); 00211 } 00212 else 00213 { 00214 eZDebug::writeWarning( "Node #$nodeID doesn't exist", "XML output handler: link" ); 00215 } 00216 } 00217 elseif ( $element->getAttribute( 'object_id' ) != null ) 00218 { 00219 $objectID = $element->getAttribute( 'object_id' ); 00220 if ( isset( $this->ObjectArray["$objectID"] ) ) 00221 { 00222 $object = $this->ObjectArray["$objectID"]; 00223 $node = $object->attribute( 'main_node' ); 00224 if ( $node ) 00225 { 00226 $nodeID = $node->attribute( 'node_id' ); 00227 00228 $view = $element->getAttribute( 'view' ); 00229 if ( $view ) 00230 $href = 'content/view/' . $view . '/' . $nodeID; 00231 else 00232 $href = $node->attribute( 'url_alias' ); 00233 } 00234 else 00235 { 00236 eZDebug::writeWarning( "Object #$objectID doesn't have assigned nodes", "XML output handler: link" ); 00237 } 00238 } 00239 else 00240 { 00241 eZDebug::writeWarning( "Object #$objectID doesn't exist", "XML output handler: link" ); 00242 } 00243 } 00244 elseif ( $element->getAttribute( 'href' ) != null ) 00245 { 00246 $href = $element->getAttribute( 'href' ); 00247 } 00248 00249 if ( $element->getAttribute( 'anchor_name' ) != null ) 00250 { 00251 $href .= '#' . $element->getAttribute( 'anchor_name' ); 00252 } 00253 00254 if ( $href !== false ) 00255 { 00256 $attributes['href'] = $href; 00257 $parentParams['link_parameters'] = $attributes; 00258 } 00259 00260 return $ret; 00261 } 00262 00263 function initHandlerEmbed( $element, &$attributes, &$siblingParams, &$parentParams ) 00264 { 00265 // default return value in case of errors 00266 $ret = array( 'no_render' => true ); 00267 00268 $tplSuffix = ''; 00269 $objectID = $element->getAttribute( 'object_id' ); 00270 if ( $objectID && 00271 !empty( $this->ObjectArray["$objectID"] ) ) 00272 { 00273 $object = $this->ObjectArray["$objectID"]; 00274 } 00275 else 00276 { 00277 $nodeID = $element->getAttribute( 'node_id' ); 00278 if ( $nodeID ) 00279 { 00280 if ( isset( $this->NodeArray[$nodeID] ) ) 00281 { 00282 $node = $this->NodeArray[$nodeID]; 00283 $objectID = $node->attribute( 'contentobject_id' ); 00284 $object = $node->object(); 00285 $tplSuffix = '_node'; 00286 } 00287 else 00288 { 00289 eZDebug::writeWarning( "Node #$nodeID doesn't exist", "XML output handler: embed" ); 00290 return $ret; 00291 } 00292 } 00293 } 00294 00295 if ( !isset( $object ) || !$object || !( $object instanceof eZContentObject ) ) 00296 { 00297 eZDebug::writeWarning( "Can't fetch object #$objectID", "XML output handler: embed" ); 00298 return $ret; 00299 } 00300 if ( $object->attribute( 'status' ) != eZContentObject::STATUS_PUBLISHED ) 00301 { 00302 eZDebug::writeWarning( "Object #$objectID is not published", "XML output handler: embed" ); 00303 return $ret; 00304 } 00305 00306 if ( eZINI::instance()->variable( 'SiteAccessSettings', 'ShowHiddenNodes' ) !== 'true' ) 00307 { 00308 if ( isset( $node ) ) 00309 { 00310 // embed with a node ID 00311 if ( $node->attribute( 'is_invisible' ) ) 00312 { 00313 eZDebug::writeNotice( "Node #{$nodeID} is invisible", "XML output handler: embed" ); 00314 return $ret; 00315 } 00316 } 00317 else 00318 { 00319 // embed with an object id 00320 // checking if at least a location is visible 00321 $oneVisible = false; 00322 foreach( $object->attribute( 'assigned_nodes' ) as $assignedNode ) 00323 { 00324 if ( !$assignedNode->attribute( 'is_invisible' ) ) 00325 { 00326 $oneVisible = true; 00327 break; 00328 } 00329 } 00330 if ( !$oneVisible ) 00331 { 00332 eZDebug::writeNotice( "None of the object #{$objectID}'s location(s) is visible", "XML output handler: embed" ); 00333 return $ret; 00334 } 00335 } 00336 } 00337 00338 if ( $object->attribute( 'can_read' ) || 00339 $object->attribute( 'can_view_embed' ) ) 00340 { 00341 $templateName = $element->nodeName . $tplSuffix; 00342 } 00343 else 00344 { 00345 $templateName = $element->nodeName . '_denied'; 00346 } 00347 00348 $objectParameters = array(); 00349 $excludeAttrs = array( 'view', 'class', 'node_id', 'object_id' ); 00350 00351 foreach ( $attributes as $attrName => $value ) 00352 { 00353 if ( !in_array( $attrName, $excludeAttrs ) ) 00354 { 00355 if ( strpos( $attrName, ':' ) !== false ) 00356 $attrName = substr( $attrName, strpos( $attrName, ':' ) + 1 ); 00357 00358 $objectParameters[$attrName] = $value; 00359 unset( $attributes[$attrName] ); 00360 } 00361 } 00362 00363 if ( isset( $parentParams['link_parameters'] ) ) 00364 $linkParameters = $parentParams['link_parameters']; 00365 else 00366 $linkParameters = array(); 00367 00368 $ret = array( 'template_name' => $templateName, 00369 'tpl_vars' => array( 'object' => $object, 00370 'link_parameters' => $linkParameters, 00371 'object_parameters' => $objectParameters ), 00372 'design_keys' => array( 'class_identifier' => $object->attribute( 'class_identifier' ) ) ); 00373 00374 if ( $tplSuffix == '_node') 00375 $ret['tpl_vars']['node'] = $node; 00376 00377 return $ret; 00378 } 00379 00380 function initHandlerTable( $element, &$attributes, &$siblingParams, &$parentParams ) 00381 { 00382 // Backing up the section_level, headings' level should be restarted inside tables. 00383 // @see http://issues.ez.no/11536 00384 $this->SectionLevelStack[] = $parentParams['section_level']; 00385 $parentParams['section_level'] = 0; 00386 00387 // Numbers of rows and cols are lower by 1 for back-compatibility. 00388 $rowCount = self::childTagCount( $element ) -1; 00389 $lastRow = $element->lastChild; 00390 00391 while ( $lastRow && !( $lastRow instanceof DOMElement && $lastRow->nodeName == 'tr' ) ) 00392 { 00393 $lastRow = $lastRow->previousSibling; 00394 } 00395 00396 $colCount = self::childTagCount( $lastRow ); 00397 00398 if ( $colCount ) 00399 $colCount--; 00400 00401 $ret = array( 'tpl_vars' => array( 'col_count' => $colCount, 00402 'row_count' => $rowCount ) ); 00403 return $ret; 00404 } 00405 00406 function leavingHandlerTable( $element, &$attributes, &$siblingParams, &$parentParams ) 00407 { 00408 // Restoring the section_level as it was before entering the table. 00409 // @see http://issues.ez.no/11536 00410 $parentParams['section_level'] = array_pop($this->SectionLevelStack); 00411 } 00412 00413 function initHandlerTr( $element, &$attributes, &$siblingParams, &$parentParams ) 00414 { 00415 $ret = array(); 00416 if( !isset( $siblingParams['table_row_count'] ) ) 00417 $siblingParams['table_row_count'] = 0; 00418 else 00419 $siblingParams['table_row_count']++; 00420 00421 $parentParams['table_row_count'] = $siblingParams['table_row_count']; 00422 00423 // Number of cols is lower by 1 for back-compatibility. 00424 $colCount = self::childTagCount( $element ); 00425 if ( $colCount ) 00426 $colCount--; 00427 00428 $ret = array( 'tpl_vars' => array( 'row_count' => $parentParams['table_row_count'], 00429 'col_count' => $colCount ) ); 00430 00431 // Allow overrides based on table class 00432 $parent = $element->parentNode; 00433 if ( $parent instanceof DOMElement && $parent->hasAttribute('class') ) 00434 $ret['design_keys'] = array( 'table_classification' => $parent->getAttribute('class') ); 00435 00436 return $ret; 00437 } 00438 00439 function initHandlerTd( $element, &$attributes, &$siblingParams, &$parentParams ) 00440 { 00441 if( !isset( $siblingParams['table_col_count'] ) ) 00442 $siblingParams['table_col_count'] = 0; 00443 else 00444 $siblingParams['table_col_count']++; 00445 00446 $ret = array( 'tpl_vars' => array( 'col_count' => &$siblingParams['table_col_count'], 00447 'row_count' => &$parentParams['table_row_count'] ) ); 00448 00449 // Allow overrides based on table class 00450 $parent = $element->parentNode->parentNode; 00451 if ( $parent instanceof DOMElement && $parent->hasAttribute('class') ) 00452 $ret['design_keys'] = array( 'table_classification' => $parent->getAttribute('class') ); 00453 00454 if ( !$this->RenderParagraphInTableCells 00455 && self::childTagCount( $element ) == 1 ) 00456 { 00457 // paragraph will not be rendered so its align attribute needs to 00458 // be taken into account at the td/th level 00459 // Looking for the paragraph with align attribute 00460 foreach( $element->childNodes as $c ) 00461 { 00462 if ( $c instanceof DOMElement ) 00463 { 00464 if ( $c->hasAttribute( 'align' ) ) 00465 { 00466 $attributes['align'] = $c->getAttribute( 'align' ); 00467 } 00468 break ; 00469 } 00470 } 00471 } 00472 return $ret; 00473 } 00474 00475 function initHandlerCustom( $element, &$attributes, &$siblingParams, &$parentParams ) 00476 { 00477 $ret = array( 'template_name' => $attributes['name'] ); 00478 return $ret; 00479 } 00480 00481 // Render handlers 00482 00483 function renderParagraph( $element, $childrenOutput, $vars ) 00484 { 00485 // don't render if inside 'li' or inside 'td'/'th' (by option) 00486 $parent = $element->parentNode; 00487 00488 00489 if ( ( $parent->nodeName == 'li' && self::childTagCount( $parent ) == 1 ) || 00490 ( in_array( $parent->nodeName, array( 'td', 'th' ) ) && !$this->RenderParagraphInTableCells && self::childTagCount( $parent ) == 1 ) ) 00491 00492 { 00493 return $childrenOutput; 00494 } 00495 00496 // Break paragraph by block tags (like table, ol, ul, header and paragraphs) 00497 $tagText = ''; 00498 $lastTagInline = null; 00499 $inlineContent = ''; 00500 foreach( $childrenOutput as $key => $childOutput ) 00501 { 00502 if ( $childOutput[0] === true )// is inline 00503 { 00504 if( $childOutput[1] === ' ' ) 00505 { 00506 if ( isset( $childrenOutput[$key+1] ) && $childrenOutput[$key+1][0] === false ) 00507 continue; 00508 else if ( isset( $childrenOutput[ $key - 1 ] ) && $childrenOutput[ $key - 1 ][0] === false ) 00509 continue; 00510 } 00511 00512 $inlineContent .= $childOutput[1]; 00513 } 00514 00515 // Only render paragraph if current tag is block and previous was an inline tag 00516 // OR if current one is inline and it's the last item in the child list 00517 if ( ( $childOutput[0] === false && $lastTagInline === true ) || 00518 ( $childOutput[0] === true && !isset( $childrenOutput[ $key + 1 ] ) ) ) 00519 { 00520 $tagText .= $this->renderTag( $element, $inlineContent, $vars ); 00521 $inlineContent = ''; 00522 } 00523 00524 if ( $childOutput[0] === false )// is block 00525 $tagText .= $childOutput[1]; 00526 00527 $lastTagInline = $childOutput[0]; 00528 } 00529 return array( false, $tagText ); 00530 } 00531 00532 /* Count child elemnts, ignoring whitespace and text 00533 * 00534 * @param DOMElement $parent 00535 * @return int 00536 */ 00537 protected static function childTagCount( DOMElement $parent ) 00538 { 00539 $count = 0; 00540 foreach( $parent->childNodes as $child ) 00541 { 00542 if ( $child instanceof DOMElement ) $count++; 00543 } 00544 return $count; 00545 } 00546 00547 function renderInline( $element, $childrenOutput, $vars ) 00548 { 00549 $renderedArray = array(); 00550 $lastTagInline = null; 00551 $inlineContent = ''; 00552 00553 foreach( $childrenOutput as $key=>$childOutput ) 00554 { 00555 if ( $childOutput[0] === true )// is inline 00556 $inlineContent .= $childOutput[1]; 00557 00558 // Only render tag if current tag is block and previous was an inline tag 00559 // OR if current one is inline and it's the last item in the child list 00560 if ( ( $childOutput[0] === false && $lastTagInline === true ) || 00561 ( $childOutput[0] === true && !isset( $childrenOutput[ $key + 1 ] ) ) ) 00562 { 00563 $tagText = $this->renderTag( $element, $inlineContent, $vars ); 00564 $renderedArray[] = array( true, $tagText ); 00565 $inlineContent = ''; 00566 } 00567 00568 if ( $childOutput[0] === false )// is block 00569 $renderedArray[] = array( false, $childOutput[1] ); 00570 00571 $lastTagInline = $childOutput[0]; 00572 00573 } 00574 return $renderedArray; 00575 } 00576 00577 function renderLine( $element, $childrenOutput, $vars ) 00578 { 00579 $renderedArray = array(); 00580 $lastTagInline = null; 00581 $inlineContent = ''; 00582 00583 foreach( $childrenOutput as $key=>$childOutput ) 00584 { 00585 if ( $childOutput[0] === true )// is inline 00586 $inlineContent .= $childOutput[1]; 00587 00588 // Render line tag only if the last part of childrenOutput is inline and the next tag 00589 // within the same paragraph is 'line' too. 00590 00591 if ( $childOutput[0] === false && $lastTagInline === true ) 00592 { 00593 $renderedArray[] = array( true, $inlineContent ); 00594 $inlineContent = ''; 00595 } 00596 elseif ( $childOutput[0] === true && !isset( $childrenOutput[ $key + 1 ] ) ) 00597 { 00598 $next = $element->nextSibling; 00599 // Make sure we get next element that is an element (ignoring whitespace) 00600 while ( $next && !$next instanceof DOMElement ) 00601 { 00602 $next = $next->nextSibling; 00603 } 00604 00605 if ( $next && $next->nodeName == 'line' ) 00606 { 00607 $tagText = $this->renderTag( $element, $inlineContent, $vars ); 00608 $renderedArray[] = array( true, $tagText ); 00609 } 00610 else 00611 $renderedArray[] = array( true, $inlineContent ); 00612 } 00613 00614 if ( $childOutput[0] === false )// is block 00615 $renderedArray[] = array( false, $childOutput[1] ); 00616 00617 $lastTagInline = $childOutput[0]; 00618 } 00619 return $renderedArray; 00620 } 00621 00622 function renderCustom( $element, $childrenOutput, $vars ) 00623 { 00624 if ( $this->XMLSchema->isInline( $element ) ) 00625 { 00626 $ret = $this->renderInline( $element, $childrenOutput, $vars ); 00627 } 00628 else 00629 { 00630 $ret = $this->renderAll( $element, $childrenOutput, $vars ); 00631 } 00632 return $ret; 00633 } 00634 00635 function renderChildrenOnly( $element, $childrenOutput, $vars ) 00636 { 00637 $tagText = ''; 00638 foreach( $childrenOutput as $childOutput ) 00639 { 00640 $tagText .= $childOutput[1]; 00641 } 00642 00643 return array( false, $tagText ); 00644 } 00645 00646 function renderText( $element, $childrenOutput, $vars ) 00647 { 00648 if ( $element->parentNode->nodeName != 'literal' ) 00649 { 00650 if ( trim( $element->textContent ) === '' 00651 && ( ( $element->previousSibling && $element->previousSibling->nodeName === 'line' ) 00652 || ( $element->nextSibling && $element->nextSibling->nodeName === 'line' ) ) ) 00653 { 00654 // spaces before or after a line element are irrelevant 00655 return array( true, '' ); 00656 } 00657 $text = htmlspecialchars( $element->textContent ); 00658 $text = str_replace( array( '&nbsp;', "\xC2\xA0" ), ' ', $text); 00659 // Get rid of linebreak and spaces stored in xml file 00660 $text = str_replace( "\n", '', $text ); 00661 00662 if ( $this->AllowMultipleSpaces ) 00663 $text = str_replace( ' ', ' ', $text ); 00664 else 00665 $text = preg_replace( "# +#", " ", $text ); 00666 00667 if ( $this->AllowNumericEntities ) 00668 $text = preg_replace( '/&#([0-9]+);/', '&#\1;', $text ); 00669 } 00670 else 00671 { 00672 $text = $element->textContent; 00673 } 00674 00675 return array( true, $text ); 00676 } 00677 00678 00679 /// Array of parameters for rendering tags that are children of 'link' tag 00680 public $LinkParameters = array(); 00681 00682 public $HeaderCount = array(); 00683 00684 /** 00685 * Stack of section levels saved when entering tables. 00686 * @var array 00687 */ 00688 protected $SectionLevelStack = array(); 00689 00690 public $RenderParagraphInTableCells = true; 00691 } 00692 00693 ?>