[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZContentClassPackageCreator class 4 // 5 // Created on: <21-Nov-2003 12:39:59 amos> 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 ezcontentclasspackagecreator.php 30 */ 31 32 /*! 33 \ingroup package 34 \class eZContentClassPackageCreator ezcontentclasspackagecreator.php 35 \brief A package creator for content classes 36 37 */ 38 39 include_once ( 'kernel/classes/ezpackagecreationhandler.php' ); 40 41 class eZContentClassPackageCreator extends eZPackageCreationHandler 42 { 43 /*! 44 \reimp 45 */ 46 function eZContentClassPackageCreator( $id ) 47 { 48 $steps = array(); 49 $steps[] = array( 'id' => 'class', 50 'name' => ezi18n( 'kernel/package', 'Content classes to include' ), 51 'methods' => array( 'initialize' => 'initializeClassData', 52 'validate' => 'validateClassData', 53 'commit' => 'commitClassData' ), 54 'template' => 'class.tpl' ); 55 $steps[] = $this->packageInformationStep(); 56 $steps[] = $this->packageMaintainerStep(); 57 $steps[] = $this->packageChangelogStep(); 58 $this->eZPackageCreationHandler( $id, 59 ezi18n( 'kernel/package', 'Content class export' ), 60 $steps ); 61 } 62 63 /*! 64 \reimp 65 Creates the package and adds the selected content classes. 66 */ 67 function finalize( &$package, &$http, &$persistentData ) 68 { 69 $this->createPackage( $package, $http, $persistentData, $cleanupFiles ); 70 71 $classHandler = eZPackage::packageHandler( 'ezcontentclass' ); 72 $classList = $persistentData['classlist']; 73 foreach ( $classList as $classID ) 74 { 75 $classHandler->addClass( $package, $classID ); 76 } 77 $package->setAttribute( 'is_active', true ); 78 $package->store(); 79 } 80 81 /*! 82 \reimp 83 Returns \c 'stable', content class packages are always stable. 84 */ 85 function packageInitialState( &$package, &$persistentData ) 86 { 87 return 'stable'; 88 } 89 90 /*! 91 \return \c 'contentclass'. 92 */ 93 function packageType( &$package, &$persistentData ) 94 { 95 return 'contentclass'; 96 } 97 98 function initializeClassData( &$package, &$http, $step, &$persistentData, &$tpl ) 99 { 100 } 101 102 /*! 103 Checks if at least one content class has been selected. 104 */ 105 function validateClassData( &$package, &$http, $currentStepID, &$stepMap, &$persistentData, &$errorList ) 106 { 107 $classList = array(); 108 if ( $http->hasPostVariable( 'ClassList' ) ) 109 $classList = $http->postVariable( 'ClassList' ); 110 111 $persistentData['classlist'] = $classList; 112 113 $result = true; 114 if ( count( $classList ) == 0 ) 115 { 116 $errorList[] = array( 'field' => ezi18n( 'kernel/package', 'Class list' ), 117 'description' => ezi18n( 'kernel/package', 'You must select at least one class for inclusion' ) ); 118 $result = false; 119 } 120 return $result; 121 } 122 123 function commitClassData( &$package, &$http, $step, &$persistentData, &$tpl ) 124 { 125 } 126 127 /*! 128 \reimp 129 Fetches the selected content classes and generates a name, summary and description from the selection. 130 */ 131 function generatePackageInformation( &$packageInformation, &$package, &$http, $step, &$persistentData ) 132 { 133 $classList = $persistentData['classlist']; 134 135 if ( count( $classList ) == 1 ) 136 { 137 $classID = $classList[0]; 138 $class = eZContentClass::fetch( $classID ); 139 if ( $class ) 140 { 141 $packageInformation['name'] = $class->attribute( 'name' ); 142 $packageInformation['summary'] = 'Export of content class ' . $class->attribute( 'name' ); 143 $packageInformation['description'] = 'This package contains an exported definition of the content class ' . $class->attribute( 'name' ) . ' which can be imported to another eZ publish site'; 144 } 145 } 146 else if ( count( $classList ) > 1 ) 147 { 148 $classNames = array(); 149 foreach ( $classList as $classID ) 150 { 151 $class = eZContentClass::fetch( $classID ); 152 if ( $class ) 153 { 154 $classNames[] = $class->attribute( 'name' ); 155 } 156 } 157 $packageInformation['name'] = count( $classList ) . ' Classes'; 158 $packageInformation['summary'] = 'Export of ' . count( $classList ) . ' content classes'; 159 $description = 'This package contains exported definitions of the following content classes:' . "\n"; 160 foreach ( $classNames as $className ) 161 { 162 $description .= '- ' . $className . "\n"; 163 } 164 $packageInformation['description'] = $description; 165 } 166 } 167 } 168 169 ?>
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 |