You are here

function hijri_preprocess_node in Hijri 7

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

Processes variables for node.tpl.php.

The $variables array contains the following arguments:

  • $node
  • $view_mode
  • $page.

See also

node.tpl.php

File

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

Code

function hijri_preprocess_node(&$variables) {
  $node = $variables['node'];
  $node_types = variable_get('hijri_types', array());
  if (isset($node_types[$node->type]) && (string) $node_types[$node->type] == $node->type) {
    $correction = isset($node->field_hijri_correction[$node->language][0]['value']) ? $node->field_hijri_correction[$node->language][0]['value'] : 0;
    switch (variable_get('hijri_display')) {
      case 'full':
      case 'long':
      case 'medium':
      case 'short':
        $format = hijri_format_date($node->created, variable_get('hijri_display'), NULL, $correction);
        break;
      default:
        $format = $variables['date'];
        break;
    }

    // Display post information only on certain node types.
    if (variable_get('node_submitted_' . $node->type, TRUE)) {
      $variables['display_submitted'] = TRUE;
      $variables['submitted'] = t('Submitted by !username on !datetime', array(
        '!username' => $variables['name'],
        '!datetime' => $format,
      ));
    }
    else {
      $variables['display_submitted'] = FALSE;
      $variables['submitted'] = '';
    }
  }
}