Commit 51879a6c authored by malcomio's avatar malcomio Committed by generalredneck

Issue #2832865 by malcomio: Tidy up code

parent bcbf2ae0
......@@ -65,7 +65,7 @@ function views_natural_sort_remove_symbols($string) {
* Transform numbers in a string into a natural sortable string.
*
* Rules are as follows:
* - Embeded numbers will sort in numerical order. The following possibilities
* - Embedded numbers will sort in numerical order. The following possibilities
* are supported
* - A leading dash indicates a negative number, unless it is preceded by a
* non-whitespace character, which case it is considered just a dash.
......@@ -107,7 +107,7 @@ 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 trailing 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])) {
......
; $Id$
name = Views Natural Sort
description = Sort results naturaly on a text field skipping articles like "the" and "a."
dependencies[] = views
package = Views
core = 6.x
......@@ -15,15 +15,17 @@ function views_natural_sort_help($route_name, RouteMatchInterface $route_match)
switch ($route_name) {
// Main module help for the views_natural_sort module.
case 'help.page.views_natural_sort':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Sort results naturaly on a node&#039;s title skipping articles like &quot;the&quot; and &quot;a.&quot;') . '</p>';
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Sort results naturally on a node&#039;s title skipping articles like &quot;the&quot; and &quot;a.&quot;') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_module_implements_alter().
*/
function views_natural_sort_module_implements_alter(&$implements, $hook) {
if ($hook == 'views_data_alter') {
// Make views natural sort always last so we get all the up to date info.
......@@ -114,7 +116,7 @@ function views_natural_sort_entity_update(EntityInterface $entity) {
/**
* Implementation of hook_entity_delete().
*
* This keep sour natural sort index clean.
* This keeps our natural sort index clean.
*/
function views_natural_sort_entity_delete(EntityInterface $entity) {
views_natural_sort_remove($entry = array(
......@@ -151,13 +153,12 @@ function views_natural_sort_store_multiple(array $index_entries) {
* be sorted by.
* @Not-Rewritten
*/
function views_natural_sort_store(array $index_entry) {
// This should take a formatted object and store it into the views_natural_sort table.
$string = views_natural_sort_transform($index_entry);
// The size limit on the content field for views_natual_sort is sometimes not
// enough. Lets truncate all data down to that size. I personally feel the
// The size limit on the content field for views_natural_sort is sometimes not
// enough. Let's truncate all data down to that size. I personally feel the
// inaccuracy is an acceptable loss, as the bigger the string gets, the less
// permanent the sort.
//
......@@ -189,7 +190,7 @@ function views_natural_sort_store(array $index_entry) {
* $entity_type - The Entity Type. Ex. node
* $field - (optional) reference to the property or field name
* $delta - (optional)the item number in that field or property
* If an optional parameter doesn't exist, this is treated as a wild care
* If an optional parameter doesn't exist, this is treated as a wild card
* delete
* @Not-Rewritten
*/
......@@ -208,7 +209,7 @@ function views_natural_sort_remove($index_entry) {
/**
* Encodes a string into an ascii-sortable string such as:
* - Leading articles in common languages are ingored: The A An El La Le Il
* - Leading articles in common languages are ignored: The A An El La Le Il
* - Unimportant punctuation is ignored: # ' " ( )
* - Unimportant words are ignored: and of or
*
......
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