[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/classes/packageinstallers/ezcontentobject/ -> ezcontentobjectpackageinstaller.php (source)

   1  <?php
   2  //
   3  // Definition of eZContentObjectPackageInstaller class
   4  //
   5  // Created on: <01-Apr-2004 12:39:59 kk>
   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 ezcontentobjectpackageinstaller.php
  30  */
  31  
  32  /*!
  33    \ingroup package
  34    \class eZContentObjectPackageInstaller ezcontentclasspackageinstaller.php
  35    \brief A package creator for content objects
  36  */
  37  
  38  include_once ( 'kernel/classes/ezpackageinstallationhandler.php' );
  39  
  40  class eZContentObjectPackageInstaller extends eZPackageInstallationHandler
  41  {
  42  
  43      /*!
  44       \reimp
  45      */
  46      function eZContentObjectPackageInstaller( &$package, $type, $installItem )
  47      {
  48          $steps = array();
  49          $steps[] = array( 'id' => 'site_access',
  50                            'name' => ezi18n( 'kernel/package', 'Site access mapping' ),
  51                            'methods' => array( 'initialize' => 'initializeSiteAccess',
  52                                                'validate' => 'validateSiteAccess' ),
  53                            'template' => 'site_access.tpl' );
  54          $steps[] = array( 'id' => 'top_nodes',
  55                            'name' => ezi18n( 'kernel/package', 'Top node placements' ),
  56                            'methods' => array( 'initialize' => 'initializeTopNodes',
  57                                                'validate' => 'validateTopNodes' ),
  58                            'template' => 'top_nodes.tpl' );
  59          $this->eZPackageInstallationHandler( $package,
  60                                               $type,
  61                                               $installItem,
  62                                               ezi18n( 'kernel/package', 'Content object import' ),
  63                                               $steps );
  64      }
  65  
  66      /*!
  67       \reimp
  68       Returns \c 'stable', content class packages are always stable.
  69      */
  70      function packageInitialState( &$package, &$persistentData )
  71      {
  72          return 'stable';
  73      }
  74  
  75      /*!
  76       \return \c 'contentclass'.
  77      */
  78  	function packageType( &$package, &$persistentData )
  79      {
  80          return 'contentobject';
  81      }
  82  
  83      /*!
  84       \reimp
  85      */
  86      function initializeSiteAccess( &$package, &$http, $step, &$persistentData, &$tpl )
  87      {
  88          include_once ( 'lib/ezutils/classes/ezini.php' );
  89          $ini =& eZINI::instance();
  90          $availableSiteAccessArray = $ini->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' );
  91  
  92          if ( !isset( $persistentData['site_access_map'] ) )
  93          {
  94              $persistentData['site_access_map'] = array();
  95              $persistentData['site_access_available'] = $availableSiteAccessArray;
  96              $rootDOMNode = $this->rootDOMNode();
  97              $siteAccessListNode = $rootDOMNode->elementByName( 'site-access-list' );
  98  
  99              foreach( $siteAccessListNode->elementsByName( 'site-access' ) as $siteAccessNode )
 100              {
 101                  $originalSiteAccessName = $siteAccessNode->textContent();
 102                  if ( in_array( $originalSiteAccessName, $availableSiteAccessArray ) )
 103                  {
 104                      $persistentData['site_access_map'][$originalSiteAccessName] = $originalSiteAccessName;
 105                  }
 106                  else
 107                  {
 108                      $persistentData['site_access_map'][$originalSiteAccessName] = '';
 109                  }
 110              }
 111          }
 112  
 113          $tpl->setVariable( 'site_access_map', $persistentData['site_access_map'] );
 114          $tpl->setVariable( 'available_site_access_array', $availableSiteAccessArray );
 115      }
 116  
 117      /*!
 118       \reimp
 119      */
 120      function validateSiteAccess( &$package, &$http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
 121      {
 122          $validate = true;
 123          foreach( $persistentData['site_access_map'] as $originalSiteAccess => $newSiteAccess )
 124          {
 125              $persistentData['site_access_map'][$originalSiteAccess] = $http->postVariable( 'SiteAccessMap_'.$originalSiteAccess );
 126              if ( !in_array( $persistentData['site_access_map'][$originalSiteAccess], $persistentData['site_access_available'] ) )
 127              {
 128                  $validate = false;
 129              }
 130          }
 131  
 132          return $validate;
 133      }
 134  
 135      /*!
 136       \reimp
 137      */
 138      function initializeTopNodes( &$package, &$http, $step, &$persistentData, &$tpl, &$module )
 139      {
 140          if ( !isset( $persistentData['top_nodes_map'] ) )
 141          {
 142              $persistentData['top_nodes_map'] = array();
 143              $rootDOMNode = $this->rootDOMNode();
 144              $topNodeListNode = $rootDOMNode->elementByName( 'top-node-list' );
 145  
 146              $ini =& eZINI::instance( 'content.ini' );
 147              $defaultPlacementNodeID = $ini->variable( 'NodeSettings', 'RootNode' );
 148              $defaultPlacementNode = eZContentObjectTreeNode::fetch( $defaultPlacementNodeID );
 149              $defaultPlacementName = $defaultPlacementNode->attribute( 'name' );
 150              foreach ( $topNodeListNode->elementsByName( 'top-node' ) as $topNodeDOMNode )
 151              {
 152                  $persistentData['top_nodes_map'][(string)$topNodeDOMNode->attributeValue( 'node-id' )] = array( 'old_node_id' => $topNodeDOMNode->attributeValue( 'node-id' ),
 153                                                                                                                  'name' => $topNodeDOMNode->textContent(),
 154                                                                                                                  'new_node_id' => $defaultPlacementNodeID,
 155                                                                                                                  'new_parent_name' => $defaultPlacementName );
 156              }
 157          }
 158  
 159          foreach( array_keys( $persistentData['top_nodes_map'] ) as $topNodeArrayKey )
 160          {
 161              if ( $http->hasPostVariable( 'BrowseNode_' . $topNodeArrayKey ) )
 162              {
 163                  include_once ( 'kernel/classes/ezcontentbrowse.php' );
 164                  eZContentBrowse::browse( array( 'action_name' => 'SelectObjectRelationNode',
 165                                                  'description_template' => 'design:package/installers/ezcontentobject/browse_topnode.tpl',
 166                                                  'from_page' => '/package/install',
 167                                                  'persistent_data' => array( 'PackageStep' => $http->postVariable( 'PackageStep' ),
 168                                                                              'InstallerType' => $http->postVariable( 'InstallerType' ),
 169                                                                              'InstallStepID' => $http->postVariable( 'InstallStepID' ),
 170                                                                              'ReturnBrowse_' . $topNodeArrayKey => 1 ) ),
 171                                           $module );
 172              }
 173              else if ( $http->hasPostVariable( 'ReturnBrowse_' . $topNodeArrayKey ) && !$http->hasPostVariable( 'BrowseCancelButton' ) )
 174              {
 175                  $nodeIDArray = $http->postVariable( 'SelectedNodeIDArray' );
 176                  if ( $nodeIDArray != null )
 177                  {
 178                      $persistentData['top_nodes_map'][$topNodeArrayKey]['new_node_id'] = $nodeIDArray[0];
 179                      $contentNode = eZContentObjectTreeNode::fetch( $nodeIDArray[0] );
 180                      $persistentData['top_nodes_map'][$topNodeArrayKey]['new_parent_name'] = $contentNode->attribute( 'name' );
 181                  }
 182              }
 183          }
 184  
 185          $tpl->setVariable( 'top_nodes_map', $persistentData['top_nodes_map'] );
 186      }
 187  
 188      /*!
 189       \reimp
 190      */
 191      function validateTopNodes( &$package, &$http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
 192      {
 193          $validate = true;
 194          foreach( array_keys( $persistentData['top_nodes_map'] ) as $topNodeArrayKey )
 195          {
 196              if ( $persistentData['top_nodes_map'][$topNodeArrayKey]['new_node_id'] === false )
 197              {
 198                  $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Select parent nodes' ),
 199                                        'description' => ezi18n( 'kernel/package', 'You must assign all nodes to new parent nodes.' ) );
 200                  $validate = false;
 201                  break;
 202              }
 203          }
 204  
 205          return $validate;
 206      }
 207  
 208      /*!
 209       \reimp
 210      */
 211      function finalize( &$package, &$http, &$persistentData )
 212      {
 213          $package->installItem( $this->InstallItem, $persistentData );
 214      }
 215  
 216  }
 217  ?>


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