/[drupal]/contributions/modules/wordfilter/wordfilter.module
ViewVC logotype

Diff of /contributions/modules/wordfilter/wordfilter.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.7.2.9.2.14, Fri Jun 5 07:59:43 2009 UTC revision 1.7.2.9.2.15, Fri Sep 11 05:32:23 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: wordfilter.module,v 1.7.2.9.2.13 2009/04/14 08:15:49 jaydub Exp $  // $Id: wordfilter.module,v 1.7.2.9.2.14 2009/06/05 07:59:43 jaydub Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 339  function wordfilter_filter_process($text Line 339  function wordfilter_filter_process($text
339        $replacement = ($word->replacement) ? $word->replacement : variable_get('wordfilter_default_replacement', '[filtered word]');        $replacement = ($word->replacement) ? $word->replacement : variable_get('wordfilter_default_replacement', '[filtered word]');
340    
341        if ($word->standalone) {        if ($word->standalone) {
342          $text = preg_replace("/(\W)". preg_quote($word->words, '/') ."(\W)/i". ($utf8 ? 'u' : ''), "$1". $replacement ."$2", $text);          $pattern = '/(\W)'. preg_quote($word->words, '/') .'(\W)/i';
343        }        }
344        else {        else {
345          $text = preg_replace('/'. preg_quote($word->words, '/') .'/i'. ($utf8 ? 'u' : ''), $replacement, $text);          $pattern = '/'. preg_quote($word->words, '/') .'/i';
346          }
347          if ($utf8) {
348            $pattern .= 'u';
349          }
350    
351          $split_text = preg_split('/(<[^>]*>)/i', substr($text, 1, -1), -1, PREG_SPLIT_DELIM_CAPTURE);
352          $split_text = array_values(array_filter($split_text));
353          if (count($split_text) > 1) {
354            $new_string = '';
355            foreach ($split_text as $part) {
356              if (!preg_match('/^</', $part)) {
357                $new_string .= preg_replace($pattern, "$1". $replacement ."$2", $part);
358              }
359              else {
360                $new_string .= $part;
361              }
362            }
363            $text = ' '. $new_string .' ';
364          }
365          else {
366            $text = preg_replace($pattern, "$1". $replacement ."$2", $text);
367        }        }
368      }      }
369    }    }

Legend:
Removed from v.1.7.2.9.2.14  
changed lines
  Added in v.1.7.2.9.2.15

  ViewVC Help
Powered by ViewVC 1.1.2