You are here

simple_timeline.module in A Simple Timeline 7

Same filename and directory in other branches
  1. 8 simple_timeline.module

simple_timeline.module Created by JetBrains PhpStorm. User: alan

File

simple_timeline.module
View source
<?php

/**
 * @file
 * simple_timeline.module
 * Created by JetBrains PhpStorm.
 * User: alan
 */

/**
 * Implements hook_views_api().
 */
function simple_timeline_views_api() {
  return array(
    'api' => '3.0',
  );
}

/**
 * Implements hook_theme().
 */
function simple_timeline_theme() {
  return array(
    'simple_timeline_fields' => array(
      'arguments' => array(
        'plugin' => NULL,
        'input' => NULL,
      ),
      'path' => drupal_get_path('module', 'simple_timeline'),
      'template' => 'simple-timeline-fields',
    ),
  );
}

/**
 * Implements template_preprocess_hook().
 *
 * @param array $vars
 *   The variables that will be passed to the template.
 */
function template_preprocess_simple_timeline_fields(&$vars) {
  $view =& $vars['view'];
  $options = $vars['options'];
  $vars['simple_timeline_date'] = $vars['simple_timeline_text'] = array();
  $vars['simple_timeline_image'] = NULL;
  foreach ($view->field as $id => $field) {
    $field_output = $view->field[$id]
      ->theme($vars['row']);
    if (in_array($id, array_filter($options['simple_timeline_date']))) {
      $vars['simple_timeline_date'][] = $field_output;
    }
    if (in_array($id, array_filter($options['simple_timeline_text']))) {
      $vars['simple_timeline_text'][] = $field_output;
    }
    if ($id == $options['simple_timeline_image']) {
      $vars['simple_timeline_image'] = $field_output;
    }
  }
  $vars['simple_timeline_date'] = implode($options['simple_timeline_date_separator'], $vars['simple_timeline_date']);
  $vars['simple_timeline_text'] = implode($options['simple_timeline_text_separator'], $vars['simple_timeline_text']);
}

Functions

Namesort descending Description
simple_timeline_theme Implements hook_theme().
simple_timeline_views_api Implements hook_views_api().
template_preprocess_simple_timeline_fields Implements template_preprocess_hook().