ultimix

- Main Page
- Data Structures
- Files
- Examples

- Data Structures
- Data Structure Index
- Data Fields

Public Member Functions | Data Fields
file_input_controller_1_0_0 Class Reference

## Public Member Functions
| __construct ()
| save_uploaded_file ($SavePath, $FileName, $OriginalFileName)
| display_file_info ($SavePath, $FileId, $OriginalFileName)
| handle_request (&$Options)
| upload_file (&$Options)
| controller ($Options)

## Data Fields
| $UploadedFile = false
| $FileInputAlgorithms = false
| $Security = false

## Detailed Description

Class processes file uploads.

Author
  Dodonov A.A.

Definition at line 28 of file file_input_controller.php.

## Constructor & Destructor Documentation

__construct | ( |  | ) |

Constructor.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 69 of file file_input_controller.php.

{
try
{
$this->FileInputAlgorithms = get_package( 'file_input::file_input_algorithms' , 'last' , __FILE__ );
$this->Security = get_package( 'security' , 'last' , __FILE__ );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Member Function Documentation

controller | ( |  | $Options | ) |

Component's controller.

Parameters

  $Options | - Settings.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 290 of file file_input_controller.php.

{
try
{
$UploadFile = $Options->get_setting( 'upload_file' , false );
$NotDirectControllerCall = $this->Security->get_s( 'direct_controller' , 'integer' , 0 ) == 0;
if( $UploadFile && $NotDirectControllerCall && count( $_FILES ) )
{
$this->upload_file( $Options );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

display_file_info | ( |  | $SavePath,
|  |  | $FileId,
|  |  | $OriginalFileName
| ) |  |

Function displays data for client.

Parameters

  $SavePath | - Destination path.
  $FileId | - id of the uploaded file.
  $OriginalFileName | - Name of the uploaded file.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 162 of file file_input_controller.php.

{
try
{
$ServerData = new stdClass;
set_field( $ServerData , 'href' , $SavePath );
set_field( $ServerData , 'id' , $FileId );
set_field( $ServerData , 'original_file_name' , $OriginalFileName );
$JSON = get_package( 'json' , 'last' , __FILE__ );
print_r( $JSON->encode( $ServerData ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

handle_request | ( | & | $Options | ) |

Function processes request.

Parameters

  $Options | - Settings.

Returns
  array( $save_path , $file_name , $original_file_name ).

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 202 of file file_input_controller.php.

{
try
{
global $extension_whitelist;
$extension_whitelist = $this->FileInputAlgorithms->get_extensions(
$Options->get_setting( 'file_types' , 'default' )
);
$PackagePath = _get_package_relative_path_ex( 'file_input::file_input_controller' , '1.0.0' );
$DirectoryPath = $PackagePath.'/data/'.date( 'Ymd' );
@mkdir_ex( $DirectoryPath );
global $save_path;
$save_path = $DirectoryPath.'/';
global $file_name;
global $original_file_name;
define( 'NO_DIRECT_CALL' , 1 );
require_once( $PackagePath.'/include/php/upload.php' );
return( array( $save_path , $file_name , $original_file_name ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

save_uploaded_file | ( |  | $SavePath,
|  |  | $FileName,
|  |  | $OriginalFileName
| ) |  |

Function returns a list of the uploading files.

Parameters

  $SavePath | - Destination path.
  $FileName | - New file name.
  $OriginalFileName | - Original file name.

Returns
  id of the uploaded file.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 112 of file file_input_controller.php.

{
try
{
$FileInputAccess = get_package( 'file_input::file_input_access' , 'last' , __FILE__ );
$Record = array( 'file_path' => $SavePath.$FileName , 'original_file_name' => $OriginalFileName );
$id = $FileInputAccess->create( $Record );
$EventManager = get_package( 'event_manager' , 'last' , __FILE__ );
$EventManager->trigger_event( 'on_load_file' , array( 'id' => $id ) );
$Record[ 'id' ] = $id;
$FileInputAlgorithms = get_package( 'file_input::file_input_algorithms' , 'last' , __FILE__ );
$this->UploadedFile = $Record;
return( $id );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

upload_file | ( | & | $Options | ) |

Function uploads file.

Parameters

  $Options | - Settings.

Exceptions

  Exception | An exception of this type is thrown.

Author
  Dodonov A.A.

Definition at line 248 of file file_input_controller.php.

{
try
{
list( $save_path , $file_name , $original_file_name ) = $this->handle_request( $Options );
$id = $this->save_uploaded_file( $save_path , $file_name , $original_file_name );
$VarName = $this->Security->get_gp( 'page_name' , 'command' ).'_file';
if( $Options->get_setting( 'var_name' , false ) !== false )
{
$VarName = $Options->get_setting( 'var_name' );
}
/* saving info in the session */
$this->Security->set_s( $VarName , $id );
$this->display_file_info( $save_path."$file_name" , $id , $original_file_name );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

## Field Documentation

$FileInputAlgorithms = false

Cached packages.

Author
  Dodonov A.A.

Definition at line 52 of file file_input_controller.php.

$Security = false

Definition at line 53 of file file_input_controller.php.

$UploadedFile = false

Last uploaded file.

Author
  Dodonov A.A.

Definition at line 40 of file file_input_controller.php.

The documentation for this class was generated from the following file:

- packages/file_input/packages/file_input_controller/file_input_controller.php