Commit c4133883 authored by generalredneck's avatar generalredneck

Merge branch '7.x-2.x' into 7.x-2.x-table-sort

parents 00483d79 e901b17a
......@@ -17,23 +17,25 @@ class views_natural_sort_handler_sort_text_field extends views_natural_sort_hand
$join = new views_join();
$other_join = $this->get_join();
$table_data = views_fetch_data($other_join->definition['left_table']);
// If you look at where natural_sort_join is called, this alias will be
// used.
$vns_alias = 'vns_' . $this->table_alias;
// Make the join. Can't use extra as an array because I have to join on two
// fields and not 1 field with other fields == to a hard coded value.
// I don't like this because it's insecure. Look for better way.
// @see http://drupal.org/node/1090432
$join->definition = array(
'table' => 'views_natural_sort',
'field' => 'eid',
'left_field' => 'entity_id',
'left_table' => $this->table_alias,
'extra' => $vns_alias . '.delta = ' . $this->table_alias . '.delta AND ' .
$vns_alias . ".entity_type = '" . $table_data['table']['entity type'] . "' AND " .
$vns_alias . ".field = '" . preg_replace('/_value$/', '', $this->field) . "'",
'extra' => array(
array(
'field' => 'delta',
'value' => $this->table_alias . '.delta',
),
array(
'field' => 'entity_type',
'value' => $table_data['table']['entity type'],
),
array(
'field' => 'field',
'value' => preg_replace('/_value$/', '', $this->field),
),
),
);
$join->construct();
$join->adjusted = TRUE;
......
......@@ -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+/iu',
'',
$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+/iu',
'/^(' . implode('|', $words) . ')\s+/iu',
),
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
);
......
......@@ -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.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment