~ubuntu-gr-webteam/ubuntu-gr-website/drupal6-site

« back to all changes in this revision

Viewing changes to sites/all/modules/date/theme/theme.inc

  • Committer: Thanos Lefteris
  • Date: 2009-07-29 17:46:54 UTC
  • Revision ID: alefteris@gmail.com-20090729174654-pgfr1vtqw8ikvo5r
* Upgraded calendar module
* Upgraded commentrss module
* Upgraded date module
* Upgraded webfm module

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Id: theme.inc,v 1.1.4.33 2009/02/17 17:04:31 karens Exp $
 
2
// $Id: theme.inc,v 1.1.4.36 2009/06/08 23:10:58 karens Exp $
3
3
/**
4
4
 *  Preprocessor to construct back and next navigation from the date argument.
5
5
 */
52
52
  if (!empty($prev_date) && !empty($vars['prev_url']) && date_format($prev_date, 'Y') < $view->date_info->min_allowed_year) {
53
53
    $vars['prev_url'] = '';    
54
54
  }
 
55
 
 
56
  $vars['prev_options'] += array('attributes' => array());
 
57
  $vars['next_options'] += array('attributes' => array());
 
58
  $prev_title = '';
 
59
  $next_title = '';
 
60
 
 
61
  // Build next/prev link titles.
 
62
  switch($view->date_info->granularity) {
 
63
    case 'year':
 
64
      $prev_title = t('Navigate to previous year');
 
65
      $next_title = t('Navigate to next year');
 
66
      break;
 
67
    case 'month':
 
68
      $prev_title = t('Navigate to previous month');
 
69
      $next_title = t('Navigate to next month');
 
70
      break;
 
71
    case 'week':
 
72
      $prev_title = t('Navigate to previous week');
 
73
      $next_title = t('Navigate to next week');
 
74
      break;      
 
75
    case 'day':
 
76
      $prev_title = t('Navigate to previous day');
 
77
      $next_title = t('Navigate to next day');
 
78
      break;
 
79
  }
 
80
  $vars['prev_options']['attributes'] += array('title' => $prev_title);
 
81
  $vars['next_options']['attributes'] += array('title' => $next_title);
55
82
  
56
 
  $vars['prev_options'] += array('attributes' => array('rel' => 'nofollow'));
57
 
  $vars['next_options'] += array('attributes' => array('rel' => 'nofollow'));
 
83
  // Add nofollow for next/prev links.
 
84
  $vars['prev_options']['attributes'] += array('rel' => 'nofollow');
 
85
  $vars['next_options']['attributes'] += array('rel' => 'nofollow');
58
86
  
59
87
  $link = FALSE;
60
88
  // Month navigation titles are used as links in the block view.
94
122
  // TODO Update this.
95
123
  if (!empty($view->date_info->mini) || $link) {
96
124
        // Month navigation titles are used as links in the mini view.
97
 
        return l($title, $view->date_info->url);
 
125
   $attributes = array('title' => t('View full page month'));
 
126
        return l($title, $view->date_info->url, array('attributes' => $attributes));
98
127
  }
99
128
  else {
100
129
    return $title;
325
354
}
326
355
function theme_date_part_label_timezone($part_type, $element) {
327
356
  return t('Timezone');
 
357
}
 
358
 
 
359
/**
 
360
 * Theme for a date block that looks like a mini calendar day.
 
361
 * Pass in a date object already set to the right timezone, 
 
362
 * format as a calendar page date. The calendar styling is created in css.
 
363
 */
 
364
function theme_date_calendar_day($date) {
 
365
  if (empty($date)) {
 
366
    return NULL;
 
367
  }
 
368
  return '<div class="date-calendar-day">' .
 
369
    '<span class="month">' . date_format_date($date, 'custom', 'M') . '</span>' .
 
370
    '<span class="day">' . date_format_date($date, 'custom', 'j') . '</span>' .
 
371
    '<span class="year">' . date_format_date($date, 'custom', 'Y') . '</span>' .
 
372
  '</div>';
 
373
}
 
374
 
 
375
function theme_date_time_ago($start_date, $end_date, $interval = 2) {
 
376
  // If no date is sent, then return nothing
 
377
  if (empty($start_date) || empty($end_date)){
 
378
    return NULL;
 
379
  }
 
380
 
 
381
  // Time to compare dates to
 
382
  $now = date_format(date_now(), DATE_FORMAT_DATETIME);
 
383
  $start = date_format($start_date, DATE_FORMAT_DATETIME);
 
384
  $end = date_format($end_date, DATE_FORMAT_DATETIME);
 
385
  
 
386
  // 1) The date is entirely in the future
 
387
  if ($now < $start) {
 
388
    return t('!time from now', array('!time' => date_format_interval($start_date, $interval)));
 
389
  }
 
390
  // 2) Ongoing date
 
391
  elseif ($now > $start && $now <= $end) {
 
392
    //return t('Started !time ago', array('!time' => $dates['value']['interval']));
 
393
    return t('ongoing');
 
394
  }
 
395
  // 3) Date is in the past (format_interval added 'ago' to the value).
 
396
  else {
 
397
    return date_format_interval($start_date, $interval);
 
398
  }
328
399
}
 
 
b'\\ No newline at end of file'