function taxonomy_tools_copier_content in Taxonomy Tools 8
Same name and namespace in other branches
- 7 taxonomy_tools_copier/taxonomy_tools_copier.admin.inc \taxonomy_tools_copier_content()
Builds taxonomy term hierarchical tree.
Parameters
int $root: The current taxonomy term identificator.
int $parent: The parent identificator of current taxonomy term.
1 call to taxonomy_tools_copier_content()
- taxonomy_tools_copier_copy_form in taxonomy_tools_copier/
taxonomy_tools_copier.admin.inc - Builds taxonomy term branch copying form.
File
- taxonomy_tools_copier/
taxonomy_tools_copier.admin.inc, line 222 - Administrative page callbacks for the Taxonomy Copier module.
Code
function taxonomy_tools_copier_content($root, $parent = 0) {
$content = array();
$term = array(
'#type' => 'container',
);
// Set proper class for container.
if ($parent == 0) {
$term['#attributes']['class'] = array(
'root-container',
);
}
else {
$term['#attributes']['class'] = array(
'child-container',
);
$term['#attributes']['name'] = $parent . '-children';
}
$term['tid'] = array(
'#type' => 'hidden',
'#value' => $root,
);
// Parent value.
$term[$root . '-parent'] = array(
'#type' => 'hidden',
'#value' => $parent,
'#attributes' => array(
'class' => array(
$root . '-parent',
),
),
);
// Checkbox representing whether to copy this term.
$term[$root . '-option'] = array(
'#type' => 'checkbox',
'#title' => taxonomy_tools_term_title($root),
);
$term_copy_options = variable_get('taxonomy_tools_copier_term_config', 'none');
if ($parent == 0 && $term_copy_options != 'none' || $parent > 0 && $term_copy_options == 'all') {
$term[$root . '-option']['#attributes'] = array(
'checked' => 'checked',
);
}
// Set proper checkbox class.
$term[$root . '-option']['#attributes']['class'] = array(
$root . '-option',
);
// Nodes associated with this term.
$term += taxonomy_tools_copier_nodes($root);
// Check for term children.
$children = taxonomy_get_children($root);
if (!empty($children)) {
// Create a similar container for each child.
$term[$root . '-children'] = array();
foreach ($children as $child) {
$child_content = taxonomy_tools_copier_content($child->tid, $root);
$term[$root . '-children'] = array_merge($term[$root . '-children'], $child_content);
}
}
$content[$root . '-content'] = $term;
return $content;
}