function theme_nodehierarchy_parent_selector in Node Hierarchy 7.4
Same name and namespace in other branches
- 6.3 nodehierarchy.module \theme_nodehierarchy_parent_selector()
- 6.2 nodehierarchy.module \theme_nodehierarchy_parent_selector()
- 7.2 nodehierarchy.module \theme_nodehierarchy_parent_selector()
Theme the parent selector pulldown, allowing for disabled options.
1 theme call to theme_nodehierarchy_parent_selector()
- _nodehierarchy_get_parent_selector in ./
nodehierarchy.admin.inc - Get the parent selector pulldown.
File
- ./
nodehierarchy.admin.inc, line 440 - Admin functions for Node Hierarchy
Code
function theme_nodehierarchy_parent_selector($variables) {
$element = $variables['element'];
element_set_attributes($element, array(
'id',
'name',
'size',
));
_form_set_class($element, array(
'form-select',
));
// Assemble the options.
$options = '';
foreach ($element['#options'] as $key => $option) {
$attributes = '';
// If the option represents a parent item (and not just the none option).
if (!empty($element['#items'][$key]) && ($item = $element['#items'][$key])) {
if ($element['#value'] == $key) {
$attributes .= ' selected="selected"';
}
if ($item->disabled) {
$attributes .= ' disabled="disabled"';
$option .= '*';
$element['#description'] = t('Nodes marked with a * cannot be a parent for this node because they are not an allowed parent type.');
if (user_access('administer hierarchy')) {
$element['#description'] .= t(' To allow these nodes to be parents of this node, change the setting for that node type in the !settings', array(
'!settings' => l(t('Node Hierarchy settings'), 'admin/config/nodehierarchy'),
));
}
}
}
$options .= '<option value="' . check_plain($key) . '"' . $attributes . '>' . $option . '</option>';
}
return '<select' . drupal_attributes($element['#attributes']) . '>' . $options . '</select>';
}