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