You are here

jalalidate_nodes.module in PersianTools 7

File

jalalidate_nodes/jalalidate_nodes.module
View source
<?php

module_load_include("inc", "persiantools", "includes/jalalidate_lib");

/**
 * Implements hook_preprocess_node().
 */
function jalalidate_nodes_preprocess_node(&$variables) {
  global $language;
  if ($language->name == 'Persian') {
    $node = $variables['node'];
    $time = $variables['created'];
    $date = jalalidate_convert($time);
    $variables['date'] = $date;
    if (variable_get('node_submitted_' . $node->type, TRUE)) {
      $variables['submitted'] = t('Submitted by !username on !datetime', array(
        '!username' => $variables['name'],
        '!datetime' => $variables['date'],
      ));
    }
  }
}

/**
 * Implements hook_preprocess_comment().
 */
function jalalidate_nodes_preprocess_comment(&$variables) {
  global $language;
  if ($language->name == 'Persian') {
    $comment = $variables['elements']['#comment'];
    $variables['created'] = jalalidate_convert($comment->created);
    $variables['changed'] = jalalidate_convert($comment->changed);
    $variables['submitted'] = t('Submitted by !username on !datetime', array(
      '!username' => $variables['author'],
      '!datetime' => $variables['created'],
    ));
  }
}

/**
 * Implements hook_menu().
 */
function jalalidate_nodes_menu() {
  $items['admin/config/jalalidate'] = array(
    'title' => 'Jalali Date',
    'description' => 'Implements Jalali date for Views module.',
    'position' => 'right',
    'weight' => -5,
    'page callback' => 'system_admin_menu_block_page',
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'system.admin.inc',
    'file path' => drupal_get_path('module', 'system'),
  );
  $items['admin/config/jalalidate/settings'] = array(
    'title' => 'Jalali Date Settings',
    'description' => 'Jalali Date features can be managed here!',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'jalalidate_nodes_admin_settings',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'type' => MENU_NORMAL_ITEM,
    'file' => 'jalalidate_nodes.admin.inc',
  );
  return $items;
}

Functions

Namesort descending Description
jalalidate_nodes_menu Implements hook_menu().
jalalidate_nodes_preprocess_comment Implements hook_preprocess_comment().
jalalidate_nodes_preprocess_node Implements hook_preprocess_node().