You are here

function hijri_preprocess_comment in Hijri 7

Same name and namespace in other branches
  1. 8.2 hijri.module \hijri_preprocess_comment()
  2. 8 hijri.module \hijri_preprocess_comment()
  3. 3.0.x hijri.module \hijri_preprocess_comment()
  4. 1.0.x hijri.module \hijri_preprocess_comment()

Process variables for comment.tpl.php.

See also

comment.tpl.php

File

./hijri.module, line 354
This module convert to Hijri date in nodes,comments and a block.

Code

function hijri_preprocess_comment(&$variables) {
  $comment = $variables['elements']['#comment'];
  $node = $variables['elements']['#node'];
  $variables['comment'] = $comment;
  $variables['author'] = theme('username', array(
    'account' => $comment,
  ));
  $variables['created'] = format_date($comment->created);
  $correction = isset($node->field_hijri_correction[$node->language][0]['value']) ? $node->field_hijri_correction[$node->language][0]['value'] : 0;
  switch (variable_get('hijri_comment_display')) {
    case 'full':
    case 'long':
    case 'medium':
    case 'short':
      $format = hijri_format_date($node->created, variable_get('hijri_comment_display'), NULL, $correction);
      break;
    default:
      $format = $variables['created'];
      break;
  }
  $node_types = variable_get('hijri_types', array());
  if ((string) $node_types[$node->type] == $node->type) {
    $variables['submitted'] = t('Submitted by !username on !datetime', array(
      '!username' => $variables['author'],
      '!datetime' => $format,
    ));
    $variables['created'] = $format;
  }
}