function _image_gallery_parent_select in Image 6
Same name and namespace in other branches
- 5.2 contrib/image_gallery/image_gallery.module \_image_gallery_parent_select()
- 5 contrib/image_gallery/image_gallery.module \_image_gallery_parent_select()
- 7 contrib/image_gallery/image_gallery.admin.inc \_image_gallery_parent_select()
1 call to _image_gallery_parent_select()
- image_gallery_admin_form in contrib/
image_gallery/ image_gallery.admin.inc - Form for editing or adding a gallery.
File
- contrib/
image_gallery/ image_gallery.admin.inc, line 170 - Contains menu callbacks for image_gallery admin pages.
Code
function _image_gallery_parent_select($tid, $title) {
$parents = taxonomy_get_parents($tid);
if ($parents) {
$parent = array_shift($parents);
$parent = $parent->tid;
}
else {
$parent = 0;
}
$children = taxonomy_get_tree(_image_gallery_get_vid(), $tid);
// A term can't be the child of itself, nor of its children.
foreach ($children as $child) {
$exclude[] = $child->tid;
}
$exclude[] = $tid;
$tree = taxonomy_get_tree(_image_gallery_get_vid());
$options[0] = '<' . t('root') . '>';
if ($tree) {
foreach ($tree as $term) {
if (!in_array($term->tid, $exclude)) {
$options[$term->tid] = str_repeat(' -- ', $term->depth) . ' ' . $term->name;
}
}
}
return array(
'#type' => 'select',
'#title' => $title,
'#default_value' => $parent,
'#options' => $options,
'#description' => t('Image galleries may be nested below other galleries.'),
'#required' => TRUE,
);
}