[ Index ]
 

Code source de eZ Publish 3.9.0

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

title

Body

[fermer]

/kernel/class/ -> translation.php (source)

   1  <?php
   2  //
   3  // Created on: <02-Oct-2006 13:37:23 dl>
   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  $module =& $Params['Module'];
  28  
  29  if ( !$module->hasActionParameter( 'ClassID' ) )
  30  {
  31      eZDebug::writeError( 'Missing ClassID parameter for action ' . $module->currentAction(),
  32                           'class/translation' );
  33      return $module->redirectToView( 'grouplist' );
  34  }
  35  
  36  $classID = $module->actionParameter( 'ClassID' );
  37  
  38  if ( !$module->hasActionParameter( 'LanguageCode' ) )
  39  {
  40      eZDebug::writeError( 'Missing LanguageCode parameter for action ' . $module->currentAction(),
  41                           'class/translation' );
  42      return $module->redirectToView( 'view', array( $classID ) );
  43  }
  44  
  45  $languageCode = $module->actionParameter( 'LanguageCode' );
  46  
  47  if ( $module->isCurrentAction( 'Cancel' ) )
  48  {
  49      return $module->redirectToView( 'view', array( $classID ), array( 'Language' => $languageCode ) );
  50  }
  51  
  52  $class = eZContentClass::fetch( $classID );
  53  
  54  if ( !$class )
  55  {
  56      return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' );
  57  }
  58  
  59  if ( $module->isCurrentAction( 'UpdateInitialLanguage' ) )
  60  {
  61      if ( $module->hasActionParameter( 'InitialLanguageID' ) )
  62      {
  63          $newInitialLanguageID = $module->actionParameter( 'InitialLanguageID' );
  64  
  65          include_once ( 'kernel/classes/ezcontentlanguage.php' );
  66          $language = eZContentLanguage::fetch( $newInitialLanguageID );
  67          if ( $language )
  68          {
  69              $class->setAttribute( 'initial_language_id', $newInitialLanguageID );
  70              $class->setAlwaysAvailableLanguageID( $newInitialLanguageID );
  71          }
  72      }
  73  
  74      return $module->redirectToView( 'view', array( $classID ), array( 'Language' => $languageCode ) );
  75  }
  76  else if ( $module->isCurrentAction( 'RemoveTranslation' ) )
  77  {
  78      if ( !$module->hasActionParameter( 'LanguageID' ) )
  79      {
  80          return $module->redirectToView( 'view', array( $classID ), array( 'Language' => $languageCode ) );
  81      }
  82  
  83      $languageIDArray = $module->actionParameter( 'LanguageID' );
  84  
  85      if ( $module->hasActionParameter( 'ConfirmRemoval' ) && $module->actionParameter( 'ConfirmRemoval' ) )
  86      {
  87          foreach( $languageIDArray as $languageID )
  88          {
  89              if ( !$class->removeTranslation( $languageID ) )
  90              {
  91                  eZDebug::writeError( "Class with id " . $class->attribute( 'id' ) . ": cannot remove the translation with language id $languageID!", 'class/translation' );
  92              }
  93          }
  94  
  95          //probably we've just removed translation we were viewing.
  96          if ( !$class->hasNameInLanguage( $languageCode ) )
  97              $languageCode = $class->alwaysAvailableLanguageLocale();
  98  
  99          return $module->redirectToView( 'view', array( $classID ), array( 'Language' => $languageCode ) );
 100      }
 101  
 102      include_once ( 'kernel/classes/ezcontentlanguage.php' );
 103  
 104      $languages = array();
 105      foreach( $languageIDArray as $languageID )
 106      {
 107          $language = eZContentLanguage::fetch( $languageID );
 108          if ( $language )
 109          {
 110              $languages[] = $language;
 111          }
 112      }
 113  
 114      if ( !$languages )
 115      {
 116          return $module->redirectToView( 'view', array( $classID ), array( $languageCode ) );
 117      }
 118  
 119      include_once ( "kernel/common/template.php" );
 120  
 121      $tpl =& templateInit();
 122  
 123      $tpl->setVariable( 'class_id', $classID );
 124      $tpl->setVariable( 'class', $class );
 125      $tpl->setVariable( 'language_code', $languageCode );
 126      $tpl->setVariable( 'languages', $languages );
 127  
 128      $Result = array();
 129      $Result['content'] =& $tpl->fetch( 'design:class/removetranslation.tpl' );
 130      $Result['path'] = array( array( 'url' => false,
 131                                      'text' => ezi18n( 'kernel/class', 'Remove translation' ) ) );
 132  
 133      return;
 134  }
 135  
 136  
 137  
 138  
 139  
 140  ?>


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