rounded_corners.inc
Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 function panels_rounded_corners_panels_styles() {
00016 return array(
00017 'rounded_corners' => array(
00018 'title' => t('Rounded corners'),
00019 'description' => t('Presents the panes or panels with a rounded corner box around them'),
00020 'render panel' => 'panels_rounded_corners_style_render_panel',
00021 'render pane' => 'panels_rounded_corners_style_render_pane',
00022 'settings form' => 'panels_rounded_corners_style_settings_form',
00023 ),
00024 );
00025 }
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 function theme_panels_rounded_corners_style_render_panel($display, $panel_id, $panes, $settings) {
00036 $output = '';
00037
00038
00039
00040 $where = empty($settings['corner_location']) ? 'pane' : $settings['corner_location'];
00041
00042 $print_separator = FALSE;
00043 foreach ($panes as $pane_id => $pane) {
00044
00045 if ($print_separator) {
00046 $output .= '<div class="panel-separator"></div>';
00047 }
00048 $text = panels_render_pane($pane, $display->content[$pane_id], $display);
00049 if ($text) {
00050 $output .= ($where == 'pane') ? theme('rounded_corners_box', $text) : $text;
00051 }
00052
00053
00054
00055 $print_separator = (bool) $text;
00056 }
00057
00058 if ($where == 'panel') {
00059 $output = theme('rounded_corners_box', $output);
00060 }
00061
00062 panels_add_rounded_corners_css($display, $where);
00063
00064 return $output;
00065 }
00066
00067 function panels_add_rounded_corners_css($display, $where) {
00068 static $displays_used = array();
00069 if (empty($displays_used[$display->css_id])) {
00070 theme('rounded_corners_css', $display, $where);
00071 $displays_used[$display->css_id] = TRUE;
00072 }
00073 }
00074
00075
00076
00077
00078 function theme_panels_rounded_corners_style_render_pane($content, $pane, $display) {
00079 $output = theme('panels_pane', $content, $pane, $display);
00080
00081 if (!$output) {
00082 return;
00083 }
00084
00085
00086 $output = panels_rounded_corners_box($output);
00087 panels_add_rounded_corners_css($display, 'pane');
00088 return $output;
00089 }
00090
00091
00092
00093
00094 function panels_rounded_corners_style_settings_form($style_settings) {
00095 $form['corner_location'] = array(
00096 '#type' => 'select',
00097 '#title' => t('Box around'),
00098 '#options' => array(
00099 'pane' => t('Each pane'),
00100 'panel' => t('Each panel'),
00101 ),
00102 '#default_value' => (isset($style_settings['corner_location'])) ? $style_settings['corner_location'] : 'ul',
00103 '#description' => t('Choose whether to include the box around each pane (piece of content) or panel (each column or region)'),
00104 );
00105
00106 return $form;
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 function theme_rounded_corners_css($display, $where = 'pane') {
00128 $idstr = empty($display->css_id) ? '.rounded_corner' : "#$display->css_id";
00129 $url = panels_get_path('styles/corners', TRUE);
00130
00131 $css = <<<EOF
00132
00133 $idstr .t-edge, .b-edge, .l-edge, .r-edge, .wrap-corner {
00134 position: relative;
00135
00136 zoom: 1;
00137 }
00138 $idstr .t-edge {
00139 background: url($url/shadow-t.png) repeat-x 0 top;
00140 font-size: 1px;
00141 }
00142 $idstr .b-edge {
00143 background: url($url/shadow-b.png) repeat-x 0 bottom;
00144 font-size: 1px;
00145 }
00146 $idstr .l-edge {
00147 background: url($url/shadow-l.png) repeat-y 0 0;
00148 }
00149 $idstr .r-edge {
00150 background: url($url/shadow-r.png) repeat-y right 0;
00151 }
00152 $idstr .wrap-corner {
00153 background: #fff !important;
00154 }
00155 $idstr .wrap-corner .t-edge, .wrap-corner .b-edge {
00156 height: 11px;
00157 }
00158 $idstr .wrap-corner .l, .wrap-corner .r {
00159 position: absolute;
00160 top: 0;
00161 height: 11px;
00162 width: 11px;
00163 background-image: url($url/corner-bits.png);
00164 }
00165 $idstr .wrap-corner .l {
00166 left: 0;
00167 }
00168 $idstr .wrap-corner .r {
00169 right: 0;
00170 background-position: -11px 0;
00171 }
00172 $idstr .wrap-corner .b-edge .l {
00173 background-position: 0 -11px;
00174 }
00175 $idstr .wrap-corner .b-edge .r {
00176 background-position: -11px -11px;
00177 }
00178 $idstr .wrap-corner .r-edge {
00179 padding: 5px 24px;
00180 }
00181 $idstr div.admin-links {
00182 margin-top: -14px;
00183 margin-left: -12px;
00184 }
00185
00186 EOF;
00187
00188 if ($where == 'panel') {
00189 $css .= <<<EOF
00190 $idstr .panel-separator {
00191 background: url($url/shadow-b.png) repeat-x 0 center;
00192 font-size: 1px;
00193 height: 30px;
00194 }
00195 EOF;
00196 }
00197
00198 drupal_set_html_head("<style type=\"text/css\" media=\"all\">\n$css</style>\n");
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 function theme_rounded_corners_box($content) {
00211 return <<<EOF
00212 <div class="rounded_corner">
00213 <div class="wrap-corner">
00214 <div class="t-edge"><div class="l"></div><div class="r"></div></div>
00215 <div class="l-edge">
00216 <div class="r-edge">
00217 $content
00218 </div>
00219 </div>
00220 <div class="b-edge"><div class="l"></div><div class="r"></div></div>
00221 </div>
00222 </div>
00223 EOF;
00224 }
00225
00226
00227
00228
00229