| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <07-Jul-2003 13:42:06 jhe> 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 include_once ( "kernel/common/template.php" ); 30 include_once ( "kernel/common/eztemplatedesignresource.php" ); 31 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 32 33 $ini =& eZINI::instance(); 34 $tpl =& templateInit(); 35 36 $steps = array( 'basic' => array( 'template' => 'datatype_basic.tpl', 37 'function' => 'datatypeBasic' ), 38 'describe' => array( 'pre_function' => 'datatypeBasicFetchData', 39 'template' => 'datatype_describe.tpl', 40 'function' => 'datatypeDescribe' ), 41 'download' => array( 'pre_function' => 'datatypeDescribeFetchData', 42 'function' => 'datatypeDownload' ) ); 43 44 $template = 'datatype.tpl'; 45 46 $http =& eZHTTPTool::instance(); 47 48 $persistentData = array(); 49 if ( $http->hasPostVariable( 'PersistentData' ) ) 50 $persistentData = $http->postVariable( 'PersistentData' ); 51 52 $currentStep = false; 53 if ( $http->hasPostVariable( 'OperatorStep' ) and 54 $http->hasPostVariable( 'DatatypeStepButton' ) ) 55 { 56 $step = $http->postVariable( 'OperatorStep' ); 57 if ( isset( $steps[$step] ) ) 58 { 59 $currentStep = $steps[$step]; 60 $currentStep['name'] = $step; 61 } 62 } 63 64 if ( $http->hasPostVariable( 'DatatypeRestartButton' ) ) 65 { 66 $currentStep = false; 67 $persistentData = array(); 68 } 69 70 if ( $currentStep ) 71 { 72 if ( isset( $currentStep['pre_function'] ) ) 73 { 74 $preFunctionName = $currentStep['pre_function']; 75 if ( function_exists( $preFunctionName ) ) 76 $preFunctionName( $tpl, $persistentData ); 77 else 78 eZDebug::writeWarning( 'Unknown pre step function ' . $preFunctionName ); 79 } 80 if ( isset( $currentStep['function'] ) ) 81 { 82 $functionName = $currentStep['function']; 83 if ( function_exists( $functionName ) ) 84 $functionName( $tpl, $persistentData, $currentStep ); 85 else 86 eZDebug::writeWarning( 'Unknown step function ' . $functionName ); 87 } 88 if ( isset( $currentStep['template'] ) ) 89 $template = $currentStep['template']; 90 } 91 92 $tpl->setVariable( 'persistent_data', $persistentData ); 93 94 $Result = array(); 95 $Result['content'] =& $tpl->fetch( "design:setup/$template" ); 96 $Result['path'] = array( array( 'url' => false, 97 'text' => ezi18n( 'kernel/setup', 'Datatype wizard' ) ) ); 98 99 100 function datatypeBasic( &$tpl, &$persistentData, $stepData ) 101 { 102 } 103 104 function datatypeBasicFetchData( &$tpl, &$persistentData ) 105 { 106 $http =& eZHTTPTool::instance(); 107 $datatypeName = false; 108 if ( $http->hasPostVariable( 'Name' ) ) 109 $datatypeName = $http->postVariable( 'Name' ); 110 $parameterCheck = false; 111 if ( $http->hasPostVariable( 'DescName' ) ) 112 $descName = $http->postVariable( 'DescName' ); 113 $classInput = false; 114 if ( $http->hasPostVariable( 'ClassInput' ) ) 115 $classInput = true; 116 117 $datatypeName = preg_replace( array( "#([a-z])([A-Z])#", 118 "#__+#", 119 "#(^_|_$)#" ), 120 array( '$1_$2', 121 '_', 122 '' ), 123 $datatypeName ); 124 $datatypeName = strtolower( $datatypeName ); 125 126 if ( substr( $datatypeName, 0, 2 ) != "ez" ) 127 $extensionName = "ez" . $datatypeName; 128 129 $persistentData['extension-name'] = $extensionName; 130 $persistentData['name'] = $datatypeName; 131 $persistentData['class-input'] = $classInput; 132 $persistentData['desc-name'] = $descName; 133 } 134 135 function datatypeDescribe( &$tpl, &$persistentData, $stepData ) 136 { 137 $datatypeName = $persistentData['name']; 138 $classInput = $persistentData['class-input']; 139 $descName = $persistentData['desc-name']; 140 141 if ( substr( $datatypeName, 0, 2 ) != "ez" ) 142 $fullClassName = "ez" . $datatypeName; 143 144 $persistentData['datatype-name'] = $fullClassName; 145 146 if ( substr( $datatypeName, -4 ) != "type" ) 147 $fullClassName .= "type"; 148 149 $constantName = "EZ_DATATYPESTRING_" . strtoupper( $datatypeName ); 150 151 $tpl->setVariable( 'class_name', $fullClassName ); 152 $tpl->setVariable( 'datatype_name', $datatypeName ); 153 $tpl->setVariable( 'constant_name', $constantName ); 154 $tpl->setVariable( 'class_input', $classInput ); 155 $tpl->setVariable( 'desc-name', $descName ); 156 } 157 158 function datatypeDescribeFetchData( &$tpl, &$persistentData ) 159 { 160 $http =& eZHTTPTool::instance(); 161 $className = false; 162 if ( $http->hasPostVariable( 'ClassName' ) ) 163 $className = $http->postVariable( 'ClassName' ); 164 $constantName= false; 165 if ( $http->hasPostVariable( 'ConstantName' ) ) 166 $constantName = $http->postVariable( 'ConstantName' ); 167 $creatorName = false; 168 if ( $http->hasPostVariable( 'CreatorName' ) ) 169 $creatorName = $http->postVariable( 'CreatorName' ); 170 $description = false; 171 if ( $http->hasPostVariable( 'Description' ) ) 172 $description = $http->postVariable( 'Description' ); 173 174 $persistentData['class-name'] = $className; 175 $persistentData['constant-name'] = $constantName; 176 $persistentData['creator-name'] = $creatorName; 177 $persistentData['description'] = $description; 178 } 179 180 function datatypeDownload( &$tpl, &$persistentData, $stepData ) 181 { 182 $datatypeName = $persistentData['name']; 183 $classInput = $persistentData['class-input']; 184 $descName = $persistentData['desc-name']; 185 $className = $persistentData['class-name']; 186 $constantName = $persistentData['constant-name']; 187 $creator = $persistentData['creator-name']; 188 $description = $persistentData['description']; 189 $datatypeName = $persistentData['datatype-name']; 190 191 $filename = strtolower( $className ) . '.php'; 192 193 $brief = ''; 194 $full = ''; 195 $lines = explode( "\n", $description ); 196 if ( count( $lines ) > 0 ) 197 { 198 $brief = $lines[0]; 199 $full = implode( "\n", array_slice( $lines, 1 ) ); 200 } 201 202 $tpl->setVariable( 'full_class_name', $className ); 203 $tpl->setVariable( 'constant_name', $constantName ); 204 $tpl->setVariable( 'datatype_name', $datatypeName ); 205 $tpl->setVariable( 'desc_name', $descName ); 206 $tpl->setVariable( 'file_name', $filename ); 207 $tpl->setVariable( 'creator_name', $creator ); 208 $tpl->setVariable( 'description_brief', $brief ); 209 $tpl->setVariable( 'description_full', $full ); 210 $tpl->setVariable( 'class_input', $classInput ); 211 212 $content = $tpl->fetch( 'design:setup/datatype_code.tpl' ); 213 214 $contentLength = strlen( $content ); 215 $mimeType = 'application/octet-stream'; 216 217 include_once ( 'lib/version.php' ); 218 $version = eZPublishSDK::version(); 219 220 header( "Pragma: " ); 221 header( "Cache-Control: " ); 222 header( "Content-Length: $contentLength" ); 223 header( "Content-Type: $mimeType" ); 224 header( "X-Powered-By: eZ publish $version" ); 225 header( "Content-Disposition: attachment; filename=$filename" ); 226 header( "Content-Transfer-Encoding: binary" ); 227 ob_end_clean(); 228 print( $content ); 229 fflush(); 230 eZExecution::cleanExit(); 231 } 232 233 ?>
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 |