Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //TRK Confirm Params
- function trk_confirm_params( $params = array(), &$set = array() )
- {
- for( $offset = 0; $offset <= 3; $offset++ )
- {
- $set[ $offset ] = true;
- if( $set[ $offset ] ) { $set[ $offset ] = isset( $params[ $offset ] ); }
- if( $set[ $offset ] ) { $set[ $offset ] = is_string( $params[ $offset ] ); }
- if( $set[ $offset] ) { $set[$offset] = strlen( $params[ $offset ] ) > 0; }
- }
- return $set;
- }
- // TRK_Generate_Link
- function trk_generate_link($params = array(), $set = array() )
- {
- return
- '<a href="?' . urlencode( $set[ 0 ] ? $params[ 0 ] : 'prj' ) .
- '=' . urlencode( $set[ 1 ] ? $params[ 1 ] : 'Roe' ) .
- '">' .
- ( $set[ 2 ] ? ( '<img src="' . urlencode( $params[ 2 ] ) . '">' ) : '<img style="width:72px;height:72px;" src="' . './site data/art/disks/blank disk.png' . '">' ) .
- ( $set[ 2 ] && $set[ 3 ] ? '<br>' : '' ) .
- ( $set[ 3 ] ? $params[ 3 ] :( $set[ 1 ] ? $params[ 1 ] : 'Roe' ) ) .
- '</a>';
- }
- //TRK Is Valid
- function trk_is_valid( $value )
- {
- return
- (
- isset ( $value )
- ?
- (
- ! is_null( $value )
- ?
- true
- :
- false
- )
- :
- false
- );
- }
- //TRK Replace Link
- function trk_replace_link( $buffer )
- {
- $pattern = '/{{(.*)}}/';
- $strip = array( '{{', '}}' );
- $sep = '|';
- if ( preg_match_all( $pattern, $buffer, $matches, PREG_PATTERN_ORDER ) )
- {
- foreach( $matches as $key => $value )
- {
- if ( $key > 0 )
- {
- if( trk_is_valid($value) )
- {
- $target = '{{'.$value[ 1 ].'}}';
- trk_echo3( 'target', $target );
- $parts = explode( $sep, str_replace( $strip, '', $value[ 1 ] ) );
- //if( count( $parts ) > 1 )
- //{
- $set = trk_confirm_params( $parts, $set );
- foreach($parts as $k => $part )
- {
- if( isset( $set[ $k ] ) )
- {
- trk_echo3( 'part ' . $k, $part );
- }
- }
- $replace = trk_generate_link( $parts, $set );
- trk_echo3( 'replace', $replace );
- $buffer = str_replace( $target, $replace, $buffer );
- //}
- }
- }
- }
- }
- return $buffer;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement