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

Drupal example source code file (filter_test.module)

This example Drupal source code file (filter_test.module) 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, cache, cache_id, description, filter, filter_test_replace, format, function, invoked, php, return, text, title, uncacheable

The filter_test.module Drupal example source code

<?php
// $Id: filter_test.module,v 1.6 2010/09/18 02:18:35 dries Exp $

/**
 * @file
 * Test module for Filter module hooks and functions not used in core.
 */

/**
 * Implements hook_filter_format_insert().
 */
function filter_test_filter_format_insert($format) {
  drupal_set_message('hook_filter_format_insert invoked.');
}

/**
 * Implements hook_filter_format_update().
 */
function filter_test_filter_format_update($format) {
  drupal_set_message('hook_filter_format_update invoked.');
}

/**
 * Implements hook_filter_format_disable().
 */
function filter_test_filter_format_disable($format) {
  drupal_set_message('hook_filter_format_disable invoked.');
}

/**
 * Implements hook_filter_info().
 */
function filter_test_filter_info() {
  $filters['filter_test_uncacheable'] = array(
    'title' => 'Uncacheable filter',
    'description' => 'Does nothing, but makes a text format uncacheable.',
    'cache' => FALSE,
  );
  $filters['filter_test_replace'] = array(
    'title' => 'Testing filter',
    'description' => 'Replaces all content with filter and text format information.',
    'process callback' => 'filter_test_replace',
  );
  return $filters;
}

/**
 * Process handler for filter_test_replace filter.
 *
 * Replaces all text with filter and text format information.
 */
function filter_test_replace($text, $filter, $format, $langcode, $cache, $cache_id) {
  $text = array();
  $text[] = 'Filter: ' . $filter->title . ' (' . $filter->name . ')';
  $text[] = 'Format: ' . $format->name . ' (' . $format->format . ')';
  $text[] = 'Language: ' . $langcode;
  $text[] = 'Cache: ' . ($cache ? 'Enabled' : 'Disabled');
  if ($cache_id) {
    $text[] = 'Cache ID: ' . $cache_id;
  }
  return implode("<br />\n", $text);
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal filter_test.module 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.