loadFilter('output','groupslayout'); * from application. * Author: Nick Palmer based on highlight filter by * Greg Hinkle * and mose * ------------------------------------------------------------- */ function smarty_outputfilter_groupslayout( $source, &$gBitSmarty ) { if( empty($_REQUEST['group_layout_id']) || !is_numeric($_REQUEST['group_layout_id']) ) { return $source; } // get all text that needs to be $extractor = "|]*>.*?|is"; preg_match_all( $extractor, $source, $match ); $contents = $match[0]; $ret = []; foreach( $contents as $key => $content ) { // if we picked something up, we rip it out and modify if( !empty( $content ) ) { $source = preg_replace( $extractor, "@@@SMARTY:TRIM:CONTENT@@@", $source ); // Protect some parts $patterns = [ "!]+>.*?!is" => "@@@SMARTY:TRIM:SCRIPT@@@", ]; // ksort( $patterns ); foreach( $patterns as $pattern => $replace ) { preg_match_all( $pattern, $content, $match ); $matches[$replace] = $match[0]; $content = preg_replace( $pattern, $replace, $content ); } // Now we can finally fix up the anchor tags $pattern = '#(]*>)#'; $content = preg_replace_callback($pattern, group_replace_url_hander, $content); // Put the protected parts back in. foreach( $patterns as $pattern ) { foreach( $matches[$pattern] as $insert ) { $content = preg_replace( "!{$pattern}!", $insert, $content, 1 ); } } $ret[] = $content; } } // insert the code back into the source foreach( $ret as $content ) { // Escape dollars in content so they don't back reference $content = preg_replace('!\$!','\\\$', $content); $source = preg_replace( "!@@@SMARTY:TRIM:CONTENT@@@!", $content, $source, 1 ); } return $source; }