55 $this->SupportedDataTypes =
get_package(
'security::supported_data_types' ,
'last' , __FILE__ );
89 private function get_alias( $Name , $Predicates )
93 foreach( $Predicates as $p )
95 if( strpos( $p ,
'alias_' ) === 0 )
97 $Alias = str_replace(
'alias_' ,
'' , $p );
104 catch( Exception $e )
136 private function get_default( $Name , $Predicates )
142 foreach( $Predicates as $p )
144 if( strpos( $p ,
'default_' ) === 0 )
146 return( str_replace(
'default_' ,
'' , $p ) );
152 catch( Exception $e )
184 foreach( $Predicates as $p )
186 if( $p ===
'allow_not_set' )
194 catch( Exception $e )
230 private function handle_allow_not_set( $ScriptLine , $GlobalPredicates , $Result )
234 $Name = $ScriptLine[ 0 ];
235 $Predicates = array_unique( array_merge( explode(
',' , $ScriptLine[ 1 ] ) , $GlobalPredicates ) );
239 $Default = $this->get_default( $Name , $Predicates );
241 if( $Default !==
false )
249 $ScriptLine = serialize( $ScriptLine );
250 throw(
new Exception(
"Field \"$Name\" must be set, but it has not been set in $ScriptLine" ) );
253 catch( Exception $e )
293 private function parse_value( $Params , $ScriptLine , $Result , $GlobalPredicates )
297 $Name = $ScriptLine[ 0 ];
298 $Predicates = array_unique( array_merge( explode(
',' , $ScriptLine[ 1 ] ) , $GlobalPredicates ) );
301 $Type = $this->SupportedDataTypes->get_type( $Predicates );
302 $Alias = $this->get_alias( $Name , $Predicates );
304 set_field( $Result , $Name , $this->Security->get( $Value , $Type ) );
309 catch( Exception $e )
349 private function parse_script_line( $Params , $ScriptLine , $Result , $GlobalPredicates )
353 $ScriptLine = explode(
':' , $ScriptLine );
354 $Name = $ScriptLine[ 0 ];
357 if( $ValueWasSet ===
false )
359 $Result = $this->handle_allow_not_set( $ScriptLine , $GlobalPredicates , $Result );
363 $Result = $this->parse_value( $Params , $ScriptLine , $Result , $GlobalPredicates );
368 catch( Exception $e )
408 if( $this->Security ===
false )
410 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
413 $GlobalPredicates = explode(
',' , $GlobalPredicates );
415 $Result =
new stdClass();
417 $ParsingScript = str_replace(
'#' ,
';' , $ParsingScript );
418 $Script = explode(
';' , $ParsingScript );
420 foreach( $Script as $ScriptLine )
422 $Result = $this->parse_script_line( $Params , $ScriptLine , $Result , $GlobalPredicates );
427 catch( Exception $e )
461 return( $this->
parse_parameters( array_merge( $_GET , $_POST ) , $ParsingScript ) );
463 catch( Exception $e )