Пример #1
0
 function getOptions()
 {
     parent::getOptions();
     $this->search = WT_Filter::get('search');
     $this->replace = WT_Filter::get('replace');
     $this->method = WT_Filter::get('method', 'exact|words|wildcards|regex', 'exact');
     $this->case = WT_Filter::get('case', 'i');
     $this->error = '';
     switch ($this->method) {
         case 'exact':
             $this->regex = preg_quote($this->search, '/');
             break;
         case 'words':
             $this->regex = '\\b' . preg_quote($this->search, '/') . '\\b';
             break;
         case 'wildcards':
             $this->regex = '\\b' . str_replace(array('\\*', '\\?'), array('.*', '.'), preg_quote($this->search, '/')) . '\\b';
             break;
         case 'regex':
             $this->regex = $this->search;
             // Check for invalid regexes
             // If the regex is bad, $ct will be left at -1
             $ct = -1;
             $ct = @preg_match('/' . $this->search . '/', '');
             if ($ct == -1) {
                 $this->error = '<br><span class="error">' . WT_I18N::translate('The regex appears to contain an error.  It can’t be used.') . '</span>';
             }
             break;
     }
 }
Пример #2
0
 function getOptions()
 {
     parent::getOptions();
     $this->surname = WT_Filter::get('surname', 'add|replace', 'replace');
 }