/[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.20, Fri Jun 5 07:59:19 2009 UTC revision 1.7.2.21, Fri Sep 11 05:33:33 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: wordfilter.module,v 1.7.2.19 2009/04/14 09:35:18 jaydub Exp $  // $Id: wordfilter.module,v 1.7.2.20 2009/06/05 07:59:19 jaydub Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 342  function wordfilter_filter_process($text Line 342  function wordfilter_filter_process($text
342        $replacement = ($word->replacement) ? $word->replacement : variable_get('wordfilter_default_replacement', '[filtered word]');        $replacement = ($word->replacement) ? $word->replacement : variable_get('wordfilter_default_replacement', '[filtered word]');
343    
344        if ($word->standalone) {        if ($word->standalone) {
345          $text = preg_replace("/(\W)". preg_quote($word->words, '/') ."(\W)/i". ($utf8 ? 'u' : ''), "$1". $replacement ."$2", $text);          $pattern = '/(\W)'. preg_quote($word->words, '/') .'(\W)/i';
346        }        }
347        else {        else {
348          $text = preg_replace('/'. preg_quote($word->words, '/') .'/i'. ($utf8 ? 'u' : ''), $replacement, $text);          $pattern = '/'. preg_quote($word->words, '/') .'/i';
349          }
350          if ($utf8) {
351            $pattern .= 'u';
352          }
353    
354          $split_text = preg_split('/(<[^>]*>)/i', substr($text, 1, -1), -1, PREG_SPLIT_DELIM_CAPTURE);
355          $split_text = array_values(array_filter($split_text));
356          if (count($split_text) > 1) {
357            $new_string = '';
358            foreach ($split_text as $part) {
359              if (!preg_match('/^</', $part)) {
360                $new_string .= preg_replace($pattern, "$1". $replacement ."$2", $part);
361              }
362              else {
363                $new_string .= $part;
364              }
365            }
366            $text = ' '. $new_string .' ';
367          }
368          else {
369            $text = preg_replace($pattern, "$1". $replacement ."$2", $text);
370        }        }
371      }      }
372    }    }

Legend:
Removed from v.1.7.2.20  
changed lines
  Added in v.1.7.2.21

  ViewVC Help
Powered by ViewVC 1.1.2