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
bfc9734c
Commit
bfc9734c
authored
Jan 29, 2013
by
generalredneck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#1614234
] Enabling field index creation and update in views_natural_sort table.
parent
062b8731
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
3 deletions
+75
-3
views_natural_sort.module
views_natural_sort.module
+6
-1
views_natural_sort_text_field.module
views_natural_sort_text_field.module
+68
-0
views_natural_sort_text_field.views.inc
views_natural_sort_text_field.views.inc
+1
-2
No files found.
views_natural_sort.module
View file @
bfc9734c
...
...
@@ -57,6 +57,11 @@ function views_natural_sort_menu() {
return
$items
;
}
function
views_natural_sort_store_multiple
(
array
$index_entries
)
{
foreach
(
$index_entries
as
$entry
)
{
views_natural_sort_store
(
$entry
);
}
}
function
views_natural_sort_store
(
$index_entry
)
{
//This should take a formatted object and store it into the views_natural_sort table.
return
db_merge
(
'views_natural_sort'
)
...
...
@@ -91,7 +96,7 @@ function views_natural_sort_remove($index_entry) {
*/
function
views_natural_sort_views_api
()
{
return
array
(
'api'
=>
2
.0
,
'api'
=>
3
.0
,
);
}
...
...
views_natural_sort_text_field.module
View file @
bfc9734c
...
...
@@ -14,3 +14,71 @@ function views_natural_sort_text_field_form_field_ui_field_edit_form_alter(&$for
'#default_value'
=>
0
,
);
}
function
views_natural_sort_text_field_views_natural_sort_get_rebuild_data
()
{
$data
=
array
();
$configured_fields
=
views_natural_sort_text_field_get_configured_fields
();
foreach
(
$configured_fields
as
$field
)
{
//TODO: in get_configured_fields() remove the entity types and bundles we don't want.
foreach
(
$field
[
'bundles'
]
as
$entity_type
=>
$bundles
)
{
$entities
=
entity_load
(
$entity_type
);
foreach
(
$entities
as
$entity
)
{
//TODO: add = back in.
$data
+=
_views_natural_sort_text_field_to_vns
(
$entity_type
,
$entity
,
$field
);
}
}
}
return
$data
;
}
function
views_natural_sort_text_field_field_attach_insert
(
$entity_type
,
$entity
)
{
$configured_fields
=
views_natural_sort_text_field_get_configured_fields
();
foreach
(
$configured_fields
as
$field
)
{
if
(
in_array
(
$entity_type
,
array_keys
(
$field
[
'bundles'
]))){
_views_natural_sort_text_field_store
(
$entity_type
,
$entity
,
$field
);
}
}
}
function
views_natural_sort_text_field_field_attach_update
(
$entity_type
,
$entity
)
{
$configured_fields
=
views_natural_sort_text_field_get_configured_fields
();
foreach
(
$configured_fields
as
$field
)
{
if
(
in_array
(
$entity_type
,
array_keys
(
$field
[
'bundles'
]))){
_views_natural_sort_text_field_store
(
$entity_type
,
$entity
,
$field
);
}
}
}
function
views_natural_sort_text_field_get_configured_fields
(){
$all_fields
=
field_info_fields
();
$returned_fields
=
array
();
foreach
(
$all_fields
as
$field_name
=>
$field
)
{
if
(
$field
[
'module'
]
==
'text'
&&
$field
[
'storage'
][
'type'
]
==
'field_sql_storage'
&&
$field
[
'columns'
][
'value'
][
'type'
]
==
'varchar'
)
{
$returned_fields
[
$field
[
'id'
]]
=
$field
;
}
}
return
$returned_fields
;
}
function
_views_natural_sort_text_field_store
(
$entity_type
,
$entity
,
$field
)
{
views_natural_sort_store_multiple
(
_views_natural_sort_text_field_to_vns
(
$entity_type
,
$entity
,
$field
));
}
function
_views_natural_sort_text_field_to_vns
(
$entity_type
,
$entity
,
$field
)
{
$entity_info
=
entity_get_info
(
$entity_type
);
$entity_id_property
=
$entity_info
[
'entity keys'
][
'id'
];
$field_name
=
$field
[
'field_name'
];
//TODO: add support for Field Language
$entries
=
array
();
foreach
(
field_get_items
(
$entity_type
,
$entity
,
$field_name
)
as
$delta
=>
$row
)
{
$entries
[]
=
array
(
'eid'
=>
$entity
->
$entity_id_property
,
'entity_type'
=>
$entity_type
,
'field'
=>
$field_name
,
'delta'
=>
$delta
,
'content'
=>
$row
[
'value'
]
);
}
return
$entries
;
}
views_natural_sort_text_field.views.inc
View file @
bfc9734c
...
...
@@ -2,10 +2,9 @@
function
views_natural_sort_text_field_field_views_data_alter
(
&
$data
,
$field
,
$module
)
{
// TODO: check to see if field is "registered" to be sort naturally.
if
(
$module
!=
'text'
||
$field
[
'storage'
][
'type'
]
!=
'field_sql_storage'
||
$field
[
'columns'
][
'value'
][
'type'
]
!=
'varchar'
)
{
if
(
!
in_array
(
$field
[
'id'
],
array_keys
(
views_natural_sort_text_field_get_configured_fields
()))
)
{
return
;
}
$field_table
=
_field_sql_storage_tablename
(
$field
);
$data
[
$field_table
][
$field
[
'field_name'
]
.
'_value'
][
'sort'
][
'handler'
]
=
'views_natural_sort_handler_sort_text_field'
;
dvm
(
$data
[
$field_table
]);
}
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