Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
V
views_natural_sort
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
views_natural_sort
Commits
321de921
Commit
321de921
authored
Dec 22, 2016
by
generalredneck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Queue logic to replace the array logic for data.
parent
9ac8d938
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
373 additions
and
159 deletions
+373
-159
handlers/views_natural_sort_handler_sort.inc
handlers/views_natural_sort_handler_sort.inc
+39
-13
handlers/views_natural_sort_handler_sort_text_field.inc
handlers/views_natural_sort_handler_sort_text_field.inc
+15
-3
tests/modules/views_natural_sort_test/views_natural_sort_test.install
...s/views_natural_sort_test/views_natural_sort_test.install
+8
-0
tests/modules/views_natural_sort_test/views_natural_sort_test.module
...es/views_natural_sort_test/views_natural_sort_test.module
+40
-0
views_natural_sort.admin.inc
views_natural_sort.admin.inc
+31
-42
views_natural_sort.api.php
views_natural_sort.api.php
+23
-15
views_natural_sort.inc
views_natural_sort.inc
+35
-15
views_natural_sort.install
views_natural_sort.install
+4
-5
views_natural_sort.module
views_natural_sort.module
+37
-29
views_natural_sort.test
views_natural_sort.test
+54
-11
views_natural_sort.views.inc
views_natural_sort.views.inc
+9
-5
views_natural_sort_text_field.install
views_natural_sort_text_field.install
+7
-0
views_natural_sort_text_field.module
views_natural_sort_text_field.module
+63
-20
views_natural_sort_text_field.views.inc
views_natural_sort_text_field.views.inc
+8
-1
No files found.
handlers/views_natural_sort_handler_sort.inc
View file @
321de921
<?php
/**
* @file
*/
/**
*
*/
class
views_natural_sort_handler_sort
extends
views_handler_sort
{
function
init
(
&
$view
,
&
$options
)
{
/**
*
*/
public
function
init
(
&
$view
,
&
$options
)
{
parent
::
init
(
$view
,
$options
);
$this
->
natural_sort
=
substr
(
$this
->
options
[
'order'
],
0
,
1
)
==
'N'
;
$this
->
natural_sort
=
substr
(
$this
->
options
[
'order'
],
0
,
1
)
==
'N'
;
}
/**
* Provide a list of options for the default sort form.
* Should be overridden by classes that don't override sort_form
* Should be overridden by classes that don't override sort_form
.
*/
function
sort_options
()
{
public
function
sort_options
()
{
return
array
(
'ASC'
=>
t
(
'Sort ascending'
),
'DESC'
=>
t
(
'Sort descending'
),
...
...
@@ -19,7 +30,10 @@ class views_natural_sort_handler_sort extends views_handler_sort {
);
}
function
query
()
{
/**
*
*/
public
function
query
()
{
// If this field isn't being used as a Natural Sort Field, move along
// nothing to see here.
if
(
!
$this
->
natural_sort
)
{
...
...
@@ -27,7 +41,7 @@ class views_natural_sort_handler_sort extends views_handler_sort {
return
;
}
// If someone has submitted the exposed form, lets grab it here
// If someone has submitted the exposed form, lets grab it here
.
if
(
$this
->
options
[
'exposed'
]
&&
$this
->
view
->
exposed_data
[
'sort_order'
])
{
$temporder
=
$this
->
view
->
exposed_data
[
'sort_order'
];
}
...
...
@@ -47,7 +61,10 @@ class views_natural_sort_handler_sort extends views_handler_sort {
$this
->
query
->
add_orderby
(
$vns_alias
,
'content'
,
$order
);
}
function
natural_sort_join
()
{
/**
*
*/
public
function
natural_sort_join
()
{
$join
=
new
views_join
();
$table_data
=
views_fetch_data
(
$this
->
table
);
$join
->
definition
=
array
(
...
...
@@ -64,13 +81,17 @@ class views_natural_sort_handler_sort extends views_handler_sort {
'field'
=>
'field'
,
'value'
=>
$this
->
real_field
,
),
)
)
,
);
$join
->
construct
();
$join
->
adjusted
=
TRUE
;
return
$join
;
}
function
admin_summary
()
{
/**
*
*/
public
function
admin_summary
()
{
if
(
!
empty
(
$this
->
options
[
'exposed'
]))
{
return
t
(
'Exposed'
);
}
...
...
@@ -79,17 +100,22 @@ class views_natural_sort_handler_sort extends views_handler_sort {
case
'asc'
:
default
:
return
t
(
'asc'
);
break
;
break
;
case
'DESC'
:
case
'desc'
:
return
t
(
'desc'
);
break
;
break
;
case
'NASC'
:
return
t
(
'natural asc'
);
break
;
break
;
case
'NDESC'
:
return
t
(
'natural asc'
);
break
;
break
;
}
}
}
handlers/views_natural_sort_handler_sort_text_field.inc
View file @
321de921
<?php
/**
* @file
*/
/**
*
*/
class
views_natural_sort_handler_sort_text_field
extends
views_natural_sort_handler_sort
{
function
natural_sort_join
()
{
/**
*
*/
public
function
natural_sort_join
()
{
$join
=
new
views_join
();
$other_join
=
$this
->
get_join
();
$table_data
=
views_fetch_data
(
$other_join
->
definition
[
'left_table'
]);
...
...
@@ -19,8 +30,8 @@ class views_natural_sort_handler_sort_text_field extends views_natural_sort_hand
'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
)
.
"'"
,
$vns_alias
.
".entity_type = '"
.
$table_data
[
'table'
][
'entity type'
]
.
"' AND "
.
$vns_alias
.
".field = '"
.
preg_replace
(
'/_value$/'
,
''
,
$this
->
field
)
.
"'"
,
/*'extra' => array(
"views_natural_sort.delta = $this->table_alias.delta",
array(
...
...
@@ -37,4 +48,5 @@ class views_natural_sort_handler_sort_text_field extends views_natural_sort_hand
$join
->
adjusted
=
TRUE
;
return
$join
;
}
}
tests/modules/views_natural_sort_test/views_natural_sort_test.install
View file @
321de921
<?php
/**
* @file
*/
/**
* Implements hook_install().
*/
/**
*
*/
function
views_natural_sort_test_install
()
{
node_types_rebuild
();
$types
=
node_type_get_types
();
...
...
tests/modules/views_natural_sort_test/views_natural_sort_test.module
View file @
321de921
<?php
/**
* @file
*/
/**
* Implement hook_form()
*/
/**
*
*/
function
views_natural_sort_test_form
(
$node
,
$form_state
)
{
return
node_content_form
(
$node
,
$form_state
);
}
...
...
@@ -78,3 +86,35 @@ function views_natural_sort_test_views_default_views() {
$views
[
$view
->
name
]
=
$view
;
return
$views
;
}
/**
*
*/
function
views_natural_sort_test_views_create_test_content
()
{
$titles
=
array
(
'1 apple'
,
'2 apples'
,
'10 apples'
,
'-1 apples'
,
'-10 apples'
,
'-2 appels'
,
'-3.550 apples'
,
'-3.5501 apples'
,
'3.5501 apples'
,
'3.550 apples'
,
'A(Z'
,
'A[B'
,
'A\\C'
,
'A Stripped Zebra'
,
'Oklahoma'
,
'The King And I'
,
);
foreach
(
$titles
as
$title
)
{
$node
=
new
stdClass
();
$node
->
type
=
'views_natural_sort_test_content'
;
$node
->
title
=
$title
;
node_object_prepare
(
$node
);
$node
=
node_submit
(
$node
);
node_save
(
$node
);
}
}
views_natural_sort.admin.inc
View file @
321de921
<?php
/**
* @file
* Callbacks for managing Views Natural Sort.
...
...
@@ -42,7 +43,7 @@ function views_natural_sort_rebuild_index_form() {
}
/**
* Form callback for the Views Natural Sort settings page
* Form callback for the Views Natural Sort settings page
.
*
* Allows the removal of specific words and symbols from all your titles.
*/
...
...
@@ -94,9 +95,9 @@ function views_natural_sort_settings_form() {
* Submit handler that saves custom word handlers and other settings.
*/
function
views_natural_sort_settings_form_submit
(
$form
,
&
$form_state
)
{
$beginning_words
=
explode
(
','
,
$form_state
[
'values'
][
'beginning_words'
]);
$beginning_words
=
explode
(
','
,
$form_state
[
'values'
][
'beginning_words'
]);
array_walk
(
$beginning_words
,
create_function
(
'&$val'
,
'$val = trim($val);'
));
$words
=
explode
(
','
,
$form_state
[
'values'
][
'words'
]);
$words
=
explode
(
','
,
$form_state
[
'values'
][
'words'
]);
array_walk
(
$words
,
create_function
(
'&$val'
,
'$val = trim($val);'
));
$symbols
=
trim
(
$form_state
[
'values'
][
'symbols'
]);
...
...
@@ -115,17 +116,22 @@ function views_natural_sort_rebuild_index_submit() {
views_natural_sort_rebuild_index_batch_set
();
}
/**
* Sets up the batch job for reindexing all or specified VNS entry types.
*/
function
views_natural_sort_rebuild_index_batch_set
(
array
$entry_types
=
array
())
{
if
(
empty
(
$entry_types
))
{
$entry_types
=
module_invoke_all
(
'views_natural_sort_get_entry_types'
);
}
$operations
=
array
();
foreach
(
$entry_types
as
$entry_type
)
{
$operations
[]
=
array
(
'views_natural_sort_rebuild_index'
,
array
(
$entry_type
));
foreach
(
$entry_types
as
$entry_type
)
{
// Queue up all the data that needs to be rebuilt.
module_invoke_all
(
'views_natural_sort_queue_rebuild_data'
,
$entry_type
);
}
// Run the queue.
$batch
=
array
(
'operations'
=>
$operations
,
'operations'
=>
array
(
array
(
'views_natural_sort_rebuild_index'
,
array
()))
,
'title'
=>
t
(
'Rebuilding Views Natural Sort Indexing Entries'
),
'finished'
=>
'views_natural_sort_rebuild_index_finished'
,
'file'
=>
drupal_get_path
(
'module'
,
'views_natural_sort'
)
.
'/views_natural_sort.admin.inc'
,
...
...
@@ -137,46 +143,29 @@ function views_natural_sort_rebuild_index_batch_set(array $entry_types = array()
/**
* Batch API callback for rebuild_index.
*/
function
views_natural_sort_rebuild_index
(
$entry_type
,
&
$context
)
{
function
views_natural_sort_rebuild_index
(
&
$context
)
{
$queue
=
views_natural_sort_get_queue
();
// Alias sandbox for easier referencing.
$sandbox
=
&
$context
[
'sandbox'
];
// Initialize our context.
if
(
!
isset
(
$context
[
'results'
][
'entries'
]))
{
$context
[
'results'
][
'entries'
]
=
0
;
}
if
(
!
isset
(
$sandbox
[
'max'
]))
{
// Hook for modules to implement and return data that views_natural_sort can
// store as an index for that module's entries.
$sandbox
[
'entries'
]
=
module_invoke_all
(
'views_natural_sort_get_rebuild_data'
,
$entry_type
);
$sandbox
[
'progress'
]
=
0
;
$sandbox
[
'max'
]
=
count
(
$sandbox
[
'entries'
])
-
1
;
$sandbox
[
'total'
]
=
count
(
$sandbox
[
'entries'
]);
// Alias results for easier referencing.
$results
=
&
$context
[
'results'
];
if
(
empty
(
$sandbox
))
{
$sandbox
[
'current'
]
=
0
;
if
(
$sandbox
[
'total'
]
==
0
)
{
$context
[
'finished'
]
=
1
;
return
;
$sandbox
[
'max'
]
=
$queue
->
numberOfItems
();
$sandbox
[
'items_per_batch'
]
=
variable_get
(
'views_natural_sort_rebuild_items_per_batch'
,
'500'
);
}
for
(
$i
=
0
;
$i
<
$sandbox
[
'items_per_batch'
]
&&
$sandbox
[
'current'
]
<
$sandbox
[
'max'
];
$i
++
)
{
$item
=
$queue
->
claimItem
(
10
);
if
(
$item
)
{
views_natural_sort_store
(
$item
->
data
);
$queue
->
deleteItem
(
$item
);
}
$sandbox
[
'current'
]
++
;
}
$results
=
array_slice
(
$sandbox
[
'entries'
],
$sandbox
[
'current'
],
variable_get
(
'views_natural_sort_rebuild_items_per_batch'
,
'500'
));
$entity_type
=
''
;
$field
=
''
;
foreach
(
$results
as
$row
)
{
views_natural_sort_store
(
$row
);
++
$sandbox
[
'progress'
];
$sandbox
[
'current'
]
=
$sandbox
[
'progress'
];
$entity_type
=
$row
[
'entity_type'
];
$field
=
$row
[
'field'
];
++
$context
[
'results'
][
'entries'
];
$results
[
'entries'
]
=
$sandbox
[
'current'
];
if
(
$sandbox
[
'current'
]
!=
$sandbox
[
'max'
])
{
$context
[
'finished'
]
=
$sandbox
[
'current'
]
/
$sandbox
[
'max'
];
}
$context
[
'message'
]
=
t
(
'Processing %entity_type %field'
,
array
(
'%entity_type'
=>
$entity_type
,
'%field'
=>
$field
));
$context
[
'finished'
]
=
$sandbox
[
'progress'
]
/
$sandbox
[
'total'
];
}
/**
...
...
@@ -184,7 +173,7 @@ function views_natural_sort_rebuild_index($entry_type, &$context) {
*/
function
views_natural_sort_rebuild_index_finished
(
$success
,
$results
,
$operations
)
{
if
(
$success
)
{
drupal_set_message
(
t
(
'Index
update
has completed.'
));
drupal_set_message
(
t
(
'Index
rebuild
has completed.'
));
drupal_set_message
(
t
(
'Indexed %count.'
,
array
(
'%count'
=>
format_plural
(
$results
[
'entries'
],
'1 entry'
,
'@count entries'
),
)));
...
...
views_natural_sort.api.php
View file @
321de921
<?php
/**
* @file
*
* Hook Definition file for Views Natural Sort
* Hook Definition file for Views Natural Sort.
*/
/**
...
...
@@ -11,7 +11,7 @@
* This information is passed to each module during re-index so that modules can
* determine whether it needs to return items or not.
*
* @return array
$entity_types
* @return array
* Array of arrays defining fields and entities to reindex
* array(
* array(
...
...
@@ -25,12 +25,12 @@ function hook_views_natural_sort_get_entry_types() {
array
(
'entity_type'
=>
'user'
,
'field'
=>
'book_favorites'
,
)
)
,
);
}
/**
* Used for a custom module to
defin
e data that needs to be re-indexed when the
* Used for a custom module to
queu
e data that needs to be re-indexed when the
* module is installed or settings are changed.
*
* @param array $entry_type
...
...
@@ -38,20 +38,18 @@ function hook_views_natural_sort_get_entry_types() {
* $entity_type - The type of the entity we are getting
* data that needs to be re-indexed from
* $field - The field that needs to be re-indexed.
*
* @return array $index_entries An array of index entries that need re-indexing.
*/
function
hook_views_natural_sort_
get_rebuild_data
(
$entry_type
)
{
if
(
$entry_type
[
'entity_type'
]
!=
'user'
||
$entry_type
[
'field'
]
!=
'book_favorites'
)
{
function
hook_views_natural_sort_
queue_rebuild_data
(
$entry_type
)
{
if
(
$entry_type
[
'entity_type'
]
!=
'user'
||
$entry_type
[
'field'
]
!=
'book_favorites'
)
{
return
array
();
}
$result
=
db_select
(
'user'
,
'u'
)
->
fields
(
'u'
,
array
(
'uid'
,
'book_favorites'
))
->
execute
();
$
data
=
array
();
foreach
(
$result
as
$row
)
{
$
queue
=
views_natural_sort_get_queue
();
foreach
(
$result
as
$row
)
{
// Grab the data returned and queue it up for transformation.
$
data
[]
=
array
(
$
queue
->
createItem
=
array
(
'eid'
=>
$row
->
uid
,
'entity_type'
=>
'user'
,
'field'
=>
'book_favorites'
,
...
...
@@ -59,7 +57,6 @@ function hook_views_natural_sort_get_rebuild_data($entry_type){
'content'
=>
$row
->
book_favorites
,
);
}
return
$data
;
}
/**
...
...
@@ -76,7 +73,7 @@ function hook_views_natural_sort_get_rebuild_data($entry_type){
* $field - reference to the property or field name
* $delta - the item number in that field or property
* $content - The original string before
* transformations
* transformations
.
*/
function
hook_views_natural_sort_transformations_alter
(
&
$transformations
,
$index_entry
)
{
// This function will receive a single argument that is the string that needs
...
...
@@ -98,10 +95,21 @@ function hook_views_natural_sort_transformations_alter(&$transformations, $index
/**
* This is NOT A HOOK. Example transformation function.
*
* @param string $string The string to be transformed.
* @param string $string
* The string to be transformed.
*
* @return string A transformed string used for sorting "Naturally".
*/
function
_my_special_transformation_function
(
$string
)
{
return
str_replace
(
'a'
,
''
,
$string
);
}
/**
* This hook has been deprecated and is no longer called.
*
* @deprecated
*
* @see hook_views_natural_sort_queue_rebuild_data
*/
function
hook_views_natural_sort_queue_rebuild_data
(
$entry_type
)
{
}
views_natural_sort.inc
View file @
321de921
<?php
/**
* @file
*/
/**
*
*/
function
views_natural_sort_remove_beginning_words
(
$string
)
{
$beginning_words
=
variable_get
(
'views_natural_sort_beginning_words_remove'
,
array
());
if
(
empty
(
$beginning_words
))
{
...
...
@@ -14,6 +21,9 @@ function views_natural_sort_remove_beginning_words($string) {
);
}
/**
*
*/
function
views_natural_sort_remove_words
(
$string
)
{
$words
=
variable_get
(
'views_natural_sort_words_remove'
,
array
());
if
(
empty
(
$words
))
{
...
...
@@ -28,12 +38,15 @@ function views_natural_sort_remove_words($string) {
),
array
(
' '
,
''
''
,
),
$string
);
}
/**
*
*/
function
views_natural_sort_remove_symbols
(
$string
)
{
$symbols
=
variable_get
(
'views_natural_sort_symbols_remove'
,
''
);
if
(
strlen
(
$symbols
)
==
0
)
{
...
...
@@ -90,9 +103,9 @@ function views_natural_sort_numbers($string) {
*/
function
_views_natural_sort_number_transform_match_callback
(
$match
)
{
// Remove commas and leading zeros from whole number
$whole
=
(
string
)
(
int
)
str_replace
(
','
,
''
,
(
isset
(
$match
[
4
])
&&
strlen
(
$match
[
4
])
>
0
)
?
$match
[
4
]
:
$match
[
2
]);
// Remove traililng 0's from fraction, then add the decimal and one trailing 0
// Remove commas and leading zeros from whole number
.
$whole
=
(
string
)
(
int
)
str_replace
(
','
,
''
,
(
isset
(
$match
[
4
])
&&
strlen
(
$match
[
4
])
>
0
)
?
$match
[
4
]
:
$match
[
2
]);
// Remove traililng 0's from fraction, then add the decimal and one trailing 0
.
$fraction
=
trim
(
'.'
.
$match
[
3
],
'0'
)
.
'0'
;
$encode
=
sprintf
(
'%02u'
,
strlen
(
$whole
))
.
$whole
.
$fraction
;
if
(
strlen
(
$match
[
1
]))
{
...
...
@@ -103,7 +116,7 @@ function _views_natural_sort_number_transform_match_callback($match) {
$digits
=
array
(
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
);
$intermediate
=
array
(
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
,
'g'
,
'h'
,
'i'
,
'j'
);
$rev_digits
=
array
(
'9'
,
'8'
,
'7'
,
'6'
,
'5'
,
'4'
,
'3'
,
'2'
,
'1'
,
'0'
);
$encode
=
$match
[
1
]
.
str_replace
(
$intermediate
,
$rev_digits
,
str_replace
(
$digits
,
$intermediate
,
$encode
));
$encode
=
$match
[
1
]
.
str_replace
(
$intermediate
,
$rev_digits
,
str_replace
(
$digits
,
$intermediate
,
$encode
));
}
return
$encode
;
}
...
...
@@ -126,37 +139,43 @@ function views_natural_sort_days_of_the_week_sort_days($string) {
$sorted_days
=
$day_list
;
// Go through list and resort it and Translate it.
$start
=
array_search
(
$first_day
,
$day_list
);
for
(
$i
=
0
;
$i
<
7
;
$i
++
)
{
$current_day
=
(
$i
+
$start
)
%
7
;
for
(
$i
=
0
;
$i
<
7
;
$i
++
)
{
$current_day
=
(
$i
+
$start
)
%
7
;
$abbreviations
=
views_natural_sort_days_of_the_week_get_acceptable_day_abbreviations
(
$day_list
[
$current_day
],
$used_language
);
$translated_day
=
t
(
$day_list
[
$current_day
]);
$string
=
preg_replace
(
array
(
'/\b'
.
$translated_day
.
'\b/i'
,
'/\b('
.
implode
(
views_natural_sort_days_of_the_week_get_acceptable_day_abbreviations
(
$day_list
[
$current_day
]),
'\.?|'
)
.
')\b/i'
'/\b('
.
implode
(
views_natural_sort_days_of_the_week_get_acceptable_day_abbreviations
(
$day_list
[
$current_day
]),
'\.?|'
)
.
')\b/i'
,
),
' '
.
$i
.
' '
,
' '
.
$i
.
' '
,
$string
);
}
return
$string
;
}
/**
*
*/
function
views_natural_sort_days_of_the_week_get_default_days
()
{
return
array
(
return
array
(
"Sunday"
,
"Monday"
,
"Tuesday"
,
"Wednesday"
,
"Thursday"
,
"Friday"
,
"Saturday"
"Saturday"
,
);
}
/**
*
*/
function
views_natural_sort_days_of_the_week_get_acceptable_day_abbreviations
(
$day
,
$lang
=
'en'
)
{
$default_days
=
views_natural_sort_days_of_the_week_get_default_days
();
$index
=
array_search
(
$day
,
$default_days
);
$index
=
array_search
(
$day
,
$default_days
);
$default_abbrev
=
views_natural_sort_days_of_the_week_get_default_day_abbreviations
();
return
variable_get
(
'views_natural_sort_days_of_the_week_'
.
$lang
.
'_'
.
$day
,
...
...
@@ -164,8 +183,11 @@ function views_natural_sort_days_of_the_week_get_acceptable_day_abbreviations($d
);
}
/**
*
*/
function
views_natural_sort_days_of_the_week_get_default_day_abbreviations
()
{
return
array
(
return
array
(
array
(
"Sun"
),
array
(
"Mon"
),
array
(
"Tu"
,
"Tue"
,
"Tues"
),
...
...
@@ -175,5 +197,3 @@ function views_natural_sort_days_of_the_week_get_default_day_abbreviations() {
array
(
"Sat"
),
);
}
views_natural_sort.install
View file @
321de921
<?php
/**
* @file
*
*/
/**
* Implementation of hook_schema().
*/
...
...
@@ -67,7 +66,7 @@ function views_natural_sort_install() {
t
(
'An'
),
t
(
'La'
),
t
(
'Le'
),
t
(
'Il'
)
t
(
'Il'
)
,
)
);
variable_set
(
...
...
@@ -127,7 +126,7 @@ function views_natural_sort_update_7200() {
'type'
=>
'varchar'
,
'length'
=>
128
,
'not null'
=>
TRUE
,
'default'
=>
'node'
'default'
=>
'node'
,
)
);
db_add_field
(
...
...
@@ -163,7 +162,7 @@ function views_natural_sort_update_7200() {
* Upgrading 1.x VNS views to 2.x VNS views.
*/
function
views_natural_sort_update_7201
()
{
foreach
(
$views
as
$view_name
=>
$view
)
{
foreach
(
$views
as
$view_name
=>
$view
)
{
foreach
(
$view
->
display
as
&
$display
)
{
if
(
!
empty
(
$display
->
display_options
[
'sorts'
]))
{
foreach
(
$display
->
display_options
[
'sorts'
]
as
&
$sort
)
{
...
...
views_natural_sort.module
View file @
321de921
<?php
/**
* @file
* Provides a views filter that sorts titles by a more natural manner by
* ignoring articles like "The" and "A."
* ignoring articles like "The" and "A."
.
*
* Normal sort:
* A Chorus Line
* All American
* Fiddler on the Roof
* Oklahoma!
* The King And I
* The King And I
.
*
* Natural sort:
* All American
...
...
@@ -44,6 +45,10 @@ function views_natural_sort_views_api() {