1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Page Layout CSS Builder.
|
6
|
*/
|
7
|
|
8
|
global $theme_key, $theme_name;
|
9
|
$theme_name = $theme_key;
|
10
|
$_path_to_mayo = drupal_get_path('theme', 'mayo');
|
11
|
require_once($_path_to_mayo . '/inc/plugins.inc');
|
12
|
|
13
|
/**
|
14
|
* Build Page Layouts
|
15
|
*
|
16
|
* Unlike the Panels layouts which hold CSS in their data array the Page layout
|
17
|
* plugins each include a unique CSS builder function. This is required because
|
18
|
* page layouts are all bespoke and can accept arbitrary user input for the
|
19
|
* sidebar widths and must support three value units - pixles, em's and
|
20
|
* percentages. In other words building a one-size-fits-all builder function
|
21
|
* would be overly complex and its far more flexible for themers to be able to
|
22
|
* define thier own.
|
23
|
*
|
24
|
* As values come in from the submit function they are dispatched to the right
|
25
|
* builder function.
|
26
|
*
|
27
|
* @param $method, tells the function which layout builder function to call.
|
28
|
* @param $sidebar_first, an arbitrary numeric value.
|
29
|
* @param $sidebar_second, an arbitrary numeric value.
|
30
|
* @param $sidebar_unit, one of px, em or %.
|
31
|
* @param $theme_name, the active theme.
|
32
|
*
|
33
|
* @see three_col_grail_layout() for an example of a builder function with docs.
|
34
|
*/
|
35
|
function mayo_build_page_layout($method, $sidebar_first, $sidebar_second, $sidebar_unit, $theme_name = NULL) {
|
36
|
// Use the passed in theme_name, else grab it from global $theme_key
|
37
|
if ($theme_name == NULL) {
|
38
|
global $theme_key;
|
39
|
$theme_name = $theme_key;
|
40
|
}
|
41
|
|
42
|
$output = '';
|
43
|
|
44
|
// We need to invoke mayo_load_plugins() to get the function names, this is
|
45
|
// rather expensive but we're in a submit function so IMO this is OK.
|
46
|
mayo_load_plugins($theme_name, $plugin_type = 'page_layout');
|
47
|
|
48
|
$builder_functions = page_layouts_data_structure($theme_name);
|
49
|
foreach ($builder_functions as $function_prefix => $redundant_values) {
|
50
|
if ($method === $function_prefix) {
|
51
|
$function = $function_prefix . '_layout';
|
52
|
$output = $function($sidebar_first, $sidebar_second, $sidebar_unit);
|
53
|
}
|
54
|
}
|
55
|
return $output;
|
56
|
}
|