Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezbinaryfilehandler.php
Go to the documentation of this file.
1 <?php
22 class eZBinaryFileHandler
23 {
24 const HANDLE_UPLOAD = 0x1;
25 const HANDLE_DOWNLOAD = 0x2;
26
27 const HANDLE_ALL = 0x3; // HANDLE_UPLOAD | HANDLE_DOWNLOAD
28
29 const TYPE_FILE = 'file';
30 const TYPE_MEDIA = 'media';
31
32 const RESULT_OK = 1;
33 const RESULT_UNAVAILABLE = 2;
34
42 public function __construct( $identifier, $name, $handleType )
43 {
44 $this->Info = array();
45 $this->Info['identifier'] = $identifier;
46 $this->Info['name'] = $name;
47 $this->Info['handle-type'] = $handleType;
48 }
49
50 function attributes()
51 {
52 return array_keys( $this->Info );
53 }
54
55 function hasAttribute( $attribute )
56 {
57 return isset( $this->Info[$attribute] );
58 }
59
60 function attribute( $attribute )
61 {
62 if ( isset( $this->Info[$attribute] ) )
63 {
64 return $this->Info[$attribute];
65 }
66
67 eZDebug::writeError( "Attribute '$attribute' does not exist", __METHOD__ );
68 return null;
69 }
70
75 function viewTemplate( $contentobjectAttribute )
76 {
77 $retVal = false;
78 return $retVal;
79 }
80
85 function editTemplate( $contentobjectAttribute )
86 {
87 $retVal = false;
88 return $retVal;
89 }
90
95 function informationTemplate( $contentobjectAttribute )
96 {
97 $retVal = false;
98 return $retVal;
99 }
100
101 function handleUpload()
102 {
103 return false;
104 }
105
109 function downloadFileObject( $contentObject, $contentObjectAttribute )
110 {
111 $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );
112 $version = $contentObject->attribute( 'current_version' );
113 $fileObject = eZBinaryFile::fetch( $contentObjectAttributeID, $version );
114 if ( $fileObject )
115 return $fileObject;
116 $fileObject = eZMedia::fetch( $contentObjectAttributeID, $version );
117 return $fileObject;
118 }
119
120 function handleDownload( $contentObject, $contentObjectAttribute, $type )
121 {
122 $contentObjectAttributeID = $contentObjectAttribute->attribute( 'id' );
123 $version = $contentObject->attribute( 'current_version' );
124
125
126
127 if ( !$contentObjectAttribute->hasStoredFileInformation( $contentObject, $version,
128 $contentObjectAttribute->attribute( 'language_code' ) ) )
129 return self::RESULT_UNAVAILABLE;
130
131 $fileInfo = $contentObjectAttribute->storedFileInformation( $contentObject, $version,
132 $contentObjectAttribute->attribute( 'language_code' ) );
133 if ( !$fileInfo )
134 return self::RESULT_UNAVAILABLE;
135 if ( !$fileInfo['mime_type'] )
136 return self::RESULT_UNAVAILABLE;
137
138 $contentObjectAttribute->handleDownload( $contentObject, $version,
139 $contentObjectAttribute->attribute( 'language_code' ) );
140
141 return $this->handleFileDownload( $contentObject, $contentObjectAttribute, $type, $fileInfo );
142 }
143
144 function handleFileDownload( $contentObject, $contentObjectAttribute, $type, $mimeData )
145 {
146 return false;
147 }
148
149 function repositories()
150 {
151 return array( 'kernel/classes/binaryhandlers' );
152 }
153
161 static function instance( $identifier = false )
162 {
163 if ( $identifier === false )
164 {
165 $fileINI = eZINI::instance( 'file.ini' );
166 $identifier = $fileINI->variable( 'BinaryFileSettings', 'Handler' );
167 }
168 $instance =& $GLOBALS['eZBinaryFileHandlerInstance-' . $identifier];
169 if ( !isset( $instance ) )
170 {
171 $optionArray = array( 'iniFile' => 'file.ini',
172 'iniSection' => 'BinaryFileSettings',
173 'iniVariable' => 'Handler' );
174
175 $options = new ezpExtensionOptions( $optionArray );
176
177 $instance = eZExtension::getHandlerClass( $options );
178
179 if( $instance === false )
180 {
181 eZDebug::writeError( "Could not find binary file handler '$identifier'", __METHOD__ );
182 }
183 }
184 return $instance;
185 }
186
188 public $Info;
189 }
190
191 ?>
eZBinaryFileHandler
Interface for all binary file handlers.
Definition: ezbinaryfilehandler.php:23
eZBinaryFileHandler\informationTemplate
informationTemplate( $contentobjectAttribute)
Definition: ezbinaryfilehandler.php:95
eZBinaryFileHandler\handleDownload
handleDownload( $contentObject, $contentObjectAttribute, $type)
Definition: ezbinaryfilehandler.php:120
eZBinaryFileHandler\hasAttribute
hasAttribute( $attribute)
Definition: ezbinaryfilehandler.php:55
eZBinaryFileHandler\RESULT_OK
const RESULT_OK
Definition: ezbinaryfilehandler.php:32
eZBinaryFileHandler\HANDLE_DOWNLOAD
const HANDLE_DOWNLOAD
Definition: ezbinaryfilehandler.php:25
eZBinaryFileHandler\attributes
attributes()
Definition: ezbinaryfilehandler.php:50
eZBinaryFileHandler\editTemplate
editTemplate( $contentobjectAttribute)
Definition: ezbinaryfilehandler.php:85
eZBinaryFileHandler\HANDLE_ALL
const HANDLE_ALL
Definition: ezbinaryfilehandler.php:27
eZBinaryFileHandler\instance
static instance( $identifier=false)
Definition: ezbinaryfilehandler.php:161
eZBinaryFileHandler\__construct
__construct( $identifier, $name, $handleType)
Definition: ezbinaryfilehandler.php:42
eZBinaryFileHandler\TYPE_FILE
const TYPE_FILE
Definition: ezbinaryfilehandler.php:29
eZBinaryFileHandler\RESULT_UNAVAILABLE
const RESULT_UNAVAILABLE
Definition: ezbinaryfilehandler.php:33
eZBinaryFileHandler\handleFileDownload
handleFileDownload( $contentObject, $contentObjectAttribute, $type, $mimeData)
Definition: ezbinaryfilehandler.php:144
eZBinaryFileHandler\TYPE_MEDIA
const TYPE_MEDIA
Definition: ezbinaryfilehandler.php:30
eZBinaryFileHandler\$Info
$Info
Definition: ezbinaryfilehandler.php:188
eZBinaryFileHandler\downloadFileObject
downloadFileObject( $contentObject, $contentObjectAttribute)
Definition: ezbinaryfilehandler.php:109
eZBinaryFileHandler\HANDLE_UPLOAD
const HANDLE_UPLOAD
Definition: ezbinaryfilehandler.php:24
eZBinaryFileHandler\repositories
repositories()
Definition: ezbinaryfilehandler.php:149
eZBinaryFileHandler\attribute
attribute( $attribute)
Definition: ezbinaryfilehandler.php:60
eZBinaryFileHandler\handleUpload
handleUpload()
Definition: ezbinaryfilehandler.php:101
eZBinaryFileHandler\viewTemplate
viewTemplate( $contentobjectAttribute)
Definition: ezbinaryfilehandler.php:75
eZBinaryFile\fetch
static fetch( $id, $version=null, $asObject=true)
Definition: ezbinaryfile.php:105
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZExtension\getHandlerClass
static getHandlerClass(ezpExtensionOptions $options)
Definition: ezextension.php:531
eZMedia\fetch
static fetch( $id, $version, $asObject=true)
Definition: ezmedia.php:142
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.