<?php
// $Id: panels_twocol_stk.inc,v 1.1.2.1 2006/11/14 02:12:42 merlinofchaos Exp $
// $Name: DRUPAL-4-7--1-1 $

function views_bonus_panels_twocol_stk_info() {
  $items['panels_twocol_stk'] = array(
    'name' => t('Panels: Teasers, 1 top + 2 columns'),
    'description' => t('Show views as teasers with the first entry spanning 2 columns on the top, then additional entries alternating left and right beneath. .'),
    'requires' => array('panels'),
  );
  return $items;
}

function views_bonus_panels_twocol_stk_style_plugins() {
  $items['panels_twocol_stk'] = array(
    'name' => t('Panels: Teasers, 1 top + 2 columns'),
    'theme' => 'views_bonus_panels_twocol_stacked',
    'summary_theme' => 'views_summary',
  );
  return $items;
}

/**
 * Because views doesn't currently support configuration options for
 * plugins, the best way to make configuration changes here is 
 * to override the theme.
 */
function theme_views_bonus_panels_twocol_stacked($view, $nodes, $type) {
  $teasers = true;
  $links = true;
  if (!module_exist('panels')) {
    return theme('views_view_nodes', $view, $nodes, $type, $teasers, $links);
  }
  $content = array();
  foreach ($nodes as $count => $n) {
    $node = node_load($n->nid);
    if ($count == 0) {
      $section = 'top';
    }
    else if ($count % 2) {
      $section = 'left';
    }
    else {
      $section = 'right';
    }
    $content[$section] .= node_view($node, $teasers, false, $links);
  }
  return panels_print_layout('twocol_stacked', $content);
}
