Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

reorder_nodes()

Description

Virtually re-order nodes

Temporarily re-order nodes (mostly) for display purposes

Parameters

ColumnTypeDefaultDescription
$unordered_nodes array Original nodes array

Return

array

Location

include/node_functions.php lines 596 to 633

Definition

 
function reorder_nodes(array $unordered_nodes)
    {
    
// Put $auto_order_checkbox and $auto_order_checkbox_case_insensitive as global 
    // to future proof function for when we will drop globals for easier refactoring
    
global $auto_order_checkbox$auto_order_checkbox_case_insensitive;

    
$reordered_options = array();
    
$use_index_key     = array();
    foreach(
$unordered_nodes as $unordered_node_index => $node)
        {
        
$reordered_options[$node['ref']] = normalize_keyword(i18n_get_translated($node['name']),true);
        
$use_index_key[$node['ref']]     = ($unordered_node_index == $node['ref']);
        }

    if(isset(
$auto_order_checkbox) && $auto_order_checkbox && $auto_order_checkbox_case_insensitive)
        {
        
natcasesort($reordered_options);
        }
    else
        {
        
natsort($reordered_options);
        }

    
$reordered_nodes = array();
    foreach(
$reordered_options as $reordered_node_id => $reordered_node_option)
        {
        if(!
$use_index_key[$reordered_node_id])
            {
            
$reordered_nodes[$reordered_node_id] = $unordered_nodes[array_search($reordered_node_idarray_column($unordered_nodes'ref'))];
            }
        else
            {
            
$reordered_nodes[$reordered_node_id] = $unordered_nodes[array_search($reordered_node_idarray_column($unordered_nodes'ref''ref'))];
            }
        }

    return 
$reordered_nodes;
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.