Projet

Général

Profil

Paste
Télécharger (1,49 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / author_pane / modules / user_titles.author-pane.inc @ 6c9579f7

1
<?php
2

    
3
/**
4
 * @file
5
 *   Provides a preprocess function on behalf of the user titles module.
6
 */
7

    
8
/**
9
 * Implements hook_preprocess_author_pane().
10
 */
11
function user_titles_preprocess_author_pane(&$variables) {
12
  // Check if this preprocess needs to be run given who's calling it.
13
  if (!author_pane_run_preprocess('user_titles', $variables['caller'])) {
14
    return;
15
  }
16

    
17
  $account = $variables['account'];
18
  $account_id = $account->uid;
19

    
20
  if ($account_id != 0) {
21
    // Implement static caching for cases where this Author Pane appears more
22
    // than once on a given page.
23
    static $cached_user_title = array();
24
    static $cached_user_title_image = array();
25

    
26
    // Get text title (from cache, if set)
27
    if (isset($cached_user_title[$account_id])) {
28
      $variables['user_title'] = $cached_user_title[$account_id];
29
    }
30
    else {
31
      $variables['user_title'] = user_titles_get_user_title($account);
32
      $cached_user_title[$account_id] = $variables['user_title'];
33
    }
34

    
35
    // Get image title (from cache, if set)
36
    if (isset($cached_user_title_image[$account_id])) {
37
      $variables['user_title_image'] = $cached_user_title_image[$account_id];
38
    }
39
    else {
40
      $variables['user_title_image'] = user_titles_get_user_image($account);
41
      $cached_user_title_image[$account_id] = $variables['user_title_image'];
42
    }
43
  }
44
}
45

    
46
/**
47
 * Implements hook_author_pane_allow_preprocess_disable().
48
 */
49
function user_titles_author_pane_allow_preprocess_disable() {
50
  return array('user_titles' => 'User Titles');
51
}