Projet

Général

Profil

Paste
Télécharger (2,42 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / commerce / modules / product / includes / commerce_product_ui.products.inc @ 9d13637e

1
<?php
2

    
3
/**
4
 * @file
5
 * Page callbacks and form builder functions for administering products.
6
 */
7

    
8

    
9
/**
10
 * Menu callback: display a list of product types that the user can create.
11
 */
12
function commerce_product_ui_add_page() {
13
  $item = menu_get_item();
14
  $content = system_admin_menu_block($item);
15

    
16
  // Bypass the admin/commerce/products/add listing if only one product type is
17
  // available.
18
  if (count($content) == 1) {
19
    $item = array_shift($content);
20
    drupal_goto($item['href']);
21
  }
22

    
23
  return theme('product_add_list', array('content' => $content));
24
}
25

    
26
/**
27
 * Displays the list of available product types for product creation.
28
 *
29
 * @ingroup themeable
30
 */
31
function theme_product_add_list($variables) {
32
  $content = $variables['content'];
33
  $output = '';
34

    
35
  if ($content) {
36
    $output = '<dl class="commerce-product-type-list">';
37
    foreach ($content as $item) {
38
      $output .= '<dt>' . l($item['title'], $item['href'], $item['localized_options']) . '</dt>';
39
      $output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
40
    }
41
    $output .= '</dl>';
42
  }
43
  else {
44
    if (user_access('administer product types')) {
45
      $output = '<p>' . t('You have not created any product types yet. Go to the <a href="@create-product-type">product type creation page</a> to add a new product type.', array('@create-product-type' => url('admin/commerce/products/types/add'))) . '</p>';
46
    }
47
    else {
48
      $output = '<p>' . t('No product types have been created yet for you to use.') . '</p>';
49
    }
50
  }
51

    
52
  return $output;
53
}
54

    
55
/**
56
 * Form callback wrapper: create or edit a product.
57
 *
58
 * @param $product
59
 *   The product object being edited by this form.
60
 *
61
 * @see commerce_product_product_form()
62
 */
63
function commerce_product_ui_product_form_wrapper($product) {
64
  // Include the forms file from the Product module.
65
  module_load_include('inc', 'commerce_product', 'includes/commerce_product.forms');
66
  return drupal_get_form('commerce_product_ui_product_form', $product);
67
}
68

    
69
/**
70
 * Form callback wrapper: confirmation form for deleting a product.
71
 *
72
 * @param $product
73
 *   The product object being deleted by this form.
74
 *
75
 * @see commerce_product_product_delete_form()
76
 */
77
function commerce_product_ui_product_delete_form_wrapper($product) {
78
  // Include the forms file from the Product module.
79
  module_load_include('inc', 'commerce_product', 'includes/commerce_product.forms');
80
  return drupal_get_form('commerce_product_ui_product_delete_form', $product);
81
}