[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/extension/ezdhtml/ezxmltext/handlers/input/ -> ezdhtmlxmlinput.php (source)

   1  <?php
   2  //
   3  // Definition of eZDHTMLXMLInput class
   4  //
   5  // Created on: <06-Nov-2002 15:10:02 wy>
   6  //
   7  // Copyright (C) 1999-2006 eZ systems as. All rights reserved.
   8  //
   9  
  10  /*! \file ezdhtmlxmlinput.php
  11  */
  12  
  13  /*!
  14    \class eZDHTMLXMLInput
  15    \brief The class eZDHTMLXMLInput does
  16  
  17  */
  18  include_once ( "lib/ezxml/classes/ezxml.php" );
  19  include_once ( 'kernel/common/template.php' );
  20  include_once ( 'lib/eztemplate/classes/eztemplateincludefunction.php' );
  21  /*include_once( "kernel/classes/datatypes/ezimage/ezimagevariation.php");
  22  include_once( "kernel/classes/datatypes/ezimage/ezimage.php");
  23  include_once( "lib/ezimage/classes/ezimagelayer.php" );
  24  include_once( "lib/ezimage/classes/ezimagetextlayer.php" );
  25  include_once( "lib/ezimage/classes/ezimagefont.php" );
  26  include_once( "lib/ezimage/classes/ezimageobject.php" );
  27  include_once( "lib/eztemplate/classes/eztemplateimageoperator.php" );
  28  */
  29  include_once ( "lib/ezutils/classes/ezini.php" );
  30  include_once ( "lib/ezutils/classes/ezsys.php" );
  31  include_once ( "kernel/classes/ezcontentobject.php");
  32  include_once ( 'kernel/classes/datatypes/ezurl/ezurlobjectlink.php' );
  33  
  34  include_once ( 'extension/ezdhtml/lib/system.php' );
  35  include_once ( 'extension/ezdhtml/ezinfo.php' );
  36  
  37  datatype_class( 'ezxmltext', 'eZXMLInputHandler' );
  38  
  39  class eZDHTMLXMLInput extends eZXMLInputHandler
  40  {
  41      /*!
  42       Constructor
  43      */
  44      function eZDHTMLXMLInput( &$xmlData, $aliasedType, $contentObjectAttribute )
  45      {
  46          $this->eZXMLInputHandler( $xmlData, $aliasedType, $contentObjectAttribute );
  47          $contentIni =& eZINI::instance( 'content.ini' );
  48          if ( $contentIni->hasVariable( 'header', 'UseStrictHeaderRule' ) )
  49          {
  50              if ( $contentIni->variable( 'header', 'UseStrictHeaderRule' ) == "true" )
  51                  $this->IsStrictHeader = true;
  52          }
  53  
  54          include_once ( 'lib/version.php' );
  55          $this->eZPublishVersion = eZPublishSDK::majorVersion() + eZPublishSDK::minorVersion() * 0.1;
  56  
  57          $this->browserType = $this->browserSupportsDHTMLType();
  58  
  59          if ( $this->eZPublishVersion >= 3.8 )
  60          {
  61              $ini =& eZINI::instance( 'ezxml.ini' );
  62              if ( $ini->hasVariable( 'InputSettings', 'TrimSpaces' ) )
  63              {
  64                  $trimSpaces = $ini->variable( 'InputSettings', 'TrimSpaces' );
  65                  $this->trimSpaces = $trimSpaces == 'true' ? true : false;
  66              }
  67      
  68              if ( $ini->hasVariable( 'InputSettings', 'AllowMultipleSpaces' ) )
  69              {
  70                  $allowMultipleSpaces = $ini->variable( 'InputSettings', 'AllowMultipleSpaces' );
  71                  $this->allowMultipleSpaces = $allowMultipleSpaces == 'true' ? true : false;
  72              }
  73          }
  74          else
  75          {
  76              $this->trimSpaces = true;
  77              $this->allowMultipleSpaces = false;
  78          }
  79      }
  80  
  81      /*!
  82       \reimp
  83      */
  84      function hasAttribute( $name )
  85      {
  86          return ( $name == 'is_editor_enabled' or
  87                   $name == 'browser_supports_dhtml_type' or
  88                   $name == 'is_compatible_version' or
  89                   $name == 'version' or
  90                   $name == 'required_version' or
  91                   $name == 'ezpublish_version' or
  92                   eZXMLInputHandler::hasAttribute( $name ) );
  93      }
  94  
  95      /*!
  96       \reimp
  97      */
  98      function &attribute( $name )
  99      {
 100          if ( $name == 'is_editor_enabled' )
 101              $attr = eZDHTMLXMLInput::isEditorEnabled();
 102          else if ( $name == 'browser_supports_dhtml_type' )
 103              $attr = eZDHTMLXMLInput::browserSupportsDHTMLType();
 104          else if ( $name == 'is_compatible_version' )
 105              $attr = eZDHTMLXMLInput::isCompatibleVersion();
 106          else if ( $name == 'version' )
 107              $attr = eZDHTMLXMLInput::version();
 108          else if ( $name == 'required_version' )
 109              $attr = eZDHTMLXMLInput::requiredVersion();
 110          else if ( $name == 'ezpublish_version' )
 111              $attr = $this->eZPublishVersion;
 112          else
 113              $attr =& eZXMLInputHandler::attribute( $name );
 114          return $attr;
 115      }
 116  
 117      /*!
 118       \static
 119       \return true if the browser supports DHTML editing.
 120      */
 121      function browserSupportsDHTMLType()
 122      {
 123          $supportsDHTMLType = false;
 124          $userAgent = eZSys::serverVariable( 'HTTP_USER_AGENT' );
 125          if ( eregi('MSIE[ \/]([0-9\.]+)', $userAgent, $browserInfo ) )
 126          {
 127              $version = $browserInfo[1];
 128              if ( $version >= 5.0 )
 129              {
 130                  $supportsDHTMLType = "IE";
 131              }
 132          }
 133  
 134          if ( preg_match ("/opera/i", $userAgent ) )
 135               $supportsDHTMLType = false;
 136  
 137          if ( preg_match ("/gecko/i", $userAgent ) )
 138               $supportsDHTMLType = "Gecko";
 139  
 140          if ( preg_match ("/konqueror/i", $userAgent ) )
 141               $supportsDHTMLType = false;
 142          return $supportsDHTMLType;
 143      }
 144  
 145      /*!
 146       \static
 147       \return boolean
 148      */
 149      function isCompatibleVersion()
 150      {
 151          if ( $this->eZPublishVersion >= 3.5 )
 152          {
 153              return true;
 154          }
 155          else
 156          {
 157              return false;
 158          }
 159      }
 160  
 161      /*!
 162       \static
 163       \return OE version
 164      */
 165      function version()
 166      {
 167          $info = ezdhtmlInfo::info();
 168          $version = $info['Version'];
 169          return $version;
 170      }
 171  
 172      /*!
 173       This function is deprecated, left for compatibility.
 174       \static
 175       \return eZ publish required OE version list
 176      */
 177      function requiredVersion()
 178      {
 179          $requiredVersion = false;
 180          include_once( 'kernel/common/ezoe.php' );
 181          if ( file_exists( 'kernel/common/ezoe.php' ) )
 182          {
 183              $requiredVersionList = eZOE::requiredVersionList();
 184              $requiredVersion = implode( "," , $requiredVersionList );
 185          }
 186  
 187          return $requiredVersion;
 188      }
 189  
 190      /*!
 191       \static
 192       \return true if the editor is enabled. The editor can be enabled/disabled by a
 193               button in the web interface.
 194      */
 195      function isEditorEnabled()
 196      {
 197          $dhtmlInput = true;
 198          $http =& eZHTTPTool::instance();
 199          if ( $http->hasSessionVariable( 'eZDHTMLXMLInputExtension' ) )
 200              $dhtmlInput = $http->sessionVariable( 'eZDHTMLXMLInputExtension' );
 201          return $dhtmlInput;
 202      }
 203  
 204      /*!
 205       Sets whether the DHTML editor is enabled or not.
 206      */
 207      function setIsEditorEnabled( $isEnabled )
 208      {
 209          $http =& eZHTTPTool::instance();
 210          $http->setSessionVariable( 'eZDHTMLXMLInputExtension', $isEnabled );
 211      }
 212  
 213      /*!
 214       \static
 215       \return true if the editor can be used. This is determinded by whether the browser supports DHTML and that
 216               the editor is enabled.
 217      */
 218      function isEditorActive()
 219      {
 220          if ( !eZDHTMLXMLInput::browserSupportsDHTMLType() )
 221              return false;
 222  
 223          return eZDHTMLXMLInput::isEditorEnabled();
 224      }
 225  
 226      /*!
 227       \reimp
 228      */
 229      function isValid()
 230      {
 231          return eZDHTMLXMLInput::browserSupportsDHTMLType();
 232      }
 233  
 234      /*!
 235       \reimp
 236      */
 237      function customObjectAttributeHTTPAction( $http, $action, &$contentObjectAttribute )
 238      {
 239          switch ( $action )
 240          {
 241              case 'enable_editor':
 242              {
 243                  eZDHTMLXMLInput::setIsEditorEnabled( true );
 244              } break;
 245              case 'disable_editor':
 246              {
 247                  eZDHTMLXMLInput::setIsEditorEnabled( false );
 248              } break;
 249              default :
 250              {
 251                  eZDebug::writeError( 'Unknown custom HTTP action: ' . $action, 'eZDHTMLXMLInput' );
 252              } break;
 253          }
 254      }
 255  
 256      /*!
 257       \reimp
 258      */
 259      function &editTemplateSuffix( &$contentobjectAttribute )
 260      {
 261          $suffix = 'ezdhtml';
 262          return $suffix;
 263      }
 264  
 265      /*!
 266        Updates URL - object links.
 267      */
 268      function updateUrlObjectLinks( $contentObjectAttribute, $urlIDArray )
 269      {
 270          $objectAttributeID = $contentObjectAttribute->attribute( "id" );
 271          $objectAttributeVersion = $contentObjectAttribute->attribute('version');
 272  
 273          foreach( $urlIDArray as $urlID )
 274          {
 275              $linkObjectLink = eZURLObjectLink::fetch( $urlID, $objectAttributeID, $objectAttributeVersion );
 276              if ( $linkObjectLink == null )
 277              {
 278                  $linkObjectLink = eZURLObjectLink::create( $urlID, $objectAttributeID, $objectAttributeVersion );
 279                  $linkObjectLink->store();
 280              }
 281          }
 282      }
 283  
 284      /*!
 285       \reimp
 286      */
 287      function validateInput( &$http, $base, &$contentObjectAttribute )
 288      {
 289          $isGecko = false;
 290          $this->ContentObjectAttributeID = $contentObjectAttributeID = $contentObjectAttribute->attribute( "id" );
 291          $this->ContentObjectAttributeVersion = $contentObjectAttributeVersion = $contentObjectAttribute->attribute('version');
 292  
 293          if ( !$this->isEditorEnabled() )
 294          {
 295              $aliasedHandler =& $this->attribute( 'aliased_handler' );
 296              return $aliasedHandler->validateInput( $http, $base, $contentObjectAttribute );
 297          }
 298          if ( $http->hasPostVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) ) )
 299          {
 300              $text = $http->postVariable( $base . "_data_text_" . $contentObjectAttribute->attribute( "id" ) );
 301  
 302              $text = preg_replace( '#<!--.*?-->#s', '', $text ); // remove HTML comments
 303              $text = str_replace( "\r", '', $text);
 304  
 305              if ( $this->browserType == 'IE' )
 306                  $text = preg_replace( "/[\n\t]/", '', $text);
 307              else
 308                  $text = preg_replace( "/[\n\t]/", ' ', $text);
 309  
 310              //eZDebug::writeDebug( $text, 'HTML input' );
 311  
 312              include_once ( 'extension/ezdhtml/lib/advdomnode.php' );
 313              include_once ( 'extension/ezdhtml/ezxmltext/handlers/input/ezdhtmlinputparser.php' );
 314  
 315              $parser = new eZDHTMLInputParser();
 316              $parser->setDOMDocumentClass( 'advDOMDocument' );
 317  
 318              $document = $parser->process( $text );
 319  
 320              // Remove last empty paragraph (added in the output part)
 321              $parent =& $document->Root;
 322              $lastChild =& $parent->lastChild();
 323              while( $lastChild && $lastChild->nodeName != 'paragraph' )
 324              {
 325                  $parent =& $lastChild;
 326                  $lastChild =& $parent->lastChild();
 327              }
 328  
 329              if ( $lastChild && $lastChild->nodeName == 'paragraph' )
 330              {
 331                  $textChild =& $lastChild->lastChild();
 332                  if ( !$textChild ||
 333                       ( $lastChild->childrenCount() == 1 &&
 334                         $textChild->Type == EZ_XML_NODE_TEXT &&
 335                         ( $textChild->Content == ' ' || $textChild->Content == '' ) ) )
 336                  {
 337                      $parent->removeChild( $lastChild );
 338                  }
 339              }
 340  
 341              $classAttribute =& $contentObjectAttribute->contentClassAttribute();
 342              if ( $classAttribute->attribute( "is_required" ) == true )
 343              {
 344                  $root =& $document->Root;
 345                  if ( !count( $root->Children ) )
 346                  {
 347                      $contentObjectAttribute->setValidationError( ezi18n( 'kernel/classes/datatypes',
 348                                                                           'Content required' ) );
 349                      return EZ_INPUT_VALIDATOR_STATE_INVALID;
 350                  }
 351              }
 352  
 353              // Update URL-object links
 354              $urlIDArray = $parser->getUrlIDArray();
 355              if ( count( $urlIDArray ) > 0 )
 356              {
 357                  $this->updateUrlObjectLinks( $contentObjectAttribute, $urlIDArray );
 358              }
 359  
 360              if ( $this->eZPublishVersion >= 3.9 )
 361              {
 362                  $contentObject =& $contentObjectAttribute->attribute( 'object' );
 363                  $contentObject->appendInputRelationList( $parser->getEmbeddedObjectIDArray(), EZ_CONTENT_OBJECT_RELATION_EMBED );
 364                  $contentObject->appendInputRelationList( $parser->getLinkedObjectIDArray(), EZ_CONTENT_OBJECT_RELATION_LINK );
 365              }
 366  
 367              $xmlString = eZXMLTextType::domString( $document );
 368  
 369              //eZDebug::writeDebug( $xmlString, 'eZXML output' );
 370  
 371              $document->cleanup();
 372  
 373              $contentObjectAttribute->setAttribute( "data_text", $xmlString );
 374              $contentObjectAttribute->setValidationLog( $parser->Messages );
 375  
 376              return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
 377          }
 378          else
 379          {
 380              return EZ_INPUT_VALIDATOR_STATE_ACCEPTED;
 381          }
 382          return EZ_INPUT_VALIDATOR_STATE_INVALID;
 383      }
 384  
 385  
 386      /*
 387  
 388        Editor inner output implementation
 389  
 390      */
 391  
 392      // Get section level and reset cuttent node according to input header.
 393      function &sectionLevel( &$sectionLevel, $headerLevel, &$TagStack, &$currentNode, &$domDocument )
 394      {
 395          if ( $sectionLevel < $headerLevel )
 396          {
 397              if ( $this->IsStrictHeader )
 398              {
 399                  $sectionLevel += 1;
 400              }
 401              else
 402              {
 403                  if ( ( $sectionLevel + 1 ) == $headerLevel )
 404                  {
 405                      $sectionLevel += 1;
 406                  }
 407                  else
 408                  {
 409                      for ( $i=1;$i<=( $headerLevel - $sectionLevel - 1 );$i++ )
 410                      {
 411                          // Add section tag
 412                          unset( $subNode );
 413                          $subNode = new eZDOMNode();
 414                          $subNode->Name = "section";
 415                          $subNode->LocalName = "section";
 416                          $subNode->Type = EZ_NODE_TYPE_ELEMENT;
 417                          $domDocument->registerElement( $subNode );
 418                          $currentNode->appendChild( $subNode );
 419                          $childTag = $this->SectionArray;
 420                          $TagStack[] = array( "TagName" => "section", "ParentNodeObject" => &$currentNode, "ChildTag" => $childTag );
 421                          $currentNode =& $subNode;
 422                      }
 423                      $sectionLevel = $headerLevel;
 424                  }
 425              }
 426          }
 427          elseif ( $sectionLevel == $headerLevel )
 428          {
 429              $lastNodeArray = array_pop( $TagStack );
 430              $lastNode =& $lastNodeArray["ParentNodeObject"];
 431              unset( $currentNode );
 432              $currentNode =& $lastNode;
 433              $sectionLevel = $headerLevel;
 434          }
 435          else
 436          {
 437              for ( $i=1;$i<=( $sectionLevel - $headerLevel + 1 );$i++ )
 438              {
 439                  $lastNodeArray = array_pop( $TagStack );
 440                  $lastTag = $lastNodeArray["TagName"];
 441                  $lastNode =& $lastNodeArray["ParentNodeObject"];
 442                  $lastChildTag = $lastNodeArray["ChildTag"];
 443                  unset( $currentNode );
 444                  $currentNode =& $lastNode;
 445              }
 446              $sectionLevel = $headerLevel;
 447          }
 448          return $currentNode;
 449      }
 450  
 451      /*!
 452       Returns the input XML representation of the datatype.
 453      */
 454      function &inputXML( )
 455      {
 456          $node = null;
 457          $xml  = new eZXML();
 458  
 459          $dom  =& $xml->domTree( $this->XMLData, array( 'ConvertSpecialChars' => false, 'TrimWhiteSpace' => false ) );
 460  
 461          if ( $dom )
 462              $node =& $dom->elementsByName( "section" );
 463  
 464          $output = "";
 465          if ( count( $node ) > 0 )
 466          {
 467              $output = "";
 468              //$children = $node[0]->children();
 469              $output .= $this->inputSectionXML( $node[0], 0 );
 470          }
 471  
 472          if ( $this->browserType == 'IE' )
 473              $output = str_replace( "<p></p>", "<p>&nbsp;</p>", $output );
 474          else
 475              $output = str_replace( "<p></p>", "<p><br/></p>", $output );
 476  
 477          $output = str_replace( "\n", "", $output );
 478  
 479          if ( $this->browserType == 'IE' )
 480              $output .= '<p>&nbsp;</p>';
 481          else
 482              $output .= '<p><br/></p>';
 483  
 484          //eZDebug::writeDebug( $output, '$output' );
 485  
 486          $output = htmlspecialchars( $output );
 487  
 488          return $output;
 489      }
 490  
 491      /*!
 492       \private
 493       \return the user input format for the given section
 494      */
 495      function &inputSectionXML( &$section, $currentSectionLevel, $tdSectionLevel = null )
 496      {
 497          $output = "";
 498          $imgName = "anchor_image.gif";
 499  
 500          $imgSrc = extension_path( 'ezdhtml', true, true, true );
 501          $imgSrc .= '/design/standard/images/ezdhtml/' . $imgName;
 502  
 503          foreach ( $section->children() as $sectionNode )
 504          {
 505              if ( $tdSectionLevel == null )
 506              {
 507                  $sectionLevel = $currentSectionLevel;
 508              }
 509              else
 510              {
 511                  $sectionLevel = $tdSectionLevel;
 512                  $currentSectionLevel = $currentSectionLevel;
 513              }
 514              if ( get_class( $sectionNode ) == "ezdomnode" )
 515                  $tagName = $sectionNode->name();
 516              else
 517                  $tagName = "";
 518              switch ( $tagName )
 519              {
 520                  case 'header' :
 521                  {
 522                      $level = $sectionLevel;
 523                      $headerClassName = $sectionNode->attributeValue( 'class' );
 524  
 525                      if ( $headerClassName != null )
 526                          $headerClassString = " class='$headerClassName'";
 527                      else
 528                          $headerClassString = "";
 529  
 530                      $tagContent = '';
 531                      // render children tags
 532                      $tagChildren = $sectionNode->children();
 533                      foreach ( $tagChildren as $childTag )
 534                      {
 535                          $tagContent .= $this->inputTagXML( $childTag, $currentSectionLevel, $tdSectionLevel );
 536                      }
 537  
 538                      /*$tagContent = htmlspecialchars( $sectionNode->textContent() );
 539                      $tagContent = preg_replace( "#\n[ ]*#", '', $tagContent );
 540  
 541                      // A fix for IE
 542                      $tagContent = str_replace( '&amp;apos;', '&amp;#039;', $tagContent );
 543                      */
 544  
 545                      switch ( $level )
 546                      {
 547                          case "1":
 548                          {
 549                              $archorName = $sectionNode->attributeValue( 'anchor_name' );
 550                              if ( $archorName != null )
 551                                  $output .= "<h1$headerClassString><img src=\"$imgSrc\" name=\"$archorName\" type=\"anchor\" />" . $sectionNode->textContent(). "</h1>";
 552                              else
 553                                  $output .= "<h1$headerClassString>" . $tagContent . "</h1>";
 554                          }break;
 555  
 556                          case "2":
 557                          {
 558                              $archorName = $sectionNode->attributeValue( 'anchor_name' );
 559                              if ( $archorName != null )
 560                                  $output .= "<h2$headerClassString><img src=\"$imgSrc\" name=\"$archorName\" type=\"anchor\" />" . $sectionNode->textContent(). "</h2>";
 561                              else
 562                                  $output .= "<h2$headerClassString>" . $tagContent . "</h2>";
 563                          }break;
 564  
 565                          case "3":
 566                          {
 567                              $archorName = $sectionNode->attributeValue( 'anchor_name' );
 568                              if ( $archorName != null )
 569                                  $output .= "<h3$headerClassString><img src=\"$imgSrc\" name=\"$archorName\" type=\"anchor\" />" . $sectionNode->textContent(). "</h3>";
 570                              else
 571                                  $output .= "<h3$headerClassString>" . $tagContent . "</h3>";
 572                          }break;
 573  
 574                          case "4":
 575                          {
 576                              $archorName = $sectionNode->attributeValue( 'anchor_name' );
 577                              if ( $archorName != null )
 578                                  $output .= "<h4$headerClassString><img src=\"$imgSrc\" name=\"$archorName\" type=\"anchor\" />" . $sectionNode->textContent(). "</h4>";
 579                              else
 580                                  $output .= "<h4$headerClassString>" . $tagContent . "</h4>";
 581                          }break;
 582  
 583                          case "5":
 584                          {
 585                              $archorName = $sectionNode->attributeValue( 'anchor_name' );
 586                              if ( $archorName != null )
 587                                  $output .= "<h5$headerClassString><img src=\"$imgSrc\" name=\"$archorName\" type=\"anchor\" />" . $sectionNode->textContent(). "</h5>";
 588                              else
 589                                  $output .= "<h5$headerClassString>" . $tagContent . "</h5>";
 590                          }break;
 591  
 592                          case "6":
 593                          {
 594                              $archorName = $sectionNode->attributeValue( 'name' );
 595                              if ( $archorName != null )
 596                                  $output .= "<h6$headerClassString><img src=\"$imgSrc\" name=\"$archorName\" type=\"anchor\" />" . $sectionNode->textContent(). "</h6>";
 597                              else
 598                                  $output .= "<h6$headerClassString>" . $tagContent . "</h6>";
 599                          }break;
 600  
 601                          default:
 602                          {
 603                              $archorName = $sectionNode->attributeValue( 'anchor_name' );
 604                              if ( $archorName != null )
 605                                  $output .= "<h1$headerClassString><img src=\"$imgSrc\" name=\"$archorName\" type=\"anchor\" />" . $sectionNode->textContent(). "</h1>";
 606                              else
 607                                  $output .= "<h1$headerClassString>" . $tagContent . "</h1>";
 608                          }break;
 609                      }
 610  
 611                  }break;
 612  
 613                  case 'paragraph' :
 614                  {
 615                      if ( $tdSectionLevel == null )
 616                          $output .= $this->inputParagraphXML( $sectionNode, $currentSectionLevel );
 617                      else
 618                          $output .= $this->inputParagraphXML( $sectionNode, $currentSectionLevel, $tdSectionLevel );
 619                  }break;
 620  
 621                  case 'section' :
 622                  {
 623                      $sectionLevel += 1;
 624                      if ( $tdSectionLevel == null )
 625                          $output .= $this->inputSectionXML( $sectionNode, $sectionLevel );
 626                      else
 627                          $output .= $this->inputSectionXML( $sectionNode, $currentSectionLevel, $sectionLevel );
 628                  }break;
 629  
 630                  default :
 631                  {
 632                      eZDebug::writeError( "Unsupported tag at this level: $tagName", "eZXMLTextType::inputSectionXML()" );
 633                  }break;
 634              }
 635          }
 636          return $output;
 637      }
 638  
 639      /*!
 640       \private
 641       \return the user input format for the given table cell
 642      */
 643      function &inputListXML( &$listNode, $currentSectionLevel, $listSectionLevel = null )
 644      {
 645          $output = "";
 646          if ( get_class( $listNode ) == "ezdomnode" )
 647              $tagName = $listNode->name();
 648          else
 649              $tagName = "";
 650          switch ( $tagName )
 651          {
 652              case 'paragraph' :
 653              {
 654                  $output .= $this->inputParagraphXML( $listNode, $currentSectionLevel, $listSectionLevel, true );
 655              }break;
 656              case 'section' :
 657              {
 658                  $listSectionLevel += 1;
 659                  $output .= $this->inputSectionXML( $tdNode, $currentSectionLevel, $listSectionLevel );
 660              }break;
 661  
 662              default :
 663              {
 664                  eZDebug::writeError( "Unsupported tag at this level: $tagName", "eZXMLTextType::inputListXML()" );
 665              }break;
 666          }
 667          return $output;
 668      }
 669  
 670      /*!
 671       \private
 672       \return the user input format for the given section
 673      */
 674      function &inputTdXML( &$tdNode, $currentSectionLevel, $tdSectionLevel = null )
 675      {
 676          $output = "";
 677          if ( get_class( $tdNode ) == "ezdomnode" )
 678              $tagName = $tdNode->name();
 679          else
 680              $tagName = "";
 681          switch ( $tagName )
 682          {
 683              case 'paragraph' :
 684              {
 685                  $output .= $this->inputParagraphXML( $tdNode, $currentSectionLevel, $tdSectionLevel  );
 686              }break;
 687              case 'section' :
 688              {
 689                  $tdSectionLevel += 1;
 690                  $output .= $this->inputSectionXML( $tdNode, $currentSectionLevel, $tdSectionLevel );
 691              }break;
 692              default :
 693              {
 694                  eZDebug::writeError( "Unsupported tag at this level: $tagName", "eZXMLTextType::inputTdXML()" );
 695              }break;
 696          }
 697          return $output;
 698      }
 699  
 700      /*!
 701       \return the input xml of the given paragraph
 702      */
 703      function &inputParagraphXML( &$paragraph, $currentSectionLevel, $tdSectionLevel = null, $noRender = false )
 704      {
 705          $output = '';
 706          $children =& $paragraph->Children;
 707          if ( $noRender )
 708          {
 709              foreach ( $children as $key=>$child )
 710              {
 711                  $output .= $this->inputTagXML( $child, $currentSectionLevel, $tdSectionLevel );
 712              }
 713              return $output;
 714          }
 715  
 716          $paragraphClassName = $paragraph->attributeValue( 'class' );
 717  
 718          $customAttributePart = $this->getCustomAttrPart( $paragraph );
 719  
 720          if ( $paragraphClassName != null )
 721              $openPara = "<p class='$paragraphClassName'$customAttributePart>";
 722          else
 723              $openPara = "<p$customAttributePart>";
 724          $closePara = '</p>';
 725  
 726          if ( !count( $children ) )
 727          {
 728              $output = $openPara . $closePara;
 729              return $output;
 730          }
 731  
 732          $lastChildInline = null;
 733          $innerContent = '';
 734          foreach ( $children as $key=>$child )
 735          {
 736              $childOutput = $this->inputTagXML( $child, $currentSectionLevel, $tdSectionLevel );
 737  
 738              $inline = !( $child->Name == 'ul' || $child->Name == 'ol');
 739              if ( $inline )
 740                  $innerContent .= $childOutput;
 741  
 742              if ( ( !$inline && $lastChildInline ) ||
 743                   ( $inline && !array_key_exists( $key + 1, $children ) ) )
 744              {
 745                  $output .= $openPara . $innerContent . $closePara;
 746                  $innerContent = '';
 747              }
 748  
 749              if ( !$inline )
 750                  $output .= $childOutput;
 751  
 752              $lastChildInline = $inline;
 753          }
 754  
 755          return $output;
 756      }
 757  
 758      function getCustomAttrPart( $tag )
 759      {
 760          $customAttributePart = "";
 761          $customAttributes =& $tag->attributesNS( "http://ez.no/namespaces/ezpublish3/custom/" );
 762          if ( $customAttributes != null )
 763          {
 764              $customAttributePart = " customAttributes=\"";
 765              $customAttributePart .= $customAttributes[0]->name() . "|" . $customAttributes[0]->content();
 766              for ( $i=1;$i<count($customAttributes);$i++ )
 767              {
 768                 $customAttributePart .= 'attribute_separation' . $customAttributes[$i]->name() . "|" . $customAttributes[$i]->content();
 769              }
 770              $customAttributePart .= "\"";
 771          }
 772          return $customAttributePart;
 773      }
 774  
 775      /*!
 776       \return the input xml for the given tag
 777      */
 778      function &inputTagXML( &$tag, $currentSectionLevel, $tdSectionLevel = null )
 779      {
 780          $output = "";
 781          $tagName = $tag->name();
 782          $childTagText = "";
 783          // render children tags
 784          $tagChildren = $tag->children();
 785          foreach ( $tagChildren as $childTag )
 786          {
 787              $childTagText .= $this->inputTagXML( $childTag, $currentSectionLevel, $tdSectionLevel );
 788          }
 789          switch ( $tagName )
 790          {
 791              case '#text' :
 792              {
 793                  //$tagContent = htmlspecialchars( $tag->content() );
 794                  $tagContent = $tag->content();
 795                  if ( !strlen( $tagContent ) )
 796                      break;
 797  
 798                  if ( $this->allowMultipleSpaces )
 799                      $tagContent = str_replace( "  ", " &nbsp;", $tagContent );
 800                  else
 801                      $tagContent = preg_replace( "/ {2,}/", " ", $tagContent );
 802  
 803                  if ( $tagContent[0] == ' ' )
 804                  {
 805                      $tagContent[0] = ';';
 806                      $tagContent = '&nbsp' . $tagContent;
 807                  }
 808  
 809                  //$tagContent = preg_replace( "#\n[ ]*#", '', $tagContent );
 810  
 811                  // A fix for IE
 812                  $tagContent = str_replace( '&amp;apos;', '&amp;#039;', $tagContent );
 813  
 814                  $output .= $tagContent;
 815  
 816              }break;
 817              
 818              case 'object' :
 819              {
 820                  $size = "";
 821                  $view = $tag->attributeValue( 'view' );
 822                  $size = $tag->attributeValue( 'size' );
 823                  $alignment = $tag->attributeValue( 'align' );
 824                  $className = $tag->attributeValue( 'class' );
 825                  $optionalLinkParameters = "";
 826                  $hasLink = false;
 827                  $linkID = $tag->attributeValueNS( 'ezurl_id', "http://ez.no/namespaces/ezpublish3/image/" );
 828  
 829                  if ( $linkID != null )
 830                  {
 831                      $href =& eZURL::url( $linkID );
 832                      $target = $tag->attributeValueNS( 'ezurl_target', "http://ez.no/namespaces/ezpublish3/image/" );
 833                      if ( $target == null )
 834                          $target = "_self";
 835                      $title = $tag->attributeValueNS( 'ezurl_title', "http://ez.no/namespaces/ezpublish3/image/" );
 836                      $id = $tag->attributeValueNS( 'ezurl_linkid', "http://ez.no/namespaces/ezpublish3/image/" );
 837                      $hasLink = true;
 838                      if ( $title != null )
 839                      {
 840                          $optionalLinkParameters .= " title=" . $title;
 841                      }
 842                      if ( $id != null )
 843                      {
 844                          $optionalLinkParameters .= " id=" . $id;
 845                      }
 846                  }
 847  
 848                  $customAttributePart = "";
 849                  $customAttributes =& $tag->attributesNS( "http://ez.no/namespaces/ezpublish3/custom/" );
 850                  if ( $customAttributes != null )
 851                  {
 852                      $customAttributePart = "customAttributes=\"";
 853                      $customAttributePart .= $customAttributes[0]->name() . "|" . $customAttributes[0]->content();
 854                      for ( $i=1;$i<count($customAttributes);$i++ )
 855                      {
 856                         $customAttributePart .= 'attribute_separation' . $customAttributes[$i]->name() . "|" . $customAttributes[$i]->content();
 857                      }
 858                      $customAttributePart .= "\"";
 859                  }
 860  
 861                  if ( strlen( $view ) == 0 )
 862                      $view = "embed";
 863                  $srcString = "";
 864                  $objectID = $tag->attributeValue( 'id' );
 865                  $object =& eZContentObject::fetch( $objectID );
 866  
 867                  if ( $object != null )
 868                  {
 869                      $objectName = $object->attribute( 'name' );
 870                      $classID = $object->attribute( 'contentclass_id' );
 871                  }
 872                  else
 873                  {
 874                      $objectName = "Unknow";
 875                      $classID = 0;
 876                  }
 877                  
 878                  $URL = serverURL();
 879                  
 880                  $ini =& eZINI::instance( 'site.ini' );
 881                  $imageClassArray = $ini->variable("MediaClassSettings", "ImageClassID" );
 882                  $imageDatatypeArray = $ini->variable( "ImageDataTypeSettings", "AvailableImageDataTypes" );
 883                  if ( in_array( $classID, $imageClassArray ) )
 884                  {
 885                      $contentObjectAttributes =& $object->contentObjectAttributes();
 886                      foreach ( $contentObjectAttributes as $contentObjectAttribute )
 887                      {
 888                          $classAttribute =& $contentObjectAttribute->contentClassAttribute();
 889                          $dataTypeString = $classAttribute->attribute( 'data_type_string' );
 890                          if ( in_array ( $dataTypeString, $imageDatatypeArray ) )
 891                          {
 892                              $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );
 893                              $contentObjectAttributeVersion = $contentObjectAttribute->attribute( 'version' );
 894                              $content = $contentObjectAttribute->content();
 895                              if ( $content != null )
 896                              {
 897                                  if ( $size == "" )
 898                                      $size = "medium";
 899                                  $imageAlias = $content->imageAlias( $size );
 900                                  $srcString = $URL . '/' . $imageAlias['url'];
 901                              }
 902                              else
 903                              {
 904                                  $srcString = "";
 905                              }
 906                          }
 907                      }
 908                  }
 909                  else
 910                  {
 911                      $srcString = $URL . "/";;
 912                      $srcString .= extension_path( 'ezdhtml', false, false, false );
 913                      $srcString .= '/design/standard/images/ezdhtml/object_insert.png';
 914                  }
 915                  if ( $className != null )
 916                  {
 917                      if ( $size == "" )
 918                          $output .= "<img id=\"eZObject_$objectID\" src=\"$srcString\" align=\"$alignment\" class='$className' $customAttributePart />";
 919                      else if ( $size != "" and $hasLink )
 920                          $output .= "<a href='$href' target='$target'$optionalLinkParameters><img id=\"eZObject_$objectID\" src=\"$srcString\" align=\"$alignment\" alt=\"$size\" class='$className' $customAttributePart /></a>";
 921                      else
 922                          $output .= "<img id=\"eZObject_$objectID\" src=\"$srcString\" align=\"$alignment\" alt=\"$size\" class='$className' $customAttributePart />";
 923                  }
 924                  else
 925                  {
 926                      if ( $size == "" )
 927                          $output .= "<img id=\"eZObject_$objectID\" src=\"$srcString\" align=\"$alignment\" $customAttributePart />";
 928                      else if ( $size != "" and $hasLink )
 929                          $output .= "<a href='$href' target='$target'$optionalLinkParameters><img id=\"eZObject_$objectID\" src=\"$srcString\" align=\"$alignment\" alt=\"$size\" $customAttributePart /></a>";
 930                      else
 931                          $output .= "<img id=\"eZObject_$objectID\" src=\"$srcString\" align=\"$alignment\" alt=\"$size\" $customAttributePart />";
 932                  }
 933              }break;
 934  
 935              case 'embed' :
 936              case 'embed-inline' :
 937              {
 938                  $view = $tag->attributeValue( 'view' );
 939                  $size = $tag->attributeValue( 'size' );
 940                  $alignment = $tag->attributeValue( 'align' );
 941                  if ( !$alignment )
 942                      $alignment = 'right';
 943  
 944                  $objectID = $tag->attributeValue( 'object_id' );
 945                  $nodeID = $tag->attributeValue( 'node_id' );
 946                  $showPath = $tag->attributeValue( 'show_path' );
 947                  $htmlID = $tag->attributeValueNS( 'id', 'http://ez.no/namespaces/ezpublish3/xhtml/' );
 948                  $className = $tag->attributeValue( 'class' );
 949                  $linkToObject = true;
 950  
 951                  $objectAttr = "";
 952  
 953                  if ( $size != null )
 954                      $objectAttr .= " alt='$size'";
 955                  else
 956                  {
 957                      $objectAttr .= " alt='medium'";
 958                      $size = "medium";
 959                  }
 960                  if ( $alignment != null )
 961                      $objectAttr .= " align='$alignment'";
 962                  if ( $view != null )
 963                      $objectAttr .= " view='$view'";
 964                  if ( $htmlID != '' )
 965                      $objectAttr .= " html_id='$htmlID'";
 966                  if ( $className != '' )
 967                      $objectAttr .= " class='$className'";
 968                  if ( $showPath == 'true' )
 969                      $objectAttr .= " show_path='true'";
 970  
 971                  if ( $this->eZPublishVersion >= 3.8 )
 972                  {
 973                      if ( $tagName == 'embed-inline' )
 974                      {
 975                          $objectAttr .= " inline='true'";
 976                      }
 977                      else
 978                      {
 979                          $objectAttr .= " inline='false'";
 980                      }
 981                  }
 982                  
 983                  $customAttributePart = $this->getCustomAttrPart( $tag );
 984  
 985                  if ( is_numeric( $objectID ) )
 986                  {
 987                      $object =& eZContentObject::fetch( $objectID );
 988                  }
 989                  elseif ( is_numeric( $nodeID ) )
 990                  {
 991                      $linkToObject = false;
 992                      $object =& eZContentObject::fetchByNodeID( $nodeID );
 993                  }
 994  
 995                  if ( $object != null )
 996                  {
 997                      $objectName = $object->attribute( 'name' );
 998                      $classID = $object->attribute( 'contentclass_id' );
 999                  }
1000                  else
1001                  {
1002                      $objectName = "Unknow";
1003                      $classID = 0;
1004                  }
1005  
1006                  $URL = serverURL();
1007  
1008                  $ini =& eZINI::instance( 'site.ini' );
1009                  $imageClassArray = $ini->variable("MediaClassSettings", "ImageClassID" );
1010                  $imageDatatypeArray = $ini->variable( "ImageDataTypeSettings", "AvailableImageDataTypes" );
1011                  if ( in_array( $classID, $imageClassArray ) )
1012                  {
1013                      $contentObjectAttributes =& $object->contentObjectAttributes();
1014                      foreach ( $contentObjectAttributes as $contentObjectAttribute )
1015                      {
1016                          $classAttribute =& $contentObjectAttribute->contentClassAttribute();
1017                          $dataTypeString = $classAttribute->attribute( 'data_type_string' );
1018                          if ( in_array ( $dataTypeString, $imageDatatypeArray ) )
1019                          {
1020                              $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );
1021                              $contentObjectAttributeVersion = $contentObjectAttribute->attribute( 'version' );
1022                              $content = $contentObjectAttribute->content();
1023                              if ( $content != null )
1024                              {
1025                                  $imageAlias = $content->imageAlias( $size );
1026                                  $srcString = $URL . '/' . $imageAlias['url'];
1027                              }
1028                              else
1029                              {
1030                                  $srcString = "";
1031                              }
1032                          }
1033                      }
1034                  }
1035                  else
1036                  {
1037                      $srcString = $URL . "/";;
1038                      $srcString .= extension_path( 'ezdhtml', false, false, false );
1039                      $srcString .= '/design/standard/images/ezdhtml/object_insert.png';
1040                  }
1041  
1042                  if ( $linkToObject )
1043                  {
1044                      $output .= "<img id=\"eZObject_$objectID\" src=\"$srcString\" $objectAttr$customAttributePart />";
1045                  }
1046                  else
1047                  {
1048                      $output .= "<img id=\"eZNode_$nodeID\" src=\"$srcString\" $objectAttr$customAttributePart />";
1049                  }
1050              }break;
1051  
1052              case 'anchor' :
1053              {
1054                  $name = $tag->attributeValue( 'name' );
1055                  $imgName = "anchor_image.gif";
1056  
1057                  $customAttributePart = $this->getCustomAttrPart( $tag );
1058  
1059                  $src = imagePath( $imgName );
1060                  $output .= "<img src=\"$src\" name=\"$name\" type=\"anchor\"$customAttributePart/>";
1061              }break;
1062  
1063              case 'custom' :
1064              {
1065                  $name = $tag->attributeValue( 'name' );
1066  
1067                  $customAttributePart = $this->getCustomAttrPart( $tag );
1068                  
1069                  $isInline = false;
1070                  include_once ( "lib/ezutils/classes/ezini.php" );
1071                  $ini =& eZINI::instance( 'content.ini' );
1072  
1073                  $isInlineTagList = $ini->variable( 'CustomTagSettings', 'IsInline' );
1074                  foreach ( array_keys ( $isInlineTagList ) as $key )
1075                  {
1076                      $isInlineTagValue =& $isInlineTagList[$key];
1077                      if ( $isInlineTagValue )
1078                      {
1079                          if ( $name == $key )
1080                              $isInline = true;
1081                      }
1082                  }
1083  
1084                  if ( $isInline )
1085                  {
1086                      $imgName = "customtag_insert.gif";
1087  
1088                      if ( !$childTagText )
1089                      {
1090                          $src = imagePath( $imgName );
1091                          $output .= "<img src=\"$src\" name=\"$name\" value=\"\" type=\"custom\"$customAttributePart />";
1092                      }
1093                      else
1094                      {
1095                          $output .= "<span class=\"$name\" name=\"$name\" type=\"custom\"$customAttributePart>$childTagText</span>";
1096                      }
1097                  }
1098                  else
1099                  {
1100                      $customTagContent = "";
1101                      foreach ( $tag->children() as $tagChild )
1102                      {
1103                          $customTagContent .= $this->inputTdXML( $tagChild, $currentSectionLevel, $tdSectionLevel );
1104                      }
1105                      $output .= "<table id='custom' class='custom' title='$name' width='100%' border='1'$customAttributePart><tr><td class='" . $name . "'>$customTagContent</td></tr></table>";
1106                  }
1107              }break;
1108  
1109              case 'literal' :
1110              {
1111                  $literalText = "";
1112                  foreach ( $tagChildren as $childTag )
1113                  {
1114                      $literalText .= $childTag->content();
1115                  }
1116                  $className = $tag->attributeValue( 'class' );
1117  
1118                  $customAttributePart = $this->getCustomAttrPart( $tag );
1119  
1120                  //$literalText = htmlspecialchars( $literalText );
1121  
1122                  $literalText = str_replace( "  ", " &nbsp;", $literalText );
1123                  $literalText = str_replace( "\n\n", "</p><p>", $literalText );
1124                  $literalText = str_replace( "\n", "<br>", $literalText );
1125                  //$literalText = htmlspecialchars( $literalText );
1126  
1127                  if ( $className == null )
1128                      $output .= "<table id='literal' width='100%' border='1' class='literal'$customAttributePart><tr><td><p>$literalText</p></td></tr></table>";
1129                  else
1130                      $output .= "<table id='literal' width='100%' border='1' class='literal' title='$className'$customAttributePart><tr><td class='$className'><p>$literalText</p></td></tr></table>";
1131              }break;
1132  
1133              case 'ul' :
1134              case 'ol' :
1135              {
1136                  $listContent = "";
1137  
1138                  $customAttributePart = $this->getCustomAttrPart( $tag );
1139  
1140                  // find all list elements
1141                  foreach ( $tag->children() as $listItemNode )
1142                  {
1143                      $LIcustomAttributePart = $this->getCustomAttrPart( $listItemNode );
1144  
1145                      $listItemContent = "";
1146                      foreach ( $listItemNode->children() as $itemChildNode )
1147                      {
1148                          $listSectionLevel = $currentSectionLevel;
1149                          if ( $itemChildNode->name() == "section" or $itemChildNode->name() == "paragraph" )
1150                              $listItemContent .= $this->inputListXML( $itemChildNode, $currentSectionLevel, $listSectionLevel );
1151                          else
1152                              $listItemContent .= $this->inputTagXML( $itemChildNode, $currentSectionLevel, $tdSectionLevel );
1153                      }
1154                      /*foreach ( $listItemNode->children() as $itemChildNode )
1155                      {
1156                          $listItemContent .= $this->inputTagXML( $itemChildNode, $currentSectionLevel, $tdSectionLevel );
1157                      }*/
1158                      $listContent .= "<li$LIcustomAttributePart>$listItemContent</li>";
1159                  }
1160                  $className = $tag->attributeValue( 'class' );
1161                  if ( $className != null )
1162                      $output .= "<$tagName class='$className'$customAttributePart>$listContent</$tagName>";
1163                  else
1164                      $output .= "<$tagName$customAttributePart>$listContent</$tagName>";
1165              }break;
1166  
1167              case 'table' :
1168              {
1169                  $tableRows = "";
1170                  $border = $tag->attributeValue( 'border' );
1171                  $width = $tag->attributeValue( 'width' );
1172                  $tableClassName = $tag->attributeValue( 'class' );
1173  
1174                  $customAttributePart = $this->getCustomAttrPart( $tag );
1175  
1176                  // find all table rows
1177                  foreach ( $tag->children() as $tableRow )
1178                  {
1179                      $TRcustomAttributePart = $this->getCustomAttrPart( $tableRow );
1180  
1181                      $tableData = "";
1182                      foreach ( $tableRow->children() as $tableCell )
1183                      {
1184                          $TDcustomAttributePart = $this->getCustomAttrPart( $tableCell );
1185  
1186                          $cellAttribute = "";
1187                          $className = $tableCell->attributeValue( 'class' );
1188  
1189                          $colspan = $tableCell->attributeValueNS( 'colspan', "http://ez.no/namespaces/ezpublish3/xhtml/" );
1190                          $rowspan = $tableCell->attributeValueNS( 'rowspan', "http://ez.no/namespaces/ezpublish3/xhtml/" );
1191                          $cellWidth = $tableCell->attributeValueNS( 'width', "http://ez.no/namespaces/ezpublish3/xhtml/" );
1192                          if ( $className != null )
1193                              $cellAttribute .= " class='$className'";
1194                          if ( $cellWidth != null )
1195                              $cellAttribute .= " width='$cellWidth'";
1196                          if ( $colspan != null )
1197                              $cellAttribute .= " colspan='$colspan'";
1198                          if ( $rowspan != null )
1199                              $cellAttribute .= " rowspan='$rowspan'";
1200                          $cellContent = "";
1201                          if ( $tableCell->Name == "th" )
1202                          {
1203                              $tdSectionLevel = $currentSectionLevel;
1204                              foreach ( $tableCell->children() as $tableCellChildNode )
1205                              {
1206                                  $cellContent .= $this->inputTdXML( $tableCellChildNode, $currentSectionLevel, $tdSectionLevel - $currentSectionLevel );
1207                              }
1208                              $tableData .= "<th" . $cellAttribute . $TDcustomAttributePart . ">" . $cellContent . "</th>";
1209  
1210                          }
1211                          else
1212                          {
1213                              $tdSectionLevel = $currentSectionLevel;
1214                              foreach ( $tableCell->children() as $tableCellChildNode )
1215                              {
1216                                  $cellContent .= $this->inputTdXML( $tableCellChildNode, $currentSectionLevel, $tdSectionLevel - $currentSectionLevel );
1217                              }
1218                              $tableData .= "<td" . $cellAttribute . $TDcustomAttributePart . ">" . $cellContent . "</td>";
1219                          }
1220                      }
1221                      $tableRows .= "<tr$TRcustomAttributePart>$tableData</tr>";
1222                  }
1223                  if ( $this->browserSupportsDHTMLType() == "Gecko" )
1224                  {
1225                      $widthAttribute = "style='width: $width;'";
1226                  }
1227                  else
1228                  {
1229                      $widthAttribute = "width='$width'";
1230                  }
1231  
1232                  if ( is_string( $border ) )
1233                  {
1234                      $borderAttribute = "ezborder='$border'";
1235                      if ( $border == 0 )
1236                          $borderAttribute .= " border='1' bordercolor='red'";
1237                      else
1238                          $borderAttribute .= " border='$border'";
1239                  }
1240                  else
1241                      $borderAttribute = "";
1242  
1243                  if ( $tableClassName != null )
1244                      $classAttribute = "class='$tableClassName'";
1245                  else
1246                      $classAttribute = "";
1247  
1248                  $output .= "<table id='table' $classAttribute $widthAttribute $borderAttribute$customAttributePart>$tableRows</table>";
1249              }break;
1250  
1251              // normal content tags
1252              case 'emphasize' :
1253              {
1254                  $customAttributePart = $this->getCustomAttrPart( $tag );
1255  
1256                  $className = $tag->attributeValue( 'class' );
1257                  if ( $className != null )
1258                      $output .= "<i class='$className'$customAttributePart>" . $childTagText . "</i>";
1259                  else
1260                  $output .= "<i>" . $childTagText  . "</i>";
1261              }break;
1262  
1263              case 'strong' :
1264              {
1265                  $customAttributePart = $this->getCustomAttrPart( $tag );
1266  
1267                  $className = $tag->attributeValue( 'class' );
1268                  if ( $className != null )
1269                      $output .= "<b class='$className'$customAttributePart>" . $childTagText . "</b>";
1270                  else
1271                      $output .= "<b>" . $childTagText . "</b>";
1272              }break;
1273  
1274              case 'line' :
1275              {
1276                  $output .= $childTagText . "<br />";
1277              }break;
1278  
1279              case 'link' :
1280              {
1281                  $customAttributePart = $this->getCustomAttrPart( $tag );
1282  
1283                  if ( $this->eZPublishVersion >= 3.6 )
1284                      $linkID = $tag->attributeValue( 'url_id' );
1285                  else
1286                      $linkID = $tag->attributeValue( 'id' );
1287                  $target = $tag->attributeValue( 'target' );
1288                  $className = $tag->attributeValue( 'class' );
1289                  $viewName = $tag->attributeValue( 'view' );
1290                  $objectID = $tag->attributeValue( 'object_id' );
1291                  $nodeID = $tag->attributeValue( 'node_id' );
1292                  $anchorName = $tag->attributeValue( 'anchor_name' );
1293                  $showPath = $tag->attributeValue( 'show_path' );
1294                  $htmlID = $tag->attributeValueNS( 'id', 'http://ez.no/namespaces/ezpublish3/xhtml/' );
1295                  $htmlTitle = $tag->attributeValueNS( 'title', 'http://ez.no/namespaces/ezpublish3/xhtml/' );
1296  
1297                  if ( $objectID != null )
1298                  {
1299                      $href = 'ezobject://' .$objectID;
1300                  }
1301                  elseif ( $nodeID != null )
1302                  {
1303                          if ( $showPath == 'true' )
1304                      {
1305                              $node = eZContentObjectTreeNode::fetch( $nodeID );
1306                              if ( $node )
1307                                  $href = 'eznode://' . $node->attribute('path_identification_string');
1308                              else
1309                                  $href = 'eznode://' . $nodeID;
1310                              }
1311                          else
1312                              $href = 'eznode://' . $nodeID;
1313                  }
1314                  elseif ( $linkID != null )
1315                  {
1316                      $href = eZURL::url( $linkID );
1317                  }
1318                  else
1319                  {
1320                      $href = $tag->attributeValue( 'href' );
1321                  }
1322  
1323                  if ( $anchorName != null )
1324                  {
1325                      $href .= '#' .$anchorName;
1326                  }
1327  
1328                  $attributes = array();
1329                  if ( $className != '' )
1330                      $attributes[] = "class='$className'";
1331                  if ( $viewName != '' )
1332                      $attributes[] = "view='$viewName'";
1333  
1334                  $attributes[] = "href='$href'";
1335                  if ( $target != '' )
1336                      $attributes[] = "target='$target'";
1337                  if ( $htmlTitle != '' )
1338                      $attributes[] = "title='$htmlTitle'";
1339                  if ( $htmlID != '' )
1340                      $attributes[] = "id='$htmlID'";
1341  
1342                  $attributeText = '';
1343                  if ( count( $attributes ) > 0 )
1344                      $attributeText = ' ' .implode( ' ', $attributes );
1345                  $output .= "<a$attributeText$customAttributePart>" . $childTagText . "</a>";
1346              }break;
1347              case 'tr' :
1348              case 'td' :
1349              case 'th' :
1350              case 'li' :
1351              case 'paragraph' :
1352              {
1353              }break;
1354              default :
1355              {
1356                  //eZDebug::writeDebug( "Unsupported tag: $tagName", "eZXMLTextType::inputTagXML()" );
1357              }break;
1358          }
1359          return $output;
1360      }
1361  
1362  
1363      var $LineTagArray = array( 'emphasize', 'strong', 'link', 'a', 'em', 'i', 'b', 'bold','anchor' );
1364      /// Contains the XML data
1365      var $XMLData;
1366  
1367      var $ContentObjectAttributeID;
1368      var $ContentObjectAttributeVersion;
1369  
1370      var $IsStrictHeader = false;
1371      var $SectionArray = array(  "h1", "h2", "h3", "h4", "h5", "h6", "p", "section" );
1372  
1373      var $browserType;
1374      var $eZPublishVersion;
1375  
1376      var $trimSpaces = true;
1377      var $allowMultipleSpaces = false;
1378  }
1379  
1380  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7