summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Boyer2008-09-20 04:22:37 (GMT)
committerSam Boyer2008-09-20 04:22:37 (GMT)
commit6dda62e1e7ace072246534c8e9688644db2b87e7 (patch)
tree823f5bf98de6fc26c1b7e2908b57fd0b13038de6
parentfeb2071d5c5080a4e08ff704da105d63766fe9f4 (diff)
Forward port from D5 of some minor bugfixes to the display fetching logic.
-rw-r--r--panels_page/panels_page.read.inc39
1 files changed, 27 insertions, 12 deletions
diff --git a/panels_page/panels_page.read.inc b/panels_page/panels_page.read.inc
index 447cd04..1991f92 100644
--- a/panels_page/panels_page.read.inc
+++ b/panels_page/panels_page.read.inc
@@ -203,39 +203,54 @@ function panels_page_fetch_primary_display(&$panel_page) {
}
function panels_page_fetch_alternate_display(&$panel_page, $id) {
+ // Get the metadata abpit the requested display.
$info = $panel_page->displays[$id];
+ // Using the metadata, determine if the desired display exists.
$requested_display_exists = panels_page_fetch_display_from_info($panel_page, $info, $id);
- if (!$requested_display_exists) {
- // The requested display does not exist. First, we try to fall back to the
- // default display for the context we're switching on.
- if (!empty($info['default']) && !empty($panel_page->displays[$info['default']])) {
- panels_page_fetch_display_from_info($panel_page, $panel_page->displays[$info['default']], $id);
- }
- // Otherwise, use the primary display. Load it if it's not already loaded.
- else {
+ if ($requested_display_exists) {
+ // The requested display exists. Drop the $id into $current and bug out.
+ $panel_page->current = $id;
+ return;
+ }
+
+ // The requested display does not exist - determine the fallback display. We
+ // save the $id into the object because we'll need it later for updating
+ // the metadata if we export & save the default we fetch here.
+ $panel_page->export = $id;
+ // First, check for a default display for the context we're switching on,
+ // and try to load that.
+ if (!empty($info['default']) && !empty($panel_page->displays[$info['default']])) {
+ // A default has been defined - figure out if it actually has a display
+ // associated with it.
+ if (!panels_page_fetch_display_from_info($panel_page, $panel_page->displays[$info['default']], $id)) {
+ // No display is associated with the switched default either, so double
+ // fall back to the primary display. Load it if it's not already.
panels_page_fetch_primary_display($panel_page);
}
}
- return TRUE;
+ // There's no default display defined for the context we're switching on, so
+ // just use the primary display as the default. Load it if it's not already.
+ else {
+ panels_page_fetch_primary_display($panel_page);
+ }
}
/**
* Get a display based on whether it's already in code or needs to be loaded.
*/
function panels_page_fetch_display_from_info(&$panel_page, $info, $id) {
- $ret = NULL;
// If the 'display' is set it's the result of an export/default
if (isset($info['display'])) {
$panel_page->display = $info['display'];
- $panel_page->current = $id;
return TRUE;
}
+ // If the $did is numeric, it corresponds to an existing display - load it.
if (is_numeric($info['did'])) {
$panel_page->display = panels_load_display($info['did']);
- $panel_page->current = $id;
return TRUE;
}
+
return FALSE;
}