Projet

Général

Profil

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

root / drupal7 / sites / all / modules / commerce / modules / customer / includes / commerce_customer_ui.profile_types.inc @ b858700c

1
<?php
2

    
3
/**
4
 * @file
5
 */
6

    
7

    
8
/**
9
 * Menu callback: display an overview of available types.
10
 */
11
function commerce_customer_ui_customer_profile_types_overview() {
12
  drupal_add_css(drupal_get_path('module', 'commerce_customer') . '/theme/commerce_customer.admin.css');
13

    
14
  $header = array(
15
    t('Name'),
16
    t('Operations'),
17
  );
18

    
19
  $rows = array();
20

    
21
  // Loop through all defined customer profile types.
22
  foreach (commerce_customer_profile_types() as $type => $profile_type) {
23
    // Build the operation links for the current profile type.
24
    $links = menu_contextual_links('commerce-customer-profile-type', 'admin/commerce/customer-profiles/types', array(strtr($type, array('_' => '-'))));
25

    
26
    // Add the profile type's row to the table's rows array.
27
    $rows[] = array(
28
      theme('customer_profile_type_admin_overview', array('profile_type' => $profile_type)),
29
      theme('links', array('links' => $links, 'attributes' => array('class' => 'links inline operations'))),
30
    );
31
  }
32

    
33
  // If no profile types are defined...
34
  if (empty($rows)) {
35
    // Add a standard empty row.
36
    $rows[] = array(
37
      array(
38
        'data' => t('There are no customer profile types defined on this site.'),
39
        'colspan' => 2,
40
      )
41
    );
42
  }
43

    
44
  return theme('table', array('header' => $header, 'rows' => $rows));
45
}
46

    
47
/**
48
 * Builds an overview of a customer profile type for display to an administrator.
49
 *
50
 * @param $variables
51
 *   An array of variables used to generate the display; by default includes the
52
 *     type key with a value of the profile type object.
53
 *
54
 * @ingroup themeable
55
 */
56
function theme_customer_profile_type_admin_overview($variables) {
57
  $profile_type = $variables['profile_type'];
58

    
59
  $output = check_plain($profile_type['name']);
60
  $output .= ' <small>' . t('(Machine name: @type)', array('@type' => $profile_type['type'])) . '</small>';
61
  $output .= '<div class="description">' . filter_xss_admin($profile_type['description']) . '</div>';
62

    
63
  return $output;
64
}