diff --git a/custom_breadcrumbs.info b/custom_breadcrumbs.info index 983f09e..5103127 100644 --- a/custom_breadcrumbs.info +++ b/custom_breadcrumbs.info @@ -8,3 +8,4 @@ files[] = custom_breadcrumbs.admin.inc files[] = custom_breadcrumbs.install files[] = custom_breadcrumbs.module files[] = custom_breadcrumbs_common.inc +files[] = custom_breadcrumbs.features.inc diff --git a/custom_breadcrumbs.install b/custom_breadcrumbs.install index d0b486f..01162b6 100644 --- a/custom_breadcrumbs.install +++ b/custom_breadcrumbs.install @@ -24,16 +24,19 @@ function custom_breadcrumbs_schema() { 'not null' => FALSE, 'description' => 'An optional name for the custom breadcrumb.', ), - 'titles' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'default' => '', + 'description' => 'The unique machine name for the custom breadcrumb.', + ), + 'titles' => array( + 'type' => 'text', + 'not null' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.', ), 'paths' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.', ), @@ -62,6 +65,9 @@ function custom_breadcrumbs_schema() { 'language' => array('language'), 'node_language' => array('node_type', 'language'), ), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), 'primary key' => array('bid'), ); return $schema; @@ -199,3 +205,22 @@ function custom_breadcrumbs_update_6203() { module_enable(array('custom_breadcrumbs_identifiers')); return t('Custom_breadcrumbs_identifiers was enabled for legacy reasons. Please disable it if you do not need special identifiers in your breadcrumb settings.'); } + +/** + * Adds unique machine name field for integration with features + */ +function custom_breadcrumbs_update_7000() { + db_change_field('custom_breadcrumb', 'titles', 'titles', array('type' => 'text', 'NOT NULL' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.')); + db_change_field('custom_breadcrumb', 'paths', 'paths', array('type' => 'text', 'NOT NULL' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.')); + db_add_field('custom_breadcrumb', 'machine_name', array('type' => 'varchar', 'length' => 255, 'NOT NULL' => TRUE, 'description' => 'The unique machine name for the custom breadcrumb.')); + db_add_unique_key('custom_breadcrumb', 'machine_name', array('machine_name')); + + $result = db_query("SELECT * FROM {custom_breadcrumb}")->execute(); + foreach ($result as $crumb) { + db_update('custom_breadcrumbs') + ->fields(array('machine_name' => $crumb->node_type .'-'. $crumb->bid)) + ->condition('bid', $crumb->bid) + ->execute(); + } + return t('Removed size limit on titles and paths fields. Added unique machine name field for integration with features.'); +} diff --git a/custom_breadcrumbs.module b/custom_breadcrumbs.module index 815875a..6b3c99f 100644 --- a/custom_breadcrumbs.module +++ b/custom_breadcrumbs.module @@ -18,6 +18,7 @@ define('CUSTOM_BREADCRUMBS_SHOW_FORM_TABLE_DEFAULT', 1); * 'field' a unique field of the database table used to identify the breadcrumb, * 'type' a string used for indicating the breadcrumb type on the admin list. * 'name_constructor' a function which generates the breadcrumb name from the breadcrumb. + * 'machine_name_constructor' a function which generates the machine name for use with features from the breadcrumb. */ function custom_breadcrumbs_cb_breadcrumb_info() { $breadcrumb_type_info = array(); @@ -26,6 +27,7 @@ function custom_breadcrumbs_cb_breadcrumb_info() { 'field' => 'node_type', 'type' => 'node', 'name_constructor' => '_custom_breadcrumbs_breadcrumb_name', + 'machine_name_constructor' => '_custom_breadcrumbs_breadcrumb_machine_name', ); return $breadcrumb_type_info; } @@ -40,6 +42,15 @@ function _custom_breadcrumbs_breadcrumb_name($breadcrumb) { } /** + * Constructs a unique default machine name for features integration. + */ +function _custom_breadcrumbs_breadcrumb_machine_name($breadcrumb) { + if (isset($breadcrumb->node_type)) { + return $breadcrumb->node_type .'-'. $breadcrumb->bid; + } +} + +/** * Implements hook_theme(). */ function custom_breadcrumbs_theme() { @@ -514,12 +525,18 @@ function _custom_breadcrumbs_save_breadcrumb($module, $key, $breadcrumb) { if ((!isset($breadcrumb->name) || $breadcrumb->name == '') && isset($info[$key]['name_constructor']) && function_exists($info[$key]['name_constructor'])) { $breadcrumb->name = $info[$key]['name_constructor']($breadcrumb); } - if (isset($breadcrumb->bid)) { - drupal_write_record($info[$key]['table'], $breadcrumb, 'bid'); - } - else { + if (!isset($breadcrumb->bid)) { + $breadcrumb->machine_name = $breadcrumb->node_type .'-'. rand(); drupal_write_record($info[$key]['table'], $breadcrumb); } + // drupal_write_record passes $breadcrumb by reference, + // so we're good and $breadcrumb->bid is set now + // and the machine_name will be set by the constructor. + $machine_name = db_query('SELECT machine_name FROM {'. $info[$key]['table'] .'} WHERE bid = :bid', array(':bid' => $breadcrumb->bid))->fetchField(); + if ((!isset($machine_name) || !$machine_name || $machine_name == '') && isset($info[$key]['machine_name_constructor']) && function_exists($info[$key]['machine_name_constructor'])) { + $breadcrumb->machine_name = $info[$key]['machine_name_constructor']($breadcrumb); + } + drupal_write_record($info[$key]['table'], $breadcrumb, 'bid'); } } @@ -1227,3 +1244,20 @@ function _custom_breadcrumbs_identifiers_option($part = 0, $bid = NULL) { return $options; } + +/** + * Implementation of hook_features_api + * + * Here we define the components that we want to make exportable. For this + * particular module, we want to make the configurations exportable. + */ +function custom_breadcrumbs_features_api() { + return array( + 'custom_breadcrumbs_config' => array( + 'name' => 'Custom Breadcrumbs Node', + 'file' => drupal_get_path('module', 'custom_breadcrumbs') .'/custom_breadcrumbs.features.inc', + 'default_hook' => 'custom_breadcrumbs_config_features_default_settings', + 'feature_source' => TRUE, + ), + ); +} diff --git a/custom_breadcrumbs_panels/custom_breadcrumbs_panels.info b/custom_breadcrumbs_panels/custom_breadcrumbs_panels.info index 6aa5d3f..4ceb150 100644 --- a/custom_breadcrumbs_panels/custom_breadcrumbs_panels.info +++ b/custom_breadcrumbs_panels/custom_breadcrumbs_panels.info @@ -10,3 +10,4 @@ configure = admin/config/user-interface/custom-breadcrumbs files[] = custom_breadcrumbs_panels.install files[] = custom_breadcrumbs_panels.module +files[] = custom_breadcrumbs_panels.features.inc diff --git a/custom_breadcrumbs_panels/custom_breadcrumbs_panels.install b/custom_breadcrumbs_panels/custom_breadcrumbs_panels.install index 845aebe..7e5fb31 100644 --- a/custom_breadcrumbs_panels/custom_breadcrumbs_panels.install +++ b/custom_breadcrumbs_panels/custom_breadcrumbs_panels.install @@ -23,18 +23,21 @@ function custom_breadcrumbs_panels_schema() { 'not null' => FALSE, 'description' => 'An optional name for the custom breadcrumb.', ), - 'titles' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'default' => '', - 'description' => 'A return-delimited list of titles for the breadcrumb links.', + 'description' => 'The unique machine name for the custom breadcrumb.', + ), + 'titles' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => "A return-delimited list of titles for the breadcrumb links.", ), 'paths' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => FALSE, - 'description' => 'A return-delimited list of url paths for the breadcrumb links.', + 'description' => "A return-delimited list of url paths for the breadcrumb links.", ), 'visibility_php' => array( 'type' => 'text', @@ -60,6 +63,9 @@ function custom_breadcrumbs_panels_schema() { 'language' => array('language'), 'panelid_language' => array('panel_id', 'language'), ), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), 'primary key' => array('bid'), ); return $schema; @@ -74,6 +80,25 @@ function custom_breadcrumbs_panels_update_6200() { } /** + * Adds unique machine name field for integration with features + */ +function custom_breadcrumbs_panels_update_7000() { + db_change_field('custom_breadcrumbs_panels', 'titles', 'titles', array('type' => 'text', 'NOT NULL' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.')); + db_change_field('custom_breadcrumbs_panels', 'paths', 'paths', array('type' => 'text', 'NOT NULL' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.')); + db_add_field('custom_breadcrumbs_panels', 'machine_name', array('type' => 'varchar', 'length' => 255, 'NOT NULL' => TRUE, 'description' => 'The unique machine name for the custom breadcrumb.')); + db_add_unique_key('custom_breadcrumbs_panels', 'machine_name', array('machine_name')); + + $result = db_query("SELECT * FROM {custom_breadcrumbs_panels}"); + foreach ($result as $crumb) { + db_update('custom_breadcrumbs_panels') + ->fields(array('machine_name' => $crumb->panel_id .'-'. $crumb->bid)) + ->condition('bid', $crumb->bid) + ->execute(); + } + return t('Removed size limit on titles and paths fields. Added unique machine name field for integration with features.'); +} + +/** * Implements hook_uninstall(). */ function custom_breadcrumbs_panels_uninstall() { diff --git a/custom_breadcrumbs_panels/custom_breadcrumbs_panels.module b/custom_breadcrumbs_panels/custom_breadcrumbs_panels.module index d2d767a..f62444c 100644 --- a/custom_breadcrumbs_panels/custom_breadcrumbs_panels.module +++ b/custom_breadcrumbs_panels/custom_breadcrumbs_panels.module @@ -23,6 +23,7 @@ function custom_breadcrumbs_panels_cb_breadcrumb_info() { 'field' => 'panel_id', 'type' => 'panels', 'name_constructor' => '_custom_breadcrumbs_panels_breadcrumb_name', + 'machine_name_constructor' => '_custom_breadcrumbs_panels_breadcrumb_machine_name', ); return $breadcrumb_type_info; } @@ -43,6 +44,21 @@ function _custom_breadcrumbs_panels_breadcrumb_name($breadcrumb) { } /** + * Constructs a default name for features integration. + * + * @param $breadcrumb + * The breadcrumb object. + * + * @return + * A text string that will be used for features integration. + */ +function _custom_breadcrumbs_panels_breadcrumb_machine_name($breadcrumb) { + if (isset($breadcrumb->panel_id)) { + return $breadcrumb->panel_id .'-'. $breadcrumb->bid; + } +} + +/** * Implements hook_menu(). */ function custom_breadcrumbs_panels_menu() { @@ -260,3 +276,20 @@ function custom_breadcrumbs_panels_form($form, &$form_state, $type) { return $form; } + +/** + * Implementation of hook_features_api + * + * Here we define the components that we want to make exportable. For this + * particular module, we want to make the configurations exportable. + */ +function custom_breadcrumbs_panels_features_api() { + return array( + 'custom_breadcrumbs_panels_config' => array( + 'name' => 'Custom Breadcrumbs Panels', + 'file' => drupal_get_path('module', 'custom_breadcrumbs_panels') .'/custom_breadcrumbs_panels.features.inc', + 'default_hook' => 'custom_breadcrumbs_panels_config_features_default_settings', + 'feature_source' => TRUE, + ), + ); +} diff --git a/custom_breadcrumbs_paths/custom_breadcrumbs_paths.info b/custom_breadcrumbs_paths/custom_breadcrumbs_paths.info index eb3d4a3..51e7822 100644 --- a/custom_breadcrumbs_paths/custom_breadcrumbs_paths.info +++ b/custom_breadcrumbs_paths/custom_breadcrumbs_paths.info @@ -10,3 +10,4 @@ configure = admin/config/user-interface/custom-breadcrumbs files[] = custom_breadcrumbs_paths.install files[] = custom_breadcrumbs_paths.module +files[] = custom_breadcrumbs_paths.features.inc diff --git a/custom_breadcrumbs_paths/custom_breadcrumbs_paths.install b/custom_breadcrumbs_paths/custom_breadcrumbs_paths.install index 17300c7..4fd176e 100644 --- a/custom_breadcrumbs_paths/custom_breadcrumbs_paths.install +++ b/custom_breadcrumbs_paths/custom_breadcrumbs_paths.install @@ -60,18 +60,21 @@ function custom_breadcrumbs_paths_schema() { 'not null' => FALSE, 'description' => 'An optional name for the custom breadcrumb.', ), - 'titles' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'default' => '', - 'description' => 'A return-delimited list of titles for the breadcrumb links.', + 'description' => 'The unique machine name for the custom breadcrumb.', + ), + 'titles' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => "A return-delimited list of titles for the breadcrumb links.", ), 'paths' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => FALSE, - 'description' => 'A return-delimited list of url paths for the breadcrumb links.', + 'description' => "A return-delimited list of url paths for the breadcrumb links.", ), 'visibility_php' => array( 'type' => 'text', @@ -97,6 +100,9 @@ function custom_breadcrumbs_paths_schema() { 'language' => array('language'), 'path_language' => array('specific_path', 'language'), ), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), 'primary key' => array('bid'), ); return $schema; @@ -128,6 +134,25 @@ function custom_breadcrumbs_paths_update_6200() { } /** + * Adds unique machine name field for integration with features + */ +function custom_breadcrumbs_paths_update_7000() { + db_change_field('custom_breadcrumbs_paths', 'titles', 'titles', array('type' => 'text', 'NOT NULL' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.')); + db_change_field('custom_breadcrumbs_paths', 'paths', 'paths', array('type' => 'text', 'NOT NULL' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.')); + db_add_field('custom_breadcrumbs_paths', 'machine_name', array('type' => 'varchar', 'length' => 255, 'NOT NULL' => TRUE, 'description' => 'The unique machine name for the custom breadcrumb.')); + db_add_unique_key('custom_breadcrumbs_paths', 'machine_name', array('machine_name')); + + $result = db_query("SELECT * FROM {custom_breadcrumbs_paths}"); + foreach ($result as $crumb) { + db_update('custom_breadcrumbs_paths') + ->fields(array('machine_name' => str_replace('*', 'all', $crumb->specific_path) . '-' . $crumb->bid)) + ->condition('bid', $crumb->bid) + ->execute(); + } + return t('Removed size limit on titles and paths fields. Added unique machine name field for integration with features.'); +} + +/** * Implements hook_uninstall(). */ function custom_breadcrumbs_paths_uninstall() { diff --git a/custom_breadcrumbs_paths/custom_breadcrumbs_paths.module b/custom_breadcrumbs_paths/custom_breadcrumbs_paths.module index 3652a79..9e23782 100644 --- a/custom_breadcrumbs_paths/custom_breadcrumbs_paths.module +++ b/custom_breadcrumbs_paths/custom_breadcrumbs_paths.module @@ -23,6 +23,7 @@ function custom_breadcrumbs_paths_cb_breadcrumb_info() { 'field' => 'specific_path', 'type' => 'path', 'name_constructor' => '_custom_breadcrumbs_paths_breadcrumb_name', + 'machine_name_constructor' => '_custom_breadcrumbs_paths_breadcrumb_machine_name', ); return $breadcrumb_type_info; } @@ -43,6 +44,21 @@ function _custom_breadcrumbs_paths_breadcrumb_name($breadcrumb) { } /** + * Constructs a default name for features integration. + * + * @param $breadcrumb + * The breadcrumb object. + * + * @return + * A text string that will be used for features integration. + */ +function _custom_breadcrumbs_paths_breadcrumb_machine_name($breadcrumb) { + if (isset($breadcrumb->specific_path)) { + return str_replace('*', 'all', $breadcrumb->specific_path) .'-'. $breadcrumb->bid; + } +} + +/** * Implements hook_menu(). */ function custom_breadcrumbs_paths_menu() { @@ -310,3 +326,20 @@ function custom_breadcrumbs_paths_form_custom_breadcrumbs_admin_settings_alter(& '#weight' => -20, ); } + +/** + * Implementation of hook_features_api + * + * Here we define the components that we want to make exportable. For this + * particular module, we want to make the configurations exportable. + */ +function custom_breadcrumbs_paths_features_api() { + return array( + 'custom_breadcrumbs_paths_config' => array( + 'name' => 'Custom Breadcrumbs Paths', + 'file' => drupal_get_path('module', 'custom_breadcrumbs_paths') .'/custom_breadcrumbs_paths.features.inc', + 'default_hook' => 'custom_breadcrumbs_paths_config_features_default_settings', + 'feature_source' => TRUE, + ), + ); +} diff --git a/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.info b/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.info index 093d37f..1b36929 100644 --- a/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.info +++ b/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.info @@ -9,3 +9,4 @@ files[] = custom_breadcrumbs_taxonomy.admin.inc files[] = custom_breadcrumbs_taxonomy.inc files[] = custom_breadcrumbs_taxonomy.install files[] = custom_breadcrumbs_taxonomy.module +files[] = custom_breadcrumbs_taxonomy.features.inc diff --git a/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.install b/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.install index a1f5b55..0c2a3f4 100644 --- a/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.install +++ b/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.install @@ -96,18 +96,21 @@ function custom_breadcrumbs_taxonomy_schema() { 'not null' => FALSE, 'description' => 'An optional name for the custom breadcrumb.', ), - 'titles' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'default' => '', - 'description' => 'A title for the breadcrumb link.', + 'description' => 'The unique machine name for the custom breadcrumb.', + ), + 'titles' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => "A return-delimited list of titles for the breadcrumb links.", ), 'paths' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => FALSE, - 'description' => 'A path for the breadcrumb link.', + 'description' => "A return-delimited list of url paths for the breadcrumb links.", ), 'tid' => array( 'type' => 'int', @@ -133,6 +136,9 @@ function custom_breadcrumbs_taxonomy_schema() { 'language' => array('language'), 'tid_language' => array('tid', 'language'), ), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), 'primary key' => array('bid'), ); @@ -151,18 +157,21 @@ function custom_breadcrumbs_taxonomy_schema() { 'not null' => FALSE, 'description' => 'An optional name for the custom breadcrumb.', ), - 'titles' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'default' => '', - 'description' => 'A titles for the breadcrumb link.', + 'description' => 'The unique machine name for the custom breadcrumb.', + ), + 'titles' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => "A return-delimited list of titles for the breadcrumb links.", ), 'paths' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => FALSE, - 'description' => 'A paths for the breadcrumb link.', + 'description' => "A return-delimited list of url paths for the breadcrumb links.", ), 'vid' => array( 'type' => 'int', @@ -188,6 +197,9 @@ function custom_breadcrumbs_taxonomy_schema() { 'language' => array('language'), 'vid_language' => array('vid', 'language'), ), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), 'primary key' => array('bid'), ); @@ -218,3 +230,34 @@ function custom_breadcrumbs_taxonomy_update_6200() { db_add_field('custom_breadcrumbs_taxonomy_vocabulary', 'name', array('type' => 'varchar', 'length' => 128, 'NOT NULL' => FALSE, 'description' => 'An optional name for the custom breadcrumb.')); return t('Added name fields to custom breadcrumbs taxonomy tables for improved organization of custom breadcrumbs.'); } + +/** + * Adds unique machine name field for integration with features + */ +function custom_breadcrumbs_taxonomy_update_7000() { + db_change_field('custom_breadcrumbs_taxonomy_term', 'titles', 'titles', array('type' => 'text', 'NOT NULL' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.')); + db_change_field('custom_breadcrumbs_taxonomy_term', 'paths', 'paths', array('type' => 'text', 'NOT NULL' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.')); + db_add_field('custom_breadcrumbs_taxonomy_term', 'machine_name', array('type' => 'varchar', 'length' => 255, 'NOT NULL' => TRUE, 'description' => 'The unique machine name for the custom breadcrumb.')); + db_add_unique_key('custom_breadcrumbs_taxonomy_term', 'machine_name', array('machine_name')); + db_change_field('custom_breadcrumbs_taxonomy_vocabulary', 'titles', 'titles', array('type' => 'text', 'NOT NULL' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.')); + db_change_field('custom_breadcrumbs_taxonomy_vocabulary', 'paths', 'paths', array('type' => 'text', 'NOT NULL' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.')); + db_add_field('custom_breadcrumbs_taxonomy_vocabulary', 'machine_name', array('type' => 'varchar', 'length' => 255, 'NOT NULL' => TRUE, 'description' => 'The unique machine name for the custom breadcrumb.')); + db_add_unique_key('custom_breadcrumbs_taxonomy_vocabulary', 'machine_name', array('machine_name')); + + $result = db_query("SELECT * FROM {custom_breadcrumbs_taxonomy_term}"); + foreach ($result as $crumb) { + $term = taxonomy_term_load($crumb->tid); + db_update('custom_breadcrumbs_taxonomy_term') + ->fields(array('machine_name' => $term->vid . '-' . $crumb->tid . '-' . $crumb->bid)) + ->condition('bid', $crumb->bid) + ->execute(); + } + $result = db_query("SELECT * FROM {custom_breadcrumbs_taxonomy_vocabulary}"); + foreach ($result as $crumb) { + db_update('custom_breadcrumbs_taxonomy_vocabulary') + ->fields(array('machine_name' => $crumb->vid . '-' . $crumb->bid)) + ->condition('bid', $crumb->bid) + ->execute(); + } + return t('Removed size limit on titles and paths fields. Added unique machine name field for integration with features.'); +} diff --git a/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.module b/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.module index d00ae85..a1b1105 100644 --- a/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.module +++ b/custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.module @@ -52,12 +52,14 @@ function custom_breadcrumbs_taxonomy_cb_breadcrumb_info() { 'field' => 'vid', 'type' => 'taxonomy_vocabulary', 'name_constructor' => '_custom_breadcrumbs_taxonomy_vocabulary_breadcrumb_name', + 'machine_name_constructor' => '_custom_breadcrumbs_taxonomy_vocabulary_breadcrumb_machine_name', ); $breadcrumb_type_info['taxonomy_term'] = array( 'table' => 'custom_breadcrumbs_taxonomy_term', 'field' => 'tid', 'type' => 'taxonomy_term', 'name_constructor' => '_custom_breadcrumbs_taxonomy_term_breadcrumb_name', + 'machine_name_constructor' => '_custom_breadcrumbs_taxonomy_term_breadcrumb_machine_name', ); return $breadcrumb_type_info; } @@ -100,6 +102,34 @@ function _custom_breadcrumbs_taxonomy_vocabulary_breadcrumb_name($breadcrumb) { } /** + * Constructs a default machine name from the taxonomy vocabulary for features integration. + * + * @param $breadcrumb + * The breadcrumb object. + * + * @return + * A text string that will be used for feature integration. + */ +function _custom_breadcrumbs_taxonomy_term_breadcrumb_machine_name($breadcrumb) { + $term = taxonomy_term_load($breadcrumb->tid); + return $term->vid .'-'. $breadcrumb->tid . '-'. $breadcrumb->bid; +} + +/** + * Constructs a default machine name from the taxonomy vocabulary for features integration. + * + * @param $breadcrumb + * The breadcrumb object. + * + * @return + * A text string that will be used for feature integration. + */ +function _custom_breadcrumbs_taxonomy_vocabulary_breadcrumb_machine_name($breadcrumb) { + $vocabulary = taxonomy_vocabulary_load($breadcrumb->vid); + return $breadcrumb->vid . '-'. $breadcrumb->bid; +} + +/** * Implements hook_menu(). */ function custom_breadcrumbs_taxonomy_menu() { @@ -582,6 +612,23 @@ function custom_breadcrumbs_taxonomy_minimum_module_weight() { } /** + * Implementation of hook_features_api + * + * Here we define the components that we want to make exportable. For this + * particular module, we want to make the configurations exportable. + */ +function custom_breadcrumbs_taxonomy_features_api() { + return array( + 'custom_breadcrumbs_taxonomy_config' => array( + 'name' => 'Custom Breadcrumbs Taxonomy', + 'file' => drupal_get_path('module', 'custom_breadcrumbs_taxonomy') .'/custom_breadcrumbs_taxonomy.features.inc', + 'default_hook' => 'custom_breadcrumbs_taxonomy_config_features_default_settings', + 'feature_source' => TRUE, + ), + ); +} + +/** * Implements hook_exit(). */ function custom_breadcrumbs_taxonomy_exit() { diff --git a/custom_breadcrumbs_views/custom_breadcrumbs_views.info b/custom_breadcrumbs_views/custom_breadcrumbs_views.info index fa1a848..6eaf3e3 100644 --- a/custom_breadcrumbs_views/custom_breadcrumbs_views.info +++ b/custom_breadcrumbs_views/custom_breadcrumbs_views.info @@ -8,3 +8,4 @@ configure = admin/config/user-interface/custom-breadcrumbs files[] = custom_breadcrumbs_views.install files[] = custom_breadcrumbs_views.module +files[] = custom_breadcrumbs_views.features.inc diff --git a/custom_breadcrumbs_views/custom_breadcrumbs_views.install b/custom_breadcrumbs_views/custom_breadcrumbs_views.install index 3f5055b..cc6bf9e 100644 --- a/custom_breadcrumbs_views/custom_breadcrumbs_views.install +++ b/custom_breadcrumbs_views/custom_breadcrumbs_views.install @@ -60,18 +60,21 @@ function custom_breadcrumbs_views_schema() { 'not null' => FALSE, 'description' => 'An optional name for the custom breadcrumb.', ), - 'titles' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'default' => '', - 'description' => 'A return-delimited list of titles for the breadcrumb links.', + 'description' => 'The unique machine name for the custom breadcrumb.', + ), + 'titles' => array( + 'type' => 'text', + 'not null' => TRUE, + 'description' => "A return-delimited list of titles for the breadcrumb links.", ), 'paths' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => FALSE, - 'description' => 'A return-delimited list of url paths for the breadcrumb links.', + 'description' => "A return-delimited list of url paths for the breadcrumb links.", ), 'visibility_php' => array( 'type' => 'text', @@ -97,6 +100,9 @@ function custom_breadcrumbs_views_schema() { 'language' => array('language'), 'vpath_language' => array('views_path', 'language'), ), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), 'primary key' => array('bid'), ); return $schema; @@ -114,5 +120,21 @@ function custom_breadcrumbs_views_update_6200() { db_drop_field('set_active_menu'); } +/** + * Adds unique machine name field for integration with features + */ +function custom_breadcrumbs_views_update_7000() { + db_change_field('custom_breadcrumbs_views', 'titles', 'titles', array('type' => 'text', 'NOT NULL' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.')); + db_change_field('custom_breadcrumbs_views', 'paths', 'paths', array('type' => 'text', 'NOT NULL' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.')); + db_add_field('custom_breadcrumbs_views', 'machine_name', array('type' => 'varchar', 'length' => 255, 'NOT NULL' => TRUE, 'description' => 'The unique machine name for the custom breadcrumb.')); + db_add_unique_key('custom_breadcrumbs_views', 'machine_name', array('machine_name')); - + $result = db_query("SELECT * FROM {custom_breadcrumbs_views}"); + foreach ($result as $crumb) { + db_update('custom_breadcrumbs_views') + ->fields(array('machine_name' => str_replace('%', 'arg', $crumb->views_path) . '-' . $crumb->bid)) + ->condition('bid', $crumb->bid) + ->execute(); + } + return t('Removed size limit on titles and paths fields. Added unique machine name field for integration with features.'); +} diff --git a/custom_breadcrumbs_views/custom_breadcrumbs_views.module b/custom_breadcrumbs_views/custom_breadcrumbs_views.module index 8be183f..26216b8 100644 --- a/custom_breadcrumbs_views/custom_breadcrumbs_views.module +++ b/custom_breadcrumbs_views/custom_breadcrumbs_views.module @@ -22,6 +22,7 @@ function custom_breadcrumbs_views_cb_breadcrumb_info() { 'field' => 'views_path', 'type' => 'views', 'name_constructor' => '_custom_breadcrumbs_views_breadcrumb_name', + 'machine_name_constructor' => '_custom_breadcrumbs_views_breadcrumb_machine_name', ); return $breadcrumb_type_info; } @@ -42,6 +43,22 @@ function _custom_breadcrumbs_views_breadcrumb_name($breadcrumb) { } /** + * Constructs a default name for features integration. + * + * @param $breadcrumb + * The breadcrumb object. + * + * @return + * A text string that will be used for features integration. + */ +function _custom_breadcrumbs_views_breadcrumb_machine_name($breadcrumb) { +drupal_set_message('Tralala...'); + if (isset($breadcrumb->views_path)) { + return str_replace('%', 'arg', $breadcrumb->views_path) . '-' . $breadcrumb->bid; + } +} + +/** * Implements hook_menu(). */ function custom_breadcrumbs_views_menu() { @@ -172,3 +189,20 @@ function custom_breadcrumbs_views_form($form, &$form_state, $type) { return $form; } + +/** + * Implementation of hook_features_api + * + * Here we define the components that we want to make exportable. For this + * particular module, we want to make the configurations exportable. + */ +function custom_breadcrumbs_views_features_api() { + return array( + 'custom_breadcrumbs_views_config' => array( + 'name' => 'Custom Breadcrumbs Views', + 'file' => drupal_get_path('module', 'custom_breadcrumbs_views') .'/custom_breadcrumbs_views.features.inc', + 'default_hook' => 'custom_breadcrumbs_views_config_features_default_settings', + 'feature_source' => TRUE, + ), + ); +} diff --git a/custom_breadcrumbsapi/custom_breadcrumbsapi.info b/custom_breadcrumbsapi/custom_breadcrumbsapi.info index c529e82..0e64bd0 100644 --- a/custom_breadcrumbsapi/custom_breadcrumbsapi.info +++ b/custom_breadcrumbsapi/custom_breadcrumbsapi.info @@ -6,3 +6,4 @@ core = 7.x files[] = custom_breadcrumbsapi.install files[] = custom_breadcrumbsapi.module +files[] = custom_breadcrumbsapi.features.inc diff --git a/custom_breadcrumbsapi/custom_breadcrumbsapi.install b/custom_breadcrumbsapi/custom_breadcrumbsapi.install index 3e01740..7fe8eaa 100644 --- a/custom_breadcrumbsapi/custom_breadcrumbsapi.install +++ b/custom_breadcrumbsapi/custom_breadcrumbsapi.install @@ -23,16 +23,19 @@ function custom_breadcrumbsapi_schema() { 'not null' => FALSE, 'description' => 'An optional name for the custom breadcrumb.', ), - 'titles' => array( + 'machine_name' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - 'default' => '', + 'description' => 'The unique machine name for the custom breadcrumb.', + ), + 'titles' => array( + 'type' => 'text', + 'not null' => TRUE, 'description' => "A return-delimited list of titles for the breadcrumb links.", ), 'paths' => array( - 'type' => 'varchar', - 'length' => 255, + 'type' => 'text', 'not null' => FALSE, 'description' => "A return-delimited list of url paths for the breadcrumb links.", ), @@ -60,6 +63,9 @@ function custom_breadcrumbsapi_schema() { 'language' => array('language'), 'module_language' => array('module_page', 'language'), ), + 'unique keys' => array( + 'machine_name' => array('machine_name'), + ), 'primary key' => array('bid'), ); return $schema; @@ -73,3 +79,21 @@ function custom_breadcrumbsapi_update_6200() { db_add_field('name', array('type' => 'varchar', 'length' => 128, 'NOT NULL' => FALSE, 'description' => 'An optional name for the custom breadcrumb.')); } +/** + * Adds unique machine name field for integration with features + */ +function custom_breadcrumbsapi_update_7000() { + db_change_field('custom_breadcrumbsapi', 'titles', 'titles', array('type' => 'text', 'NOT NULL' => TRUE, 'description' => 'A return-delimited list of titles for the breadcrumb links.')); + db_change_field('custom_breadcrumbsapi', 'paths', 'paths', array('type' => 'text', 'NOT NULL' => FALSE, 'description' => 'A return-delimited list of url paths for the breadcrumb links.')); + db_add_field('custom_breadcrumbsapi', 'machine_name', array('type' => 'varchar', 'length' => 255, 'NOT NULL' => TRUE, 'description' => 'The unique machine name for the custom breadcrumb.')); + db_add_unique_key('custom_breadcrumbsapi', 'machine_name', array('machine_name')); + + $result = db_query("SELECT * FROM {custom_breadcrumbsapi}"); + foreach ($result as $crumb) { + db_update('custom_breadcrumbsapi') + ->fields(array('machine_name' => $crumb->module_page .'-'. $crumb->bid)) + ->condition('bid', $crumb->bid) + ->execute(); + } + return t('Removed size limit on titles and paths fields. Added unique machine name field for integration with features.'); +} diff --git a/custom_breadcrumbsapi/custom_breadcrumbsapi.module b/custom_breadcrumbsapi/custom_breadcrumbsapi.module index 259ccd1..cd1a20b 100644 --- a/custom_breadcrumbsapi/custom_breadcrumbsapi.module +++ b/custom_breadcrumbsapi/custom_breadcrumbsapi.module @@ -21,6 +21,7 @@ function custom_breadcrumbsapi_cb_breadcrumb_info() { 'field' => 'module_page', 'type' => 'module', 'name_constructor' => '_custom_breadcrumbsapi_breadcrumb_name', + 'machine_name_constructor' => '_custom_breadcrumbsapi_breadcrumb_machine_name', ); return $breadcrumb_type_info; } @@ -41,6 +42,21 @@ function _custom_breadcrumbsapi_breadcrumb_name($breadcrumb) { } /** + * Constructs a default name for features integration. + * + * @param $breadcrumb + * The breadcrumb object. + * + * @return + * A text string that will be used for features integration. + */ +function _custom_breadcrumbsapi_breadcrumb_machine_name($breadcrumb) { + if (isset($breadcrumb->module_page)) { + return $breadcrumb->module_page .'-'. $breadcrumb->bid; + } +} + +/** * Implements hook_help(). */ function custom_breadcrumbsapi_help($path, $arg) { @@ -193,3 +209,20 @@ function custom_breadcrumbsapi_preprocess(&$variables, $hook) { } } } + +/** + * Implementation of hook_features_api + * + * Here we define the components that we want to make exportable. For this + * particular module, we want to make the configurations exportable. + */ +function custom_breadcrumbsapi_features_api() { + return array( + 'custom_breadcrumbsapi_config' => array( + 'name' => 'Custom Breadcrumbs Api', + 'file' => drupal_get_path('module', 'custom_breadcrumbsapi') .'/custom_breadcrumbsapi.features.inc', + 'default_hook' => 'custom_breadcrumbsapi_config_features_default_settings', + 'feature_source' => TRUE, + ), + ); +}