function panels_page_view_page in Panels 5.2
Page callback to view a panel page.
2 string references to 'panels_page_view_page'
- panels_page_admin_menu_items in panels_page/
panels_page.module - Helper function to add a menu item for a panel.
- _panels_page_menu_item in panels_page/
panels_page.module - Helper function to create a menu item for a panel.
File
- panels_page/
panels_page.module, line 621 - panels_page.module
Code
function panels_page_view_page($panel_page, $admin) {
if (!is_object($panel_page)) {
$panel_page = panels_page_load($panel_page);
}
if (!$panel_page) {
return drupal_not_found();
}
panels_load_include('plugins');
$switchers = panels_get_switchers();
if ($switchers) {
$list = array();
$candidates = array();
$result = db_query("SELECT name FROM {panels_page} WHERE switcher_name = '%s'", $panel_page->name);
// get a list of all pages that might switch for this one
while ($candidate = db_fetch_object($result)) {
$list[] = $candidate->name;
}
// Add default panels that apply to the list as well
foreach (panels_page_default_panels() as $page) {
if ($page->switcher_name == $panel_page->name) {
$candidates[$page->name] = $page;
}
}
if ($list) {
$candidates += count($list) > 1 ? panels_page_load_all($list) : array(
panels_page_load($list[0]),
);
}
if ($candidates) {
// separate them based on switcher type
$pages = array();
foreach ($candidates as $candidate) {
$pages[$candidate->switcher_type][$candidate->name] = $candidate;
}
// go through switcher types and switch the first one that matches.
foreach ($pages as $plugin => $candidates) {
if ($page = panels_switcher_switch($plugin, 'panel_page', $panel_page->name, $candidates)) {
$panel_page = $page;
break;
}
}
}
}
$args = func_get_args();
// remove the name.
array_shift($args);
// remove the admin flag.
array_shift($args);
$output = '';
if ($admin) {
// Display an admin form to make it easy to set up arguments.
panels_load_include('panels_page.admin', 'panels_page/');
$output .= drupal_get_form('panels_page_admin_view', $panel_page, $args);
}
else {
// This piece of code goes deep into the menu system, finds the
// administrative link for this panel and puts it between us and
// whatever menu item is our parent. This causes the tabs to follow us
// around without losing our previous menu context.
panels_move_menu_tabs("admin/panels/panel-page/{$panel_page->name}", "/edit/general");
}
if (empty($panel_page->context)) {
$panel_page->context = array();
}
if ($panel_page->arguments) {
if (!panels_argument_load_contexts($panel_page->arguments, $panel_page->context, $args)) {
if ($admin) {
return $output . t('Page reports "Page not found" due to argument restrictions');
}
else {
return drupal_not_found();
}
}
}
$panel_page->context = panels_context_load_contexts($panel_page, FALSE, $panel_page->context);
$panel_page->keywords = panels_context_get_keywords($panel_page->context);
// Figure out which display to use.
$display_id = panels_argument_get_display($panel_page->arguments, $panel_page->context);
panels_page_fetch_display($panel_page, $display_id);
$display = $panel_page->display;
// Figure out if these contexts include a form; will be NULL if there
// isn't one, or the context if there is.
$form = panels_context_get_form($panel_page->context);
// This is the first point at which it is safe to add items to the display
// as the argument handling, above, may choose which display is actually
// used.
$display->args = $args;
$display->context = $panel_page->context;
$display->keywords = $panel_page->keywords;
$display->css_id = $panel_page->css_id;
$display->owner = $panel_page;
// unique id of this display's owner.
$display->owner->id = $panel_page->name;
$display->type = 'panel_page';
// Set this as 'current' so that other stuff can utilize it.
panels_page_get_current($panel_page);
if ($form) {
$form->form['#theme'] = 'panels_page_render_form';
$form->form['#display'] = $display;
$output .= drupal_render_form($form->form_id, $form->form);
}
else {
$output .= panels_render_display($display);
}
// set title afterward to ensure title is retained.
if ($output == NULL) {
return drupal_not_found();
}
if (!$display->hide_title && ($title = filter_xss_admin(panels_page_get_title($panel_page, 'page', '')))) {
drupal_set_title($title);
}
else {
drupal_set_title('');
}
if ($panel_page->css) {
panels_load_include('panels_page.css_filter', 'panels_page/');
$css = panels_page_filter_css(panels_page_disassemble_css($panel_page->css));
// If the custom css didn't survive filtering, don't bother adding it.
if (!empty($css)) {
drupal_set_html_head("<style type=\"text/css\" media=\"all\">" . panels_page_compress_css($css) . "</style>\n");
}
}
if ($panel_page->no_blocks) {
print theme('page', $output, FALSE);
}
else {
return $output;
}
}