summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/page_title/modules/forum.page_title.inc
blob: b69d168a91e200bdbd2e70822a3eabaa6b422772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php

/**
 * @file
 * Forum implementations of the page title hooks
 */


/**
 * Implements hook_page_title_alter().
 */
function forum_page_title_alter(&$title) {
  $menu_item = menu_get_item();
  // Check we're on a forum page and if there is a number to confirm it's a
  // container or forum (rather than root).
  if ( !strncmp($menu_item['path'], 'forum/%', 7) &&
       ($term = menu_get_object('taxonomy_term')) &&
       variable_get('page_title_vocab_' . $term->vocabulary_machine_name . '_showfield', 0) &&
       ($forum_title = page_title_load_title($term->tid, 'term')) ) {
    $title = $forum_title;
  }
}


/**
 * Implements hook_page_title_pattern_alter().
 */
function forum_page_title_pattern_alter(&$pattern, &$types) {
  $menu_item = menu_get_item();

  // Forums Page title Patterns
  if ( !strncmp($menu_item['path'], 'forum/%', 7) &&
       ($forum = menu_get_object('forum_forum', 1)) ) {
    $types['term'] = $forum;

    $forum_vid = variable_get('forum_nav_vocabulary', '');
    $forum_vocab = taxonomy_vocabulary_load($forum_vid);
    $pattern = variable_get('page_title_vocab_' . $forum_vocab->machine_name, '');

    $types['vocabulary'] = $forum_vocab;
  }
  // Otherwise it's the root - let's grab the root pattern.
  elseif ($menu_item['path'] == 'forum') {
    $pattern = variable_get('page_title_forum_root_title', '');
    $forum_vid = variable_get('forum_nav_vocabulary', 0);
    $types['vocabulary'] = taxonomy_vocabulary_load($forum_vid);
  }
}


/**
 * Implements hook_page_title_settings().
 */
function forum_page_title_settings() {
  return array(
    'page_title_forum_root_title' => array(
      'label' => 'Forum Root',
      'scopes' => array('global'),
      'show field' => FALSE,
      'description' => 'This pattern will be used on the forum root page (ie <code>/forum</code>)',
    ),
  );
}