diff --git a/advagg.install b/advagg.install index 7f59828..b673802 100644 --- a/advagg.install +++ b/advagg.install @@ -428,6 +428,7 @@ function advagg_install_check_via_http(&$requirements) { || empty($request->headers['content-encoding']) || ($request->headers['content-encoding'] != 'gzip' && $request->headers['content-encoding'] != 'deflate') ) { + $config_path = advagg_admin_config_path(); // Gzip failed. if (!variable_get('advagg_gzip', ADVAGG_GZIP)) { // Recommend that gzip be turned on. @@ -436,7 +437,7 @@ function advagg_install_check_via_http(&$requirements) { 'severity' => REQUIREMENT_WARNING, 'value' => $t('Gzip is failing for %type files.', array('%type' => $type)), 'description' => $t('Try enabling on the "Create .gz files" setting on the Advanced CSS/JS Aggregation Configuration page', array( - '@advagg' => url('admin/config/development/advagg'), + '@advagg' => url($config_path), '%type' => $type, )), ); @@ -448,7 +449,7 @@ function advagg_install_check_via_http(&$requirements) { 'severity' => REQUIREMENT_WARNING, 'value' => $t('Gzip is failing for %type files.', array('%type' => $type)), 'description' => $t('The web servers configuration will need to be adjusted. In most cases make sure that the webroots .htaccess file still contains this section "Rules to correctly serve gzip compressed CSS and JS files".', array( - '@advagg' => url('admin/config/development/advagg'), + '@advagg' => url($config_path), )), ); } diff --git a/advagg.module b/advagg.module index 47eb41c..bd2d9ac 100644 --- a/advagg.module +++ b/advagg.module @@ -46,6 +46,11 @@ define('ADVAGG_USE_HTTPRL', TRUE); */ define('ADVAGG_COMBINE_CSS_MEDIA', TRUE); +/** + * Default location of AdvAgg configuration items. + */ +define('ADVAGG_ADMIN_CONFIG_PATH', 'admin/config/development/advagg'); + // Core hook implementations. /** * Implements hook_hook_info(). @@ -60,6 +65,7 @@ function advagg_hook_info() { 'advagg_save_aggregate_alter', 'advagg_build_aggregate_plans_alter', 'advagg_changed_files', + 'advagg_scan_for_changes', ); $hooks = array(); foreach ($advagg_hooks as $hook) { @@ -69,6 +75,35 @@ function advagg_hook_info() { } /** + * Implements hook_system_info_alter(). + */ +function advagg_system_info_alter(&$info, $file, $type) { + static $config_path; + static $module_path; + // Get advagg config path + if (!isset($config_path)) { + $config_path = advagg_admin_config_path(); + } + if (!isset($module_path)) { + $module_path = drupal_get_path('module', 'advagg') . '/advagg.module'; + } + + // Replace advagg path. + if ( !empty($info['configure']) + && strpos($info['configure'], '/advagg') !== FALSE + && (( + !empty($info['dependencies']) + && is_array($info['dependencies']) + && in_array('advagg', $info['dependencies']) + ) || $file->name == 'advagg' ) + ) { + $pos = strpos($info['configure'], '/advagg') + 7; + $substr = substr($info['configure'], 0, $pos); + $info['configure'] = str_replace($substr, $config_path, $info['configure']); + } +} + +/** * Implements hook_permission(). */ function advagg_permission() { @@ -86,6 +121,7 @@ function advagg_permission() { function advagg_menu() { list($css_path, $js_path) = advagg_get_root_files_dir(); $file_path = drupal_get_path('module', 'advagg'); + $config_path = advagg_admin_config_path(); $items = array(); $items[$css_path[1] . '/%'] = array( @@ -104,7 +140,7 @@ function advagg_menu() { 'file path' => $file_path, 'file' => 'advagg.missing.inc', ); - $items['admin/config/development/advagg'] = array( + $items[$config_path] = array( 'title' => 'Advanced CSS/JS Aggregation', 'description' => 'Configuration for Advanced CSS/JS Aggregation.', 'page callback' => 'drupal_get_form', @@ -115,12 +151,12 @@ function advagg_menu() { 'file' => 'advagg.admin.inc', 'weight' => -10, ); - $items['admin/config/development/advagg/config'] = array( + $items[$config_path . '/config'] = array( 'title' => 'Configuration', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); - $items['admin/config/development/advagg/operations'] = array( + $items[$config_path . '/operations'] = array( 'title' => 'Preform An Operation', 'description' => 'Flush caches, set the bypass cookie, take drastic actions.', 'page callback' => 'drupal_get_form', @@ -131,7 +167,7 @@ function advagg_menu() { 'file' => 'advagg.admin.inc', 'weight' => -9, ); - $items['admin/config/development/advagg/info'] = array( + $items[$config_path . '/info'] = array( 'title' => 'Information', 'description' => 'More detailed information about advagg.', 'page callback' => 'drupal_get_form', @@ -257,7 +293,6 @@ function advagg_admin_menu_output_alter(&$content) { } // Core CSS/JS override functions. - /** * #pre_render callback so elements can be modified before they are rendered. * @@ -780,6 +815,16 @@ function advagg_enabled() { } /** + * Get the current path used for advagg admin configuration. + * + * @return string + * Path to root advagg config. + */ +function advagg_admin_config_path() { + return variable_get('advagg_admin_config_path', ADVAGG_ADMIN_CONFIG_PATH); +} + +/** * Get an array of all hooks and settings that affect aggregated files contents. * * @return diff --git a/advagg_bundler/advagg_bundler.module b/advagg_bundler/advagg_bundler.module index 0dbbc5a..d77e3fb 100644 --- a/advagg_bundler/advagg_bundler.module +++ b/advagg_bundler/advagg_bundler.module @@ -36,8 +36,9 @@ define('ADVAGG_BUNDLER_ACTIVE', TRUE); function advagg_bundler_menu() { $items = array(); $file_path = drupal_get_path('module', 'advagg_bundler'); + $config_path = advagg_admin_config_path(); - $items['admin/config/development/advagg/bundler'] = array( + $items[$config_path . '/bundler'] = array( 'title' => 'Bundler', 'description' => 'Adjust Bundler settings.', 'page callback' => 'drupal_get_form', diff --git a/advagg_js_compress/advagg_js_compress.module b/advagg_js_compress/advagg_js_compress.module index 5ae8556..a18f150 100644 --- a/advagg_js_compress/advagg_js_compress.module +++ b/advagg_js_compress/advagg_js_compress.module @@ -36,8 +36,9 @@ define('ADVAGG_JS_MAX_COMPRESS_RATIO', 0.9); function advagg_js_compress_menu() { $items = array(); $file_path = drupal_get_path('module', 'advagg_js_compress'); + $config_path = advagg_admin_config_path(); - $items['admin/config/development/advagg/js-compress'] = array( + $items[$config_path . '/js-compress'] = array( 'title' => 'JS Compression', 'description' => 'Adjust JS Compression settings.', 'page callback' => 'drupal_get_form', diff --git a/advagg_mod/advagg_mod.module b/advagg_mod/advagg_mod.module index c150e63..02db62c 100644 --- a/advagg_mod/advagg_mod.module +++ b/advagg_mod/advagg_mod.module @@ -70,8 +70,9 @@ function advagg_mod_init() { function advagg_mod_menu() { $items = array(); $file_path = drupal_get_path('module', 'advagg_mod'); + $config_path = advagg_admin_config_path(); - $items['admin/config/development/advagg/mod'] = array( + $items[$config_path . '/mod'] = array( 'title' => 'Modifications', 'description' => 'Turn on or off various mods for CSS/JS.', 'page callback' => 'drupal_get_form',