[Easymod-cvs] easymod2/mods/easymod/em_includes em_functions.php,1.4,1.5
Status: Beta
Brought to you by:
wgeric
From: Jim W. <ter...@us...> - 2005-06-08 03:12:36
|
Update of /cvsroot/easymod/easymod2/mods/easymod/em_includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6023/mods/easymod/em_includes Modified Files: em_functions.php Log Message: - added support for the INCREMENT action - a few other small changes Index: em_functions.php =================================================================== RCS file: /cvsroot/easymod/easymod2/mods/easymod/em_includes/em_functions.php,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** em_functions.php 25 May 2005 01:10:41 -0000 1.4 --- em_functions.php 8 Jun 2005 03:12:20 -0000 1.5 *************** *** 365,369 **** // if this new line fits in the correct order of the search array, then things are looking // more like this could be a match; we also know it's not a whitespace line ! if (strstr( $current_line, trim($search_array[count($potential_find)]))) { // load the line into the find array --- 365,369 ---- // if this new line fits in the correct order of the search array, then things are looking // more like this could be a match; we also know it's not a whitespace line ! if (preg_match('#'.preg_replace('#\\\\\\{%\\\\\\:(\\d+)\\\\\\}#','(\\d+|\\{%\\:$1\\})', preg_quote(trim($search_array[count($potential_find)]), '#')).'#', $current_line)) { // load the line into the find array *************** *** 565,569 **** { // found the fragment, cool! ! if (strstr( $find_array[$file_count][$looper], $search_fragment)) { $found_fragment = true ; --- 565,569 ---- { // found the fragment, cool! ! if (preg_match('#'.preg_replace('#\\\\\\{%\\\\\\:(\\d+)\\\\\\}#','(\\d+|\\{%\\:$1\\})', preg_quote($search_fragment, '#')).'#', $find_array[$file_count][$looper])) { $found_fragment = true ; *************** *** 656,659 **** --- 656,673 ---- } + // Increments variables in strings as appropriate. + function increment_wildcard( $wildcard_identifier, $increment_value, $wildcard_search, $search_result ) + { + $parts = preg_split('#\{%\:\d+\}#',substr($wildcard_search,0,strpos($wildcard_search,$wildcard_identifier))); + for ($i=0;$i<count($parts);$i++) + { + $parts[$i] = preg_quote($parts[$i],'#'); + } + $beg = preg_replace('#^(.*'.implode('\d+',$parts).').*#s','$1',$search_result,1); + $aft = substr($search_result,strlen($beg)); + $num = preg_replace('#^(\\d+).*#','$1',$aft); + $num += $increment_value; + return $beg.preg_replace('#^\\d+(.*)#',"$num$1",$aft); + } /// |