[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of Translations class 4 // 5 // Created on: <23-ñÎ×-2003 12:52:42 sp> 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 translations.php 30 */ 31 32 include_once ( 'kernel/common/template.php' ); 33 include_once ( 'kernel/classes/ezcontentlanguage.php' ); 34 include_once ( 'kernel/classes/ezcontentobject.php' ); 35 include_once ( 'lib/ezdb/classes/ezdb.php' ); 36 37 $tpl =& templateInit(); 38 $http =& eZHTTPTool::instance(); 39 $Module =& $Params['Module']; 40 41 $tpl->setVariable( 'module', $Module ); 42 43 44 if ( $Module->isCurrentAction( 'New' ) /*or 45 $Module->isCurrentAction( 'Edit' )*/ ) 46 { 47 $tpl->setVariable( 'is_edit', $Module->isCurrentAction( 'Edit' ) ); 48 $Result['content'] =& $tpl->fetch( 'design:content/translationnew.tpl' ); 49 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/content', 'Translation' ), 50 'url' => false ), 51 array( 'text' => 'New', 52 'url' => false ) ); 53 return; 54 } 55 56 if ( $Module->isCurrentAction( 'StoreNew' ) /* || $http->hasPostVariable( 'StoreButton' ) */ ) 57 { 58 $localeID = $Module->actionParameter( 'LocaleID' ); 59 $translationName = ''; 60 $translationLocale = ''; 61 eZDebug::writeDebug( $localeID, 'localeID' ); 62 if ( $localeID != '' and 63 $localeID != -1 ) 64 { 65 $translationLocale = $localeID; 66 $localeInstance =& eZLocale::instance( $translationLocale ); 67 $translationName = $localeInstance->internationalLanguageName(); 68 } 69 else 70 { 71 $translationName = $Module->actionParameter( 'TranslationName' ); 72 $translationLocale = $Module->actionParameter( 'TranslationLocale' ); 73 eZDebug::writeDebug( $translationName, 'translationName' ); 74 eZDebug::writeDebug( $translationLocale, 'translationLocale' ); 75 } 76 77 include_once ( 'lib/ezlocale/classes/ezlocale.php' ); 78 // Make sure the locale string is valid, if not we try to extract a valid part of it 79 if ( !preg_match( "/^" . eZLocale::localeRegexp( false, false ) . "$/", $translationLocale ) ) 80 { 81 if ( preg_match( "/(" . eZLocale::localeRegexp( false, false ) . ")/", $translationLocale, $matches ) ) 82 { 83 $translationLocale = $matches[1]; 84 } 85 else 86 { 87 // The locale cannot be used so we show the edit page again. 88 $tpl->setVariable( 'is_edit', $Module->isCurrentAction( 'Edit' ) ); 89 $Result['content'] =& $tpl->fetch( 'design:content/translationnew.tpl' ); 90 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/content', 'Translation' ), 91 'url' => false ), 92 array( 'text' => 'New', 93 'url' => false ) ); 94 return; 95 } 96 } 97 98 if ( !eZContentLanguage::fetchByLocale( $translationLocale ) ) 99 { 100 $locale =& eZLocale::instance( $translationLocale ); 101 if ( $locale->isValid() ) 102 { 103 $translation = eZContentLanguage::addLanguage( $locale->localeCode(), $translationName ); 104 } 105 else 106 { 107 // The locale cannot be used so we show the edit page again. 108 $tpl->setVariable( 'is_edit', $Module->isCurrentAction( 'Edit' ) ); 109 $Result['content'] =& $tpl->fetch( 'design:content/translationnew.tpl' ); 110 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/content', 'Translation' ), 111 'url' => false ), 112 array( 'text' => 'New', 113 'url' => false ) ); 114 return; 115 } 116 } 117 } 118 119 if ( $Module->isCurrentAction( 'Remove' ) ) 120 { 121 $seletedIDList = $Module->actionParameter( 'SelectedTranslationList' ); 122 123 $db =& eZDB::instance(); 124 125 $db->begin(); 126 foreach ( $seletedIDList as $translationID ) 127 { 128 eZContentLanguage::removeLanguage( $translationID ); 129 } 130 $db->commit(); 131 } 132 133 134 if ( $Params['TranslationID'] ) 135 { 136 $translation = eZContentLanguage::fetch( $Params['TranslationID'] ); 137 138 if( !$translation ) 139 { 140 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 141 } 142 143 $tpl->setVariable( 'translation', $translation ); 144 145 $Result['content'] =& $tpl->fetch( 'design:content/translationview.tpl' ); 146 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/content', 'Content translations' ), 147 'url' => 'content/translations' ), 148 array( 'text' => $translation->attribute( 'name' ), 149 'url' => false ) ); 150 return; 151 } 152 153 $availableTranslations = eZContentLanguage::fetchList(); 154 155 $tpl->setVariable( 'available_translations', $availableTranslations ); 156 157 $Result['content'] =& $tpl->fetch( 'design:content/translations.tpl' ); 158 $Result['path'] = array( array( 'text' => ezi18n( 'kernel/content', 'Languages' ), 159 'url' => false ) ); 160 161 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |