You are here

function nodesymlinks_pathauto in NodeSymlinks 7

Same name and namespace in other branches
  1. 6 nodesymlinks.module \nodesymlinks_pathauto()

Implements hook_pathauto().

File

./nodesymlinks.module, line 191
Node Symlinks allows creating duplicate menu links with unique id to all nodes. As a result all these duplicates have unique menu trails and breadcrumbs.

Code

function nodesymlinks_pathauto($op) {
  switch ($op) {
    case 'settings':
      $settings = array(
        'module' => 'nodesymlinks',
        'token_type' => 'nodesymlink',
        'groupheader' => t('Nodesymlinks paths'),
        'patterndescr' => t('Default path pattern (applies to all node types with blank patterns below)'),
        'patterndefault' => '[nodesymlink:menu-link:parents:join-path]/[nodesymlink:menu-link:title]',
        'bulkname' => t('Bulk generate aliases for nodesymlinks that are not aliased'),
        'bulkdescr' => t('Generate aliases for all existing nodesymlinks which do not already have aliases.'),
        'batch_update_callback' => '_nodesymlinks_pathauto_bulkupdate',
        'batch_file' => drupal_get_path('module', 'nodesymlinks') . '/nodesymlinks.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;
  }
}