|
Lines 939-944
sub _clean_search_term {
Link Here
|
| 939 |
} |
939 |
} |
| 940 |
$term = $self->_query_regex_escape_process($term); |
940 |
$term = $self->_query_regex_escape_process($term); |
| 941 |
|
941 |
|
|
|
942 |
# because of _truncate_terms and if QueryAutoTruncate enabled |
| 943 |
# we will have any special operators ruined by _truncate_terms: |
| 944 |
# for ex. search for "test [6 TO 7]" will be converted to "test* [6* TO* 7]" |
| 945 |
# so no reason to keep ranges in QueryAutoTruncate==true case: |
| 946 |
my $truncate = C4::Context->preference("QueryAutoTruncate") || 0; |
| 947 |
unless($truncate) { |
| 948 |
# replace all ranges with any square/curly brackets combinations to temporary substitutions (ex: "{a TO b]"" -> "~~LC~~a TO b~~RS~~") |
| 949 |
$term =~ s/(?<!\\)((?:[\\]{2})*)(\{|\[)([^\s\[\]\{\}]+ TO [^\s\[\]\{\}]+(?<!\\)(?:[\\]{2})*)(\}|\])/$1.'~~L'.($2 eq '[' ? 'S':'C').'~~'.$3.'~~R'.($4 eq ']' ? 'S':'C').'~~'/ge; |
| 950 |
warn "$term\n"; |
| 951 |
} |
| 942 |
# save all regex contents away before escaping brackets: |
952 |
# save all regex contents away before escaping brackets: |
| 943 |
my @saved_regexes; |
953 |
my @saved_regexes; |
| 944 |
my $rgx_i = 0; |
954 |
my $rgx_i = 0; |
|
Lines 974-979
sub _clean_search_term {
Link Here
|
| 974 |
for (my $i = 0; $i < @saved_regexes; $i++) { |
984 |
for (my $i = 0; $i < @saved_regexes; $i++) { |
| 975 |
$term =~ s/~~XI$i~~/$saved_regexes[$i]/; |
985 |
$term =~ s/~~XI$i~~/$saved_regexes[$i]/; |
| 976 |
} |
986 |
} |
|
|
987 |
unless($truncate) { |
| 988 |
# restore temporary weird substitutions back to normal brackets |
| 989 |
$term =~ s/~~L(C|S)~~([^\s\[\]\{\}]+ TO [^\s\[\]\{\}]+)~~R(C|S)~~/($1 eq 'S' ? '[':'{').$2.($3 eq 'S' ? ']':'}')/ge; |
| 990 |
} |
| 991 |
warn "$term\n"; |
| 977 |
return $term; |
992 |
return $term; |
| 978 |
} |
993 |
} |
| 979 |
|
994 |
|
| 980 |
- |
|
|