You are here

function computed_field_help in Computed Field 7

Same name and namespace in other branches
  1. 8.2 computed_field.module \computed_field_help()
  2. 8 computed_field.module \computed_field_help()
  3. 3.x computed_field.module \computed_field_help()

Implements hook_help().

File

./computed_field.module, line 11
Functionality for the computed field.

Code

function computed_field_help($path, $arg) {
  switch ($path) {
    case 'admin/help#computed_field':

      // Attempt to retrieve a README file.
      $filepath = dirname(__FILE__) . '/README.md';
      if (file_exists($filepath)) {
        $readme = file_get_contents($filepath);
      }
      else {
        $filepath = dirname(__FILE__) . '/README.txt';
        if (file_exists($filepath)) {
          $readme = file_get_contents($filepath);
        }
      }

      // If a README file was not found, do nothing here.
      if (!isset($readme)) {
        return NULL;
      }

      // Display the README file.
      if (module_exists('markdown')) {
        $filters = module_invoke('markdown', 'filter_info');
        $info = $filters['filter_markdown'];
        if (function_exists($info['process callback'])) {
          $output = $info['process callback']($readme, NULL);
        }
        else {
          $output = '<pre>' . $readme . '</pre>';
        }
      }
      else {
        $output = '<pre>' . $readme . '</pre>';
      }
      return $output;
  }
}