[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/panels/plugins/styles/corners/ -> rounded_corners.inc (source)

   1  <?php
   2  // $Id: rounded_corners.inc,v 1.1.2.16 2010/07/23 22:47:18 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   * Definition of the 'rounded_corners' panel style.
   7   */
   8  
   9  // Plugin definition
  10  $plugin = array(
  11    'title' => t('Rounded corners'),
  12    'description' => t('Presents the panes or panel regions with a rounded corner box around them'),
  13    'render region' => 'panels_rounded_corners_style_render_region',
  14    'render pane' => 'panels_rounded_corners_style_render_pane',
  15    'settings form' => 'panels_rounded_corners_style_settings_form',
  16    'hook theme' => array(
  17      'panels_rounded_corners_box' => array(
  18        'arguments' => array('content' => NULL),
  19        'path' => panels_get_path('plugins/styles/corners'),
  20        'template' => 'panels-rounded-corners-box',
  21      ),
  22    ),
  23  );
  24  
  25  /**
  26   * Render callback.
  27   *
  28   * @ingroup themeable
  29   */
  30  function theme_panels_rounded_corners_style_render_region($display, $region_id, $panes, $settings) {
  31    $output = '';
  32  
  33    // Determine where to put the box. If empty or 'pane' around each pane. If
  34    // 'panel' then just around the whole panel.
  35    $where = empty($settings['corner_location']) ? 'pane' : $settings['corner_location'];
  36  
  37    $print_separator = FALSE;
  38    foreach ($panes as $pane_id => $pane_output) {
  39      if ($pane_output) {
  40        // Add the separator if we've already displayed a pane.
  41        if ($print_separator) {
  42          $output .= '<div class="panel-region-separator">&nbsp;</div>';
  43        }
  44  
  45        if ($where == 'pane') {
  46          $output .= theme('panels_rounded_corners_box', $pane_output);
  47        }
  48        else {
  49          $output .= $pane_output;
  50          $print_separator = TRUE;
  51        }
  52      }
  53    }
  54  
  55    if ($where == 'panel') {
  56      $output = theme('panels_rounded_corners_box', $output);
  57    }
  58  
  59    panels_add_rounded_corners_css($display, $where);
  60  
  61    return $output;
  62  }
  63  
  64  function panels_add_rounded_corners_css($display, $where) {
  65    static $displays_used = array();
  66    if (empty($displays_used[$display->css_id])) {
  67      panels_rounded_corners_css($display, $where);
  68      $displays_used[$display->css_id] = TRUE;
  69    }
  70  }
  71  
  72  /**
  73   * Render callback for a single pane.
  74   */
  75  function theme_panels_rounded_corners_style_render_pane($content, $pane, $display) {
  76    if (empty($content->content)) {
  77      return;
  78    }
  79  
  80    $output = theme('panels_pane', $content, $pane, $display);
  81  
  82    // Just stick a box around the standard theme_panels_pane.
  83    $output = theme('panels_rounded_corners_box', $output);
  84    panels_add_rounded_corners_css($display, 'pane');
  85    return $output;
  86  }
  87  
  88  /**
  89   * Settings form callback.
  90   */
  91  function panels_rounded_corners_style_settings_form($style_settings) {
  92    $form['corner_location'] = array(
  93      '#type' => 'select',
  94      '#title' => t('Box around'),
  95      '#options' => array(
  96        'pane' => t('Each pane'),
  97        'panel' => t('Each region'),
  98      ),
  99      '#default_value' => (isset($style_settings['corner_location'])) ? $style_settings['corner_location'] : 'ul',
 100      '#description' => t('Choose whether to include the box around each pane (piece of content) or region (each column or region)'),
 101    );
 102  
 103    return $form;
 104  }
 105  
 106  /**
 107   * Generates the dynamic CSS.
 108   *
 109   * @param $display
 110   *   A Panels display object.
 111   */
 112  function panels_rounded_corners_css($display) {
 113    $idstr = empty($display->css_id) ? '.rounded-corner' : "#$display->css_id .rounded-corner";
 114    $css_id = 'rounded-corner:' . $idstr;
 115  
 116    ctools_include('css');
 117    $filename = ctools_css_retrieve($css_id);
 118    if (!$filename) {
 119      $filename = ctools_css_store($css_id, _panels_rounded_corners_css($idstr), FALSE);
 120    }
 121  
 122    ctools_css_add_css($filename, 'module', 'all', FALSE);
 123  }
 124  
 125  /**
 126   * Generates the dynamic CSS.
 127   */
 128  function _panels_rounded_corners_css($idstr) {
 129    $url = panels_get_path('plugins/styles/corners', TRUE);
 130  
 131    $css = <<<EOF
 132  
 133  .t-edge, .b-edge, .l-edge, .r-edge, .wrap-corner {
 134    position: relative;
 135    /* hasLayout -1 ? For IE only */
 136    zoom: 1;
 137  }
 138  $idstr .t-edge {
 139    background: url('$url/shadow-t.png') repeat-x 0 top;
 140    font-size: 1px;
 141  }
 142  $idstr .b-edge {
 143    background: url('$url/shadow-b.png') repeat-x 0 bottom;
 144    font-size: 1px;
 145  }
 146  $idstr .l-edge {
 147    background: url('$url/shadow-l.png') repeat-y 0 0;
 148  }
 149  $idstr .r-edge {
 150    background: url('$url/shadow-r.png') repeat-y right 0;
 151  }
 152  $idstr .wrap-corner {
 153    background: #fff !important;
 154  }
 155  $idstr .wrap-corner .t-edge, $idstr .wrap-corner .b-edge {
 156    height: 11px;
 157  }
 158  $idstr .wrap-corner .l, $idstr .wrap-corner .r {
 159    position: absolute;
 160    top: 0;
 161    height: 11px;
 162    width: 11px;
 163    background-image: url('$url/corner-bits.png');
 164  }
 165  $idstr .wrap-corner .l {
 166    left: 0;
 167  }
 168  $idstr .wrap-corner .r {
 169    right: 0;
 170    background-position: -11px 0;
 171  }
 172  $idstr .wrap-corner .b-edge .l {
 173    background-position: 0 -11px;
 174  }
 175  $idstr .wrap-corner .b-edge .r {
 176    background-position: -11px -11px;
 177  }
 178  $idstr .wrap-corner .r-edge {
 179    padding: 5px 24px;
 180  }
 181  $idstr div.admin-links {
 182    margin-top: -14px;
 183    margin-left: -12px;
 184  }
 185  
 186  $idstr .panel-region-separator {
 187    background: url('$url/shadow-b.png') repeat-x 0 center;
 188    font-size: 1px;
 189    height: 30px;
 190  }
 191  
 192  $idstr .rounded-corner {
 193    margin-bottom: 1em;
 194  }
 195  
 196  EOF;
 197  
 198    return $css;
 199  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7