You are here

function _panels_page_construct_argument_contexts in Panels 6.2

Extracts context data from provided URLs; helper function for _panels_page_master_loader().

Parameters

object $load:

object $panel_page:

array $args:

2 calls to _panels_page_construct_argument_contexts()
panels_page_preview_page in panels_page/panels_page.admin.inc
_panels_page_master_loader in panels_page/panels_page.module
Determine the render-time behavior of panels_page.

File

panels_page/panels_page.module, line 340
panels_page.module

Code

function _panels_page_construct_argument_contexts(&$load, &$panel_page, $args) {

  // At this point, we know we're handling a dynamic/override panels_page.
  // Start off by assuming that we won't fall back.
  $load->fallback = FALSE;

  // TODO Multiple p-pages per path will necessitate more complex logic here
  $load_objects = array();
  foreach ($panel_page->arguments as $id => $argument) {
    $ignore = $argument['default'] == 'ignore';

    // FIXME The directness of this association is questionable
    $load_objects[$id] = array_shift($args);
    $context = !empty($load_objects[$id]) ? panels_argument_get_context($argument, $load_objects[$id]) : PANELS_ARG_IS_BAD;
    if (!is_a($context, 'panels_required_context') && !is_a($context, 'panels_context')) {
      if ($context & PANELS_ARG_USE_FALLBACK) {
        if ($panel_page->load_flags & PANELS_HAS_FALLBACK_ROUTER) {
          $load->fallback = TRUE;
          break;
        }
        else {
          if ($ignore) {
            continue;
          }
        }
      }
      else {
        if ($context & PANELS_ARG_IS_BAD && $ignore) {
          continue;
        }
      }

      // Prep a 404 and bail out if we get this far.
      return _panels_page_not_found($load);
    }
    $panel_page->context[panels_context_id($argument, 'argument')] = $context;
    $load->panel_args[] = $context
      ->get_original_argument();
  }
}