You are here

function panels_renderer_editor::get_style in Panels 6.3

Same name and namespace in other branches
  1. 7.3 plugins/display_renderers/panels_renderer_editor.class.php \panels_renderer_editor::get_style()

Get the appropriate style from the panel in the cache.

Since we have styles for regions, panes and the display itself, and they are stored differently, we use this method to simplify getting style information into a way that's easy to cope with.

4 calls to panels_renderer_editor::get_style()
panels_renderer_editor::ajax_style in plugins/display_renderers/panels_renderer_editor.class.php
AJAX Router function for style owned AJAX calls.
panels_renderer_editor::ajax_style_settings in plugins/display_renderers/panels_renderer_editor.class.php
AJAX entry point to configure the style for a display, region or pane.
panels_renderer_editor::ajax_style_type in plugins/display_renderers/panels_renderer_editor.class.php
AJAX entry point to select the style for a display, region or pane.
panels_renderer_editor::get_style_links in plugins/display_renderers/panels_renderer_editor.class.php
Get the style links.

File

plugins/display_renderers/panels_renderer_editor.class.php, line 1080
Class file to control the main Panels editor.

Class

panels_renderer_editor
@file Class file to control the main Panels editor.

Code

function get_style($type, $pid = '') {
  if (isset($this->cache->style)) {
    $style = panels_get_style($this->cache->style);
    $defaults = isset($style['defaults']) ? $style['defaults'] : array();

    // Get the &$conf variable based upon whose style we're editing.
    switch ($type) {
      case 'display':
        $this->display->panel_settings['style'] = $this->cache->style;
        $this->display->panel_settings['style_settings']['default'] = $defaults;
        break;
      case 'region':
        $this->display->panel_settings[$pid]['style'] = $this->cache->style;
        $this->display->panel_settings['style_settings'][$pid] = $defaults;
        break;
      case 'pane':
        $pane =& $this->display->content[$pid];
        $pane->style['style'] = $this->cache->style;
        $pane->style['settings'] = $defaults;
        $conf =& $pane->style['settings'];
        break;
    }
  }
  else {
    switch ($type) {
      case 'display':
        $style = panels_get_style(!empty($this->display->panel_settings['style']) ? $this->display->panel_settings['style'] : 'default');
        break;
      case 'region':
        $style = panels_get_style(!empty($this->display->panel_settings[$pid]['style']) ? $this->display->panel_settings[$pid]['style'] : '-1');
        break;
      case 'pane':
        $pane =& $this->display->content[$pid];
        $style = panels_get_style(!empty($pane->style['style']) ? $pane->style['style'] : 'default');
        break;
    }
  }

  // Set up our $conf reference.
  switch ($type) {
    case 'display':
      $conf =& $this->display->panel_settings['style_settings']['default'];
      break;
    case 'region':
      $conf =& $this->display->panel_settings['style_settings'][$pid];
      break;
    case 'pane':
      ctools_include('content');
      $pane =& $this->display->content[$pid];
      $conf =& $pane->style['settings'];
      break;
  }

  // Backward compatibility: Translate old-style stylizer to new style
  // stylizer.
  if ($style['name'] == 'stylizer' && !empty($conf['style']) && $conf['style'] != '$') {
    $style = panels_get_style('stylizer:' . $conf['style']);
  }
  return array(
    $style,
    &$conf,
  );
}