[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/package/ -> upload.php (source)

   1  <?php
   2  //
   3  // Created on: <11-Aug-2003 18:12:39 amos>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  include_once ( "kernel/common/template.php" );
  28  include_once ( "kernel/classes/ezpackage.php" );
  29  include_once ( "lib/ezutils/classes/ezhttpfile.php" );
  30  
  31  $module =& $Params['Module'];
  32  
  33  if ( !eZPackage::canUsePolicyFunction( 'import' ) )
  34      return $module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' );
  35  
  36  $package = false;
  37  $installElements = false;
  38  $errorList = array();
  39  
  40  if ( $module->isCurrentAction( 'UploadPackage' ) )
  41  {
  42      if ( eZHTTPFile::canFetch( 'PackageBinaryFile' ) )
  43      {
  44          $file =& eZHTTPFile::fetch( 'PackageBinaryFile' );
  45          if ( $file )
  46          {
  47              $packageFilename = $file->attribute( 'filename' );
  48              $packageName = $file->attribute( 'original_filename' );
  49              if ( preg_match( "#^(.+)-[0-9](\.[0-9]+)-[0-9].ezpkg$#", $packageName, $matches ) )
  50                  $packageName = $matches[1];
  51              $packageName = preg_replace( array( "#[^a-zA-Z0-9]+#",
  52                                                  "#_+#",
  53                                                  "#(^_)|(_$)#" ),
  54                                           array( '_',
  55                                                  '_',
  56                                                  '' ), $packageName );
  57              $package =& eZPackage::import( $packageFilename, $packageName );
  58              if ( is_object( $package ) )
  59              {
  60                  if ( $package->attribute( 'install_type' ) != 'install' or
  61                       !$package->attribute( 'can_install' ) )
  62                  {
  63                      return $module->redirectToView( 'view', array( 'full', $package->attribute( 'name' ) ) );
  64                  }
  65                  else if ( $package->attribute( 'install_type' ) == 'install' )
  66                  {
  67                      return $module->redirectToView( 'install', array( $package->attribute( 'name' ) ) );
  68                  }
  69              }
  70              else if ( $package == EZ_PACKAGE_STATUS_ALREADY_EXISTS )
  71              {
  72                  $errorList[] = array( 'description' => ezi18n( 'kernel/package', 'Package %packagename already exists, cannot import the package', false, array( '%packagename' => $packageName ) ) );
  73              }
  74              else
  75                  eZDebug::writeError( "Uploaded file is not an eZ publish package" );
  76          }
  77          else
  78              eZDebug::writeError( "Failed fetching upload package file" );
  79      }
  80      else
  81      {
  82          eZDebug::writeError( "No uploaded package file was found" );
  83      }
  84  }
  85  else if ( $module->isCurrentAction( 'UploadCancel' ) )
  86  {
  87      $module->redirectToView( 'list' );
  88      return;
  89  }
  90  
  91  $tpl =& templateInit();
  92  
  93  $tpl->setVariable( 'package', $package );
  94  $tpl->setVariable( 'error_list', $errorList );
  95  
  96  $Result = array();
  97  $Result['content'] =& $tpl->fetch( "design:package/upload.tpl" );
  98  $Result['path'] = array( array( 'url' => 'package/list',
  99                                  'text' => ezi18n( 'kernel/package', 'Packages' ) ),
 100                           array( 'url' => false,
 101                                  'text' => ezi18n( 'kernel/package', 'Upload' ) ) );
 102  
 103  ?>


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