features_override.module 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * @file
  4. * Module file for features overrides.
  5. * Includes core/contrib hook implementations.
  6. */
  7. // Key to use when marking properties for recursion.
  8. define('FEATURES_OVERRIDE_RECURSION_MARKER', 'features_override_recursion_marker');
  9. /**
  10. * Implements hook_features_api().
  11. */
  12. function features_override_features_api() {
  13. $path = drupal_get_path('module', 'features_override') . '/features_override.features.inc';
  14. return array(
  15. 'features_override_items' => array(
  16. 'name' => t('Feature Overrides'),
  17. 'default_hook' => 'features_override_default_items',
  18. 'default_file' => FEATURES_DEFAULTS_INCLUDED,
  19. 'feature_source' => TRUE,
  20. 'file' => $path,
  21. ),
  22. 'features_overrides' => array(
  23. 'name' => t('Feature Overrides (individual -- advanced)'),
  24. 'default_hook' => 'features_override_default_overrides',
  25. 'default_file' => FEATURES_DEFAULTS_INCLUDED,
  26. 'feature_source' => TRUE,
  27. 'file' => $path,
  28. ),
  29. );
  30. }
  31. /**
  32. * Implements hook_menu().
  33. */
  34. function features_override_menu() {
  35. $items = array();
  36. $items['admin/structure/features/features_override'] = array(
  37. 'title' => 'Review Overrides',
  38. 'description' => 'Show override details for a component and element.',
  39. 'page callback' => 'features_override_render_differences',
  40. 'access callback' => 'user_access',
  41. 'access arguments' => array('administer features'),
  42. 'type' => MENU_LOCAL_TASK,
  43. 'file' => "features_override.admin.inc",
  44. 'weight' => 8,
  45. );
  46. return $items;
  47. }
  48. /**
  49. * Implements hook_menu_alter
  50. */
  51. function features_override_menu_alter(&$items) {
  52. // override the existing "Review Overrides" tab
  53. // do it here instead of hook_menu to ensure we run after features
  54. $items['admin/structure/features/%feature/diff'] = array(
  55. 'title' => 'Review overrides',
  56. 'description' => 'Compare default and current feature.',
  57. 'page callback' => 'features_override_feature_diff',
  58. 'page arguments' => array(3, 5),
  59. 'load arguments' => array(3, TRUE),
  60. 'access callback' => 'features_access_override_actions',
  61. 'access arguments' => array(3),
  62. 'type' => MENU_LOCAL_TASK,
  63. 'file' => 'features_override.admin.inc',
  64. 'module' => 'features_override',
  65. );
  66. }
  67. /**
  68. * Implements hook_features_override_ignore().
  69. */
  70. function features_override_features_override_ignore($component) {
  71. // Determine which keys need to be ignored for override diff for various components.
  72. // value is shows how many levels deep the key is
  73. $ignores = array();
  74. switch ($component) {
  75. case 'views_view':
  76. $ignores['current_display'] = 0;
  77. $ignores['display_handler'] = 0;
  78. $ignores['handler'] = 2;
  79. $ignores['query'] = 0;
  80. $ignores['localization_plugin'] = 0;
  81. // Views automatically adds these two on export to set values.
  82. $ignores['api_version'] = 0;
  83. $ignores['disabled'] = 0;
  84. break;
  85. case 'image':
  86. $ignores['module'] = 0;
  87. $ignores['name'] = 0;
  88. $ignores['storage'] = 0;
  89. // Various properities are loaded into the effect in image_styles.
  90. $ignores['summary theme'] = 2;
  91. $ignores['module'] = 2;
  92. $ignores['label'] = 2;
  93. $ignores['help'] = 2;
  94. $ignores['form callback'] = 2;
  95. $ignores['effect callback'] = 2;
  96. $ignores['dimensions callback'] = 2;
  97. break;
  98. case 'field':
  99. $ignores['locked'] = 1;
  100. break;
  101. }
  102. return $ignores;
  103. }
  104. /**
  105. * Implements hook_modules_enabled().
  106. *
  107. * Revert the parent settings when the override module is enabled.
  108. */
  109. function features_override_modules_enabled($modules) {
  110. module_load_include('inc', 'features_override', 'features_override.features');
  111. module_load_include('inc', 'features', 'features.export');
  112. foreach ($modules as $module) {
  113. if (function_exists($module . '_features_override_default')) {
  114. features_override_features_rebuild($module);
  115. }
  116. }
  117. }