Skip to content

Commit

Permalink
[gh-232] Merging from testing into staging
Browse files Browse the repository at this point in the history
git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1078 20a16fea-79d4-4915-8869-1ea9d5ebf173
  • Loading branch information
tsteiner committed Sep 26, 2011
1 parent 06fd6ce commit 45cdc80
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 26 deletions.
25 changes: 2 additions & 23 deletions page.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,34 +98,13 @@
}

if ($page['sidebar_first']) {
$t->maincontentarea .= '<div id="sidebar-first" class="sidebar col left">' . PHP_EOL
. render($page['sidebar_first']) . PHP_EOL
. '</div>';
$t->maincontentarea .= render($page['sidebar_first']) . PHP_EOL;
}

if ($page['sidebar_first'] && !$page['sidebar_second']) {
$t->maincontentarea .= '<div class="three_col right">' . PHP_EOL;
}
else if ($page['sidebar_first'] && $page['sidebar_second']) {
$t->maincontentarea .= '<div class="two_col">' . PHP_EOL;
}
else if (!$page['sidebar_first'] && $page['sidebar_second']) {
$t->maincontentarea .= '<div class="three_col left">' . PHP_EOL;
}

$t->maincontentarea .= strtr(render($page['content']), array('sticky-enabled' => 'zentable cool')) . PHP_EOL;

if ($page['sidebar_second']) {
$t->maincontentarea .= '</div>' . PHP_EOL
. '<div id="sidebar-second" class="sidebar col right">' . PHP_EOL
. render($page['sidebar_second']) . PHP_EOL
. '</div>' . PHP_EOL;
$t->maincontentarea .= render($page['sidebar_second']) . PHP_EOL;
}

if ($page['sidebar_first'] && !$page['sidebar_second']) {
$t->maincontentarea .= '</div>' . PHP_EOL;
}

// Related Links
if ($page['leftcollinks']) {
$t->leftcollinks = render($page['leftcollinks']);
Expand Down
13 changes: 10 additions & 3 deletions region.tpl.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php
// $Id: region.tpl.php,v 1.1 2009/10/05 02:43:01 webchick Exp $

/**
* @file
* Default theme implementation to display a region.
* unl_wdn theme implementation to display a region.
*
* Available variables:
* - $content: The content for this region, typically blocks.
Expand All @@ -14,6 +13,7 @@
* - region-[name]: The name of the region with underscores replaced with
* dashes. For example, the page_top region would have a region-page-top class.
* - $region: The name of the region variable as defined in the theme's .info file.
* - $region_name: The name of the region variable with '_' replaced with '-'.
*
* Helper variables:
* - $classes_array: Array of html class attribute values. It is flattened
Expand All @@ -26,5 +26,12 @@
* @see template_preprocess_region()
* @see template_process()
*/
?>

echo $content;
<?php if ($region != 'navlinks'): ?>
<div id="<?php print $region_name; ?>" class="<?php print $classes; ?>">
<?php endif;?>
<?php print $content; ?>
<?php if ($region != 'navlinks'): ?>
</div>
<?php endif;?>
62 changes: 62 additions & 0 deletions template.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,41 @@ function unl_wdn_preprocess_html(&$vars, $hook) {
$vars['head_title'] = check_plain(implode(' | ', $head_title));
}

/**
* Implements template_preprocess_region().
* Adds grid classes for sidebar_first, sidebar_second, and content regions.
*/
function unl_wdn_preprocess_region(&$vars) {
static $grid;
if (!isset($grid)) {
$grid = _unl_wdn_grid_info();
}

$vars['region_name'] = str_replace('_', '-', $vars['region']);
$vars['classes_array'][] = $vars['region_name'];

if (in_array($vars['region'], array_keys($grid['regions']))) {
$vars['classes_array'][] = 'grid' . $grid['regions'][$vars['region']]['width'];
}

// Sidebar regions receive common 'sidebar' class
$sidebar_regions = array('sidebar_first', 'sidebar_second');
if (in_array($vars['region'], $sidebar_regions)) {
$vars['classes_array'][] = 'sidebar';
}

// Determine which region needs the 'first' class
if ($vars['region'] == 'content' && $grid['regions']['sidebar_first']['width'] == 0) {
$vars['classes_array'][] = 'first';
}
else if ($vars['region'] == 'sidebar_first') {
$vars['classes_array'][] = 'first';
}
}

/**
* Implements template_preprocess_node().
*/
function unl_wdn_preprocess_node(&$vars) {
// Drupal doesn't correctly set the $page flag for the preview on node/add/page which results in the <h2> being displayed in modules/node/node.tpl.php
if (isset($vars['elements']['#node']->op) && $vars['elements']['#node']->op == 'Preview') {
Expand Down Expand Up @@ -261,3 +296,30 @@ function unl_wdn_get_site_name_abbreviated() {
return variable_get('site_name', 'Department');
}
}

/**
* Generate grid numbers for sidebar_first, sidebar_second, and content regions.
* Based on work in the Fusion theme (fusion_core_grid_info()).
*/
function _unl_wdn_grid_info() {
static $grid;
if (!isset($grid)) {
$grid = array();
$grid['width'] = 12;
$sidebar_first_width = (block_list('sidebar_first')) ? theme_get_setting('sidebar_first_width') : 0;
$sidebar_second_width = (block_list('sidebar_second')) ? theme_get_setting('sidebar_second_width') : 0;
$grid['regions'] = array();

$regions = array('sidebar_first', 'sidebar_second', 'content');
foreach ($regions as $region) {
if ($region == 'content') {
$region_width = $grid['width'] - $sidebar_first_width - $sidebar_second_width;
}
if ($region == 'sidebar_first' || $region == 'sidebar_second') {
$region_width = ($region == 'sidebar_first') ? $sidebar_first_width : $sidebar_second_width;
}
$grid['regions'][$region] = array('width' => $region_width);
}
}
return $grid;
}
12 changes: 12 additions & 0 deletions theme-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ function unl_wdn_form_system_theme_settings_alter(&$form, &$form_state) {
$form['advanced_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced Settings'),
'sidebar_first_width' => array(
'#type' => 'textfield',
'#title' => t('Sidebar first Grid Size'),
'#default_value' => theme_get_setting('sidebar_first_width'),
'#description' => t('Enter only the numeral, for grid4 just enter 4.'),
),
'sidebar_second_width' => array(
'#type' => 'textfield',
'#title' => t('Sidebar second Grid Size'),
'#default_value' => theme_get_setting('sidebar_second_width'),
'#description' => t('Enter only the numeral, for grid4 just enter 4.'),
),
'zen_forms' => array(
'#type' => 'checkbox',
'#title' => t('Use Zen Forms'),
Expand Down
2 changes: 2 additions & 0 deletions unl_wdn.info
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ settings[toggle_favicon] = 0
settings[zen_forms] = 0
settings[use_base] = 1
settings[wdn_beta] = 0
settings[sidebar_first_width] = 3
settings[sidebar_second_width] = 3

0 comments on commit 45cdc80

Please sign in to comment.