commerce_backoffice.module in Commerce Backoffice 7
File
commerce_backoffice.module
View source
<?php
function commerce_backoffice_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
if ($form_state['step'] == 'views_form_views_form' && strpos($vbo->view->name, 'commerce_backoffice_') !== FALSE) {
$form['select']['#title'] = '';
$form['select']['#collapsible'] = FALSE;
$form['select']['submit']['#value'] = t('Apply');
$form['select']['operation']['#options'][0] = t('Bulk operations');
$form['select']['#weight'] = 99999;
}
}
function commerce_backoffice_preprocess_page(&$vars) {
$view = views_get_page_view();
if (!empty($view) && strpos($view->name, 'commerce_backoffice_') !== FALSE) {
$vars['action_links'] = '';
}
}
function commerce_backoffice_views_pre_build(&$view) {
if (strpos($view->name, 'commerce_backoffice_') !== FALSE) {
$actions = menu_local_actions();
$view->attachment_before = '<ul class="action-links">' . drupal_render($actions) . '</ul>';
}
}
function commerce_backoffice_views_pre_render(&$view) {
if (strpos($view->name, 'commerce_backoffice_') !== FALSE) {
drupal_add_css(drupal_get_path('module', 'commerce_backoffice') . '/theme/commerce-backoffice.css');
}
}
function commerce_backoffice_get_vocabularies($product_display = FALSE) {
$fields = field_info_fields();
$product_display_node_types = commerce_product_reference_node_types();
if ($product_display) {
$node_types = $product_display_node_types;
}
else {
$all_node_types = node_type_get_types();
$node_types = array();
foreach ($all_node_types as $type => $node_type) {
if (!isset($product_display_node_types[$type])) {
$node_types[$type] = $node_type;
}
}
}
$voc_names = array();
foreach ($fields as $field) {
if ($field['type'] == 'taxonomy_term_reference' && isset($field['bundles']['node']) && array_intersect($field['bundles']['node'], array_keys($node_types))) {
$voc_names[$field['settings']['allowed_values'][0]['vocabulary']] = $field['settings']['allowed_values'][0]['vocabulary'];
}
}
if (!empty($voc_names)) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'taxonomy_vocabulary')
->propertyCondition('machine_name', $voc_names, 'IN');
$result = $query
->execute();
return taxonomy_vocabulary_load_multiple(array_keys($result['taxonomy_vocabulary']));
}
return array();
}
function commerce_backoffice_pre_render_add_fieldset_markup($form) {
$sort = array();
foreach (element_children($form) as $key) {
$element = $form[$key];
if (isset($element['#fieldset']) && isset($form[$element['#fieldset']])) {
$form[$element['#fieldset']][$key] = $element;
unset($form[$key]);
if (!in_array($key, $sort)) {
$sort[] = $element['#fieldset'];
}
}
}
foreach ($sort as $key) {
uasort($form[$key], 'element_sort');
}
return $form;
}