[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <21-May-2003 14:49:27 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 $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 /* 37 - Name 38 - Single operator or multiple (single default) 39 - Parameter type (no, named, sequential, custom - no default) 40 - Input (yes or not, yes default) 41 - Output (yes or no, yes default) 42 43 - Class name (optional, auto created from name) 44 - Description (optional) 45 - Creator (optional) 46 - Example code(optional) 47 48 */ 49 50 $steps = array( 'basic' => array( 'template' => 'templateoperator_basic.tpl', 51 'function' => 'templateOperatorBasic' ), 52 'describe' => array( 'pre_function' => 'templateOperatorBasicFetchData', 53 'template' => 'templateoperator_describe.tpl', 54 'function' => 'templateOperatorDescribe' ), 55 'download' => array( 'pre_function' => 'templateOperatorDescribeFetchData', 56 'function' => 'templateOperatorDownload' ) ); 57 58 $template = 'templateoperator.tpl'; 59 60 $http =& eZHTTPTool::instance(); 61 62 $persistentData = array(); 63 if ( $http->hasPostVariable( 'PersistentData' ) ) 64 $persistentData = $http->postVariable( 'PersistentData' ); 65 66 $currentStep = false; 67 if ( $http->hasPostVariable( 'OperatorStep' ) and 68 $http->hasPostVariable( 'TemplateOperatorStepButton' ) ) 69 { 70 $step = $http->postVariable( 'OperatorStep' ); 71 if ( isset( $steps[$step] ) ) 72 { 73 $currentStep = $steps[$step]; 74 $currentStep['name'] = $step; 75 } 76 } 77 78 if ( $http->hasPostVariable( 'TemplateOperatorRestartButton' ) ) 79 { 80 $currentStep = false; 81 $persistentData = array(); 82 } 83 84 if ( $currentStep ) 85 { 86 if ( isset( $currentStep['pre_function'] ) ) 87 { 88 $preFunctionName = $currentStep['pre_function']; 89 if ( function_exists( $preFunctionName ) ) 90 $preFunctionName( $tpl, $persistentData ); 91 else 92 eZDebug::writeWarning( 'Unknown pre step function ' . $preFunctionName ); 93 } 94 if ( isset( $currentStep['function'] ) ) 95 { 96 $functionName = $currentStep['function']; 97 if ( function_exists( $functionName ) ) 98 $functionName( $tpl, $persistentData, $currentStep ); 99 else 100 eZDebug::writeWarning( 'Unknown step function ' . $functionName ); 101 } 102 if ( isset( $currentStep['template'] ) ) 103 $template = $currentStep['template']; 104 } 105 106 $tpl->setVariable( 'persistent_data', $persistentData ); 107 108 $Result = array(); 109 $Result['content'] =& $tpl->fetch( "design:setup/$template" ); 110 $Result['path'] = array( array( 'url' => false, 111 'text' => ezi18n( 'kernel/setup', 'Template operator wizard' ) ) ); 112 113 114 function templateOperatorBasic( &$tpl, &$persistentData, $stepData ) 115 { 116 } 117 118 function templateOperatorBasicFetchData( &$tpl, &$persistentData ) 119 { 120 $http =& eZHTTPTool::instance(); 121 $operatorName = false; 122 if ( $http->hasPostVariable( 'Name' ) ) 123 $operatorName = $http->postVariable( 'Name' ); 124 $singleOperator = false; 125 if ( $http->hasPostVariable( 'SingleOperatorCheck' ) ) 126 $singleOperator = true; 127 $useInput = false; 128 if ( $http->hasPostVariable( 'InputCheck' ) ) 129 $useInput = true; 130 $useOutput = false; 131 if ( $http->hasPostVariable( 'OutputCheck' ) ) 132 $useOutput = true; 133 $parameterCheck = 1; 134 if ( $http->hasPostVariable( 'Parameter' ) ) 135 $parameterCheck = $http->postVariable( 'Parameter' ); 136 137 $operatorName = preg_replace( array( "#([a-z])([A-Z])#", 138 "#__+#", 139 "#(^_|_$)#" ), 140 array( '$1_$2', 141 '_', 142 '' ), 143 $operatorName ); 144 $operatorName = strtolower( $operatorName ); 145 146 $persistentData['name'] = $operatorName; 147 $persistentData['single-operator'] = $singleOperator; 148 $persistentData['use-input'] = $useInput; 149 $persistentData['use-output'] = $useOutput; 150 $persistentData['parameter-check'] = $parameterCheck; 151 } 152 153 function templateOperatorDescribe( &$tpl, &$persistentData, $stepData ) 154 { 155 $operatorName = $persistentData['name']; 156 $fullClassName = 'Template' . strtoupper( $operatorName[0] ) . substr( $operatorName, 1 ) . 'Operator'; 157 158 $singleOperator = $persistentData['single-operator']; 159 $useInput = $persistentData['use-input']; 160 $useOutput = $persistentData['use-output']; 161 $parameterCheck = $persistentData['parameter-check']; 162 $exampleCode = '{'; 163 if ( $useInput ) 164 $exampleCode .= "\$value|"; 165 $exampleCode .= $operatorName; 166 if ( $parameterCheck != 1 ) 167 $exampleCode .= '(\'first\',$input2)'; 168 else if ( !$useInput and !$useOutput ) 169 $exampleCode .= '()'; 170 if ( $useOutput ) 171 $exampleCode .= "|wash"; 172 $exampleCode .= '}'; 173 174 $tpl->setVariable( 'class_name', $fullClassName ); 175 $tpl->setVariable( 'example_code', $exampleCode ); 176 $tpl->setVariable( 'operator_name', $operatorName ); 177 $tpl->setVariable( 'single_operator', $singleOperator ); 178 $tpl->setVariable( 'use_input', $useInput ); 179 $tpl->setVariable( 'use_output', $useOutput ); 180 $tpl->setVariable( 'parameter_check', $parameterCheck ); 181 } 182 183 function templateOperatorDescribeFetchData( &$tpl, &$persistentData ) 184 { 185 $http =& eZHTTPTool::instance(); 186 $className = false; 187 if ( $http->hasPostVariable( 'ClassName' ) ) 188 $className = $http->postVariable( 'ClassName' ); 189 $description = false; 190 if ( $http->hasPostVariable( 'Description' ) ) 191 $description = $http->postVariable( 'Description' ); 192 $creatorName = false; 193 if ( $http->hasPostVariable( 'CreatorName' ) ) 194 $creatorName = $http->postVariable( 'CreatorName' ); 195 $exampleCode = false; 196 if ( $http->hasPostVariable( 'ExampleCode' ) ) 197 $exampleCode = $http->postVariable( 'ExampleCode' ); 198 199 $persistentData['class-name'] = $className; 200 $persistentData['description'] = $description; 201 $persistentData['creator-name'] = $creatorName; 202 $persistentData['example-code'] = $exampleCode; 203 } 204 205 function templateOperatorDownload( &$tpl, &$persistentData, $stepData ) 206 { 207 $singleOperator = $persistentData['single-operator']; 208 $useInput = $persistentData['use-input']; 209 $useOutput = $persistentData['use-output']; 210 $parameterCheck = $persistentData['parameter-check']; 211 $useInput = true; 212 $useOutput = false; 213 $parameterCheck = 2; 214 215 $operatorName = $persistentData['name']; 216 $className = $persistentData['class-name']; 217 if ( !$className ) 218 $fullClassName = 'Template' . strtoupper( $operatorName[0] ) . substr( $operatorName, 1 ) . 'Operator'; 219 else 220 $fullClassName = $className; 221 $filename = strtolower( $fullClassName ) . '.php'; 222 223 $description = $persistentData['description']; 224 $creator = $persistentData['creator-name']; 225 $example = $persistentData['example-code']; 226 227 $brief = ''; 228 $full = ''; 229 $lines = explode( "\n", $description ); 230 if ( count( $lines ) > 0 ) 231 { 232 $brief = $lines[0]; 233 $full = implode( "\n", array_slice( $lines, 1 ) ); 234 } 235 236 $tpl->setVariable( 'full_class_name', $fullClassName ); 237 $tpl->setVariable( 'class_name', $className ); 238 $tpl->setVariable( 'file_name', $filename ); 239 $tpl->setVariable( 'operator_name', $operatorName ); 240 $tpl->setVariable( 'example_code', $example ); 241 $tpl->setVariable( 'creator_name', $creator ); 242 $tpl->setVariable( 'description_brief', $brief ); 243 $tpl->setVariable( 'description_full', $full ); 244 245 $tpl->setVariable( 'single_operator', $singleOperator ); 246 $tpl->setVariable( 'use_input', $useInput ); 247 $tpl->setVariable( 'use_output', $useOutput ); 248 $tpl->setVariable( 'parameter_check', $parameterCheck ); 249 250 $content = $tpl->fetch( 'design:setup/templateoperator_code.tpl' ); 251 252 $contentLength = strlen( $content ); 253 $mimeType = 'application/octet-stream'; 254 255 include_once ( 'lib/version.php' ); 256 $version = eZPublishSDK::version(); 257 258 header( "Pragma: " ); 259 header( "Cache-Control: " ); 260 header( "Content-Length: $contentLength" ); 261 header( "Content-Type: $mimeType" ); 262 header( "X-Powered-By: eZ publish $version" ); 263 header( "Content-Disposition: attachment; filename=$filename" ); 264 header( "Content-Transfer-Encoding: binary" ); 265 ob_end_clean(); 266 print( $content ); 267 fflush(); 268 eZExecution::cleanExit(); 269 } 270 271 ?>
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 |