Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
V
views_natural_sort
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Drupal.org issue queue
Drupal.org issue queue
Security & Compliance
Security & Compliance
Dependency List
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
project
views_natural_sort
Commits
bdd421d5
Commit
bdd421d5
authored
Apr 14, 2017
by
generalredneck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2775643
by generalredneck, nirbhasa: Unicode issue with views_natural_sort_remove_symbols
parent
20580b61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
views_natural_sort.inc
views_natural_sort.inc
+4
-4
views_natural_sort.test
views_natural_sort.test
+16
-0
No files found.
views_natural_sort.inc
View file @
bdd421d5
...
...
@@ -22,7 +22,7 @@ function views_natural_sort_remove_beginning_words($string) {
array_walk
(
$beginning_words
,
'preg_quote'
);
return
preg_replace
(
'/^('
.
implode
(
'|'
,
$beginning_words
)
.
')\s+/i'
,
'/^('
.
implode
(
'|'
,
$beginning_words
)
.
')\s+/i
u
'
,
''
,
$string
);
...
...
@@ -46,8 +46,8 @@ function views_natural_sort_remove_words($string) {
array_walk
(
$words
,
'preg_quote'
);
return
preg_replace
(
array
(
'/\s('
.
implode
(
'|'
,
$words
)
.
')\s+/i'
,
'/^('
.
implode
(
'|'
,
$words
)
.
')\s+/i'
,
'/\s('
.
implode
(
'|'
,
$words
)
.
')\s+/i
u
'
,
'/^('
.
implode
(
'|'
,
$words
)
.
')\s+/i
u
'
,
),
array
(
' '
,
...
...
@@ -72,7 +72,7 @@ function views_natural_sort_remove_symbols($string) {
return
$string
;
}
return
preg_replace
(
'/['
.
preg_quote
(
$symbols
)
.
']/'
,
'/['
.
preg_quote
(
$symbols
)
.
']/
u
'
,
''
,
$string
);
...
...
views_natural_sort.test
View file @
bdd421d5
...
...
@@ -87,6 +87,22 @@ class ViewsNaturalSortBasicTest extends ViewsTestCase {
);
}
/**
* Test Unicode symbol removal in sorting.
*/
public
function
testNaturalSortUnicodeSymbols
()
{
$symbols
=
variable_set
(
'views_natural_sort_symbols_remove'
,
"#…
\"
,'
\\
()[]«?!»¡¿"
);
$titles
=
array
(
'Cuando… se abre, ¿dará algún tipo de señal?'
,
);
$expected
=
array
(
'Cuando se abre dará algún tipo de señal'
,
);
foreach
(
$titles
as
$key
=>
$title
)
{
$this
->
assertEqual
(
views_natural_sort_remove_symbols
(
$title
),
$expected
[
$key
]);
}
}
/**
* Test sorting strings that contain numbers in them.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment