You are here

function commerce_backoffice_order_handler_field_order_operations::render in Commerce Backoffice 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

includes/views/handlers/commerce_backoffice_order_handler_field_order_operations.inc, line 27

Class

commerce_backoffice_order_handler_field_order_operations
Displays the order operations in a ctools dropbutton.

Code

function render($values) {
  $order_id = $this
    ->get_value($values, 'order_id');
  $links = menu_contextual_links('commerce-order', 'admin/commerce/orders', array(
    $order_id,
  ));

  // Remove the View link, that functionality opens in a megarow.
  array_shift($links);

  // Add the quick-edit link which opens the megarow.
  $quick_edit['quick-edit'] = menu_get_item('commerce_backoffice/order/' . $order_id . '/' . $this->view->current_display);
  $quick_edit['quick-edit']['title'] = t('Quick edit');
  $quick_edit['quick-edit']['attributes']['class'] = 'views-megarow-open';
  $links = array_merge($quick_edit, $links);

  // Add the destination to the links if specified.
  if ($this->options['add_destination']) {
    foreach ($links as $id => &$link) {
      $link['query'] = drupal_get_destination();
    }
  }
  $context = array(
    'view' => $this->view,
    'order_id' => $order_id,
  );
  drupal_alter('commerce_backoffice_order_operations_links', $links, $context);
  $element = array(
    '#markup' => theme('links__ctools_dropbutton', array(
      'links' => $links,
      'attributes' => array(
        'class' => array(
          'links',
          'inline',
        ),
      ),
    )),
  );
  return $element;
}