| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_panels_layouts
|
| 6 |
*/
|
| 7 |
function zen_panels_panels_layouts() {
|
| 8 |
$items['zen_panels_default'] = array(
|
| 9 |
'module' => 'zen_panels',
|
| 10 |
'icon' => 'zen_panels_default.png',
|
| 11 |
'title' => t('Default Zen Layout'),
|
| 12 |
'theme' => 'zen_panels_default',
|
| 13 |
'panels' => array('left' => t('Left side'), 'middle' => t('Middle column'), 'right' => t('Right side')),
|
| 14 |
);
|
| 15 |
return $items;
|
| 16 |
}
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Callback function that themes the panel.
|
| 20 |
*
|
| 21 |
* @param $id
|
| 22 |
* The ID of the layout
|
| 23 |
* @param $content
|
| 24 |
* The content array
|
| 25 |
*/
|
| 26 |
function theme_zen_panels_default($id, $content) {
|
| 27 |
// Special case when on the admin screen we use the 25/50/25 layout, because
|
| 28 |
// panels draggables does not cope when the boxes are outside of the edit area
|
| 29 |
if (arg(0) == 'admin' && arg(1) == 'panels') {
|
| 30 |
$layout = panels_get_layout('threecol_25_50_25');
|
| 31 |
return panels_render_layout($layout, $content);
|
| 32 |
}
|
| 33 |
|
| 34 |
// On normal pages we just output content and defer the sidebar content until later
|
| 35 |
$output = $content['middle'];
|
| 36 |
zen_panels_set_content('sidebar_left', $content['left']);
|
| 37 |
zen_panels_set_content('sidebar_right', $content['right']);
|
| 38 |
return $output;
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Set content for a specified region.
|
| 43 |
*
|
| 44 |
* This is used to defer the sidebar content until the page theme variables
|
| 45 |
* are being built.
|
| 46 |
*
|
| 47 |
* @param $region
|
| 48 |
* Page region the content is assigned to.
|
| 49 |
*
|
| 50 |
* @param $data
|
| 51 |
* Content to be set.
|
| 52 |
*/
|
| 53 |
function zen_panels_set_content($region = NULL, $data = NULL) {
|
| 54 |
static $content = array();
|
| 55 |
|
| 56 |
if (!is_null($region) && !is_null($data)) {
|
| 57 |
$content[$region] = $data;
|
| 58 |
}
|
| 59 |
return $content;
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
| 63 |
* Implementation of hook_preprocess_page().
|
| 64 |
*
|
| 65 |
* This retrieves the saved sidebar content up and inserts it into the theme
|
| 66 |
* variables for the page.
|
| 67 |
*
|
| 68 |
* @param $vars
|
| 69 |
* The theme variables array to be modified
|
| 70 |
*/
|
| 71 |
function zen_panels_preprocess_page(&$vars) {
|
| 72 |
$content = zen_panels_set_content();
|
| 73 |
$vars = array_merge($vars, $content);
|
| 74 |
}
|
| 75 |
|
| 76 |
/**
|
| 77 |
* Implementation of hook_form_alter().
|
| 78 |
*
|
| 79 |
* This hides (and enables) the setting to hide existing blocks/regions, since
|
| 80 |
* it doesn't make any sense with this layout.
|
| 81 |
*
|
| 82 |
* This will only hide it if the default display layout is zen, but this
|
| 83 |
* setting is per-panel not per-display so you don't have finer control anyway.
|
| 84 |
*
|
| 85 |
* @param $form_id
|
| 86 |
* The id of the form
|
| 87 |
* @param $form
|
| 88 |
* The form array to be altered
|
| 89 |
*/
|
| 90 |
function zen_panels_form_alter($form_id, &$form) {
|
| 91 |
// dpr($form);
|
| 92 |
if ($form_id = 'panels_page_advanced_form') {
|
| 93 |
$display = panels_load_display($form['panel_page']['#value']->did);
|
| 94 |
if ($display && $display->layout == 'zen_panels_default') {
|
| 95 |
$form['right']['advanced']['no_blocks']['#type'] = 'hidden';
|
| 96 |
$form['right']['advanced']['no_blocks']['#default_value'] = TRUE;
|
| 97 |
}
|
| 98 |
}
|
| 99 |
}
|