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

function views_bonus_panels_threecol_info() {
  $items['panels_threecol'] = array(
    'name' => t('Panels: Teasers, 3 columns'),
    'description' => t('Show views as teasers alternating left, middle and right.'),
    'requires' => array('panels'),
  );
  return $items;
}

function views_bonus_panels_threecol_style_plugins() {
  $items['panels_threecol'] = array(
    'name' => t('Panels: Teasers, 3 columns'),
    'theme' => 'views_bonus_panels_threecol',
    'summary_theme' => 'views_summary',
  );
  return $items;
}

function theme_views_bonus_panels_threecol($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);
    switch ($count % 3) {
      case 0:
        $section = 'left';
        break;
      case 1:
        $section = 'middle';
        break;
      case 2:
        $section = 'right';
        break;
    }
    $content[$section] .= node_view($node, $teasers, false, $links);
  }
  return panels_print_layout('threecol_33_34_33', $content);
}
