1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * @file |
---|
5 | * |
---|
6 | * Contains Panels display rendering functions. |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * Render the administrative layout of a display. |
---|
11 | * |
---|
12 | * This is used for the edit version, so that layouts can have different |
---|
13 | * modes, such as the flexible layout designer mode. |
---|
14 | */ |
---|
15 | function panels_render_layout_admin($layout, $content, $display) { |
---|
16 | // @todo This should be abstracted. |
---|
17 | if (!empty($layout['css'])) { |
---|
18 | if (file_exists(path_to_theme() . '/' . $layout['css'])) { |
---|
19 | drupal_add_css(path_to_theme() . '/' . $layout['css']); |
---|
20 | } |
---|
21 | else { |
---|
22 | drupal_add_css($layout['path'] . '/' . $layout['css']); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | if (isset($layout['admin css'])) { |
---|
27 | drupal_add_css($layout['path'] . '/' . $layout['admin css']); |
---|
28 | } |
---|
29 | |
---|
30 | $theme = isset($layout['admin theme']) ? $layout['admin theme'] : $layout['theme']; |
---|
31 | return theme($theme, isset($display->css_id) ? $display->css_id : '', $content, $display->layout_settings, $display, $layout); |
---|
32 | } |
---|
33 | |
---|
34 | /** |
---|
35 | * Render a pane using the appropriate style. |
---|
36 | * |
---|
37 | * Legacy function; this behavior has been moved onto the display renderer |
---|
38 | * object. The function name here is included for backwards compatibility. New |
---|
39 | * style plugins should NEVER call it. |
---|
40 | * |
---|
41 | * $content |
---|
42 | * The already rendered content via panels_render_pane_content() |
---|
43 | * $pane |
---|
44 | * The $pane information from the display |
---|
45 | * $display |
---|
46 | * The display. |
---|
47 | */ |
---|
48 | function panels_render_pane($content, $pane, &$display) { |
---|
49 | if ($display->hide_title == PANELS_TITLE_PANE && !empty($display->title_pane) && $display->title_pane == $pane->pid) { |
---|
50 | |
---|
51 | // If the user selected to override the title with nothing, and selected |
---|
52 | // this as the title pane, assume the user actually wanted the original |
---|
53 | // title to bubble up to the top but not actually be used on the pane. |
---|
54 | if (empty($content->title) && !empty($content->original_title)) { |
---|
55 | $display->stored_pane_title = $content->original_title; |
---|
56 | } |
---|
57 | else { |
---|
58 | $display->stored_pane_title = !empty($content->title) ? $content->title : ''; |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | if (!empty($content->content)) { |
---|
63 | if (!empty($pane->style['style'])) { |
---|
64 | $style = panels_get_style($pane->style['style']); |
---|
65 | |
---|
66 | if (isset($style) && isset($style['render pane'])) { |
---|
67 | $output = theme($style['render pane'], $content, $pane, $display, $style); |
---|
68 | |
---|
69 | // This could be null if no theme function existed. |
---|
70 | if (isset($output)) { |
---|
71 | return $output; |
---|
72 | } |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | // fallback |
---|
77 | return theme('panels_pane', $content, $pane, $display); |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | /** |
---|
82 | * Given a display and the id of a panel, get the style in which to render |
---|
83 | * that panel. |
---|
84 | */ |
---|
85 | function panels_get_panel_style_and_settings($panel_settings, $panel) { |
---|
86 | if (empty($panel_settings)) { |
---|
87 | return array(panels_get_style('default'), array()); |
---|
88 | } |
---|
89 | |
---|
90 | if (empty($panel_settings[$panel]['style']) || $panel_settings[$panel]['style'] == -1) { |
---|
91 | if (empty($panel_settings['style'])) { |
---|
92 | return array(panels_get_style('default'), array()); |
---|
93 | } |
---|
94 | |
---|
95 | $style = panels_get_style($panel_settings['style']); |
---|
96 | $style_settings = isset($panel_settings['style_settings']['default']) ? $panel_settings['style_settings']['default'] : array(); |
---|
97 | } |
---|
98 | else { |
---|
99 | $style = panels_get_style($panel_settings[$panel]['style']); |
---|
100 | $style_settings = isset($panel_settings['style_settings'][$panel]) ? $panel_settings['style_settings'][$panel] : array(); |
---|
101 | } |
---|
102 | |
---|
103 | return array($style, $style_settings); |
---|
104 | } |
---|