home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (token.install)

This example Drupal source code file (token.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, by, duplicate_tokens, function, modules, phase, php, requirements, ret, runtime, sql, system, token, where

The token.install Drupal example source code

<?php
// $Id: token.install,v 1.2.2.2 2010/09/24 20:37:21 davereid Exp $

/**
 * @file
 * The install and update code for the token module.
 *
 * @ingroup token
 */

/**
 * Implements hook_requirements().
 */
function token_requirements($phase = 'runtime') {
  $requirements = array();
  $t = get_t();

  // Check for duplicate tokens.
  if ($phase == 'runtime') {
    if ($duplicate_tokens = token_find_duplicate_tokens()) {
      foreach ($duplicate_tokens as $token => $modules) {
        $duplicate_tokens[$token] = t('@token (defined by modules: @modules)', array('@token' => $token, '@modules' => implode(', ', $modules)));
      }
      $requirements['token_duplicates'] = array(
        'title' => $t('Duplicate tokens'),
        'value' => $t('The following tokens are defined by multiple modules and may cause problems when performing token replacement.'),
        'severity' => REQUIREMENT_WARNING,
        'description' => theme('item_list', $duplicate_tokens),
      );
    }
  }

  return $requirements;
}

function token_install() {
  db_query("UPDATE {system} SET weight = 10 WHERE name = 'token'");
}

function token_update_1() {
  $ret = array();
  $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'token'");
  return $ret;
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal token.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.