Full ELMS Learning Network documentation
function element_children
cis7 common.inc | element_children(&$elements, $sort = FALSE) |
cle7 common.inc | element_children(&$elements, $sort = FALSE) |
elmsmedia7 common.inc | element_children(&$elements, $sort = FALSE) |
icor7 common.inc | element_children(&$elements, $sort = FALSE) |
meedjum_blog7 common.inc | element_children(&$elements, $sort = FALSE) |
mooc7 common.inc | element_children(&$elements, $sort = FALSE) |
Identifies the children of an element array, optionally sorted by weight.
The children of a element array are those key/value pairs whose key does not start with a '#'. See drupal_render() for details.
Parameters
$elements: The element array whose children are to be identified.
$sort: Boolean to indicate whether the children should be sorted by weight.
Return value
The array keys of the element's children.
186 calls to element_children()
- adaptivetheme_page_alter in sites/
all/ themes/ ulmus/ adaptivetheme/ at_core/ inc/ alter.inc - hook_page_alter()
- admin_menu_admin_menu_output_build in sites/
all/ modules/ ulmus/ admin_menu/ admin_menu.module - Implements hook_admin_menu_output_build().
- admin_menu_toolbar_admin_menu_output_alter in sites/
all/ modules/ ulmus/ admin_menu/ admin_menu_toolbar/ admin_menu_toolbar.module - Implements hook_admin_menu_output_alter().
- advanced_help_form_system_modules_alter in sites/
all/ modules/ ulmus/ advanced_help/ advanced_help.module - Implements hook_form_system_modules_alter().
- alpha_calculate_position in sites/
all/ themes/ ulmus/ omega/ alpha/ includes/ alpha.inc - Calculates the position of a element in a grid container by using the #weight as the DOM position and then calculation the required pull and push CSS classes to move the affected elements to their proper #position value.
File
- includes/
common.inc, line 6413 - Common functions that many Drupal modules will need to reference.
Code
function element_children(&$elements, $sort = FALSE) {
// Do not attempt to sort elements which have already been sorted.
$sort = isset($elements['#sorted']) ? !$elements['#sorted'] : $sort;
// Filter out properties from the element, leaving only children.
$children = array();
$sortable = FALSE;
foreach ($elements as $key => $value) {
if ($key === '' || $key[0] !== '#') {
$children[$key] = $value;
if (is_array($value) && isset($value['#weight'])) {
$sortable = TRUE;
}
}
}
// Sort the children if necessary.
if ($sort && $sortable) {
uasort($children, 'element_sort');
// Put the sorted children back into $elements in the correct order, to
// preserve sorting if the same element is passed through
// element_children() twice.
foreach ($children as $key => $child) {
unset($elements[$key]);
$elements[$key] = $child;
}
$elements['#sorted'] = TRUE;
}
return array_keys($children);
}