00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 class eZPackageOperator
00041 {
00042
00043
00044
00045 function eZPackageOperator( $name = 'ezpackage' )
00046 {
00047 $this->Operators = array( $name );
00048 }
00049
00050
00051
00052
00053 function &operatorList()
00054 {
00055 return $this->Operators;
00056 }
00057
00058
00059
00060
00061 function namedParameterList()
00062 {
00063 return array( 'class' => array( 'type' => 'string',
00064 'required' => true,
00065 'default' => false ),
00066 'data' => array( 'type' => 'string',
00067 'required' => false,
00068 'default' => false ) );
00069 }
00070
00071
00072
00073
00074 function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters )
00075 {
00076 $package =& $operatorValue;
00077 $class = $namedParameters['class'];
00078 switch ( $class )
00079 {
00080 case 'thumbnail':
00081 {
00082 if ( get_class( $operatorValue ) == 'ezpackage' )
00083 {
00084 if ( !is_array( $fileList = $operatorValue->fileList( 'default' ) ) )
00085 $fileList = array();
00086 foreach ( array_keys( $fileList ) as $key )
00087 {
00088 $file =& $fileList[$key];
00089 $fileType = $file["type"];
00090 if ( $fileType == 'thumbnail' )
00091 {
00092 $operatorValue = $operatorValue->fileItemPath( $file, 'default' );
00093 return;
00094 }
00095 }
00096 $operatorValue = false;
00097 }
00098 } break;
00099
00100 case 'filepath':
00101 {
00102 if ( get_class( $operatorValue ) == 'ezpackage' )
00103 {
00104 $variableName = $namedParameters['data'];
00105 $fileList = $operatorValue->fileList( 'default' );
00106 foreach ( array_keys( $fileList ) as $key )
00107 {
00108 $file =& $fileList[$key];
00109 $fileIdentifier = $file["variable-name"];
00110 if ( $fileIdentifier == $variableName )
00111 {
00112 $operatorValue = $operatorValue->fileItemPath( $file, 'default' );
00113 return;
00114 }
00115 }
00116 $tpl->error( $operatorName,
00117 "No filepath found for variable $variableName in package " . $package->attribute( 'name' ) );
00118 $operatorValue = false;
00119 }
00120 } break;
00121
00122 case 'fileitempath':
00123 {
00124 if ( get_class( $operatorValue ) == 'ezpackage' )
00125 {
00126 $fileItem = $namedParameters['data'];
00127 $operatorValue = $operatorValue->fileItemPath( $fileItem, 'default' );
00128 }
00129 } break;
00130
00131 case 'documentpath':
00132 {
00133 if ( get_class( $package ) == 'ezpackage' )
00134 {
00135 $documentName = $namedParameters['data'];
00136 $documentList = $package->attribute( 'documents' );
00137 foreach ( array_keys( $documentList ) as $key )
00138 {
00139 $document =& $documentList[$key];
00140 $name = $document["name"];
00141 if ( $name == $documentName )
00142 {
00143 $documentFilePath = $package->path() . '/' . eZPackage::documentDirectory() . '/' . $document['name'];
00144 $operatorValue = $documentFilePath;
00145 return;
00146 }
00147 }
00148 $tpl->error( $operatorName,
00149 "No documentpath found for document $documentName in package " . $package->attribute( 'name' ) );
00150 $operatorValue = false;
00151 }
00152 } break;
00153
00154 case 'dirpath':
00155 {
00156 $dirPath = $operatorValue->currentRepositoryPath() . "/" . $operatorValue->attribute( 'name' );
00157 $operatorValue = $dirPath;
00158 } break;
00159
00160 default:
00161 $tpl->error( $operatorName, "Unknown package operator name: '$class'" );
00162 break;
00163 }
00164 }
00165
00166 var $Operators;
00167 };
00168
00169 ?>