function panels_flexible_convert_settings in Panels 7.3
Same name and namespace in other branches
- 6.3 plugins/layouts/flexible/flexible.inc \panels_flexible_convert_settings()
Flexible panel settings converter.
Convert settings from old style to new, or provide defaults for empty settings.
Parameters
array $settings: Drupal settings for the layout.
Return value
null Nothing to return.
8 calls to panels_flexible_convert_settings()
- panels_ajax_flexible_edit_add in plugins/
layouts/ flexible/ flexible.inc - AJAX responder to add a new row, column or region to a flexible layout.
- panels_ajax_flexible_edit_remove in plugins/
layouts/ flexible/ flexible.inc - Panels remove AJAX responder.
- panels_ajax_flexible_edit_resize in plugins/
layouts/ flexible/ flexible.inc - AJAX responder to store resize information when the user adjusts splitter.
- panels_ajax_flexible_edit_reuse in plugins/
layouts/ flexible/ flexible.inc - AJAX form to bring up the "reuse" modal.
- panels_ajax_flexible_edit_settings in plugins/
layouts/ flexible/ flexible.inc - AJAX responder to edit flexible settings for an item.
File
- plugins/
layouts/ flexible/ flexible.inc, line 97 - Flexible layout plugin.
Code
function panels_flexible_convert_settings(&$settings, &$layout) {
// This indicates that this is a layout that they used the checkbox
// on. The layout is still 'flexible' but it's actually pointing
// to another stored one and we have to load it.
if (!empty($settings['layout'])) {
$layout = panels_get_layout('flexible:' . $settings['layout']);
}
if (!empty($layout['layout'])) {
$settings = $layout['layout']->settings;
if ($settings) {
return $settings;
}
}
if (empty($settings)) {
// Set up a default.
$settings = array(
'items' => array(
// The 'canvas' is a special row that does not get rendered
// normally, but is used to contain the columns.
'canvas' => array(
'type' => 'row',
'contains' => 'column',
'children' => array(
'main',
),
'parent' => NULL,
),
'main' => array(
'type' => 'column',
'width' => 100,
'width_type' => '%',
'children' => array(
'main-row',
),
'parent' => 'canvas',
),
'main-row' => array(
'type' => 'row',
'contains' => 'region',
'children' => array(
'center',
),
'parent' => 'main',
),
'center' => array(
'type' => 'region',
'title' => t('Center'),
'width' => 100,
'width_type' => '%',
'parent' => 'main-row',
),
),
);
}
elseif (!isset($settings['items'])) {
// Convert an old style flexible to a new style flexible.
$old = $settings;
$settings = array();
$settings['items']['canvas'] = array(
'type' => 'row',
'contains' => 'column',
'children' => array(),
'parent' => NULL,
);
// Add the left sidebar column, row and region if it exists.
if (!empty($old['sidebars']['left'])) {
$settings['items']['canvas']['children'][] = 'sidebar-left';
$settings['items']['sidebar-left'] = array(
'type' => 'column',
'width' => $old['sidebars']['left_width'],
'width_type' => $old['sidebars']['width_type'],
'children' => array(
'sidebar-left-row',
),
'parent' => 'canvas',
);
$settings['items']['sidebar-left-row'] = array(
'type' => 'row',
'contains' => 'region',
'children' => array(
'sidebar_left',
),
'parent' => 'sidebar-left',
);
$settings['items']['sidebar_left'] = array(
'type' => 'region',
'title' => t('Left sidebar'),
'width' => 100,
'width_type' => '%',
'parent' => 'sidebar-left-row',
);
}
$settings['items']['canvas']['children'][] = 'main';
if (!empty($old['sidebars']['right'])) {
$settings['items']['canvas']['children'][] = 'sidebar-right';
$settings['items']['sidebar-right'] = array(
'type' => 'column',
'width' => $old['sidebars']['right_width'],
'width_type' => $old['sidebars']['width_type'],
'children' => array(
'sidebar-right-row',
),
'parent' => 'canvas',
);
$settings['items']['sidebar-right-row'] = array(
'type' => 'row',
'contains' => 'region',
'children' => array(
'sidebar_right',
),
'parent' => 'sidebar-right',
);
$settings['items']['sidebar_right'] = array(
'type' => 'region',
'title' => t('Right sidebar'),
'width' => 100,
'width_type' => '%',
'parent' => 'sidebar-right-row',
);
}
// Add the main column.
$settings['items']['main'] = array(
'type' => 'column',
'width' => 100,
'width_type' => '%',
'children' => array(),
'parent' => 'canvas',
);
// Add rows and regions.
for ($row = 1; $row <= intval($old['rows']); $row++) {
// Create entry for the row:
$settings['items']["row_{$row}"] = array(
'type' => 'row',
'contains' => 'region',
'children' => array(),
'parent' => 'main',
);
// Add the row to the parent's children:
$settings['items']['main']['children'][] = "row_{$row}";
for ($col = 1; $col <= intval($old["row_{$row}"]['columns']); $col++) {
// Create entry for the region:
$settings['items']["row_{$row}_{$col}"] = array(
'type' => 'region',
'width' => $old["row_{$row}"]["width_{$col}"],
'width_type' => '%',
'parent' => "row_{$row}",
);
// Add entry for the region to the row's children:
$settings['items']["row_{$row}"]['children'][] = "row_{$row}_{$col}";
// Apply the proper title to the region:
if (!empty($old["row_{$row}"]['names'][$col - 1])) {
$settings['items']["row_{$row}_{$col}"]['title'] = $old["row_{$row}"]['names'][$col - 1];
}
else {
$settings['items']["row_{$row}_{$col}"]['title'] = t("Row @row, Column @col", array(
'@row' => $row,
'@col' => $col,
));
}
}
}
}
elseif (isset($settings['canvas'])) {
// Convert the old 'canvas' to the new canvas row.
$settings['items']['canvas'] = array(
'type' => 'row',
'contains' => 'column',
'children' => $settings['canvas'],
'parent' => NULL,
);
unset($settings['canvas']);
}
}