ultimix
supported_data_types_1_0_0 Class Reference

Public Member Functions

 __construct ()
 show_safe_macro ($Str)
 hide_safe_macro ($Str)
 get_type ($Predicates)
 compile_integer ($Data)
 compile_digits ($Data)
 compile_integer_list ($Data)
 compile_float ($Data)
 compile_command ($Data)
 compile_string ($Data)
 compile_script ($Data)
 compile_unsafe_string ($Data)
 compile_email ($Data)
 compile_data (&$Data, $Type)
 dispatch_complex_data (&$Data, $Type)

Data Fields

 $String = false
 $SupportedData = array()

Detailed Description

Class with all supported data description.

Author
Dodonov A.A.

Definition at line 44 of file supported_data_types.php.

Constructor & Destructor Documentation

__construct ( )

Constructor.

Author
Dodonov A.A.

Definition at line 80 of file supported_data_types.php.

{
try
{
$this->String = get_package( 'string' , 'last' , __FILE__ );
$this->init_supported_data_types();
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Member Function Documentation

compile_command (   $Data)

Function processes data of type 'command'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 436 of file supported_data_types.php.

{
try
{
$RetData = '';
$s = strlen( $Data );
for( $i = 0 ; $i < $s ; $i++ )
{
if( ( $Data[ $i ] >= 'a' && $Data[ $i ] <= 'z' ) ||
( $Data[ $i ] >= 'A' && $Data[ $i ] <= 'Z' ) ||
( $Data[ $i ] >= '0' && $Data[ $i ] <= '9' ) ||
$Data[ $i ] == '_' || $Data[ $i ] == ':' || $Data[ $i ] == '-' || $Data[ $i ] == '.' )
{
$RetData .= $Data[ $i ];
}
}
return( $RetData );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_data ( $Data,
  $Type 
)

Function processes data.

Parameters
$Data- Data to process.
$Type- Data type.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 684 of file supported_data_types.php.

{
try
{
if( isset( $this->SupportedData[ $Type ] ) === false )
{
throw( new Exception( "Undefined data type \"$Type\"" ) );
}
if( $Type == 'raw' )
{
return( $Data );
}
return( call_user_func( array( $this->SupportedData[ $Type ] , "compile_$Type" ) , $Data ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_digits (   $Data)

Function processes data of type 'digits'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Note
'digits' is a special string subtype wich contains digits only.
Author
Dodonov A.A.

Definition at line 308 of file supported_data_types.php.

{
try
{
$RetData = '';
$s = strlen( $Data = "$Data" );
for( $i = 0 ; $i < $s ; $i++ )
{
if( ( $Data[ $i ] >= '0' && $Data[ $i ] <= '9' ) || $Data[ 0 ] == '-' )
{
$RetData .= $Data[ $i ];
}
}
return( $RetData );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_email (   $Data)

Function processes data of type 'email'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 630 of file supported_data_types.php.

{
try
{
$RetData = '';
$c = strlen( $Data );
for( $i = 0 ; $i < $c ; $i++ )
{
if( ( $Data[ $i ] >= 'a' && $Data[ $i ] <= 'z' ) ||
( $Data[ $i ] >= 'A' && $Data[ $i ] <= 'Z' ) ||
( $Data[ $i ] >= '0' && $Data[ $i ] <= '9' ) ||
$Data[ $i ] == '_' || $Data[ $i ] == ':' ||
$Data[ $i ] == '-' || $Data[ $i ] == '.' ||
$Data[ $i ] == '@' || $Data[ $i ] == '=' ||
$Data[ $i ] == '+' )
{
$RetData .= $Data[ $i ];
}
}
return( $RetData );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_float (   $Data)

Function processes data of type 'float'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 402 of file supported_data_types.php.

{
try
{
return( floatval( $Data ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_integer (   $Data)

Function processes data of type 'integer'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 270 of file supported_data_types.php.

{
try
{
return( intval( $Data ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_integer_list (   $Data)

Function processes data of type 'integer_list'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 353 of file supported_data_types.php.

{
try
{
if( is_array( $Data ) )
{
$Data = implode( ',' , $Data );
}
$Matches = array();
preg_match( '/^[0-9\,]+$/' , $Data , $Matches );
if( count( $Matches ) > 0 )
{
return( $Data );
}
else
{
throw( new Exception( "Illegal symbols were found '$Data'" ) );
}
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_script (   $Data)

Function processes data of type 'string'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 532 of file supported_data_types.php.

{
try
{
if( $this->String === false )
{
$this->String = get_package( 'string' , 'last' , __FILE__ );
}
$Data = htmlspecialchars( $Data , ENT_QUOTES , 'UTF-8' );
$Data = str_replace( '{' , '[lfb]' , $Data );
$Data = str_replace( ';' , '[dot_comma]' , $Data );
$Data = str_replace( '=' , '[eq]' , $Data );
$Data = str_replace( '#' , '[sharp]' , $Data );
$Data = str_replace( '}' , '[rfb]' , $Data );
$Data = str_replace( "\r" , '[r]' , $Data );
$Data = str_replace( "\n" , '[n]' , $Data );
$Data = str_replace( '&' , '[amp]' , $Data );
return( $Data );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_string (   $Data)

Function processes data of type 'string'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 483 of file supported_data_types.php.

{
try
{
if( $this->String === false )
{
$this->String = get_package( 'string' , 'last' , __FILE__ );
}
$Data = $this->hide_safe_macro( $Data );
$Data = htmlspecialchars( $Data , ENT_QUOTES , 'UTF-8' );
$PlaceHolders = array( '{' , ';' , '=' , '#' , '}' , "\r" , "\n" );
$Replacements = array( '[lfb]' , '[dot_comma]' , '[eq]' , '[sharp]' , '[rfb]' , '[r]' , '[n]' );
$Data = str_replace( $PlaceHolders, $Replacements , $Data );
$Data = $this->show_safe_macro( $Data );
$Data = str_replace( '&' , '[amp]' , $Data );
return( $Data );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
compile_unsafe_string (   $Data)

Function processes data of type 'unsafe_string'.

Parameters
$Data- Data to process.
Returns
- Processed data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 582 of file supported_data_types.php.

{
try
{
if( $this->String === false )
{
$this->String = get_package( 'string' , 'last' , __FILE__ );
}
$Data = str_replace( '[lfb]' , '{' , $Data );
$Data = str_replace( '[dot_comma]' , ';' , $Data );
$Data = str_replace( '[eq]' , '=' , $Data );
$Data = str_replace( '[sharp]' , '#' , $Data );
$Data = str_replace( '[rfb]' , '}' , $Data );
$Data = str_replace( '[amp]' , '&' , $Data );
$Data = htmlspecialchars_decode( $Data , ENT_QUOTES );
return( $Data );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
dispatch_complex_data ( $Data,
  $Type 
)

Function processes arrays and objects.

Parameters
$Data- Data to process.
$Type- Data type.
Returns
- Processed data.
Note
Empty string is not a valid value for the data of type 'integer' , 'float' , 'email' and 'integer_list'
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 736 of file supported_data_types.php.

{
try
{
$Ret = array();
foreach( $Data as $key => $d )
{
if( is_array( $d ) || is_object( $d ) )
{
$d = $this->compile_data( $d , $Type );
if( is_object( $d ) || count( $d ) )
{
$Ret[ $key ] = $d;
}
}
else
{
if( $Type == 'string' || $Type == 'command' || $Type == 'raw' || strlen( $d ) != 0 )
{
$Ret[ $key ] = $this->compile_data( $d , $Type );
}
}
}
return( $Ret );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
get_type (   $Predicates)

Function retrives type.

Parameters
$Predicates- Type of the parsing element.
Returns
- Name of the type.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 225 of file supported_data_types.php.

{
try
{
$Types = array( 'integer' , 'float' , 'command' , 'string' , 'email' , 'email' , 'set' , 'raw' );
foreach( $Predicates as $p )
{
$Key = array_search( $p , $Types );
if( $Key !== false )
{
return( $Types[ $Key ] );
}
}
throw( new Exception( "Type was not found" ) );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
hide_safe_macro (   $Str)

Function hides some safe macro, in a way that simple user can input them using common editor on the site.

Parameters
$Str- String to process.
Returns
- Decoded data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 189 of file supported_data_types.php.

{
try
{
$Str = preg_replace( "/\{lang\:([\{\}\[\]]{0}.*)\}/U" , "[lang:\\1]" , $Str );
return( $Str );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}
show_safe_macro (   $Str)

Function shows some safe macro, in a way that simple user can input them using common editor on the site.

Parameters
$Str- String to process.
Returns
- Decoded data.
Exceptions
ExceptionAn exception of this type is thrown.
Author
Dodonov A.A.

Definition at line 152 of file supported_data_types.php.

{
try
{
$Str = preg_replace( "/\[lang\:([\{\}\[\]]{0}.*)\]/U" , "{lang:\\1}" , $Str );
return( $Str );
}
catch( Exception $e )
{
$a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
}
}

Field Documentation

$String = false

Cached objects.

Author
Dodonov A.A.

Definition at line 56 of file supported_data_types.php.

$SupportedData = array()

A list of the supported data types.

Author
Dodonov A.A.

Definition at line 68 of file supported_data_types.php.


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