You are here

function node_pathauto in Pathauto 6

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. 7 pathauto.module \node_pathauto()

Implements hook_pathauto().

File

./pathauto_node.inc, line 13
Hook implementations for node module integration.

Code

function node_pathauto($op) {
  switch ($op) {
    case 'settings':
      $settings = array();
      $settings['module'] = 'node';
      $settings['token_type'] = 'node';
      $settings['groupheader'] = t('Node paths');
      $settings['patterndescr'] = t('Default path pattern (applies to all node types with blank patterns below)');
      $settings['patterndefault'] = 'content/[title-raw]';
      $settings['bulkname'] = t('Bulk generate aliases for nodes that are not aliased');
      $settings['bulkdescr'] = t('Generate aliases for all existing nodes which do not already have aliases.');
      $patterns = token_get_list('node');
      foreach ($patterns as $type => $pattern_set) {
        if ($type != 'global') {
          foreach ($pattern_set as $pattern => $description) {
            $settings['placeholders']['[' . $pattern . ']'] = $description;
          }
        }
      }
      $settings['supportsfeeds'] = 'feed';
      if (module_exists('locale')) {
        $languages = array(
          '' => t('Language neutral'),
        ) + locale_language_list('name');
      }
      else {
        $languages = array();
      }
      foreach (node_get_types('names') as $node_type => $node_name) {
        if (variable_get('language_content_type_' . $node_type, 0) && count($languages)) {
          $settings['patternitems'][$node_type] = t('Default path pattern for @node_type (applies to all @node_type node types with blank patterns below)', array(
            '@node_type' => $node_name,
          ));
          foreach ($languages as $lang_code => $lang_name) {
            if (!empty($lang_code)) {
              $settings['patternitems'][$node_type . '_' . $lang_code] = t('Pattern for all @node_type paths in @language', array(
                '@node_type' => $node_name,
                '@language' => $lang_name,
              ));
            }
            else {
              $settings['patternitems'][$node_type . '_' . $lang_code] = t('Pattern for all language neutral @node_type paths', array(
                '@node_type' => $node_name,
              ));
            }
          }
        }
        else {
          $settings['patternitems'][$node_type] = t('Pattern for all @node_type paths', array(
            '@node_type' => $node_name,
          ));
        }
      }
      return (object) $settings;
    default:
      break;
  }
}