/**
  * Render a pane using its designated style.
  *
  * This method also manages 'title pane' functionality, where the title from
  * an individual pane can be bubbled up to take over the title for the entire
  * display.
  *
  * @param stdClass $pane
  *  A Panels pane object, as loaded from the database.
  */
 function render_pane(&$pane)
 {
     $content = $this->render_pane_content($pane);
     if ($this->display->hide_title == PANELS_TITLE_PANE && !empty($this->display->title_pane) && $this->display->title_pane == $pane->pid) {
         // If the user selected to override the title with nothing, and selected
         // this as the title pane, assume the user actually wanted the original
         // title to bubble up to the top but not actually be used on the pane.
         if (empty($content->title) && !empty($content->original_title)) {
             $this->display->stored_pane_title = $content->original_title;
         } else {
             $this->display->stored_pane_title = !empty($content->title) ? $content->title : '';
         }
     }
     if (!empty($content->content)) {
         if (!empty($pane->style['style'])) {
             $style = panels_get_style($pane->style['style']);
             if (isset($style) && isset($style['render pane'])) {
                 $output = theme($style['render pane'], $content, $pane, $this->display, $style);
                 // This could be null if no theme function existed.
                 if (isset($output)) {
                     return $output;
                 }
             }
         }
         // fallback
         return theme('panels_pane', $content, $pane, $this->display);
     }
 }
  /**
   * 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.
   */
  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);
  }