1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294 |
- <?php
- define('FEATURES_API', '2');
- define('FEATURES_MODULE_ENABLED', 1);
- define('FEATURES_MODULE_DISABLED', 0);
- define('FEATURES_MODULE_MISSING', -1);
- define('FEATURES_MODULE_CONFLICT', 2);
- define('FEATURES_REBUILDABLE', -1);
- define('FEATURES_DEFAULT', 0);
- define('FEATURES_OVERRIDDEN', 1);
- define('FEATURES_NEEDS_REVIEW', 2);
- define('FEATURES_REBUILDING', 3);
- define('FEATURES_CONFLICT', 4);
- define('FEATURES_DISABLED', 5);
- define('FEATURES_CHECKING', 6);
- define('FEATURES_ALTER_TYPE_NORMAL', 'normal');
- define('FEATURES_ALTER_TYPE_INLINE', 'inline');
- define('FEATURES_ALTER_TYPE_NONE', 'none');
- define('FEATURES_SEMAPHORE_TIMEOUT', 10 * 60);
- define('FEATURES_DEFAULTS_INCLUDED_COMMON', 0);
- define('FEATURES_DEFAULTS_INCLUDED', 1);
- define('FEATURES_DEFAULTS_CUSTOM', 2);
- define('FEATURES_DUPLICATES_CONFLICT', 0);
- define('FEATURES_DUPLICATES_ALLOWED', 1);
- define('FEATURES_DEFAULT_EXPORT_PATH', 'sites/all/modules');
- function features_menu() {
- $items = array();
- $items['admin/structure/features'] = array(
- 'title' => 'Features',
- 'description' => 'Manage features.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('features_admin_form'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'features.admin.inc',
- );
- $items['admin/structure/features/cleanup'] = array(
- 'title' => 'Cleanup',
- 'description' => 'Clear cache after enabling/disabling a feature.',
- 'page callback' => 'features_cleanup',
- 'type' => MENU_CALLBACK,
- 'file' => 'features.admin.inc',
- 'weight' => 1,
- );
- $items['admin/structure/features/manage'] = array(
- 'title' => 'Manage',
- 'description' => 'Enable and disable features.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('features_admin_form'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'file' => 'features.admin.inc',
- );
- $items['admin/structure/features/create'] = array(
- 'title' => 'Create feature',
- 'description' => 'Create a new feature.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('features_export_form'),
- 'access callback' => 'user_access',
- 'access arguments' => array('administer features'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => "features.admin.inc",
- 'weight' => 10,
- );
- $items['admin/structure/features/settings'] = array(
- 'title' => 'Settings',
- 'description' => 'Adjust settings for using features module.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('features_settings_form'),
- 'access callback' => 'user_access',
- 'access arguments' => array('administer features'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => "features.admin.inc",
- 'weight' => 11,
- );
- $items['admin/structure/features/%feature'] = array(
- 'title callback' => 'features_get_feature_title',
- 'title arguments' => array(3),
- 'description' => 'Display components of a feature.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('features_admin_components', 3),
- 'load arguments' => array(TRUE),
- 'access callback' => 'user_access',
- 'access arguments' => array('administer features'),
- 'type' => MENU_CALLBACK,
- 'file' => 'features.admin.inc',
- );
- $items['admin/structure/features/%feature/view'] = array(
- 'title' => 'View',
- 'description' => 'Display components of a feature.',
- 'access callback' => 'user_access',
- 'access arguments' => array('administer features'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => -10,
- );
- $items['admin/structure/features/%feature/recreate'] = array(
- 'title' => 'Recreate',
- 'description' => 'Recreate an existing feature.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('features_export_form', 3),
- 'load arguments' => array(TRUE),
- 'access callback' => 'user_access',
- 'access arguments' => array('administer features'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => "features.admin.inc",
- 'weight' => 11,
- );
- if (module_exists('diff')) {
- $items['admin/structure/features/%feature/diff'] = array(
- 'title' => 'Review overrides',
- 'description' => 'Compare default and current feature.',
- 'page callback' => 'features_feature_diff',
- 'page arguments' => array(3, 5),
- 'load arguments' => array(TRUE),
- 'access callback' => 'features_access_override_actions',
- 'access arguments' => array(3),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'features.admin.inc',
- );
- }
- $items['admin/structure/features/%feature/lock'] = array(
- 'title' => 'Lock',
- 'description' => 'Lock a feature or components.',
- 'page callback' => 'features_admin_lock',
- 'page arguments' => array(3, 5, 6),
- 'load arguments' => array(TRUE),
- 'access arguments' => array('administer features'),
- 'type' => MENU_CALLBACK,
- 'file' => 'features.admin.inc',
- );
- $items['admin/structure/features/%feature/status'] = array(
- 'title' => 'Status',
- 'description' => 'Javascript status call back.',
- 'page callback' => 'features_feature_status',
- 'page arguments' => array(3),
- 'load arguments' => array(TRUE),
- 'access callback' => 'user_access',
- 'access arguments' => array('administer features'),
- 'type' => MENU_CALLBACK,
- 'file' => 'features.admin.inc',
- );
- $items['features/autocomplete/packages'] = array(
- 'page callback' => 'features_autocomplete_packages',
- 'access arguments' => array('administer features'),
- 'type' => MENU_CALLBACK,
- 'file' => 'features.admin.inc',
- );
- $items['features/ajaxcallback/%'] = array(
- 'title callback' => 'features_get_feature_components',
- 'description' => 'Return components of a feature.',
- 'page callback' => 'features_export_components_json',
- 'page arguments' => array(2),
- 'access callback' => 'user_access',
- 'access arguments' => array('administer features'),
- 'type' => MENU_CALLBACK,
- 'file' => 'features.admin.inc',
- );
- foreach ($items as $path => $item) {
- if (!isset($item['access callback'])) {
- $items[$path]['access callback'] = 'user_access';
- $items[$path]['access arguments'] = array('manage features');
- }
- }
- return $items;
- }
- function features_theme() {
- $base = array(
- 'path' => drupal_get_path('module', 'features') . '/theme',
- 'file' => 'theme.inc',
- );
- $items = array();
- $items['features_module_status'] = array(
- 'variables' => array('module' => NULL, 'status' => NULL)
- ) + $base;
- $items['features_components'] = array(
- 'variables' => array('info' => NULL, 'sources' => NULL),
- ) + $base;
- $items['features_component_key'] = $base;
- $items['features_component_list'] = array(
- 'variables' => array('components' => array(), 'source' => array(), 'conflicts' => array()),
- ) + $base;
- $items['features_storage_link'] = array(
- 'variables' => array('storage' => NULL, 'text' => NULL, 'path' => NULL, 'options' => array()),
- ) + $base;
- $items['features_lock_link'] = array(
- 'variables' => array('feature' => NULL, 'component' => NULL, 'locked' => FALSE),
- ) + $base;
- $items['features_form_components'] =
- $items['features_form_export'] =
- $items['features_form_package'] = array(
- 'render element' => 'form',
- ) + $base;
- $items['features_form_buttons'] = array(
- 'render element' => 'element',
- ) + $base;
- $items['features_admin_components'] = array(
- 'render element' => 'form',
- 'template' => 'features-admin-components',
- ) + $base;
- return $items;
- }
- function features_flush_caches() {
- if (($modules_changed = variable_get('features_modules_changed', FALSE)) || variable_get('features_rebuild_on_flush', TRUE)) {
- if ($modules_changed) {
- variable_set('features_modules_changed', FALSE);
- }
- features_rebuild();
-
- if (variable_get('install_task') == 'done') {
- features_get_modules(NULL, TRUE);
- }
- }
- if (db_table_exists('cache_features')) {
- return array('cache_features');
- }
- return array();
- }
- function features_form($node, $form_state) {
- return node_content_form($node, $form_state);
- }
- function features_permission() {
- return array(
- 'administer features' => array(
- 'title' => t('Administer features'),
- 'description' => t('Perform administration tasks on features.'),
- 'restrict access' => TRUE,
- ),
- 'manage features' => array(
- 'title' => t('Manage features'),
- 'description' => t('View, enable and disable features.'),
- 'restrict access' => TRUE,
- ),
- 'generate features' => array(
- 'title' => t('Generate features'),
- 'description' => t('Allow feature exports to be generated and written directly to site.'),
- 'restrict access' => TRUE,
- ),
- 'rename features' => array(
- 'title' => t('Edit feature machine name'),
- 'description' => t('Allows editing machine name of a disabled feature'),
- 'restrict access' => TRUE,
- ),
- );
- }
- function features_help($path, $arg) {
- switch ($path) {
- case 'admin/help#features':
- $output = file_get_contents(drupal_get_path('module', 'features') . '/README.txt');
- return module_exists('markdown') ? filter_xss_admin(module_invoke('markdown', 'filter', 'process', 0, -1, $output)) : '<pre>' . check_plain($output) . '</pre>';
- case 'admin/build/features':
- return '<p>' . t('A "Feature" is a certain type of Drupal module which contains a package of configuration that, when enabled, provides a new set of functionality for your Drupal site. Enable features by selecting the checkboxes below and clicking the Save configuration button. If the configuration of the feature has been changed its "State" will be either "overridden" or "needs review", otherwise it will be "default", indicating that the configuration has not been changed. Click on the state to see more details about the feature and its components.') . '</p>';
- }
- }
- function features_modules_disabled($modules) {
-
- $items = array();
- foreach ($modules as $module) {
- if ($feature = features_load_feature($module)) {
- $items[$module] = array_keys($feature->info['features']);
- }
- }
- if (!empty($items)) {
- _features_restore('disable', $items);
-
- features_include(TRUE);
- }
- }
- function features_modules_enabled($modules) {
-
-
- if (!variable_get('features_rebuild_on_module_install', TRUE)) {
- return;
- }
-
- variable_set('features_modules_changed', TRUE);
-
- $items = array();
- foreach ($modules as $module) {
- if ($feature = features_load_feature($module)) {
- $items[$module] = array_keys($feature->info['features']);
- }
- }
- if (!empty($items)) {
-
-
- features_include_defaults(NULL, TRUE);
- _features_restore('enable', $items);
-
- features_include(TRUE);
-
- $all_components = array_keys(features_get_components());
- foreach ($items as $module => $components) {
- $items[$module] = array_intersect($all_components, $components);
- }
- _features_restore('rebuild', $items);
- }
- }
- function features_include($reset = FALSE) {
- static $once;
- if (!isset($once) || $reset) {
- $once = TRUE;
-
-
-
- $modules = array('features', 'block', 'contact', 'context', 'field', 'filter', 'image', 'locale', 'menu', 'node', 'taxonomy', 'user', 'views', 'ctools');
- foreach (array_filter($modules, 'module_exists') as $module) {
- module_load_include('inc', 'features', "includes/features.$module");
- }
- if (module_exists('ctools')) {
-
- ctools_features_declare_functions($reset);
- }
-
- foreach (features_get_components(NULL, 'file', $reset) as $file) {
- if (is_file(DRUPAL_ROOT . '/' . $file)) {
- require_once DRUPAL_ROOT . '/' . $file;
- }
- }
- }
- }
- function features_include_defaults($components = NULL, $reset = FALSE) {
- static $include_components;
-
-
- if (!isset($include_components) || $reset) {
- $include_components = features_get_components();
- foreach ($include_components as $component => $info) {
- if (!isset($info['api']) && (!isset($info['default_file']) || $info['default_file'] !== FEATURES_DEFAULTS_INCLUDED)) {
- unset($include_components[$component]);
- }
- }
- }
-
- if (isset($components)) {
- $components = is_array($components) ? $components : array($components);
- }
-
- else {
- $components = array_keys($include_components);
- }
- foreach ($components as $component) {
- if (isset($include_components[$component])) {
- $info = $include_components[$component];
-
- if (isset($info['api'], $info['module'], $info['current_version'])) {
- ctools_include('plugins');
- ctools_plugin_api_include($info['module'], $info['api'], $info['current_version'], $info['current_version']);
- }
-
- else {
- $features = isset($features) ? $features : features_get_features(NULL, $reset);
- foreach ($features as $feature) {
- $filename = isset($info['default_file']) && $info['default_file'] == FEATURES_DEFAULTS_CUSTOM ? $info['default_filename'] : "features.{$component}";
- if (module_exists($feature->name) && isset($feature->info['features'][$component])) {
- module_load_include('inc', $feature->name, "{$feature->name}.$filename");
- }
- }
- }
- }
- }
- }
- function feature_load($name, $reset = FALSE) {
- return features_load_feature($name, $reset);
- }
- function features_load_feature($name, $reset = FALSE) {
-
- if (variable_get('install_task') != 'done') {
- static $features;
- if (!isset($features[$name])) {
-
- $defaults = array(
- 'dependencies' => array(),
- 'description' => '',
- 'package' => 'Other',
- 'version' => NULL,
- 'php' => DRUPAL_MINIMUM_PHP,
- 'files' => array(),
- 'bootstrap' => 0,
- );
- $info = drupal_parse_info_file(drupal_get_path('module', $name) . '/' . $name . '.info');
- $features[$name] = FALSE;
- if (!empty($info['features']) && empty($info['hidden'])) {
-
- $features[$name] = new stdClass;
- $features[$name]->name = $name;
- $features[$name]->filename = drupal_get_path('module', $name) . '/' . $name . '.module';
- $features[$name]->type = 'module';
- $features[$name]->info = $info + $defaults;
- }
- }
- return $features[$name];
- }
- else {
- return features_get_features($name, $reset);
- }
- }
- function features_get_modules($name = NULL, $reset = FALSE) {
- return features_get_info('module', $name, $reset);
- }
- function features_get_components($component = NULL, $key = NULL, $reset = FALSE) {
- features_include();
- $components = &drupal_static(__FUNCTION__);
- $component_by_key = &drupal_static(__FUNCTION__ . '_by_key');
- if ($reset || !isset($components) || !isset($component_by_key)) {
- $components = $component_by_key = array();
- if (!$reset && ($cache = cache_get('features_api', 'cache_features'))) {
- $components = $cache->data;
- }
- else {
- $components = module_invoke_all('features_api');
- drupal_alter('features_api', $components);
- cache_set('features_api', $components, 'cache_features');
- }
- foreach ($components as $component_type => $component_information) {
- foreach ($component_information as $component_key => $component_value) {
- $component_by_key[$component_key][$component_type] = $component_value;
- }
- }
- }
- if ($key && $component) {
- return !empty($components[$component][$key]) ? $components[$component][$key] : NULL;
- }
- elseif ($key) {
- return !empty($component_by_key[$key]) ? $component_by_key[$key] : array();
- }
- elseif ($component) {
- return $components[$component];
- }
- return $components;
- }
- function features_get_feature_components() {
- return array_intersect_key(features_get_components(), array_filter(features_get_components(NULL, 'feature_source')));
- }
- function features_invoke($component, $callback) {
- $args = func_get_args();
- unset($args[0], $args[1]);
-
- $args[] = $component;
- if ($function = features_hook($component, $callback)) {
- return call_user_func_array($function, $args);
- }
- }
- function features_hook($component, $hook, $reset = FALSE) {
-
- $base = features_get_components($component, 'base');
- $base = isset($base) ? $base : $component;
- return function_exists($base . '_' . $hook) ? $base . '_' . $hook : FALSE;
- }
- function features_install_modules($modules) {
- variable_set('features_modules_changed', TRUE);
- module_load_include('inc', 'features', 'features.export');
- $files = system_rebuild_module_data();
-
- $install = array();
- foreach ($modules as $name) {
-
- $parsed_name = drupal_parse_dependency($name);
- $name = $parsed_name['name'];
- if ($file = $files[$name]) {
- $install[] = $name;
- if (!empty($file->info['dependencies'])) {
- $install = array_merge($install, _features_export_maximize_dependencies($file->info['dependencies']));
- }
- }
- }
-
- $enabled = array_filter($install, 'module_exists');
- $install = array_diff($install, $enabled);
- if (!empty($install)) {
-
- $install = array_unique($install);
- include_once DRUPAL_ROOT . '/' . './includes/install.inc';
- module_enable($install);
- }
- }
- function features_get_features($name = NULL, $reset = FALSE) {
- return features_get_info('feature', $name, $reset);
- }
- function features_get_info($type = 'module', $name = NULL, $reset = FALSE) {
- static $cache;
- if (!isset($cache)) {
- $cache = cache_get('features_module_info', 'cache_features');
- }
- if (empty($cache) || $reset) {
- $data = array(
- 'feature' => array(),
- 'module' => array(),
- );
- $ignored = variable_get('features_ignored_orphans', array());
- $files = system_rebuild_module_data();
- foreach ($files as $row) {
-
- if (isset($row->info['mtime'])) {
- unset($row->info['mtime']);
- }
-
- if (isset($row->info['php'])) {
- unset($row->info['php']);
- }
-
- if (in_array($row->name, $ignored, TRUE) && !$row->status) {
- $key = array_search($row->name, $ignored, TRUE);
- unset($ignored[$key]);
- }
- if (!empty($row->info['features'])) {
-
- if (!empty($row->info['stylesheets'])) {
- foreach ($row->info['stylesheets'] as $media => $css) {
- $row->info['stylesheets'][$media] = array_keys($css);
- }
- }
- if (!empty($row->info['scripts'])) {
- $row->info['scripts'] = array_keys($row->info['scripts']);
- }
-
-
- foreach ($row->info['features'] as $component => $features) {
- if ($component == 'user_permission') {
- foreach ($features as $key => $feature) {
-
-
- _user_features_change_term_permission($feature);
- $row->info['features'][$component][$key] = $feature;
- }
- }
- }
- $data['feature'][$row->name] = $row;
- $data['feature'][$row->name]->components = array_keys($row->info['features']);
- if (!empty($row->info['dependencies'])) {
- $data['feature'][$row->name]->components[] = 'dependencies';
- }
- }
- $data['module'][$row->name] = $row;
- }
-
-
- $required = array();
- $non_required = array();
- $modules = array_keys($data['feature']);
- foreach ($modules as $module) {
- if ($files[$module]->requires) {
- $modules = array_merge($modules, array_keys($files[$module]->requires));
- }
- }
- $modules = array_unique($modules);
- foreach ($modules as $module) {
- if (!empty($files[$module]->info['features'])) {
- if (!empty($files[$module]->info['required'])) {
- $required[$module] = $files[$module]->sort;
- }
- else {
- $non_required[$module] = $files[$module]->sort;
- }
- }
- }
- arsort($required);
- arsort($non_required);
- $sorted = array();
- foreach ($required + $non_required as $module => $weight) {
- $sorted[$module] = $data['feature'][$module];
- }
- $data['feature'] = $sorted;
- variable_set('features_ignored_orphans', $ignored);
- cache_set('features_module_info', $data, 'cache_features');
- $cache = new stdClass();
- $cache->data = $data;
- }
- if (!empty($name)) {
- return !empty($cache->data[$type][$name]) ? clone $cache->data[$type][$name] : FALSE;
- }
- return !empty($cache->data[$type]) ? $cache->data[$type] : FALSE;
- }
- function features_get_orphans($reset = FALSE) {
- static $orphans;
- if (!isset($orphans) || $reset) {
- module_load_include('inc', 'features', 'features.export');
- $orphans = array();
-
- $dependencies = array('enabled' => array(), 'disabled' => array());
- $features = features_get_features();
- foreach ($features as $feature) {
- $key = module_exists($feature->name) ? 'enabled' : 'disabled';
- if (!empty($feature->info['dependencies'])) {
- $dependencies[$key] = array_merge($dependencies[$key], _features_export_maximize_dependencies($feature->info['dependencies']));
- }
- }
- $dependencies['enabled'] = array_unique($dependencies['enabled']);
- $dependencies['disabled'] = array_unique($dependencies['disabled']);
-
- $orphaned = array_diff($dependencies['disabled'], $dependencies['enabled']);
- $orphaned = array_intersect($orphaned, module_list(FALSE, FALSE));
- $orphaned = array_diff($orphaned, drupal_required_modules());
- $orphaned = array_diff($orphaned, array('features'));
-
- $modules = features_get_modules(NULL, TRUE);
- $enabled = module_list();
- _module_build_dependencies($modules);
- foreach ($orphaned as $module) {
- if (!empty($modules[$module]->required_by)) {
- foreach ($modules[$module]->required_by as $module_name => $dependency) {
- $modules[$module]->required_by[$module_name] = $dependency['name'];
- }
-
- $dependents = array_intersect($modules[$module]->required_by, $enabled);
- if (empty($dependents)) {
- $info = features_get_modules($module);
- $orphans[$module] = $info;
- }
- }
- }
- }
- return $orphans;
- }
- function features_get_conflicts($reset = FALSE) {
- $conflicts = array();
- $component_info = features_get_components();
- $map = features_get_component_map(NULL, $reset);
- foreach ($map as $type => $components) {
-
- if (isset($component_info[$type])) {
- foreach ($components as $component => $modules) {
- if (isset($component_info[$type]['duplicates']) && $component_info[$type]['duplicates'] == FEATURES_DUPLICATES_ALLOWED) {
- continue;
- }
- elseif (count($modules) > 1) {
- foreach ($modules as $module) {
- if (!isset($conflicts[$module])) {
- $conflicts[$module] = array();
- }
- foreach ($modules as $m) {
- if ($m != $module) {
- $conflicts[$module][$m][$type][] = $component;
- }
- }
- }
- }
- }
- }
- }
- return $conflicts;
- }
- function features_get_component_map($key = NULL, $reset = FALSE) {
- static $map;
- if (!isset($map) || $reset) {
- $map = array();
- $features = features_get_features(NULL, $reset);
- foreach ($features as $feature) {
- foreach ($feature->info['features'] as $type => $components) {
- if (!isset($map[$type])) {
- $map[$type] = array();
- }
- foreach ($components as $component) {
- $map[$type][$component][] = $feature->name;
- }
- }
- }
- }
- if (isset($key)) {
- return isset($map[$key]) ? $map[$key] : array();
- }
- return $map;
- }
- function features_get_module_status($module) {
- if (module_exists($module)) {
- return FEATURES_MODULE_ENABLED;
- }
- elseif (features_get_modules($module)) {
- return FEATURES_MODULE_DISABLED;
- }
- else {
- return FEATURES_MODULE_MISSING;
- }
- }
- function features_get_feature_title($feature) {
- return $feature->info['name'];
- }
- function features_access_override_actions($feature) {
- if (user_access('administer features')) {
- static $access = array();
- if (!isset($access[$feature->name])) {
-
- $access[$feature->name] = FALSE;
- features_include();
- module_load_include('inc', 'features', 'features.export');
- $access[$feature->name] = in_array(features_get_storage($feature->name), array(FEATURES_DEFAULT, FEATURES_OVERRIDDEN, FEATURES_NEEDS_REVIEW));
- }
- return $access[$feature->name];
- }
- return FALSE;
- }
- function features_form_system_modules_alter(&$form) {
- if (variable_get('features_rebuild_modules_page', FALSE)) {
- features_rebuild();
- }
- }
- function _features_restore($op, $items = array()) {
- $lockable = FALSE;
-
- if (variable_get('features_restore_time_limit_' . $op, FALSE) !== FALSE) {
- drupal_set_time_limit(variable_get('features_restore_time_limit_' . $op, FALSE));
- }
- module_load_include('inc', 'features', 'features.export');
- features_include();
- switch ($op) {
- case 'revert':
- $restore_states = array(FEATURES_OVERRIDDEN, FEATURES_REBUILDABLE, FEATURES_NEEDS_REVIEW);
- $restore_hook = 'features_revert';
- $log_action = 'Revert';
- $lockable = TRUE;
- break;
- case 'rebuild':
- $restore_states = array(FEATURES_REBUILDABLE);
- $restore_hook = 'features_rebuild';
- $log_action = 'Rebuild';
- $lockable = variable_get('features_lock_mode', 'all') == 'all';
- break;
- case 'disable':
- $restore_hook = 'features_disable_feature';
- $log_action = 'Disable';
- break;
- case 'enable':
- $restore_hook = 'features_enable_feature';
- $log_action = 'Enable';
- break;
- }
- if (empty($items)) {
-
-
-
-
-
-
- $states = features_get_component_states(array(), ($op == 'rebuild'), defined('DRUSH_BASE_PATH'));
- foreach ($states as $module_name => $components) {
- foreach ($components as $component => $state) {
- if (in_array($state, $restore_states)) {
- $items[$module_name][] = $component;
- }
- }
- }
- }
-
- module_invoke_all('features_pre_restore', $op, $items);
- foreach ($items as $module_name => $components) {
-
- if ($lockable && features_feature_is_locked($module_name)) {
- watchdog('features', 'Tried @actioning a locked @module_name, aborted.', array('@action' => $log_action, '@module_name' => $module_name));
- continue;
- }
- foreach ($components as $component) {
-
- if ($lockable && features_feature_is_locked($module_name, $component)) {
- watchdog('features', 'Tried @actioning a locked @module_name / @component, aborted.', array('@action' => $log_action, '@component' => $component, '@module_name' => $module_name));
- continue;
- }
-
- $pre_hook = 'pre_' . $restore_hook;
- module_invoke($module_name, $pre_hook, $component);
- if (features_hook($component, $restore_hook)) {
-
- watchdog('features', '@actioning @module_name / @component.', array('@action' => $log_action, '@component' => $component, '@module_name' => $module_name));
- features_semaphore('set', $component);
- features_invoke($component, $restore_hook, $module_name);
-
- features_semaphore('del', $component);
- features_set_signature($module_name, $component);
- watchdog('features', '@action completed for @module_name / @component.', array('@action' => $log_action, '@component' => $component, '@module_name' => $module_name));
- }
-
- $post_hook = 'post_' . $restore_hook;
- module_invoke($module_name, $post_hook, $component);
- }
- }
-
- module_invoke_all('features_post_restore', $op, $items);
- }
- function features_revert($revert = array()) {
- return _features_restore('revert', $revert);
- }
- function features_rebuild($rebuild = array()) {
- return _features_restore('rebuild', $rebuild);
- }
- function features_revert_module($module) {
- if (($feature = feature_load($module, TRUE)) && module_exists($module)) {
- $components = array();
- foreach (array_keys($feature->info['features']) as $component) {
- if (features_hook($component, 'features_revert')) {
- $components[] = $component;
- }
- }
- features_revert(array($module => $components));
- }
- }
- function features_log($message, $severity = 'status') {
- if (function_exists('drush_verify_cli')) {
- $message = strip_tags($message);
- if ($severity == 'status') {
- $severity = 'ok';
- }
- elseif ($severity == 'error') {
- drush_set_error($message);
- return;
- }
- drush_log($message, $severity);
- return;
- }
- drupal_set_message($message, $severity, FALSE);
- }
- function features_hook_info() {
- $hooks = array(
- 'features_api',
- 'features_pipe_alter',
- 'features_export_alter',
- 'features_export_options_alter',
- );
- return array_fill_keys($hooks, array('group' => 'features'));
- }
- function _user_features_change_term_permission(&$perm, $type = 'vid') {
- if (!module_exists('taxonomy')) {
- return;
- }
-
-
- if (strpos($perm, 'edit terms in ') !== FALSE || strpos($perm, 'delete terms in ') !== FALSE) {
- preg_match("/(?<=\040)([^\s]+?)$/", trim($perm), $voc_id);
- $vid = $voc_id[0];
- if (is_numeric($vid) && $type == 'vid') {
- if (function_exists('taxonomy_vocabulary_load')) {
- if ($voc = taxonomy_vocabulary_load($vid)) {
- $perm = str_replace($vid, $voc->machine_name, $perm);
- }
- }
- }
- elseif ($type == 'machine_name') {
- if ($voc = taxonomy_vocabulary_machine_name_load($vid)) {
- $perm = str_replace($vid, $voc->vid, $perm);
- }
- }
- }
- }
- function features_array_diff_assoc_recursive(array $array1, array $array2) {
- $difference = array();
- foreach ($array1 as $key => $value) {
- if (is_array($value)) {
- if (!isset($array2[$key]) || !is_array($array2[$key])) {
- $difference[$key] = $value;
- }
- else {
- $new_diff = features_array_diff_assoc_recursive($value, $array2[$key]);
- if (!empty($new_diff)) {
- $difference[$key] = $new_diff;
- }
- }
- }
- elseif (!isset($array2[$key]) || $array2[$key] != $value) {
- $difference[$key] = $value;
- }
- }
- return $difference;
- }
- function features_get_deprecated($components = array()) {
- if (empty($components)) {
- $components = features_get_components();
- }
- $deprecated = array();
- foreach ($components as $component => $component_info) {
- if (!empty($component_info['supersedes'])) {
- $deprecated[$component_info['supersedes']] = $component_info['supersedes'];
- }
- }
- return $deprecated;
- }
- function features_feature_is_locked($feature, $component = NULL, $check_global_component_setting = TRUE) {
- $locked = variable_get('features_feature_locked', array());
- if ($component) {
- return ($check_global_component_setting && features_component_is_locked($component)) || !empty($locked[$feature][$component]);
- }
- else {
- return !empty($locked[$feature]['_all']);
- }
- }
- function features_component_is_locked($component) {
- return variable_get('features_component_locked_' . $component, FALSE);
- }
- function features_feature_lock($feature, $component = NULL) {
- $locked = variable_get('features_feature_locked', array());
- $locked[$feature] = !empty($locked[$feature]) ? $locked[$feature] : array();
- if ($component) {
- $locked[$feature][$component] = TRUE;
- }
- else {
- $locked[$feature]['_all'] = TRUE;
- }
- variable_set('features_feature_locked', $locked);
- }
- function features_feature_unlock($feature, $component = NULL) {
- $locked = variable_get('features_feature_locked', array());
- if ($component) {
- unset($locked[$feature][$component]);
- }
- else {
- unset($locked[$feature]['_all']);
- }
- variable_set('features_feature_locked', $locked);
- }
- function _features_export_language($language = NULL) {
- $current = $GLOBALS['language'];
- if (isset($language)) {
- $GLOBALS['language'] = $language;
- }
- elseif ($GLOBALS['language']->language != 'en') {
-
- $GLOBALS['language'] = (object) array(
- 'language' => 'en',
- 'name' => 'English',
- 'native' => 'English',
- 'direction' => 0,
- 'enabled' => 1,
- 'plurals' => 0,
- 'formula' => '',
- 'domain' => '',
- 'prefix' => '',
- 'weight' => 0,
- 'javascript' => '',
- );
- }
- return $current;
- }
- function features_features_ignore($component) {
-
-
- $ignores = array();
- switch ($component) {
- case 'views_view':
- $ignores['current_display'] = 0;
- $ignores['display_handler'] = 0;
- $ignores['handler'] = 2;
- $ignores['query'] = 0;
- $ignores['localization_plugin'] = 0;
-
- $ignores['api_version'] = 0;
- $ignores['disabled'] = 0;
- break;
- case 'image':
- $ignores['module'] = 0;
- $ignores['name'] = 0;
- $ignores['storage'] = 0;
-
- $ignores['summary theme'] = 2;
- $ignores['module'] = 2;
- $ignores['label'] = 2;
- $ignores['help'] = 2;
- $ignores['form callback'] = 2;
- $ignores['effect callback'] = 2;
- $ignores['dimensions callback'] = 2;
- break;
- case 'field':
- $ignores['locked'] = 1;
- break;
- case 'field_base':
- $ignores['indexes'] = 0;
- break;
- case 'taxonomy':
- $ignores['hierarchy'] = 0;
- }
- return $ignores;
- }
|