function _hierarchical_select_create_export_code in Hierarchical Select 5.3
Same name and namespace in other branches
- 6.3 hierarchical_select.admin.inc \_hierarchical_select_create_export_code()
- 7.3 hierarchical_select.admin.inc \_hierarchical_select_create_export_code()
Given a config array, create the export code for it.
Parameters
$config: A Hierarchical Select config array, as described in API.txt
Return value
The code as it would appear in an editor.
1 call to _hierarchical_select_create_export_code()
- hierarchical_select_admin_export in ./
hierarchical_select.admin.inc - Form definition; config export form.
File
- ./
hierarchical_select.admin.inc, line 241 - Module settings and configuration administration UI.
Code
function _hierarchical_select_create_export_code($config) {
$output = '';
$output .= "\$config = array(\n";
$output .= " 'config_id' => '" . $config['config_id'] . "',\n";
$output .= " 'save_lineage' => " . $config['save_lineage'] . ",\n";
$output .= " 'enforce_deepest' => " . $config['enforce_deepest'] . ",\n";
$output .= " 'entity_count' => " . $config['entity_count'] . ",\n";
$output .= " 'require_entity' => " . $config['require_entity'] . ",\n";
$output .= " 'resizable' => " . $config['resizable'] . ",\n";
$output .= " 'level_labels' => array(\n";
$output .= " 'status' => " . $config['level_labels']['status'] . ",\n";
$output .= " 'labels' => array(\n";
if (isset($config['level_labels']['labels'])) {
foreach ($config['level_labels']['labels'] as $depth => $label) {
$label = str_replace("'", "\\'", $label);
$output .= " {$depth} => '{$label}',\n";
}
}
$output .= " ),\n";
$output .= " ),\n";
$output .= " 'dropbox' => array(\n";
$output .= " 'status' => " . $config['dropbox']['status'] . ",\n";
$output .= " 'title' => '" . str_replace("'", "\\'", $config['dropbox']['title']) . "',\n";
$output .= " 'limit' => " . $config['dropbox']['limit'] . ",\n";
$output .= " 'reset_hs' => " . $config['dropbox']['reset_hs'] . ",\n";
$output .= " ),\n";
$output .= " 'editability' => array(\n";
$output .= " 'status' => " . $config['editability']['status'] . ",\n";
$output .= " 'item_types' => array(\n";
if (isset($config['editability']['item_types'])) {
foreach ($config['editability']['item_types'] as $depth => $item_type) {
$item_type = str_replace("'", "\\'", $item_type);
$output .= " {$depth} => '{$item_type}',\n";
}
}
$output .= " ),\n";
$output .= " 'allowed_levels' => array(\n";
if (isset($config['editability']['allowed_levels'])) {
foreach ($config['editability']['allowed_levels'] as $depth => $allowed_level) {
$output .= " {$depth} => {$allowed_level},\n";
}
}
$output .= " ),\n";
$output .= " 'allow_new_levels' => " . $config['editability']['allow_new_levels'] . ",\n";
$output .= " 'max_levels' => " . $config['editability']['max_levels'] . ",\n";
$output .= " ),\n";
$output .= ");\n";
return $output;
}