You are here

function theme_panels_flexible_admin in Panels 7.3

Same name and namespace in other branches
  1. 6.3 plugins/layouts/flexible/flexible.inc \theme_panels_flexible_admin()

Draw the flexible layout.

File

plugins/layouts/flexible/flexible.inc, line 416
Flexible layout plugin.

Code

function theme_panels_flexible_admin($vars) {
  $css_id = $vars['css_id'];
  $content = $vars['content'];
  $settings = $vars['settings'];
  $display = $vars['display'];
  $layout = $vars['layout'];
  $handler = $vars['renderer'];

  // We never draw stored flexible layouts in admin mode; they must be edited
  // from the stored layout UI at that point.
  if (!empty($layout['layout'])) {
    return theme_panels_flexible(array(
      'css_id' => $css_id,
      'content' => $content,
      'settings' => $settings,
      'display' => $display,
      'layout' => $layout,
      'renderer' => $handler,
    ));
  }
  panels_flexible_convert_settings($settings, $layout);
  $renderer = panels_flexible_create_renderer(TRUE, $css_id, $content, $settings, $display, $layout, $handler);
  $css = panels_flexible_render_css($renderer);

  // For the administrative view, add CSS directly to head.
  drupal_add_css($css, array(
    'type' => 'inline',
    'preprocess' => FALSE,
  ));
  if (empty($display->editing_layout)) {
    $output = '<input type="submit" id="panels-flexible-toggle-layout" class="form-submit" value ="' . t('Show layout designer') . '">';
    if (user_access('administer panels layouts')) {
      $output .= '<input type="hidden" class="panels-flexible-reuse-layout-url" value="' . url($handler
        ->get_url('layout', 'reuse'), array(
        'absolute' => TRUE,
      )) . '">';
      $output .= '<input type="submit" id="panels-flexible-reuse-layout" class="form-submit ctools-use-modal" value ="' . t('Reuse layout') . '">';
    }
    $output .= "<div class=\"panel-flexible " . $renderer->base['canvas'] . " clearfix panel-flexible-admin panel-flexible-no-edit-layout\" {$renderer->id_str}>\n";
  }
  else {
    $output = "<div class=\"panel-flexible " . $renderer->base['canvas'] . " clearfix panel-flexible-admin panel-flexible-edit-layout\" {$renderer->id_str}>\n";
  }
  $output .= "<div class=\"panel-flexible-inside " . $renderer->base['canvas'] . "-inside \">\n";
  $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);

  // Wrap the whole thing up nice and snug.
  $output .= "</div>\n</div>\n";
  drupal_add_js($layout['path'] . '/flexible-admin.js');
  drupal_add_js(array(
    'flexible' => array(
      'resize' => url($handler
        ->get_url('layout', 'resize'), array(
        'absolute' => TRUE,
      )),
    ),
  ), 'setting');
  return $output;
}