You are here

function field_tools_help in Field tools 7

Same name and namespace in other branches
  1. 8 field_tools.module \field_tools_help()

Implements hook_help().

File

./field_tools.module, line 10
field_tools.module Contains useful tools for working with fields.

Code

function field_tools_help($path, $arg) {

  // system_modules() form passes us in an array of nothing but empty strings
  // which we don't want to get tripped up by.
  $args_filtered = array_filter($arg);
  if (!$args_filtered) {
    return;
  }

  // WTF: the $arg array is 12 items long with empty cruft at the end!?!
  $args_reverse = array_reverse($args_filtered);

  // Provide help for any path that ends in 'fields/%/clone'.
  if ($args_reverse[0] == 'clone' && $args_reverse[2] == 'fields') {
    return t('Apply this existing field to the other bundles by copying the current field instance.');
  }

  // Provide help for the bundle tools page.
  // Check the last path item first, so we don't perform all the bundle checking
  // on every page.
  if ($args_reverse[0] == 'tools') {

    // Check that this in indeed on a bundle admin path, rather than just any
    // old path ending in 'tools'.
    $potential_bundle_path = implode('/', array_slice($args_filtered, 0, -1));
    foreach (entity_get_info() as $entity_type => $entity_info) {
      foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
        if (isset($bundle_info['admin']['real path']) && $bundle_info['admin']['real path'] == $potential_bundle_path) {

          // We're under the admin path for this bundle.
          return t("Apply some or all fields of the %bundle bundle to other bundles by copying the field instances.", array(
            '%bundle' => $bundle_info['label'],
          ));
        }
      }
    }
  }

  // Provide help any path that ends in 'tools/clone-to'.
  if (count($args_reverse) > 1 && $args_reverse[1] == 'tools' && $args_reverse[0] == 'clone-to') {
    return t("Select the fields you want to copy to this bundle. You can only select one instance of a particular field.");
  }
}