[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <08-Jan-2003 16:36:23 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/classes/ezcontentclass.php" ); 28 include_once ( "kernel/classes/ezcontentclassattribute.php" ); 29 include_once ( "kernel/classes/ezcontentclassclassgroup.php" ); 30 31 $Module =& $Params["Module"]; 32 $ClassID = null; 33 if ( isset( $Params["ClassID"] ) ) 34 $ClassID = $Params["ClassID"]; 35 $class = eZContentClass::fetch( $ClassID, true, 0 ); 36 if ( !$class ) 37 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE ); 38 39 $classCopy = $class->clone(); 40 $classCopy->initializeCopy( $class ); 41 $classCopy->setAttribute( 'version', 1 ); 42 $classCopy->store(); 43 44 $mainGroupID = false; 45 $classGroups = eZContentClassClassGroup::fetchGroupList( $class->attribute( 'id' ), 46 $class->attribute( 'version' ) ); 47 for ( $i = 0; $i < count( $classGroups ); ++$i ) 48 { 49 $classGroup =& $classGroups[$i]; 50 $classGroup->setAttribute( 'contentclass_id', $classCopy->attribute( 'id' ) ); 51 $classGroup->setAttribute( 'contentclass_version', $classCopy->attribute( 'version' ) ); 52 $classGroup->store(); 53 if ( $mainGroupID === false ) 54 $mainGroupID = $classGroup->attribute( 'group_id' ); 55 } 56 57 $classAttributeCopies = array(); 58 $classAttributes =& $class->fetchAttributes(); 59 foreach ( array_keys( $classAttributes ) as $classAttributeKey ) 60 { 61 $classAttribute =& $classAttributes[$classAttributeKey]; 62 $classAttributeCopy = $classAttribute->clone(); 63 64 if ( $datatype = $classAttributeCopy->dataType() ) //avoiding fatal error if datatype not exist (was removed). 65 { 66 $datatype->cloneClassAttribute( $classAttribute, $classAttributeCopy ); 67 } 68 else 69 { 70 continue; 71 } 72 73 $classAttributeCopy->setAttribute( 'contentclass_id', $classCopy->attribute( 'id' ) ); 74 $classAttributeCopy->setAttribute( 'version', 1 ); 75 $classAttributeCopy->store(); 76 $classAttributeCopies[] =& $classAttributeCopy; 77 unset( $classAttributeCopy ); 78 } 79 80 $ini =& eZINI::instance( 'content.ini' ); 81 $classRedirect = strtolower( trim( $ini->variable( 'CopySettings', 'ClassRedirect' ) ) ); 82 83 switch ( $classRedirect ) 84 { 85 case 'grouplist': 86 { 87 $classCopy->storeDefined( $classAttributeCopies ); 88 return $Module->redirectToView( 'grouplist', array() ); 89 } break; 90 91 case 'classlist': 92 { 93 $classCopy->storeDefined( $classAttributeCopies ); 94 return $Module->redirectToView( 'classlist', array( $mainGroupID ) ); 95 } break; 96 97 case 'classview': 98 { 99 $classCopy->storeDefined( $classAttributeCopies ); 100 return $Module->redirectToView( 'view', array( $classCopy->attribute( 'id' ) ) ); 101 } break; 102 103 default: 104 { 105 eZDebug::writeWarning( "Invalid ClassRedirect value '$classRedirect', use one of: grouplist, classlist, classedit or classview" ); 106 } 107 108 case 'classedit': 109 { 110 return $Module->redirectToView( 'edit', array( $classCopy->attribute( 'id' ) ) ); 111 } break; 112 } 113 114 ?>
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 |