function ds_export_stylesheet in Display Suite 6
Export stylesheet.
1 string reference to 'ds_export_stylesheet'
- _ds_ui_menu in includes/
ds.registry.inc - Return menu items and import default settings.
File
- includes/
ds.tools.inc, line 337 - Tools for Display suite like export & import.
Code
function ds_export_stylesheet() {
$selectors = array();
$regions = ds_regions();
$all_build_modes = ds_get_build_modes();
// Build an array of selectors of all enabled objects and fields.
foreach (module_implements('ds_api') as $module) {
// Let's skip hds for now
if ($module == 'hds' || $module == 'vd') {
continue;
}
$api_info = ds_api_info($module);
// Title.
$selectors[] = "/* " . $api_info['title'] . " */\n";
// Regions
$selectors[] = "/* Regions */";
$selectors[] = str_replace('@replace', $module, ds_export_style_sheet_regions());
// Get all objects.
$build_modes = $all_build_modes[$module];
if (!empty($build_modes)) {
foreach ($api_info['types']() as $tkey => $type) {
$type_name = $type->type;
$type_url_str = str_replace('_', '-', $type_name);
$display_settings = variable_get($module . '_display_settings_' . $type_name, array());
// Global exclude.
if (variable_get($module . '_type_' . $type->type, FALSE)) {
continue;
}
$type_selectors = array();
$exclude_build_modes = variable_get($module . '_buildmodes_exclude', array());
foreach ($build_modes as $key => $value) {
// Check if build mode is excluded for this object type.
$excluded = isset($exclude_build_modes[$type_name][$key]) && $exclude_build_modes[$type_name][$key] == TRUE ? TRUE : FALSE;
if ($excluded) {
continue;
}
// Get any configured fields.
$field_settings = ds_default_value($display_settings, $key, 'fields');
if (empty($field_settings)) {
continue;
}
foreach ($field_settings as $field_key => $field) {
if ($field['region'] != 'disabled') {
$class = isset($field['properties']['css-class']) ? $field['properties']['css-class'] : 'field-' . strtr($field_key, '_', '-');
if (isset($field_settings[$field]['css-class']) && !empty($field_settings[$field]['css-class'])) {
$class .= ' ' . $field_settings[$field]['css-class'];
}
if ($field['type'] == DS_FIELD_TYPE_GROUP) {
$class .= ' field-group';
}
// This actually a bit hardcoded, pity.
switch ($module) {
case 'nd':
$prefix = '.buildmode-' . $key . ' .node-type-' . $type_name;
break;
case 'ud':
$prefix = '.buildmode-' . $key . ' .profile';
break;
case 'cd':
$prefix = '.buildmode-' . $key . ' .comment';
break;
}
$type_selectors[] = $prefix . " ." . $class . " {\n}";
}
}
}
// Add selectors when not empty.
if (!empty($type_selectors)) {
$selectors[] = "/* Fields of " . $type_name . " */\n";
$selectors = array_merge($selectors, $type_selectors);
$selectors[] = "";
}
}
}
}
$skeleton = implode("\n", $selectors);
$form = array();
$form['info'] = array(
'#type' => 'markup',
'#value' => t('The textarea underneath generates a skeleton stylesheet for enabled objects and fields in your site. Views displays and Heartbeat displays are not supported yet.'),
);
$form['skeleton'] = array(
'#type' => 'textarea',
'#rows' => 25,
'#default_value' => $skeleton,
);
return $form;
}