[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <20-mar-2005 13:37:23 jk> 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( 'NodeID' ) ) 30 { 31 eZDebug::writeError( 'Missing NodeID parameter for action ' . $module->currentAction(), 32 'content/translation' ); 33 return $module->redirectToView( 'view', array( 'full', 2 ) ); 34 } 35 36 $nodeID = $module->actionParameter( 'NodeID' ); 37 38 if ( !$module->hasActionParameter( 'LanguageCode' ) ) 39 { 40 eZDebug::writeError( 'Missing LanguageCode parameter for action ' . $module->currentAction(), 41 'content/translation' ); 42 return $module->redirectToView( 'view', array( 'full', 2 ) ); 43 } 44 45 $languageCode = $module->actionParameter( 'LanguageCode' ); 46 47 $viewMode = 'full'; 48 if ( !$module->hasActionParameter( 'ViewMode' ) ) 49 { 50 $viewMode = $module->actionParameter( 'ViewMode' ); 51 } 52 53 if ( $module->isCurrentAction( 'Cancel' ) ) 54 { 55 return $module->redirectToView( 'view', array( $viewMode, $nodeID, $languageCode ) ); 56 } 57 58 if ( !$module->hasActionParameter( 'ObjectID' ) ) 59 { 60 eZDebug::writeError( 'Missing ObjectID parameter for action ' . $module->currentAction(), 'content/translation' ); 61 return $module->redirectToView( 'view', array( 'full', 2 ) ); 62 } 63 $objectID = $module->actionParameter( 'ObjectID' ); 64 65 66 $object =& eZContentObject::fetch( $objectID ); 67 68 if ( !$object ) 69 { 70 return $module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 71 } 72 73 if ( $module->isCurrentAction( 'UpdateInitialLanguage' ) ) 74 { 75 if ( $module->hasActionParameter( 'InitialLanguageID' ) ) 76 { 77 $newInitialLanguageID = $module->actionParameter( 'InitialLanguageID' ); 78 79 if ( !$object->canEdit() ) 80 { 81 return $module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel', array() ); 82 } 83 84 include_once ( 'kernel/classes/ezcontentlanguage.php' ); 85 $language = eZContentLanguage::fetch( $newInitialLanguageID ); 86 if ( $language && !$language->attribute( 'disabled' ) ) 87 { 88 $object->setAttribute( 'initial_language_id', $newInitialLanguageID ); 89 $objectName = $object->name( false, $language->attribute( 'locale' ) ); 90 $object->setAttribute( 'name', $objectName ); 91 $object->store(); 92 93 if ( $object->isAlwaysAvailable() ) 94 { 95 $object->setAlwaysAvailableLanguageID( $newInitialLanguageID ); 96 } 97 98 $nodes =& $object->assignedNodes(); 99 foreach ( $nodes as $node ) 100 { 101 $node->updateSubTreePath(); 102 } 103 104 include_once ( 'kernel/classes/ezcontentcachemanager.php' ); 105 eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); 106 } 107 } 108 109 return $module->redirectToView( 'view', array( $viewMode, $nodeID, $languageCode ) ); 110 } 111 else if ( $module->isCurrentAction( 'UpdateAlwaysAvailable' ) ) 112 { 113 if ( !$object->canEdit() ) 114 { 115 return $module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel', array() ); 116 } 117 118 $newAlwaysAvailable = $module->hasActionParameter( 'AlwaysAvailable' ); 119 120 include_once ( 'kernel/classes/ezcontentcachemanager.php' ); 121 122 if ( $object->isAlwaysAvailable() & $newAlwaysAvailable == false ) 123 { 124 $object->setAlwaysAvailableLanguageID( false ); 125 eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); 126 } 127 else if ( !$object->isAlwaysAvailable() & $newAlwaysAvailable == true ) 128 { 129 $object->setAlwaysAvailableLanguageID( $object->attribute( 'initial_language_id' ) ); 130 eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); 131 } 132 133 return $module->redirectToView( 'view', array( $viewMode, $nodeID, $languageCode ) ); 134 } 135 else if ( $module->isCurrentAction( 'RemoveTranslation' ) ) 136 { 137 if ( !$module->hasActionParameter( 'LanguageID' ) ) 138 { 139 return $module->redirectToView( 'view', array( $viewMode, $nodeID, $languageCode ) ); 140 } 141 142 $languageIDArray = $module->actionParameter( 'LanguageID' ); 143 144 if ( $module->hasActionParameter( 'ConfirmRemoval' ) && $module->actionParameter( 'ConfirmRemoval' ) ) 145 { 146 foreach( $languageIDArray as $languageID ) 147 { 148 if ( !$object->removeTranslation( $languageID ) ) 149 { 150 eZDebug::writeError( "Object with id $objectID: cannot remove the translation with language id $languageID!", 'content/translation' ); 151 } 152 } 153 154 include_once ( 'kernel/content/ezcontentoperationcollection.php' ); 155 eZContentOperationCollection::registerSearchObject( $object->attribute( 'id' ), $object->attribute( 'current_version' ) ); 156 157 include_once ( 'kernel/classes/ezcontentcachemanager.php' ); 158 eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); 159 160 return $module->redirectToView( 'view', array( $viewMode, $nodeID, $languageCode ) ); 161 } 162 163 include_once ( 'kernel/classes/ezcontentlanguage.php' ); 164 165 $languages = array(); 166 foreach( $languageIDArray as $languageID ) 167 { 168 $language = eZContentLanguage::fetch( $languageID ); 169 if ( $language ) 170 { 171 $languages[] = $language; 172 } 173 } 174 175 if ( !$languages ) 176 { 177 return $module->redirectToView( 'view', array( $viewMode, $nodeID, $languageCode ) ); 178 } 179 180 include_once ( "kernel/common/template.php" ); 181 182 $tpl =& templateInit(); 183 184 $tpl->setVariable( 'object_id', $objectID ); 185 $tpl->setVariable( 'object', $object ); 186 $tpl->setVariable( 'node_id', $nodeID ); 187 $tpl->setVariable( 'language_code', $languageCode ); 188 $tpl->setVariable( 'languages', $languages ); 189 $tpl->setVariable( 'view_mode', $viewMode ); 190 191 $Result = array(); 192 $Result['content'] =& $tpl->fetch( 'design:content/removetranslation.tpl' ); 193 $Result['path'] = array( array( 'url' => false, 194 'text' => ezi18n( 'kernel/content', 'Remove translation' ) ) ); 195 196 return; 197 } 198 199 return $module->redirectToView( 'view', array( 'full', 2 ) ); 200 201 ?>
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 |