1: <?php
2:
3: 4: 5:
6: class Quform_Filter_Alpha extends Quform_Filter_Abstract
7: {
8: 9: 10: 11: 12: 13: 14: 15:
16: public function filter($value)
17: {
18: if ( ! is_string($value)) {
19: return $value;
20: }
21:
22: $whiteSpace = $this->config('allowWhiteSpace') ? '\s' : '';
23:
24: if (Quform::hasPcreUnicodeSupport()) {
25:
26: $pattern = '/[^\p{L}' . $whiteSpace . ']/u';
27: } else {
28: $pattern = '/[^a-zA-Z' . $whiteSpace . ']/';
29: }
30:
31: return preg_replace($pattern, '', $value);
32: }
33:
34: 35: 36: 37: 38: 39:
40: public static function getDefaultConfig($key = null)
41: {
42: $config = apply_filters('quform_default_config_filter_alpha', array(
43: 'allowWhiteSpace' => false
44: ));
45:
46: $config['type'] = 'alpha';
47:
48: if (Quform::isNonEmptyString($key)) {
49: return Quform::get($config, $key);
50: }
51:
52: return $config;
53: }
54: }
55: