source: sipes/modules_contrib/views_bonus/panels/views_bonus_panels.module @ c43ea01

stableversion-3.0
Last change on this file since c43ea01 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 2.0 KB
Línea 
1<?php
2// $Id: views_bonus_panels.module,v 1.4 2009/06/24 08:20:35 neclimdul Exp $
3/**
4 * @file
5 * Base module file for views bonus panels plugins.
6 */
7
8/**
9 * Implementation of hook_views_api().
10 */
11function views_bonus_panels_views_api() {
12  return array(
13    'api' => 2,
14  );
15}
16
17function theme_views_bonus_panels_render($view, $options, $rows, $title) {
18  panels_load_include('display-render');
19  list($panel_name, $content) = views_bonus_panels_shared_preprocess($view->plugin_name, $rows);
20  return panels_print_layout($panel_name, $content);
21}
22
23function template_preprocess_views_bonus_panels_threecol_term(&$vars) {
24  //
25}
26
27/**
28 * Shared preprocess to devide out rendered rows into panel sections.
29 *
30 * @param plugin_name
31 *
32 * @param $rows
33 * An array of rendered views rows.
34 * @return
35 * Panels content array.
36 */
37function views_bonus_panels_shared_preprocess($plugin_name, $rows) {
38  switch ($plugin_name) {
39    case 'panels_threecol':
40      $panel_name = 'threecol_33_34_33';
41      $stacked = false;
42      $columns = 3;
43      break;
44    case 'panels_threecol_stack':
45      $panel_name = 'threecol_33_34_33_stacked';
46      $stacked = true;
47      $columns = 3;
48      break;
49    case 'panels_twocol':
50      $panel_name = 'twocol';
51      $stacked = false;
52      $columns = 2;
53      break;
54    case 'panels_twocol_stack':
55      $panel_name = 'twocol_stacked';
56      $stacked = true;
57      $columns = 2;
58      break;
59  }
60
61  $content = array(
62    'left' => '',
63    'right' => '',
64  );
65
66  // If this is stacked, drop the first entry into the top slot.
67  if ($stacked) {
68    $content['top'] = array_shift($rows);
69  }
70
71  $col_names[] = 'left';
72  if ($columns != 2) {
73    // Assume its 3 and add the middle column.
74    $col_names[] = 'middle';
75    $content['middle'] = '';
76  }
77  $col_names[] = 'right';
78
79  // iterate over remaining rows and fill columns.
80  foreach ($rows as $offset => $row) {
81    $r = $offset % $columns;
82    $content[$col_names[$r]] .= $row;
83  }
84
85  return array($panel_name, $content);
86}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.