Commit f4f273a1 authored by Bojan Zivanovic's avatar Bojan Zivanovic Committed by Bojan Zivanovic

Replace custom_breadcrumbs and taxonomy_breadcrumb modules with the crumbs module.

Change-Id: Ib7b142241c8abf5329c43088f95981fdbd66188f
Reviewed-on: https://code.drupalcommerce.org/418Tested-by: default avatarJenkins <jenkins@commerceguys.com>
Reviewed-by: default avatarBojan Zivanovic <bojan@commerceguys.com>
parent caf0d2d0
......@@ -68,6 +68,7 @@ dependencies[] = jirafe
; Install contribs.
dependencies[] = chosen
dependencies[] = crumbs
dependencies[] = module_filter
dependencies[] = field_extractor
dependencies[] = image_delta_formatter
......
......@@ -64,6 +64,7 @@ function _commerce_kickstart_setup_localization($operation, &$context) {
);
language_negotiation_set('language', $negotiation);
}
/**
* BatchAPI callback.
*
......@@ -264,6 +265,7 @@ function _commerce_kickstart_post_import($operation, &$context) {
$context['message'] = t('@operation', array('@operation' => $operation));
_commerce_kickstart_setup_blocks();
_commerce_kickstart_setup_crumbs();
}
/**
......@@ -360,6 +362,14 @@ function _commerce_kickstart_setup_blocks() {
}
}
/**
* Configures the Crumbs module and enables the required plugins.
*/
function _commerce_kickstart_setup_crumbs() {
variable_set('crumbs_show_current_page', TRUE);
variable_set('crumbs_weights', commerce_kickstart_crumbs_get_info());
}
/*
* Helper function to create a sample order.
*
......
......@@ -186,3 +186,33 @@ function commerce_kickstart_update_status_alter(&$projects) {
}
}
}
/**
* Provides a list of Crumbs plugins and their weights.
*/
function commerce_kickstart_crumbs_get_info() {
$crumbs = array(
'crumbs.home_title' => 0
);
foreach (module_implements('commerce_kickstart_crumb_info') as $module) {
// The module-provided item might be just the name of the plugin, or it
// might be an array in the form of $plugin_name => $weight.
foreach (module_invoke($module, 'commerce_kickstart_crumb_info') as $crumb) {
if (is_array($crumb)) {
$crumbs += $crumb;
}
else {
$crumbs[$crumb] = count($crumbs);
}
}
}
// Add the fallback wildcard.
$crumbs['*'] = count($crumbs);
asort($crumbs);
return $crumbs;
}
......@@ -83,6 +83,12 @@ projects[commerce_moneybookers][version] = 1.1
projects[commerce_moneybookers][subdir] = "contrib"
; Other contribs.
projects[crumbs][version] = 1.4
projects[crumbs][subdir] = "contrib"
projects[crumbs][patch][] = "http://drupal.org/files/1776486-special-menu-items.patch"
projects[crumbs][patch][] = "http://drupal.org/files/1776490-fix-term-notice.patch"
projects[crumbs][patch][] = "http://drupal.org/files/1776532-field-get-items.patch"
projects[crumbs][patch][] = "http://drupal.org/files/1778236-show-current-page-5.patch"
projects[http_client][version] = 2.3
projects[http_client][subdir] = "contrib"
projects[oauth][version] = 3.x-dev
......@@ -102,13 +108,6 @@ projects[field_extractor][subdir] = "contrib"
projects[service_links][version] = 2.1
projects[service_links][subdir] = "contrib"
projects[service_links][patch][] = "http://drupal.org/files/twitter-share-button-ssl-page-1524562-5.patch"
projects[taxonomy_breadcrumb][version] = 1.x-dev
projects[taxonomy_breadcrumb][subdir] = "contrib"
projects[taxonomy_breadcrumb][patch][] = "http://drupal.org/files/taxonomy_breadcrumb_vocabulary_selection_bug-1220250-1_0.patch"
projects[taxonomy_breadcrumb][patch][] = "http://drupal.org/files/taxonomy_breadcrumb-view_mode_bug-1280434-2.patch"
projects[taxonomy_breadcrumb][patch][] = "http://drupal.org/files/taxonomy_term-1608070-1_views_support.patch"
projects[taxonomy_breadcrumb][patch][] = "http://drupal.org/files/empty-vid-form-alter-1292774-2.patch"
projects[taxonomy_breadcrumb][patch][] = "http://drupal.org/files/do_not_alter_on_deletion-1699676-1.patch"
projects[advanced_help][version] = 1.0
projects[advanced_help][subdir] = "contrib"
projects[advanced_help][patch][] = "http://drupal.org/files/advanced_help-invalid_argument_in_modules_alter-1086990-21.patch"
......@@ -171,8 +170,6 @@ projects[cloud_zoom][subdir] = "contrib"
projects[cloud_zoom][patch][] = "http://drupal.org/files/1579380-cloud-zoom-all-settings-integration-with-libraries-8_0.patch"
projects[views_slideshow][version] = 3.0
projects[views_slideshow][subdir] = "contrib"
projects[custom_breadcrumbs][version] = 2.x-dev
projects[custom_breadcrumbs][subdir] = "contrib"
projects[special_menu_items][version] = 1.0
projects[special_menu_items][subdir] = "contrib"
projects[special_menu_items][patch][] = "http://drupal.org/files/undefined-indexes-_over_v1.0_1407172-2.patch"
......
......@@ -5,8 +5,6 @@ package = Commerce Kickstart
php = 5.2.4
dependencies[] = commerce_kickstart_migrate
dependencies[] = ctools
dependencies[] = custom_breadcrumbs
dependencies[] = custom_breadcrumbs_views
dependencies[] = features
dependencies[] = image
dependencies[] = image_delta_formatter
......
......@@ -55,35 +55,4 @@ function commerce_kickstart_blog_enable() {
watchdog_exception('block', $e);
throw $e;
}
// Configure Custom Breadcrumbs.
variable_set('custom_breadcrumbs_exclude_list', '<front>');
variable_set('custom_breadcrumbs_force_active_trail', 0);
variable_set('custom_breadcrumbs_use_exclude_list', 1);
variable_set('custom_breadcrumb_home', 'Home');
// Custom breadcrumbs is not currently integrated with features.
$breadcrumb = new stdClass();
$breadcrumb->node_type = 'page';
$breadcrumb->name = 'page';
$breadcrumb->visibility_php = '';
$breadcrumb->titles = '[node:title]';
$breadcrumb->paths = '<none>';
_custom_breadcrumbs_save_breadcrumb('custom_breadcrumbs', 'node', $breadcrumb);
$breadcrumb = new stdClass();
$breadcrumb->views_path = 'blog';
$breadcrumb->name = 'blog';
$breadcrumb->visibility_php = '';
$breadcrumb->titles = 'Blog';
$breadcrumb->paths = '<none>';
_custom_breadcrumbs_save_breadcrumb('custom_breadcrumbs_views', 'views', $breadcrumb);
$breadcrumb = new stdClass();
$breadcrumb->node_type = 'blog_post';
$breadcrumb->name = 'blog_post';
$breadcrumb->visibility_php = '';
$breadcrumb->titles = "Blog\n[node:title]";
$breadcrumb->paths = "blog\n<none>";
_custom_breadcrumbs_save_breadcrumb('custom_breadcrumbs', 'node', $breadcrumb);
}
......@@ -15,10 +15,22 @@ function commerce_kickstart_blog_migrate_api() {
);
}
/**
* Implements hoook_commerce_kickstart_crumb_info().
*
* Enables the Crumbs plugin relevant to this module that provides taxonomy
* based breadcrumbs for each blog post.
*/
function commerce_kickstart_blog_commerce_kickstart_crumb_info() {
return array(
'taxonomy.termReference.field_blog_category.node.blog_post',
);
}
/**
* Override or insert variables into the page template.
*/
function commerce_kickstart_blog_ui_preprocess_node(&$vars) {
function commerce_kickstart_blog_preprocess_node(&$vars) {
if ($vars['type'] == 'blog_post') {
// Switching to short date format.
$vars['date'] = format_date($vars['created'], 'short');
......
......@@ -15,6 +15,18 @@ function commerce_kickstart_lite_product_migrate_api() {
);
}
/**
* Implements hoook_commerce_kickstart_crumb_info().
*
* Enables the Crumbs plugin relevant to this module that provides taxonomy
* based breadcrumbs for each product display node.
*/
function commerce_kickstart_lite_product_commerce_kickstart_crumb_info() {
return array(
'taxonomy.termReference.field_product_category.*',
);
}
/**
* Implements hook_commerce_product_type_info_alter().
*/
......
......@@ -12,10 +12,6 @@ function commerce_kickstart_lite_product_ui_ctools_plugin_api() {
if ($module == "facetapi" && $api == "facetapi_defaults") {
return array("version" => "1");
}
list($module, $api) = func_get_args();
if ($module == "strongarm" && $api == "strongarm") {
return array("version" => "1");
}
}
/**
......
......@@ -22,23 +22,14 @@ dependencies[] = options
dependencies[] = rules
dependencies[] = search_api_ranges
dependencies[] = search_api_views
dependencies[] = strongarm
dependencies[] = taxonomy
dependencies[] = taxonomy_breadcrumb
dependencies[] = views
features[ctools][] = facetapi:facetapi_defaults:1
features[ctools][] = strongarm:strongarm:1
features[ctools][] = views:views_default:3.0
features[facetapi][] = search_api@product_display:block:field_product:field_color
features[facetapi][] = search_api@product_display:block:field_product:field_size
features[features_api][] = api:1
features[rules_config][] = commerce_kickstart_add_to_cart_message
features[variable][] = taxonomy_breadcrumb_home
features[variable][] = taxonomy_breadcrumb_include_node_title
features[variable][] = taxonomy_breadcrumb_include_nodes
features[variable][] = taxonomy_breadcrumb_node_types
features[variable][] = taxonomy_breadcrumb_selected_vid
features[variable][] = taxonomy_breadcrumb_show_current_term
features[views_view][] = collection_taxonomy_term
features[views_view][] = confirm_message_product_display
features[views_view][] = shopping_cart
<?php
/**
* @file
* commerce_kickstart_lite_product_ui.strongarm.inc
*/
/**
* Implements hook_strongarm().
*/
function commerce_kickstart_lite_product_ui_strongarm() {
$export = array();
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_home';
$strongarm->value = 'Home';
$export['taxonomy_breadcrumb_home'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_include_nodes';
$strongarm->value = '1';
$export['taxonomy_breadcrumb_include_nodes'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_include_node_title';
$strongarm->value = 1;
$export['taxonomy_breadcrumb_include_node_title'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_node_types';
$strongarm->value = array(
'bags_cases' => 'bags_cases',
'drinks' => 'drinks',
'hats' => 'hats',
'shoes' => 'shoes',
'storage_devices' => 'storage_devices',
'tops' => 'tops',
'ad_push' => 0,
'page' => 0,
'blog_post' => 0,
'slideshow' => 0,
);
$export['taxonomy_breadcrumb_node_types'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_selected_vid';
$strongarm->value = '4';
$export['taxonomy_breadcrumb_selected_vid'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_show_current_term';
$strongarm->value = 1;
$export['taxonomy_breadcrumb_show_current_term'] = $strongarm;
return $export;
}
......@@ -513,6 +513,7 @@ function commerce_kickstart_menus_views_api() {
*/
function commerce_kickstart_menus_menu_breadcrumb_alter(&$active_trail, $item) {
// Home > Administration > Store settings > Product settings > Content types OR Product types
// @todo Rework this.
if (drupal_match_path($item['path'], "admin/structure/types/*\nadmin/commerce/config/types/*\nadmin/commerce/products/types*")) {
if (drupal_match_path($item['path'], "admin/structure/types/add\nadmin/commerce/products/types")) {
return;
......@@ -526,39 +527,59 @@ function commerce_kickstart_menus_menu_breadcrumb_alter(&$active_trail, $item) {
$active_trail_end = array_slice($active_trail, 6);
}
$active_trail = array_slice($active_trail, 0, 1);
$active_trail[] = menu_get_item('admin');
$active_trail[] = menu_get_item('admin/commerce/config');
$active_trail[] = menu_get_item('admin/commerce/config/product-settings');
$active_trail[] = _commerce_kickstart_menus_get_item('admin');
$active_trail[] = _commerce_kickstart_menus_get_item('admin/commerce/config');
$active_trail[] = _commerce_kickstart_menus_get_item('admin/commerce/config/product-settings');
// Append either "Product types" OR "Content types".
if ($is_product_type_page || $is_product_type) {
if ($is_product_type_page) {
array_shift($active_trail_end);
}
$active_trail[] = menu_get_item('admin/commerce/config/types');
$active_trail[] = _commerce_kickstart_menus_get_item('admin/commerce/config/types');
}
else {
$active_trail[] = menu_get_item('admin/commerce/config/types/content');
$active_trail[] = _commerce_kickstart_menus_get_item('admin/commerce/config/types/content');
}
$active_trail = array_merge($active_trail, $active_trail_end);
}
// Home > Administration > Content > Add content OR Add product
else if (drupal_match_path($item['path'], 'node/add*')) {
if (drupal_match_path($item['path'], 'node/add/add-product')) {
return;
}
$active_trail_end = array_slice($active_trail, 1);
// Set the breadcrumb for the "Add content" tab of node/add.
else if (drupal_match_path($item['path'], 'node/add')) {
$active_trail = array_slice($active_trail, 0, 1);
$active_trail[] = menu_get_item('admin');
$is_product_display_page = in_array(strtr(arg(2),'-','_'), array_keys(commerce_product_reference_node_types()));
if ($is_product_display_page) {
array_shift($active_trail_end);
$active_trail[] = menu_get_item('admin/commerce/manage-products');
$active_trail[] = menu_get_item('admin/commerce/manage-products/actions');
$active_trail[] = menu_get_item('node/add/add-product');
}
else {
$active_trail[] = array('title' => 'Content') + menu_get_item('admin/content');
$active_trail[] = _commerce_kickstart_menus_get_item('admin');
$active_trail[] = _commerce_kickstart_menus_get_item('admin/commerce/manage-content');
$active_trail[] = _commerce_kickstart_menus_get_item('admin/commerce/manage-content/actions');
$active_trail[] = _commerce_kickstart_menus_get_item('node/add/add-content');
}
}
/**
* Returns a menu router item.
*
* If the Crumbs module is enabled, uses the Crumbs-provided function and
* sets additional keys later expected by that module.
*
* @param $path
* The path, for example node/5.
*
* @return
* The loaded router item, with additional keys set if the Crumbs module is
* present.
*/
function _commerce_kickstart_menus_get_item($path) {
if (module_exists('crumbs')) {
static $loaded = FALSE;
if (!$loaded) {
module_load_include('inc', 'crumbs', 'crumbs.trail');
$loaded = TRUE;
}
$active_trail = array_merge($active_trail, $active_trail_end);
$item = crumbs_get_router_item($path);
$item['link_title'] = $item['title'];
$item['link_options'] = array();
return $item;
}
else {
return menu_get_item($path);
}
}
......@@ -15,6 +15,18 @@ function commerce_kickstart_product_migrate_api() {
);
}
/**
* Implements hoook_commerce_kickstart_crumb_info().
*
* Enables the Crumbs plugin relevant to this module that provides taxonomy
* based breadcrumbs for each product display node.
*/
function commerce_kickstart_product_commerce_kickstart_crumb_info() {
return array(
'taxonomy.termReference.field_collection.node.*',
);
}
/**
* Implements hook_commerce_product_type_info_alter().
*/
......
......@@ -12,10 +12,6 @@ function commerce_kickstart_product_ui_ctools_plugin_api() {
if ($module == "facetapi" && $api == "facetapi_defaults") {
return array("version" => "1");
}
list($module, $api) = func_get_args();
if ($module == "strongarm" && $api == "strongarm") {
return array("version" => "1");
}
}
/**
......
......@@ -22,12 +22,9 @@ dependencies[] = options
dependencies[] = rules
dependencies[] = search_api_ranges
dependencies[] = search_api_views
dependencies[] = strongarm
dependencies[] = taxonomy
dependencies[] = taxonomy_breadcrumb
dependencies[] = views
features[ctools][] = facetapi:facetapi_defaults:1
features[ctools][] = strongarm:strongarm:1
features[ctools][] = views:views_default:3.0
features[facetapi][] = search_api@product_display:block:field_brand
features[facetapi][] = search_api@product_display:block:field_category
......@@ -43,12 +40,6 @@ features[facetapi][] = search_api@product_display:block:search_api_language
features[facetapi][] = search_api@product_display:block:title
features[features_api][] = api:1
features[rules_config][] = commerce_kickstart_add_to_cart_message
features[variable][] = taxonomy_breadcrumb_home
features[variable][] = taxonomy_breadcrumb_include_node_title
features[variable][] = taxonomy_breadcrumb_include_nodes
features[variable][] = taxonomy_breadcrumb_node_types
features[variable][] = taxonomy_breadcrumb_selected_vid
features[variable][] = taxonomy_breadcrumb_show_current_term
features[views_view][] = collection_taxonomy_term
features[views_view][] = confirm_message_product_display
features[views_view][] = shopping_cart
<?php
/**
* @file
* commerce_kickstart_product_ui.strongarm.inc
*/
/**
* Implements hook_strongarm().
*/
function commerce_kickstart_product_ui_strongarm() {
$export = array();
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_home';
$strongarm->value = 'Home';
$export['taxonomy_breadcrumb_home'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_include_nodes';
$strongarm->value = '1';
$export['taxonomy_breadcrumb_include_nodes'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_include_node_title';
$strongarm->value = 1;
$export['taxonomy_breadcrumb_include_node_title'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_node_types';
$strongarm->value = array(
'bags_cases' => 'bags_cases',
'drinks' => 'drinks',
'hats' => 'hats',
'shoes' => 'shoes',
'storage_devices' => 'storage_devices',
'tops' => 'tops',
'ad_push' => 0,
'page' => 0,
'blog_post' => 0,
'slideshow' => 0,
);
$export['taxonomy_breadcrumb_node_types'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_selected_vid';
$strongarm->value = '6';
$export['taxonomy_breadcrumb_selected_vid'] = $strongarm;
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'taxonomy_breadcrumb_show_current_term';
$strongarm->value = 1;
$export['taxonomy_breadcrumb_show_current_term'] = $strongarm;
return $export;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment