You are here

function theme_panels_flexible in Panels 6.3

Same name and namespace in other branches
  1. 5.2 layouts/flexible.inc \theme_panels_flexible()
  2. 6.2 layouts/flexible/flexible.inc \theme_panels_flexible()
  3. 7.3 plugins/layouts/flexible/flexible.inc \theme_panels_flexible()

Draw the flexible layout.

1 call to theme_panels_flexible()
theme_panels_flexible_admin in plugins/layouts/flexible/flexible.inc
Draw the flexible layout.

File

plugins/layouts/flexible/flexible.inc, line 344

Code

function theme_panels_flexible($id, $content, $settings, $display, $layout, $handler) {
  panels_flexible_convert_settings($settings, $layout);
  $renderer = panels_flexible_create_renderer(FALSE, $id, $content, $settings, $display, $layout, $handler);

  // CSS must be generated because it reports back left/middle/right
  // positions.
  $css = panels_flexible_render_css($renderer);
  if (!empty($renderer->css_cache_name) && empty($display->editing_layout)) {
    ctools_include('css');

    // Generate an id based upon rows + columns:
    $filename = ctools_css_retrieve($renderer->css_cache_name);
    if (!$filename) {
      $filename = ctools_css_store($renderer->css_cache_name, $css, FALSE);
    }

    // Give the CSS to the renderer to put where it wants.
    if ($handler) {
      $handler
        ->add_css($filename, 'module', 'all', FALSE);
    }
    else {
      ctools_css_add_css($filename, 'module', 'all', FALSE);
    }
  }
  else {

    // If the id is 'new' we can't reliably cache the CSS in the filesystem
    // because the display does not truly exist, so we'll stick it in the
    // head tag. We also do this if we've been told we're in the layout
    // editor so that it always gets fresh CSS.
    drupal_set_html_head("<style type=\"text/css\">\n{$css}</style>\n");
  }

  // Also store the CSS on the display in case the live preview or something
  // needs it
  $display->add_css = $css;
  $output = "<div class=\"panel-flexible " . $renderer->base['canvas'] . " clear-block\" {$renderer->id_str}>\n";
  $output .= "<div class=\"panel-flexible-inside " . $renderer->base['canvas'] . "-inside\">\n";
  $output .= panels_flexible_render_items($renderer, $settings['items']['canvas']['children'], $renderer->base['canvas']);

  // Wrap the whole thing up nice and snug
  $output .= "</div>\n</div>\n";
  return $output;
}