106 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
107 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
109 catch( Exception $e )
145 foreach( $Parameters as $key1 => $p )
147 $p = explode(
'=' , $p );
148 foreach( $Conditions as $key2 => $rev )
150 if( $key2 == $p[ 0 ] )
153 $Result = preg_match( $rev , $p[ 1 ] , $Matches );
154 if( count( $Matches ) == 0 )
164 catch( Exception $e )
200 $Parameters = explode(
';' , $Parameters );
204 $this->RawMacroParameters = $Parameters;
210 catch( Exception $e )
254 if( $TmpStartPos !==
false && $TmpEndPos !==
false )
256 if( $TmpStartPos < $TmpEndPos )
258 $ParserCursor = $TmpEndPos;
260 if( $TmpEndPos < $TmpStartPos )
263 if( $Counter )$Counter++;
264 $ParserCursor = $TmpStartPos;
268 return( array( $Counter , $ParserCursor ) );
270 catch( Exception $e )
314 if( $TmpStartPos !==
false && $TmpEndPos ===
false )
317 $ParserCursor = $TmpStartPos;
320 if( $TmpStartPos ===
false && $TmpEndPos !==
false )
323 $ParserCursor = $TmpEndPos;
326 if( $TmpStartPos ===
false && $TmpEndPos ===
false )
328 throw(
new Exception(
'Closing '.chr( 123 ).
' was not found' ) );
331 return( array( $Counter , $ParserCursor ) );
333 catch( Exception $e )
377 $TmpStartPos = strpos( $StringData , chr( 123 ) , $ParserCursor + 1 );
378 $TmpEndPos = strpos( $StringData , chr( 125 ) , $ParserCursor + 1 );
381 $TmpStartPos , $TmpEndPos , $Counter , $ParserCursor
385 $TmpStartPos , $TmpEndPos , $Counter , $ParserCursor
388 while( $TmpStartPos && $Counter != 0 );
390 return( $Counter == 0 ? $TmpEndPos :
false );
392 catch( Exception $e )
432 function parse_macro( $StringData , $MacroName , $Conditions , $StartPos )
438 if( $EndPos !==
false )
441 $Parameters = substr( $StringData , $StartPos , $EndPos - $StartPos );
448 catch( Exception $e )
488 $this->RawMacroParameters = array();
489 $this->MacroParameters =
false;
492 $MacroStart = chr( 123 ).$MacroName.
':';
493 $MacroLength = strlen( $MacroStart );
495 for( ; ( $StartPos = strpos( $StringData , $MacroStart , $StartPos + 1 ) ) !==
false ; )
497 $StartPos += $MacroLength;
499 $Result = $this->
parse_macro( $StringData , $MacroName , $Conditions , $StartPos );
503 $this->StartPosition = $StartPos - $MacroLength;
510 catch( Exception $e )
538 if( $this->MacroParameters ===
false )
540 $this->MacroParameters =
get_package_object(
'settings::settings' ,
'last' , __FILE__ );
541 $this->MacroParameters->load_settings( $this->RawMacroParameters );
544 return( $this->MacroParameters );
546 catch( Exception $e )
582 $Positions = array();
587 for( ; $StartPos = strpos( $StringData , chr( 123 ).$MacroName.
':' , $StartPos + 1 ) ; )
589 $Positions [ $StartPos ] =
's';
592 for( ; $EndPos = strpos( $StringData , chr( 123 ).
'~'.$MacroName.chr( 125 ) , $EndPos + 1 ) ; )
594 $Positions [ $EndPos ] =
'e';
599 return( $Positions );
601 catch( Exception $e )
649 if( $StartPos ===
false && $Value ===
's' )
654 elseif( $EndPos ===
false && $Value ===
'e' && $c === 1 )
658 elseif( $Value ===
's' )
662 elseif( $Value ===
'e' )
667 return( array( $StartPos , $EndPos , $c ) );
669 catch( Exception $e )
701 $Positions = $this->
get_positions( $StringData , $MacroName );
706 foreach( $Positions as $Key => $Value )
708 if( $Value ==
'e' && $Key > $this->StartPosition )
711 $Value , $Key , $StartPos , $EndPos , $c
716 if( $EndPos ===
false )
721 $this->EndPosition = $EndPos;
723 catch( Exception $e )
761 $StringData = substr_replace( $StringData ,
763 $this->StartPosition ,
764 $this->EndPosition - $this->StartPosition + strlen( chr( 123 ).
'~'.$MacroName.chr( 125 ) )
767 return( $StringData );
769 catch( Exception $e )
807 $this->RawMacroParameters = implode(
';' , $this->RawMacroParameters );
808 $MacroLength = strlen( chr( 123 ).
"$MacroName:$this->RawMacroParameters".chr( 125 ) );
810 $Position = $this->EndPosition - $this->StartPosition - $MacroLength;
811 $MacroData = substr( $StringData , $this->StartPosition + $MacroLength , $Position );
813 $Position = $this->EndPosition - $this->StartPosition + strlen( chr( 123 ).
'~'.$MacroName.chr( 125 ) );
814 $StringData = substr_replace( $StringData , $MacroData , $this->StartPosition , $Position );
816 return( $StringData );
818 catch( Exception $e )