|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZPackageoperator class 00004 // 00005 // Created on: <16-Oct-2003 10:51:28 wy> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezpackageoperator.php 00032 */ 00033 00034 /*! 00035 \class eZPackageOperator ezpackageoperator.php 00036 \brief The class eZPackageOperator does 00037 00038 */ 00039 00040 class eZPackageOperator 00041 { 00042 /*! 00043 Constructor 00044 */ 00045 function eZPackageOperator( $name = 'ezpackage' ) 00046 { 00047 $this->Operators = array( $name ); 00048 } 00049 00050 /*! 00051 Returns the operators in this class. 00052 */ 00053 function operatorList() 00054 { 00055 return $this->Operators; 00056 } 00057 00058 /*! 00059 See eZTemplateOperator::namedParameterList() 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 \reimp 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 ( $operatorValue instanceof eZPackage ) 00083 { 00084 if ( !is_array( $fileList = $operatorValue->fileList( 'default' ) ) ) 00085 $fileList = array(); 00086 foreach ( $fileList as $file ) 00087 { 00088 $fileType = $file["type"]; 00089 if ( $fileType == 'thumbnail' ) 00090 { 00091 $operatorValue = $operatorValue->fileItemPath( $file, 'default' ); 00092 return; 00093 } 00094 } 00095 $operatorValue = false; 00096 } 00097 } break; 00098 00099 case 'filepath': 00100 { 00101 if ( $operatorValue instanceof eZPackage ) 00102 { 00103 $variableName = $namedParameters['data']; 00104 $fileList = $operatorValue->fileList( 'default' ); 00105 foreach ( $fileList as $file ) 00106 { 00107 $fileIdentifier = $file["variable-name"]; 00108 if ( $fileIdentifier == $variableName ) 00109 { 00110 $operatorValue = $operatorValue->fileItemPath( $file, 'default' ); 00111 return; 00112 } 00113 } 00114 $tpl->error( $operatorName, 00115 "No filepath found for variable $variableName in package " . $package->attribute( 'name' ) ); 00116 $operatorValue = false; 00117 } 00118 } break; 00119 00120 case 'fileitempath': 00121 { 00122 if ( $operatorValue instanceof eZPackage ) 00123 { 00124 $fileItem = $namedParameters['data']; 00125 $operatorValue = $operatorValue->fileItemPath( $fileItem, 'default' ); 00126 } 00127 } break; 00128 00129 case 'documentpath': 00130 { 00131 if ( $package instanceof eZPackage ) 00132 { 00133 $documentName = $namedParameters['data']; 00134 $documentList = $package->attribute( 'documents' ); 00135 foreach ( array_keys( $documentList ) as $key ) 00136 { 00137 $document =& $documentList[$key]; 00138 $name = $document["name"]; 00139 if ( $name == $documentName ) 00140 { 00141 $documentFilePath = $package->path() . '/' . eZPackage::documentDirectory() . '/' . $document['name']; 00142 $operatorValue = $documentFilePath; 00143 return; 00144 } 00145 } 00146 $tpl->error( $operatorName, 00147 "No documentpath found for document $documentName in package " . $package->attribute( 'name' ) ); 00148 $operatorValue = false; 00149 } 00150 } break; 00151 00152 case 'dirpath': 00153 { 00154 $dirPath = $operatorValue->currentRepositoryPath() . "/" . $operatorValue->attribute( 'name' ); 00155 $operatorValue = $dirPath; 00156 } break; 00157 00158 default: 00159 $tpl->error( $operatorName, "Unknown package operator name: '$class'" ); 00160 break; 00161 } 00162 } 00163 /// \privatesection 00164 public $Operators; 00165 }; 00166 00167 ?>