Skip to content

Instantly share code, notes, and snippets.

@haroldSanchezb
Created August 5, 2014 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haroldSanchezb/c1bd132d3920ef669e48 to your computer and use it in GitHub Desktop.
Save haroldSanchezb/c1bd132d3920ef669e48 to your computer and use it in GitHub Desktop.
<?php
/**
* @file
* Template to display a view as a calendar day, grouped by time
* and optionally organized into columns by a field value.
*
* @see template_preprocess_calendar_day.
*
* $rows: The rendered data for this day.
* $rows['date'] - the date for this day, formatted as YYYY-MM-DD.
* $rows['datebox'] - the formatted datebox for this day.
* $rows['empty'] - empty text for this day, if no items were found.
* $rows['all_day'] - an array of formatted all day items.
* $rows['items'] - an array of timed items for the day.
* $rows['items'][$time_period]['hour'] - the formatted hour for a time period.
* $rows['items'][$time_period]['ampm'] - the formatted ampm value, if any for a time period.
* $rows['items'][$time_period][$column]['values'] - An array of formatted
* items for a time period and field column.
*
* $view: The view.
* $columns: an array of column names.
* $min_date_formatted: The minimum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
* $max_date_formatted: The maximum date for this calendar in the format YYYY-MM-DD HH:MM:SS.
*
* The width of the columns is dynamically set using <col></col>
* based on the number of columns presented. The values passed in will
* work to set the 'hour' column to 10% and split the remaining columns
* evenly over the remaining 90% of the table.
*/
//dsm('Display: '. $display_type .': '. $min_date_formatted .' to '. $max_date_formatted);
?>
<?php if($view->name == 'tv_guide_channels2'): ?>
<div class="calendar-calendar-tv-guide">
<div class="calendar-top-border"></div>
<div class="calendar-calendar-tv-guide-inner">
<div class="day-view">
<?php foreach ($columns as $column): ?>
<col width="<?php print $column_width; ?>%"></col>
<?php endforeach; ?>
<div class="tv-guide-time">
<div class="hour-title">
<a href="#previous" id="left" class="action-button left"></a>
<div class="tv-channel-column">
<div class="tv-channel-column-inner">
<a href="javascript:void(0)" class="channel-change channel-change-up"></a>
<a href="javascript:void(0)" class="channel-change channel-change-down"></a>
</div>
</div>
</div>
<div class="hours-row">
<?php foreach ($rows['items'] as $hour): ?>
<div class="hours">
<div class="hours-inner">
<?php if(empty($hour['ampm'])): $time_in_12_hour_format = date("g:i a", strtotime($hour['hour'])); ?>
<?php $newDateTime = explode(' ',$time_in_12_hour_format); ?>
<span class="time"><?php print $newDateTime[0]; ?></span>
<span class="ampm"><?php print $newDateTime[1]; ?></span>
<?php else: ?>
<span class="time"><?php print $hour['hour']; ?></span>
<span class="ampm"><?php print $hour['ampm']; ?></span>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="left-button-wrapper">
<a href="#next" id="right" class="action-button right"></a>
</div>
</div>
<div class="calendar-tv-guide-shows">
<?php foreach ($columns as $column): ?>
<div class="tv-guide-row">
<div class="channel-image">
<div class="channel-items">
<?php if ($column != 'Elementos') : ?>
<?php print $column; ?>
<?php endif; ?>
</div>
</div>
<div id="show-items" class="show-items single-day">
<?php foreach ($rows['items'] as $hour): ?>
<?php if (isset($hour['values'][$column])) : ?>
<?php print implode($hour['values'][$column]); ?>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="calendar-calendar"><div class="day-view">
<table class="full">
<col width="<?php print $first_column_width?>"></col>
<thead>
<?php foreach ($columns as $column): ?>
<col width="<?php print $column_width; ?>%"></col>
<?php endforeach; ?>
<tr>
<th class="calendar-dayview-hour"><?php print $by_hour_count > 0 ? t('Time') : ''; ?></th>
<?php foreach ($columns as $column): ?>
<th class="calendar-agenda-items"><?php print $column; ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<tr>
<td class="<?php print $agenda_hour_class ?>">
<span class="calendar-hour"><?php print $by_hour_count > 0 ? t('All day', array(), array('context' => 'datetime')) : ''; ?></span>
</td>
<?php foreach ($columns as $column): ?>
<td class="calendar-agenda-items multi-day">
<div class="calendar">
<div class="inner">
<?php print isset($rows['all_day'][$column]) ? implode($rows['all_day'][$column]) : '&nbsp;';?>
</div>
</div>
</td>
<?php endforeach; ?>
</tr>
<?php foreach ($rows['items'] as $hour): ?>
<tr>
<td class="calendar-agenda-hour">
<span class="calendar-hour"><?php print $hour['hour']; ?></span><span class="calendar-ampm"><?php print $hour['ampm']; ?></span>
</td>
<?php foreach ($columns as $column): ?>
<td class="calendar-agenda-items single-day">
<div class="calendar">
<div class="inner">
<?php print isset($hour['values'][$column]) ? implode($hour['values'][$column]) : '&nbsp;'; ?>
</div>
</div>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div></div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment