[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/classes/datatypes/ezxmltext/ -> ezxmltext.php (source)

   1  <?php
   2  //
   3  // Definition of eZXMLText class
   4  //
   5  // Created on: <28-Jan-2003 12:56:49 bf>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file ezxmltext.php
  30  */
  31  
  32  /*!
  33    \class eZXMLText ezxmltext.php
  34    \ingroup eZDatatype
  35    \brief The class eZXMLText handles XML text data type instances
  36  
  37  */
  38  
  39  class eZXMLText
  40  {
  41      function eZXMLText( &$xmlData, $contentObjectAttribute )
  42      {
  43          $this->XMLData =& $xmlData;
  44          $this->ContentObjectAttribute = $contentObjectAttribute;
  45          $this->XMLInputHandler = null;
  46          $this->XMLOutputHandler = null;
  47      }
  48  
  49      function attributes()
  50      {
  51          return array( 'input',
  52                        'output',
  53                        'pdf_output',
  54                        'xml_data',
  55                        'is_empty' );
  56      }
  57  
  58      function hasAttribute( $name )
  59      {
  60          return in_array( $name, $this->attributes() );
  61      }
  62  
  63      function &attribute( $name )
  64      {
  65          switch ( $name )
  66          {
  67              case 'input' :
  68              {
  69                  if ( $this->XMLInputHandler === null )
  70                  {
  71                      $this->XMLInputHandler =& $this->inputHandler( $this->XMLData );
  72                  }
  73                  return $this->XMLInputHandler;
  74              }break;
  75  
  76              case 'output' :
  77              {
  78                  if ( $this->XMLOutputHandler === null )
  79                  {
  80                      $this->XMLOutputHandler =& $this->outputHandler( $this->XMLData );
  81                  }
  82                  return $this->XMLOutputHandler;
  83              }break;
  84  
  85              case 'pdf_output' :
  86              {
  87                  if ( $this->XMLOutputHandler === null )
  88                  {
  89                      $this->XMLOutputHandler =& $this->outputHandler( $this->XMLData, 'ezpdf' );
  90                  }
  91                  return $this->XMLOutputHandler;
  92              }break;
  93  
  94              case 'xml_data' :
  95              {
  96                  return $this->XMLData;
  97              }break;
  98  
  99              case 'is_empty' :
 100              {
 101                  $isEmpty = true;
 102                  $xml = new eZXML();
 103                  $dom =& $xml->domTree( $this->XMLData, array(), true );
 104                  if ( $dom )
 105                  {
 106                      $node = $dom->get_elements_by_tagname( "section" );
 107  
 108                      $sectionNode = $node[0];
 109                      if ( ( get_class( $sectionNode ) == "ezdomnode" ) or
 110                           ( get_class( $sectionNode ) == "domelement" ) )
 111                      {
 112                          $children = $sectionNode->children();
 113                          if ( count( $children ) > 0 )
 114                              $isEmpty = false;
 115                      }
 116                  }
 117                  return $isEmpty;
 118              }break;
 119  
 120              default:
 121              {
 122                  eZDebug::writeError( "Attribute '$name' does not exist", 'eZXMLText::attribute' );
 123                  $retValue = null;
 124                  return $retValue;
 125              }break;
 126          }
 127      }
 128  
 129      function &inputHandler( &$xmlData, $type = false, $useAlias = true )
 130      {
 131          $inputDefinition = array( 'ini-name' => 'ezxml.ini',
 132                                    'repository-group' => 'HandlerSettings',
 133                                    'repository-variable' => 'Repositories',
 134                                    'extension-group' => 'HandlerSettings',
 135                                    'extension-variable' => 'ExtensionRepositories',
 136                                    'type-group' => 'InputSettings',
 137                                    'type-variable' => 'Handler',
 138                                    'subdir' => 'input',
 139                                    'type-directory' => false,
 140                                    'extension-subdir' => 'ezxmltext/handlers/input',
 141                                    'suffix-name' => 'xmlinput.php' );
 142          if ( $type !== false )
 143              $inputDefinition['type'] = $type;
 144          if ( $useAlias )
 145          {
 146              $inputDefinition['alias-group'] = 'InputSettings';
 147              $inputDefinition['alias-variable'] = 'Alias';
 148          }
 149          $inputHandler =& eZXMLText::fetchHandler( $inputDefinition,
 150                                                    'XMLInput',
 151                                                    $xmlData );
 152          if ( $inputHandler === null )
 153          {
 154              include_once ( 'kernel/classes/datatypes/ezxmltext/handlers/input/ezsimplifiedxmlinput.php' );
 155              $inputHandler = new eZSimplifiedXMLInput( $this->XMLData, false, $this->ContentObjectAttribute );
 156          }
 157          return $inputHandler;
 158      }
 159  
 160      function &outputHandler( &$xmlData, $type = false, $useAlias = true )
 161      {
 162          $outputDefinition = array( 'ini-name' => 'ezxml.ini',
 163                                     'repository-group' => 'HandlerSettings',
 164                                     'repository-variable' => 'Repositories',
 165                                     'extension-group' => 'HandlerSettings',
 166                                     'extension-variable' => 'ExtensionRepositories',
 167                                     'type-group' => 'OutputSettings',
 168                                     'type-variable' => 'Handler',
 169                                     'subdir' => 'output',
 170                                     'type-directory' => false,
 171                                     'extension-subdir' => 'ezxmltext/handlers/output',
 172                                     'suffix-name' => 'xmloutput.php' );
 173          if ( $type !== false )
 174              $outputDefinition['type'] = $type;
 175          if ( $useAlias )
 176          {
 177              $outputDefinition['alias-group'] = 'OutputSettings';
 178              $outputDefinition['alias-variable'] = 'Alias';
 179          }
 180          $outputHandler = eZXMLText::fetchHandler( $outputDefinition,
 181                                                    'XMLOutput',
 182                                                    $xmlData );
 183          if ( $outputHandler === null )
 184          {
 185              include_once ( 'kernel/classes/datatypes/ezxmltext/handlers/output/ezxhtmlxmloutput.php' );
 186              $outputHandler = new eZXHTMLXMLOutput( $this->XMLData, false );
 187          }
 188          return $outputHandler;
 189      }
 190  
 191      function &fetchHandler( $definition, $classSuffix, &$xmlData )
 192      {
 193          $handler = null;
 194          if ( eZExtension::findExtensionType( $definition,
 195                                               $out ) )
 196          {
 197              $filePath = $out['found-file-path'];
 198              include_once( $filePath );
 199              $class = $out['type'] . $classSuffix;
 200              $handlerValid = false;
 201              $aliasedType = false;
 202              if ( $out['original-type'] != $out['type'] )
 203                  $aliasedType = $out['original-type'];
 204              if( class_exists( $class ) )
 205              {
 206                  $handler = new $class( $xmlData, $aliasedType, $this->ContentObjectAttribute );
 207                  if ( $handler->isValid() )
 208                      $handlerValid = true;
 209              }
 210              else
 211                  eZDebug::writeError( "Could not instantiate class '$class', it is not defined",
 212                                       'eZXMLText::fetchHandler' );
 213              if ( !$handlerValid and
 214                   $out['type'] != $out['original-type'] and
 215                   isset( $definition['alias-group'] ) and
 216                   isset( $definition['alias-variable'] ) )
 217              {
 218                  unset( $definition['alias-group'] );
 219                  unset( $definition['alias-variable'] );
 220                  if ( eZExtension::findExtensionType( $definition,
 221                                                       $out ) )
 222                  {
 223                      $filePath = $out['found-file-path'];
 224                      include_once( $filePath );
 225                      $class = $out['type'] . $classSuffix;
 226                      $handlerValid = false;
 227                      if( class_exists( $class ) )
 228                      {
 229                          $handler = new $class( $xmlData, false, $this->ContentObjectAttribute );
 230                          if ( $handler->isValid() )
 231                              $handlerValid = true;
 232                      }
 233                      else
 234                          eZDebug::writeError( "Could not instantiate class '$class', it is not defined",
 235                                               'eZXMLText::fetchHandler' );
 236                      if ( !$handlerValid )
 237                      {
 238                          $handler = null;
 239                      }
 240                  }
 241              }
 242          }
 243          return $handler;
 244      }
 245  
 246      /// Contains the XML data
 247      var $XMLData;
 248  
 249      var $XMLInputHandler;
 250      var $XMLOutputHandler;
 251      var $XMLAttributeID;
 252      var $ContentObjectAttribute;
 253  }
 254  
 255  ?>


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