You are here

function node_pathauto in Pathauto 7

Same name and namespace in other branches
  1. 5.2 pathauto_node.inc \node_pathauto()
  2. 5 pathauto_node.inc \node_pathauto()
  3. 6.2 pathauto.module \node_pathauto()
  4. 6 pathauto_node.inc \node_pathauto()

Implements hook_pathauto() on behalf of node module.

File

./pathauto.module, line 655
Main file for the Pathauto module, which automatically generates aliases for content.

Code

function node_pathauto($op) {
  if ($op == 'settings') {
    $settings = array();
    $settings['module'] = 'node';
    $settings['token_type'] = 'node';
    $settings['groupheader'] = t('Content paths');
    $settings['patterndescr'] = t('Default path pattern (applies to all content types with blank patterns below)');
    $settings['patterndefault'] = 'content/[node:title]';
    $settings['batch_update_callback'] = 'node_pathauto_bulk_update_batch_process';
    $settings['batch_file'] = drupal_get_path('module', 'pathauto') . '/pathauto.pathauto.inc';
    $languages = array();
    if (module_exists('locale')) {
      $languages = array(
        LANGUAGE_NONE => t('language neutral'),
      ) + locale_language_list('name');
    }
    foreach (node_type_get_names() as $node_type => $node_name) {
      if (count($languages) && variable_get('language_content_type_' . $node_type, 0)) {
        $settings['patternitems'][$node_type] = t('Default path pattern for @node_type (applies to all @node_type content types with blank patterns below)', array(
          '@node_type' => $node_name,
        ));
        foreach ($languages as $lang_code => $lang_name) {
          $settings['patternitems'][$node_type . '_' . $lang_code] = t('Pattern for all @language @node_type paths', array(
            '@node_type' => $node_name,
            '@language' => $lang_name,
          ));
        }
      }
      else {
        $settings['patternitems'][$node_type] = t('Pattern for all @node_type paths', array(
          '@node_type' => $node_name,
        ));
      }
    }
    return (object) $settings;
  }
}