62 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
63 $this->FileInputAlgorithms =
get_package(
'file_input::file_input_algorithms' ,
'last' , __FILE__ );
64 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
65 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
99 private function apply_upload_count( &
$Settings , $Code )
103 if(
$Settings->get_setting(
'single_input' ,
false ) )
105 $Code = str_replace(
'{file_upload_limit}' , 1 , $Code );
106 $Code = str_replace(
'{file_queue_limit}' , 1 , $Code );
110 $FileUploadLimit =
$Settings->get_setting(
'file_upload_limit' , 1 );
111 $Code = str_replace(
'{file_upload_limit}' , $FileUploadLimit , $Code );
112 $FileQueueLimit =
$Settings->get_setting(
'file_queue_limit' , 1 );
113 $Code = str_replace(
'{file_queue_limit}' , $FileQueueLimit , $Code );
118 catch( Exception $e )
154 private function apply_upload_limitations( &
$Settings , $Code , $Name )
158 $Type =
$Settings->get_setting(
'file_types' ,
'default' );
159 list( $FileExtensions , $FileDescription ) = $this->FileInputAlgorithms->get_file_filters( $Type );
161 $Code = str_replace(
'{file_types}' , $FileExtensions , $Code );
162 $Code = str_replace(
'{file_types_description}' , $FileDescription , $Code );
163 $FileSizeLimit =
$Settings->get_setting(
'file_size_limit' ,
'512 KB' );
164 $Code = str_replace(
'{file_size_limit}' , $FileSizeLimit , $Code );
166 $Code = $this->apply_upload_count(
$Settings , $Code );
170 catch( Exception $e )
202 private function set_event_handlers( &
$Settings , $Code )
206 $UploadSuccess =
$Settings->get_setting(
'upload_success_handler' ,
'uploadSuccess' );
207 $Code = str_replace(
'{upload_success_handler}' , $UploadSuccess , $Code );
209 $UploadComplete =
$Settings->get_setting(
'upload_complete_handler' ,
'uploadComplete' );
210 $Code = str_replace(
'{upload_complete_handler}' , $UploadComplete , $Code );
214 catch( Exception $e )
242 private function get_uploaded_file_code( &
$Settings )
246 $TemplatePath = dirname( __FILE__ ).
'/res/templates/file_field.tpl';
248 $UploadedFileCode = $this->CachedMultyFS->file_get_contents( $TemplatePath );
250 $UploadedFileCode = $this->String->print_record( $UploadedFileCode ,
$Settings->get_raw_settings() );
252 return( $UploadedFileCode );
254 catch( Exception $e )
286 $TemplatePath = dirname( __FILE__ ).
'/res/templates/file_input.tpl';
287 $Code = $this->CachedMultyFS->file_get_contents( $TemplatePath );
290 '{uploaded_file_code}' , $this->get_uploaded_file_code(
$Settings ) , $Code
293 $Url =
$Settings->get_setting(
'upload_url' );
295 $Name =
$Settings->get_setting(
'name' ,
'file_input' );
296 $Code = $this->apply_upload_limitations(
$Settings , $Code , $Name );
297 $Code = $this->set_event_handlers(
$Settings , $Code );
299 $Code = str_replace( array(
'{name}' ,
'{upload_url}' ) , array( $Name , $Url ) , $Code );
303 catch( Exception $e )