|
@@ -1,9 +1,14 @@
|
|
<?php
|
|
<?php
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Implementation of hook_panels_layouts()
|
|
+ * @file
|
|
|
|
+ * Flexible layout plugin.
|
|
*/
|
|
*/
|
|
-// Plugin definition
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Implementation of hook_panels_layouts().
|
|
|
|
+ */
|
|
|
|
+// Plugin definition.
|
|
$plugin = array(
|
|
$plugin = array(
|
|
'title' => t('Flexible'),
|
|
'title' => t('Flexible'),
|
|
'category' => t('Builders'),
|
|
'category' => t('Builders'),
|
|
@@ -18,14 +23,13 @@ $plugin = array(
|
|
'regions function' => 'panels_flexible_panels',
|
|
'regions function' => 'panels_flexible_panels',
|
|
'hook menu' => 'panels_flexible_menu',
|
|
'hook menu' => 'panels_flexible_menu',
|
|
|
|
|
|
- // Reuisable layout Builder specific directives
|
|
+ // Reusable layout Builder specific directives.
|
|
'builder' => TRUE,
|
|
'builder' => TRUE,
|
|
- 'builder tab title' => 'Add flexible layout', // menu so translated elsewhere
|
|
+ 'builder tab title' => 'Add flexible layout',
|
|
-
|
|
|
|
'get child' => 'panels_flexible_get_sublayout',
|
|
'get child' => 'panels_flexible_get_sublayout',
|
|
'get children' => 'panels_flexible_get_sublayouts',
|
|
'get children' => 'panels_flexible_get_sublayouts',
|
|
|
|
|
|
- // Define ajax callbacks
|
|
+ // Define ajax callbacks.
|
|
'ajax' => array(
|
|
'ajax' => array(
|
|
'settings' => 'panels_ajax_flexible_edit_settings',
|
|
'settings' => 'panels_ajax_flexible_edit_settings',
|
|
'add' => 'panels_ajax_flexible_edit_add',
|
|
'add' => 'panels_ajax_flexible_edit_add',
|
|
@@ -79,9 +83,16 @@ function panels_flexible_get_sublayouts($plugin, $layout_name) {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * Flexible panel settings converter.
|
|
|
|
+ *
|
|
* Convert settings from old style to new, or provide defaults for
|
|
* Convert settings from old style to new, or provide defaults for
|
|
* empty settings.
|
|
* empty settings.
|
|
- * @param <type> $settings
|
|
+ *
|
|
|
|
+ * @param array $settings
|
|
|
|
+ * Drupal settings for the layout.
|
|
|
|
+ *
|
|
|
|
+ * @return null
|
|
|
|
+ * Nothing to return.
|
|
*/
|
|
*/
|
|
function panels_flexible_convert_settings(&$settings, &$layout) {
|
|
function panels_flexible_convert_settings(&$settings, &$layout) {
|
|
// This indicates that this is a layout that they used the checkbox
|
|
// This indicates that this is a layout that they used the checkbox
|
|
@@ -99,7 +110,7 @@ function panels_flexible_convert_settings(&$settings, &$layout) {
|
|
}
|
|
}
|
|
|
|
|
|
if (empty($settings)) {
|
|
if (empty($settings)) {
|
|
- // set up a default
|
|
+ // Set up a default.
|
|
$settings = array(
|
|
$settings = array(
|
|
'items' => array(
|
|
'items' => array(
|
|
// The 'canvas' is a special row that does not get rendered
|
|
// The 'canvas' is a special row that does not get rendered
|
|
@@ -133,7 +144,7 @@ function panels_flexible_convert_settings(&$settings, &$layout) {
|
|
),
|
|
),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
- else if (!isset($settings['items'])) {
|
|
+ elseif (!isset($settings['items'])) {
|
|
// Convert an old style flexible to a new style flexible.
|
|
// Convert an old style flexible to a new style flexible.
|
|
$old = $settings;
|
|
$old = $settings;
|
|
$settings = array();
|
|
$settings = array();
|
|
@@ -143,7 +154,7 @@ function panels_flexible_convert_settings(&$settings, &$layout) {
|
|
'children' => array(),
|
|
'children' => array(),
|
|
'parent' => NULL,
|
|
'parent' => NULL,
|
|
);
|
|
);
|
|
- // add the left sidebar column, row and region if it exists.
|
|
+ // Add the left sidebar column, row and region if it exists.
|
|
if (!empty($old['sidebars']['left'])) {
|
|
if (!empty($old['sidebars']['left'])) {
|
|
$settings['items']['canvas']['children'][] = 'sidebar-left';
|
|
$settings['items']['canvas']['children'][] = 'sidebar-left';
|
|
$settings['items']['sidebar-left'] = array(
|
|
$settings['items']['sidebar-left'] = array(
|
|
@@ -205,28 +216,28 @@ function panels_flexible_convert_settings(&$settings, &$layout) {
|
|
|
|
|
|
// Add rows and regions.
|
|
// Add rows and regions.
|
|
for ($row = 1; $row <= intval($old['rows']); $row++) {
|
|
for ($row = 1; $row <= intval($old['rows']); $row++) {
|
|
- // Create entry for the row
|
|
+ // Create entry for the row:
|
|
$settings['items']["row_$row"] = array(
|
|
$settings['items']["row_$row"] = array(
|
|
'type' => 'row',
|
|
'type' => 'row',
|
|
'contains' => 'region',
|
|
'contains' => 'region',
|
|
'children' => array(),
|
|
'children' => array(),
|
|
'parent' => 'main',
|
|
'parent' => 'main',
|
|
);
|
|
);
|
|
- // Add the row to the parent's children
|
|
+ // Add the row to the parent's children:
|
|
$settings['items']['main']['children'][] = "row_$row";
|
|
$settings['items']['main']['children'][] = "row_$row";
|
|
|
|
|
|
for ($col = 1; $col <= intval($old["row_$row"]['columns']); $col++) {
|
|
for ($col = 1; $col <= intval($old["row_$row"]['columns']); $col++) {
|
|
- // Create entry for the region
|
|
+ // Create entry for the region:
|
|
$settings['items']["row_${row}_$col"] = array(
|
|
$settings['items']["row_${row}_$col"] = array(
|
|
'type' => 'region',
|
|
'type' => 'region',
|
|
'width' => $old["row_$row"]["width_$col"],
|
|
'width' => $old["row_$row"]["width_$col"],
|
|
'width_type' => '%',
|
|
'width_type' => '%',
|
|
'parent' => "row_$row",
|
|
'parent' => "row_$row",
|
|
);
|
|
);
|
|
- // Add entry for the region to the row's children
|
|
+ // Add entry for the region to the row's children:
|
|
$settings['items']["row_$row"]['children'][] = "row_${row}_$col";
|
|
$settings['items']["row_$row"]['children'][] = "row_${row}_$col";
|
|
|
|
|
|
- // Apply the proper title to the region
|
|
+ // Apply the proper title to the region:
|
|
if (!empty($old["row_$row"]['names'][$col - 1])) {
|
|
if (!empty($old["row_$row"]['names'][$col - 1])) {
|
|
$settings['items']["row_${row}_$col"]['title'] = $old["row_$row"]['names'][$col - 1];
|
|
$settings['items']["row_${row}_$col"]['title'] = $old["row_$row"]['names'][$col - 1];
|
|
}
|
|
}
|
|
@@ -236,7 +247,7 @@ function panels_flexible_convert_settings(&$settings, &$layout) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if (isset($settings['canvas'])) {
|
|
+ elseif (isset($settings['canvas'])) {
|
|
// Convert the old 'canvas' to the new canvas row.
|
|
// Convert the old 'canvas' to the new canvas row.
|
|
$settings['items']['canvas'] = array(
|
|
$settings['items']['canvas'] = array(
|
|
'type' => 'row',
|
|
'type' => 'row',
|
|
@@ -259,7 +270,7 @@ function panels_flexible_panels($display, $settings, $layout) {
|
|
if (!isset($item['type'])) {
|
|
if (!isset($item['type'])) {
|
|
unset($items[$id]);
|
|
unset($items[$id]);
|
|
}
|
|
}
|
|
- else if ($item['type'] == 'region') {
|
|
+ elseif ($item['type'] == 'region') {
|
|
$items[$id] = $item['title'];
|
|
$items[$id] = $item['title'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -276,13 +287,13 @@ function panels_flexible_panels($display, $settings, $layout) {
|
|
* @todo Convert the functions to methods and make this properly OO.
|
|
* @todo Convert the functions to methods and make this properly OO.
|
|
*/
|
|
*/
|
|
function panels_flexible_create_renderer($admin, $css_id, $content, $settings, &$display, $layout, $handler) {
|
|
function panels_flexible_create_renderer($admin, $css_id, $content, $settings, &$display, $layout, $handler) {
|
|
- $renderer = new stdClass;
|
|
+ $renderer = new stdClass();
|
|
$renderer->settings = $settings;
|
|
$renderer->settings = $settings;
|
|
$renderer->content = $content;
|
|
$renderer->content = $content;
|
|
$renderer->css_id = $css_id;
|
|
$renderer->css_id = $css_id;
|
|
$renderer->did = &$display->did;
|
|
$renderer->did = &$display->did;
|
|
if ($admin) {
|
|
if ($admin) {
|
|
- // always scale in admin mode.
|
|
+ // Always scale in admin mode.
|
|
$renderer->scale_base = 99.0;
|
|
$renderer->scale_base = 99.0;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -325,7 +336,6 @@ function panels_flexible_create_renderer($admin, $css_id, $content, $settings, &
|
|
$renderer->row_separation = !empty($settings['items']['canvas']['row_separation']) ? $settings['items']['canvas']['row_separation'] : '0.5em';
|
|
$renderer->row_separation = !empty($settings['items']['canvas']['row_separation']) ? $settings['items']['canvas']['row_separation'] : '0.5em';
|
|
|
|
|
|
// Make some appended classes so it's easier to reference them.
|
|
// Make some appended classes so it's easier to reference them.
|
|
-
|
|
|
|
$renderer->base['column'] = $renderer->item_class['column'] . '-' . $renderer->base_class;
|
|
$renderer->base['column'] = $renderer->item_class['column'] . '-' . $renderer->base_class;
|
|
$renderer->base['row'] = $renderer->item_class['row'] . '-' . $renderer->base_class;
|
|
$renderer->base['row'] = $renderer->item_class['row'] . '-' . $renderer->base_class;
|
|
$renderer->base['region'] = $renderer->item_class['region'] . '-' . $renderer->base_class;
|
|
$renderer->base['region'] = $renderer->item_class['region'] . '-' . $renderer->base_class;
|
|
@@ -386,7 +396,7 @@ function theme_panels_flexible($vars) {
|
|
}
|
|
}
|
|
|
|
|
|
// Also store the CSS on the display in case the live preview or something
|
|
// Also store the CSS on the display in case the live preview or something
|
|
- // needs it
|
|
+ // needs it.
|
|
$display->add_css = $css;
|
|
$display->add_css = $css;
|
|
|
|
|
|
$output = "<div class=\"panel-flexible " . $renderer->base['canvas'] . " clearfix\" $renderer->id_str>\n";
|
|
$output = "<div class=\"panel-flexible " . $renderer->base['canvas'] . " clearfix\" $renderer->id_str>\n";
|
|
@@ -394,7 +404,7 @@ function theme_panels_flexible($vars) {
|
|
|
|
|
|
$output .= panels_flexible_render_items($renderer, $settings['items']['canvas']['children'], $renderer->base['canvas']);
|
|
$output .= panels_flexible_render_items($renderer, $settings['items']['canvas']['children'], $renderer->base['canvas']);
|
|
|
|
|
|
- // Wrap the whole thing up nice and snug
|
|
+ // Wrap the whole thing up nice and snug.
|
|
$output .= "</div>\n</div>\n";
|
|
$output .= "</div>\n</div>\n";
|
|
|
|
|
|
return $output;
|
|
return $output;
|
|
@@ -443,7 +453,7 @@ function theme_panels_flexible_admin($vars) {
|
|
$content = panels_flexible_render_items($renderer, $settings['items']['canvas']['children'], $renderer->base['row'] . '-canvas');
|
|
$content = panels_flexible_render_items($renderer, $settings['items']['canvas']['children'], $renderer->base['row'] . '-canvas');
|
|
$output .= panels_flexible_render_item($renderer, $settings['items']['canvas'], $content, 'canvas', 0, 0, TRUE);
|
|
$output .= panels_flexible_render_item($renderer, $settings['items']['canvas'], $content, 'canvas', 0, 0, TRUE);
|
|
|
|
|
|
- // Wrap the whole thing up nice and snug
|
|
+ // Wrap the whole thing up nice and snug.
|
|
$output .= "</div>\n</div>\n";
|
|
$output .= "</div>\n</div>\n";
|
|
|
|
|
|
drupal_add_js($layout['path'] . '/flexible-admin.js');
|
|
drupal_add_js($layout['path'] . '/flexible-admin.js');
|
|
@@ -464,7 +474,7 @@ function panels_flexible_render_items($renderer, $list, $owner_id) {
|
|
$item = $renderer->settings['items'][$id];
|
|
$item = $renderer->settings['items'][$id];
|
|
$location = isset($renderer->positions[$id]) ? $renderer->positions[$id] : 'middle';
|
|
$location = isset($renderer->positions[$id]) ? $renderer->positions[$id] : 'middle';
|
|
|
|
|
|
- if ($renderer->admin && $item['type'] != 'row' && $prev ) {
|
|
+ if ($renderer->admin && $item['type'] != 'row' && $prev) {
|
|
$groups[$location] .= panels_flexible_render_splitter($renderer, $prev, $id);
|
|
$groups[$location] .= panels_flexible_render_splitter($renderer, $prev, $id);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -475,12 +485,14 @@ function panels_flexible_render_items($renderer, $list, $owner_id) {
|
|
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
|
|
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'row':
|
|
case 'row':
|
|
$content = panels_flexible_render_items($renderer, $item['children'], $renderer->base['row'] . '-' . $id);
|
|
$content = panels_flexible_render_items($renderer, $item['children'], $renderer->base['row'] . '-' . $id);
|
|
if (empty($renderer->settings['items'][$id]['hide_empty']) || trim($content)) {
|
|
if (empty($renderer->settings['items'][$id]['hide_empty']) || trim($content)) {
|
|
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max, TRUE);
|
|
$groups[$location] .= panels_flexible_render_item($renderer, $item, $content, $id, $position, $max, TRUE);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'region':
|
|
case 'region':
|
|
if (empty($renderer->settings['items'][$id]['hide_empty'])) {
|
|
if (empty($renderer->settings['items'][$id]['hide_empty'])) {
|
|
$content = isset($renderer->content[$id]) ? $renderer->content[$id] : " ";
|
|
$content = isset($renderer->content[$id]) ? $renderer->content[$id] : " ";
|
|
@@ -611,7 +623,7 @@ function panels_flexible_render_splitter($renderer, $left_id, $right_id) {
|
|
$output = '<div tabindex="0"
|
|
$output = '<div tabindex="0"
|
|
class="panels-flexible-splitter flexible-splitter-for-' . $left_class . '">';
|
|
class="panels-flexible-splitter flexible-splitter-for-' . $left_class . '">';
|
|
|
|
|
|
- // Name the left object
|
|
+ // Name the left object:
|
|
$output .= '<span class="panels-flexible-splitter-left">';
|
|
$output .= '<span class="panels-flexible-splitter-left">';
|
|
$output .= '.' . $left_class;
|
|
$output .= '.' . $left_class;
|
|
$output .= '</span>';
|
|
$output .= '</span>';
|
|
@@ -632,7 +644,7 @@ function panels_flexible_render_splitter($renderer, $left_id, $right_id) {
|
|
$output .= $left['width_type'];
|
|
$output .= $left['width_type'];
|
|
$output .= '</span>';
|
|
$output .= '</span>';
|
|
|
|
|
|
- // Name the right object
|
|
+ // Name the right object:
|
|
$output .= '<span class="panels-flexible-splitter-right">';
|
|
$output .= '<span class="panels-flexible-splitter-right">';
|
|
$output .= '.' . $right_class;
|
|
$output .= '.' . $right_class;
|
|
$output .= '</span>';
|
|
$output .= '</span>';
|
|
@@ -677,7 +689,7 @@ function panels_flexible_render_item_links($renderer, $id, $item) {
|
|
$add2 = t('Add row to bottom');
|
|
$add2 = t('Add row to bottom');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if ($item['type'] == 'row') {
|
|
+ elseif ($item['type'] == 'row') {
|
|
if ($id == 'canvas') {
|
|
if ($id == 'canvas') {
|
|
$title = t('Canvas');
|
|
$title = t('Canvas');
|
|
$settings = t('Canvas settings');
|
|
$settings = t('Canvas settings');
|
|
@@ -697,7 +709,7 @@ function panels_flexible_render_item_links($renderer, $id, $item) {
|
|
$add2 = $item['contains'] == 'region' ? t('Add region to right') : t('Add column to right');
|
|
$add2 = $item['contains'] == 'region' ? t('Add region to right') : t('Add column to right');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if ($item['type'] == 'region') {
|
|
+ elseif ($item['type'] == 'region') {
|
|
$title = t('Region');
|
|
$title = t('Region');
|
|
$settings = t('Region settings');
|
|
$settings = t('Region settings');
|
|
$remove = t('Remove region');
|
|
$remove = t('Remove region');
|
|
@@ -757,7 +769,7 @@ function panels_flexible_render_css($renderer) {
|
|
function panels_flexible_render_css_group($renderer, $list, $owner_id, $type, $id) {
|
|
function panels_flexible_render_css_group($renderer, $list, $owner_id, $type, $id) {
|
|
$css = array();
|
|
$css = array();
|
|
|
|
|
|
- // Start off with some generic CSS to properly pad regions
|
|
+ // Start off with some generic CSS to properly pad regions.
|
|
$css[$owner_id . ' .' . $renderer->item_class['region']] = array(
|
|
$css[$owner_id . ' .' . $renderer->item_class['region']] = array(
|
|
'padding' => '0',
|
|
'padding' => '0',
|
|
);
|
|
);
|
|
@@ -792,7 +804,7 @@ function panels_flexible_render_css_group($renderer, $list, $owner_id, $type, $i
|
|
'padding-right' => '0',
|
|
'padding-right' => '0',
|
|
);
|
|
);
|
|
|
|
|
|
- // And properly pad rows too
|
|
+ // And properly pad rows too:
|
|
$css[$owner_id . ' .' . $renderer->item_class['row']] = array(
|
|
$css[$owner_id . ' .' . $renderer->item_class['row']] = array(
|
|
'padding' => '0 0 ' . $renderer->row_separation . ' 0',
|
|
'padding' => '0 0 ' . $renderer->row_separation . ' 0',
|
|
'margin' => '0',
|
|
'margin' => '0',
|
|
@@ -818,7 +830,6 @@ function panels_flexible_get_css_group(&$css, $renderer, $list, $owner_id, $type
|
|
if ($type != 'row') {
|
|
if ($type != 'row') {
|
|
// Go through our items and break up into right/center/right groups so we
|
|
// Go through our items and break up into right/center/right groups so we
|
|
// can figure out our offsets.
|
|
// can figure out our offsets.
|
|
-
|
|
|
|
// right == any items on the right that are 'fixed'.
|
|
// right == any items on the right that are 'fixed'.
|
|
// middle == all fluid items.
|
|
// middle == all fluid items.
|
|
// right == any items on the right that are 'fixed'.
|
|
// right == any items on the right that are 'fixed'.
|
|
@@ -827,7 +838,7 @@ function panels_flexible_get_css_group(&$css, $renderer, $list, $owner_id, $type
|
|
$current = 'left';
|
|
$current = 'left';
|
|
foreach ($list as $id) {
|
|
foreach ($list as $id) {
|
|
if ($renderer->settings['items'][$id]['width_type'] == 'px') {
|
|
if ($renderer->settings['items'][$id]['width_type'] == 'px') {
|
|
- // fixed
|
|
+ // Fixed:
|
|
if ($current == 'left') {
|
|
if ($current == 'left') {
|
|
$left[] = $id;
|
|
$left[] = $id;
|
|
$renderer->positions[$id] = 'left';
|
|
$renderer->positions[$id] = 'left';
|
|
@@ -841,14 +852,14 @@ function panels_flexible_get_css_group(&$css, $renderer, $list, $owner_id, $type
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- // fluid
|
|
+ // Fluid:
|
|
if ($current != 'right') {
|
|
if ($current != 'right') {
|
|
$current = 'middle';
|
|
$current = 'middle';
|
|
$middle[] = $id;
|
|
$middle[] = $id;
|
|
$renderer->positions[$id] = 'middle';
|
|
$renderer->positions[$id] = 'middle';
|
|
$middle_total += $renderer->settings['items'][$id]['width'];
|
|
$middle_total += $renderer->settings['items'][$id]['width'];
|
|
}
|
|
}
|
|
- // fall through: if current is 'right' and we ran into a 'fluid' then
|
|
+ // Fall through: if current is 'right' and we ran into a 'fluid' then
|
|
// it gets *dropped* because that is invalid.
|
|
// it gets *dropped* because that is invalid.
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -903,7 +914,7 @@ function panels_flexible_get_css_group(&$css, $renderer, $list, $owner_id, $type
|
|
$css["$owner_id-inside"]['padding-left'] = '0px';
|
|
$css["$owner_id-inside"]['padding-left'] = '0px';
|
|
if ($renderer->admin || count($middle)) {
|
|
if ($renderer->admin || count($middle)) {
|
|
$css["$owner_id-middle"]['margin-left'] = $left_total . 'px';
|
|
$css["$owner_id-middle"]['margin-left'] = $left_total . 'px';
|
|
- // IE hack
|
|
+ // IE hack!
|
|
$css["* html $owner_id-left"]['left'] = $left_total . "px";
|
|
$css["* html $owner_id-left"]['left'] = $left_total . "px";
|
|
// Make this one very specific to the admin CSS so that preview
|
|
// Make this one very specific to the admin CSS so that preview
|
|
// does not stomp it.
|
|
// does not stomp it.
|
|
@@ -912,7 +923,7 @@ function panels_flexible_get_css_group(&$css, $renderer, $list, $owner_id, $type
|
|
else {
|
|
else {
|
|
$css["$owner_id-inside"]['margin-left'] = '-' . $left_total . 'px';
|
|
$css["$owner_id-inside"]['margin-left'] = '-' . $left_total . 'px';
|
|
$css["$owner_id-inside"]['padding-left'] = $left_total . 'px';
|
|
$css["$owner_id-inside"]['padding-left'] = $left_total . 'px';
|
|
- // IE hack
|
|
+ // IE hack!
|
|
$css["* html $owner_id-inside"]['left'] = $left_total . "px";
|
|
$css["* html $owner_id-inside"]['left'] = $left_total . "px";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -958,8 +969,10 @@ function panels_flexible_get_css_group(&$css, $renderer, $list, $owner_id, $type
|
|
/**
|
|
/**
|
|
* AJAX responder to edit flexible settings for an item.
|
|
* AJAX responder to edit flexible settings for an item.
|
|
*
|
|
*
|
|
- * $handler object
|
|
+ * @param object $handler
|
|
* The display renderer handler object.
|
|
* The display renderer handler object.
|
|
|
|
+ * @param mixed $id
|
|
|
|
+ * Id for the panel.
|
|
*/
|
|
*/
|
|
function panels_ajax_flexible_edit_settings($handler, $id) {
|
|
function panels_ajax_flexible_edit_settings($handler, $id) {
|
|
$settings = &$handler->display->layout_settings;
|
|
$settings = &$handler->display->layout_settings;
|
|
@@ -976,11 +989,11 @@ function panels_ajax_flexible_edit_settings($handler, $id) {
|
|
$siblings = $settings['items'][$item['parent']]['children'];
|
|
$siblings = $settings['items'][$item['parent']]['children'];
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
switch ($item['type']) {
|
|
switch ($item['type']) {
|
|
case 'column':
|
|
case 'column':
|
|
$title = t('Configure column');
|
|
$title = t('Configure column');
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'row':
|
|
case 'row':
|
|
if ($id == 'canvas') {
|
|
if ($id == 'canvas') {
|
|
$title = t('Configure canvas');
|
|
$title = t('Configure canvas');
|
|
@@ -989,6 +1002,7 @@ function panels_ajax_flexible_edit_settings($handler, $id) {
|
|
$title = t('Configure row');
|
|
$title = t('Configure row');
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'region':
|
|
case 'region':
|
|
$title = t('Configure region');
|
|
$title = t('Configure region');
|
|
break;
|
|
break;
|
|
@@ -1026,9 +1040,9 @@ function panels_ajax_flexible_edit_settings($handler, $id) {
|
|
$output[] = ajax_command_replace('.flexible-links-' . $id,
|
|
$output[] = ajax_command_replace('.flexible-links-' . $id,
|
|
panels_flexible_render_item_links($renderer, $id, $item));
|
|
panels_flexible_render_item_links($renderer, $id, $item));
|
|
|
|
|
|
- // If editing the canvas, reset the CSS width
|
|
+ // If editing the canvas, reset the CSS width.
|
|
if ($id == 'canvas') {
|
|
if ($id == 'canvas') {
|
|
- // update canvas CSS.
|
|
+ // Update canvas CSS.
|
|
$css = array(
|
|
$css = array(
|
|
'.' . $renderer->item_class['column'] . '-inside' => array(
|
|
'.' . $renderer->item_class['column'] . '-inside' => array(
|
|
'padding-left' => $renderer->column_separation,
|
|
'padding-left' => $renderer->column_separation,
|
|
@@ -1061,9 +1075,6 @@ function panels_ajax_flexible_edit_settings($handler, $id) {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Configure a row, column or region on the flexible page.
|
|
* Configure a row, column or region on the flexible page.
|
|
- *
|
|
|
|
- * @param <type> $form_state
|
|
|
|
- * @return <type>
|
|
|
|
*/
|
|
*/
|
|
function panels_flexible_config_item_form($form, &$form_state) {
|
|
function panels_flexible_config_item_form($form, &$form_state) {
|
|
$display = &$form_state['display'];
|
|
$display = &$form_state['display'];
|
|
@@ -1162,8 +1173,9 @@ function panels_flexible_config_item_form($form, &$form_state) {
|
|
if ($sibling == $id) {
|
|
if ($sibling == $id) {
|
|
$current = 'right';
|
|
$current = 'right';
|
|
}
|
|
}
|
|
- else if ($settings['items'][$sibling]['width_type'] == '%') {
|
|
+ elseif ($settings['items'][$sibling]['width_type'] == '%') {
|
|
- $$current = TRUE; // Indirection.
|
|
+ // Indirection.
|
|
|
|
+ $$current = TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1234,7 +1246,7 @@ function panels_flexible_config_item_form_submit(&$form, &$form_state) {
|
|
$item['region_separation'] = $form_state['values']['region_separation'];
|
|
$item['region_separation'] = $form_state['values']['region_separation'];
|
|
$item['row_separation'] = $form_state['values']['row_separation'];
|
|
$item['row_separation'] = $form_state['values']['row_separation'];
|
|
}
|
|
}
|
|
- else if ($item['type'] != 'row') {
|
|
+ elseif ($item['type'] != 'row') {
|
|
$item['width_type'] = $form_state['values']['width_type'];
|
|
$item['width_type'] = $form_state['values']['width_type'];
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -1270,6 +1282,7 @@ function panels_ajax_flexible_edit_add($handler, $id, $location = 'left') {
|
|
'parent' => $id,
|
|
'parent' => $id,
|
|
);
|
|
);
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'row':
|
|
case 'row':
|
|
switch ($parent['contains']) {
|
|
switch ($parent['contains']) {
|
|
case 'region':
|
|
case 'region':
|
|
@@ -1282,6 +1295,7 @@ function panels_ajax_flexible_edit_add($handler, $id, $location = 'left') {
|
|
'parent' => $id,
|
|
'parent' => $id,
|
|
);
|
|
);
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'column':
|
|
case 'column':
|
|
$title = $location == 'left' ? t('Add column to left') : t('Add column to right');
|
|
$title = $location == 'left' ? t('Add column to left') : t('Add column to right');
|
|
$item = array(
|
|
$item = array(
|
|
@@ -1295,6 +1309,7 @@ function panels_ajax_flexible_edit_add($handler, $id, $location = 'left') {
|
|
}
|
|
}
|
|
// Create the new item with defaults.
|
|
// Create the new item with defaults.
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'region':
|
|
case 'region':
|
|
// Cannot add items to regions.
|
|
// Cannot add items to regions.
|
|
break;
|
|
break;
|
|
@@ -1344,8 +1359,8 @@ function panels_ajax_flexible_edit_add($handler, $id, $location = 'left') {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- // render the item
|
|
+ // Render the item.
|
|
- $parent_class = $renderer->base[$parent['type']] . '-' . $id;
|
|
+ $parent_class = $renderer->base[$parent['type']] . '-' . $id;
|
|
$item_output = panels_flexible_render_item($renderer, $item, $content, $form_state['key'], 0, 0, $item['type'] == 'row');
|
|
$item_output = panels_flexible_render_item($renderer, $item, $content, $form_state['key'], 0, 0, $item['type'] == 'row');
|
|
|
|
|
|
// Get all the CSS necessary for the entire row (as width adjustments may
|
|
// Get all the CSS necessary for the entire row (as width adjustments may
|
|
@@ -1364,22 +1379,24 @@ function panels_ajax_flexible_edit_add($handler, $id, $location = 'left') {
|
|
$item_output .= panels_flexible_render_splitter($renderer, $form_state['key'], $form_state['sibling']);
|
|
$item_output .= panels_flexible_render_splitter($renderer, $form_state['key'], $form_state['sibling']);
|
|
$output[] = ajax_command_prepend('#panels-dnd-main .' . $parent_class . '-left', $item_output);
|
|
$output[] = ajax_command_prepend('#panels-dnd-main .' . $parent_class . '-left', $item_output);
|
|
}
|
|
}
|
|
- else if ($location == 'right') {
|
|
+ elseif ($location == 'right') {
|
|
// If we are adding to the right side of the left box, there is
|
|
// If we are adding to the right side of the left box, there is
|
|
// a splitter that we have to remove; then we add our box normally,
|
|
// a splitter that we have to remove; then we add our box normally,
|
|
// and then add a new splitter for just our guy.
|
|
// and then add a new splitter for just our guy.
|
|
$output[] = ajax_command_remove('panels-flexible-splitter-for-' . $renderer->base[$item['type']] . '-' . $form_state['key']);
|
|
$output[] = ajax_command_remove('panels-flexible-splitter-for-' . $renderer->base[$item['type']] . '-' . $form_state['key']);
|
|
- $item_output = panels_flexible_render_splitter($renderer, $form_state['sibling'], $form_state['key']) . $item_output;
|
|
+ $item_output = panels_flexible_render_splitter($renderer, $form_state['sibling'], $form_state['key']) . $item_output;
|
|
$item_output .= panels_flexible_render_splitter($renderer, $form_state['key'], NULL);
|
|
$item_output .= panels_flexible_render_splitter($renderer, $form_state['key'], NULL);
|
|
$output[] = ajax_command_append('#panels-dnd-main .' . $parent_class . '-left', $item_output);
|
|
$output[] = ajax_command_append('#panels-dnd-main .' . $parent_class . '-left', $item_output);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'right':
|
|
case 'right':
|
|
if (!empty($form_state['sibling'])) {
|
|
if (!empty($form_state['sibling'])) {
|
|
- $item_output = panels_flexible_render_splitter($renderer, $form_state['sibling'], $form_state['key']) . $item_output;
|
|
+ $item_output = panels_flexible_render_splitter($renderer, $form_state['sibling'], $form_state['key']) . $item_output;
|
|
}
|
|
}
|
|
$output[] = ajax_command_append('#panels-dnd-main .' . $parent_class . '-right', $item_output);
|
|
$output[] = ajax_command_append('#panels-dnd-main .' . $parent_class . '-right', $item_output);
|
|
break;
|
|
break;
|
|
|
|
+
|
|
case 'middle':
|
|
case 'middle':
|
|
if ($location == 'left') {
|
|
if ($location == 'left') {
|
|
if (!empty($form_state['sibling'])) {
|
|
if (!empty($form_state['sibling'])) {
|
|
@@ -1389,7 +1406,7 @@ function panels_ajax_flexible_edit_add($handler, $id, $location = 'left') {
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
if (!empty($form_state['sibling'])) {
|
|
if (!empty($form_state['sibling'])) {
|
|
- $item_output = panels_flexible_render_splitter($renderer, $form_state['sibling'], $form_state['key']) . $item_output;
|
|
+ $item_output = panels_flexible_render_splitter($renderer, $form_state['sibling'], $form_state['key']) . $item_output;
|
|
}
|
|
}
|
|
$output[] = ajax_command_append('#panels-dnd-main .' . $parent_class . '-middle', $item_output);
|
|
$output[] = ajax_command_append('#panels-dnd-main .' . $parent_class . '-middle', $item_output);
|
|
}
|
|
}
|
|
@@ -1429,8 +1446,6 @@ function panels_ajax_flexible_edit_add($handler, $id, $location = 'left') {
|
|
}
|
|
}
|
|
/**
|
|
/**
|
|
* Form to add a row, column or region to a flexible layout.
|
|
* Form to add a row, column or region to a flexible layout.
|
|
- * @param <type> $form_state
|
|
|
|
- * @return <type>
|
|
|
|
*/
|
|
*/
|
|
function panels_flexible_add_item_form($form, &$form_state) {
|
|
function panels_flexible_add_item_form($form, &$form_state) {
|
|
$display = &$form_state['display'];
|
|
$display = &$form_state['display'];
|
|
@@ -1543,7 +1558,7 @@ function panels_flexible_add_item_form_submit(&$form, &$form_state) {
|
|
$item['hide_empty'] = $form_state['values']['hide_empty'];
|
|
$item['hide_empty'] = $form_state['values']['hide_empty'];
|
|
|
|
|
|
if ($item['type'] == 'region') {
|
|
if ($item['type'] == 'region') {
|
|
- // derive the region key from the title
|
|
+ // Derive the region key from the title.
|
|
$key = preg_replace("/[^a-z0-9]/", '_', drupal_strtolower($item['title']));
|
|
$key = preg_replace("/[^a-z0-9]/", '_', drupal_strtolower($item['title']));
|
|
while (isset($settings['items'][$key])) {
|
|
while (isset($settings['items'][$key])) {
|
|
$key .= '_';
|
|
$key .= '_';
|
|
@@ -1569,7 +1584,7 @@ function panels_flexible_add_item_form_submit(&$form, &$form_state) {
|
|
// If there is no sibling, or the sibling is of a different type,
|
|
// If there is no sibling, or the sibling is of a different type,
|
|
// the default 100 will work for either fixed or fluid.
|
|
// the default 100 will work for either fixed or fluid.
|
|
if ($form_state['sibling'] && $settings['items'][$form_state['sibling']]['width_type'] == $item['width_type']) {
|
|
if ($form_state['sibling'] && $settings['items'][$form_state['sibling']]['width_type'] == $item['width_type']) {
|
|
- // steal half of the sibling's space.
|
|
+ // Steal half of the sibling's space.
|
|
$width = $settings['items'][$form_state['sibling']]['width'] / 2;
|
|
$width = $settings['items'][$form_state['sibling']]['width'] / 2;
|
|
$settings['items'][$form_state['sibling']]['width'] = $width;
|
|
$settings['items'][$form_state['sibling']]['width'] = $width;
|
|
$item['width'] = $width;
|
|
$item['width'] = $width;
|
|
@@ -1587,8 +1602,9 @@ function panels_flexible_add_item_form_submit(&$form, &$form_state) {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * AJAX responder to remove an existing row, column or region from a flexible
|
|
+ * Panels remove AJAX responder.
|
|
- * layout.
|
|
+ *
|
|
|
|
+ * Removes an existing row, column or region from a flexible layout.
|
|
*/
|
|
*/
|
|
function panels_ajax_flexible_edit_remove($handler, $id) {
|
|
function panels_ajax_flexible_edit_remove($handler, $id) {
|
|
$settings = &$handler->display->layout_settings;
|
|
$settings = &$handler->display->layout_settings;
|
|
@@ -1602,10 +1618,8 @@ function panels_ajax_flexible_edit_remove($handler, $id) {
|
|
$css_id = isset($handler->display->css_id) ? $handler->display->css_id : '';
|
|
$css_id = isset($handler->display->css_id) ? $handler->display->css_id : '';
|
|
// Create a renderer object so we can render our new stuff.
|
|
// Create a renderer object so we can render our new stuff.
|
|
$renderer = panels_flexible_create_renderer(TRUE, $css_id, array(), $settings, $handler->display, $handler->plugins['layout'], $handler);
|
|
$renderer = panels_flexible_create_renderer(TRUE, $css_id, array(), $settings, $handler->display, $handler->plugins['layout'], $handler);
|
|
-
|
|
|
|
-
|
|
|
|
$siblings = &$settings['items'][$item['parent']]['children'];
|
|
$siblings = &$settings['items'][$item['parent']]['children'];
|
|
- $parent_class = '.' . $renderer->base[$settings['items'][$item['parent']]['type']] . '-' . $item['parent'];
|
|
+ $parent_class = '.' . $renderer->base[$settings['items'][$item['parent']]['type']] . '-' . $item['parent'];
|
|
|
|
|
|
// Find the offset of our array. This will also be the key because
|
|
// Find the offset of our array. This will also be the key because
|
|
// this is a simple array.
|
|
// this is a simple array.
|
|
@@ -1627,7 +1641,7 @@ function panels_ajax_flexible_edit_remove($handler, $id) {
|
|
$settings['items'][$next]['width'] += $item['width'];
|
|
$settings['items'][$next]['width'] += $item['width'];
|
|
}
|
|
}
|
|
// If that failed, try the previous one.
|
|
// If that failed, try the previous one.
|
|
- else if (isset($prev) && $settings['items'][$prev]['width_type'] == '%') {
|
|
+ elseif (isset($prev) && $settings['items'][$prev]['width_type'] == '%') {
|
|
$settings['items'][$prev]['width'] += $item['width'];
|
|
$settings['items'][$prev]['width'] += $item['width'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1687,8 +1701,7 @@ function panels_ajax_flexible_edit_remove($handler, $id) {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * AJAX responder to store resize information when the user adjusts the
|
|
+ * AJAX responder to store resize information when the user adjusts splitter.
|
|
- * splitter.
|
|
|
|
*/
|
|
*/
|
|
function panels_ajax_flexible_edit_resize($handler) {
|
|
function panels_ajax_flexible_edit_resize($handler) {
|
|
ctools_include('ajax');
|
|
ctools_include('ajax');
|