Same name and namespace in other branches
  1. 5.0.x advagg.install \advagg_requirements() 1 commentaire
  2. 6.0.x advagg.install \advagg_requirements() 1 commentaire
  3. 7.x-2.x advagg.install \advagg_requirements() 1 commentaire
  4. 8.x-2.x advagg.install \advagg_requirements() 1 commentaire
  5. 8.x-3.x advagg.install \advagg_requirements() 1 commentaire
  6. 8.x-4.x advagg.install \advagg_requirements() 1 commentaire

Implements hook_requirements().

Fichier

./advagg.install, line 93

Code

function advagg_requirements($phase) {
    global $_advagg;
    $requirements = array();
    // Ensure translations don't break at install time
    $t = get_t();
    // Report Drupal version
    if ($phase == 'runtime') {
        list($css_path, $js_path) = array(
            'public://advagg_css',
            'public://advagg_js',
        );
        if (!file_prepare_directory($css_path, FILE_CREATE_DIRECTORY)) {
            $requirements['advagg_css_path'] = array(
                'title' => $t('Adv CSS/JS Agg - CSS Path'),
                'severity' => REQUIREMENT_ERROR,
                'value' => $t('CSS directory is not created or writable'),
                'description' => $t('%path is not setup correctly.', array(
                    '%path' => $css_path,
                )),
            );
        }
        if (!file_prepare_directory($js_path, FILE_CREATE_DIRECTORY)) {
            $requirements['advagg_js_path'] = array(
                'title' => $t('Adv CSS/JS Agg - JS Path'),
                'severity' => REQUIREMENT_ERROR,
                'value' => $t('JS directory is not created or writable'),
                'description' => $t('%path is not setup correctly.', array(
                    '%path' => $js_path,
                )),
            );
        }
        if (variable_get('preprocess_css', FALSE) || variable_get('preprocess_js', FALSE)) {
            $requirements['advagg_core_off'] = array(
                'title' => $t('Adv CSS/JS Agg - Core Variables'),
                'severity' => REQUIREMENT_ERROR,
                'value' => $t('Cores CSS and/or JS aggregation is enabled'),
                'description' => $t('"Optimize CSS files" and "Optimize JavaScript files" on the <a href="@performance">performance page</a> should be disabled.', array(
                    '@performance' => url('admin/config/development/performance'),
                )),
            );
        }
        if (variable_get('advagg_enabled', ADVAGG_ENABLED) == FALSE) {
            $requirements['advagg_not_on'] = array(
                'title' => $t('Adv CSS/JS Agg - Enabled'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('Advanced CSS/JS aggregation is not currently enabled.'),
                'description' => $t('Go to the Advanced CSS/JS aggregation <a href="@settings">settings page</a> and enable it.', array(
                    '@settings' => url('admin/config/advagg'),
                )),
            );
        }
        if (module_exists('css_gzip')) {
            $requirements['advagg_css_gzip'] = array(
                'title' => $t('Adv CSS/JS Agg - CSS Gzip'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('The CSS Gzip module is enabled'),
                'description' => $t('On the <a href="@modules">modules page</a> you can disable it, as this module is no longer needed.', array(
                    '@modules' => url('admin/modules'),
                )),
            );
        }
        if (module_exists('csstidy')) {
            $requirements['advagg_csstidy'] = array(
                'title' => $t('Adv CSS/JS Agg - CSS Tidy'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('The CSS Tidy module is enabled'),
                'description' => $t('On the <a href="@modules">modules page</a> you can disable it, as this module is no longer needed.', array(
                    '@modules' => url('admin/modules'),
                )),
            );
        }
        if (module_exists('javascript_aggregator')) {
            $requirements['advagg_javascript_aggregator'] = array(
                'title' => $t('Adv CSS/JS Agg - Javascript Aggregator'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('The Javascript Aggregator is enabled'),
                'description' => $t('On the <a href="@modules">modules page</a> you can disable it, as this module is no longer needed. Once uninstalled be sure to enable the "Use AdvAgg in closure" setting on the <a href="@config">advagg config page</a>', array(
                    '@modules' => url('admin/modules'),
                    '@config' => url('admin/config/advagg/config'),
                )),
            );
        }
        if (module_exists('unlimited_css')) {
            $requirements['advagg_unlimited_css'] = array(
                'title' => $t('Adv CSS/JS Agg - IE Unlimited CSS Loader'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('The IE Unlimited CSS Loader module is enabled'),
                'description' => $t('On the <a href="@modules">modules page</a> you can disable it, as this module is no longer needed.', array(
                    '@modules' => url('admin/modules'),
                )),
            );
        }
        if (module_exists('ie_css_optimizer')) {
            $requirements['advagg_unlimited_css'] = array(
                'title' => $t('Adv CSS/JS Agg - IE CSS Optimizer'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('The IE CSS Optimizer module is enabled'),
                'description' => $t('On the <a href="@modules">modules page</a> you can disable it, as this module is no longer needed.', array(
                    '@modules' => url('admin/modules'),
                )),
            );
        }
        if (module_exists('cmscdn')) {
            $requirements['advagg_cmscdn'] = array(
                'title' => $t('Adv CSS/JS Agg - CMS CDN'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('The CMS CDN module is enabled.'),
                'description' => $t('On the <a href="@modules">modules page</a> you can disable it, as this module is no longer needed.', array(
                    '@modules' => url('admin/modules'),
                )),
            );
        }
        if (module_exists('bundlecache')) {
            $requirements['advagg_bundlecache'] = array(
                'title' => $t('Adv CSS/JS Agg - BundleCache'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('The BundleCache module is enabled.'),
                'description' => $t('On the <a href="@modules">modules page</a> you can disable it, as this module is no longer needed.', array(
                    '@modules' => url('admin/modules'),
                )),
            );
        }
        if (module_exists('css_emimage') && !function_exists('css_emimage_advagg_filenames_alter')) {
            $requirements['advagg_css_emimage'] = array(
                'title' => $t('Adv CSS/JS Agg - CSS Embedded Images'),
                'severity' => REQUIREMENT_WARNING,
                'value' => $t('CSS Embedded Images module needs a patch.'),
                'description' => $t('You need to apply the latest patch from this issue <a href="@issue">CSS Embedded Images - Add in support for advaggs hooks</a>; otherwise these 2 modules are not compatible with each other.', array(
                    '@issue' => 'http://drupal.org/node/1078060',
                )),
            );
        }
        // @TODO: Remove this check? Is it needed in D7?
        // if (isset($_advagg['closure']) && $_advagg['closure'] == FALSE) {
        //   $requirements['advagg_closure'] = array(
        //     'title' => $t('Adv CSS/JS Agg - Closure'),
        //     'severity' => REQUIREMENT_WARNING,
        //     'value' => $t('Your theme implements its own closure function.'),
        //     'description' => $t('To solve this problem, you unfortunately have to modify your theme. Copy the phptemplate_closure() function found in <a href="@link">advagg.module source code</a> and integrate it into your theme phptemplate_closure() function or <themename>_closure() function.', array('@link' => 'http://drupalcode.org/project/advagg.git/blob/refs/heads/6.x-1.x:/advagg.module#l201')),
        //   );
        // }
        if (module_exists('cdn')) {
            $file_path_blacklist = variable_get(CDN_EXCEPTION_FILE_PATH_BLACKLIST_VARIABLE, CDN_EXCEPTION_FILE_PATH_BLACKLIST_DEFAULT);
            $file_path_blacklist = explode("\n", trim($file_path_blacklist));
            $file_path_blacklist = array_map('trim', $file_path_blacklist);
            $file_path_blacklist = array_filter($file_path_blacklist);
            if (array_search('*.js', $file_path_blacklist) !== FALSE) {
                $requirements['advagg_cdn_js_blacklist'] = array(
                    'title' => $t('Adv CSS/JS Agg - CDN Settings'),
                    'severity' => REQUIREMENT_WARNING,
                    'value' => $t('The CDN module is set to blacklist all *.js files.'),
                    'description' => $t('Check your <a href="@cdn">CDN settings</a> and adjust the blacklist to not include "*.js". Testing is important in this case. "*tiny_mce.js" is a file/pattern we had to add to the blacklist after removing *.js from it.', array(
                        '@cdn' => url('admin/config/cdn/other'),
                    )),
                );
            }
        }
        $hooks = theme_get_registry();
        // Test location of advagg_processor in $hooks['page']['preprocess functions'].
        $function = advagg_install_theme_registry_location($hooks);
        if ($function != '_advagg_process_html') {
            $requirements['advagg_theme'] = array(
                'title' => $t('Adv CSS/JS Agg - Theme Hook'),
                'severity' => REQUIREMENT_ERROR,
                'value' => $t('Theme hook is not in the correct place.'),
                'description' => $t('On the <a href="@performance">performance page</a> clear the cache. If this is still an issue open up a bug on the <a href="http://drupal.org/node/add/project-issue/advagg">advagg issue queue</a> and be sure to include the "Hook Theme Info" output from the Advanced CSS/JS aggregation <a href="@settings">settings page</a>.', array(
                    '@performance' => url('admin/config/development/performance'),
                    '@settings' => url('admin/config/advagg'),
                )),
            );
        }
        // @TODO: Remove this check? Is it needed in D7?
        // // Test closure function.
        // $function = $hooks['closure']['function'];
        // if ($function != 'phptemplate_closure' && variable_get('advagg_closure', ADVAGG_CLOSURE)) {
        //   $requirements['advagg_closure'] = array(
        //     'title' => $t('Adv CSS/JS Agg - Closure'),
        //     'severity' => REQUIREMENT_ERROR,
        //     'value' => $t('Closure theme function issue.') . $function,
        //     'description' => $t('On the <a href="@performance">performance page</a> clear the cache or just the theme registry if you know how to do that. If this is still an issue open up a bug on the <a href="http://drupal.org/node/add/project-issue/advagg">advagg issue queue</a>.', array(
        //       '@performance' => url('admin/config/development/performance'),
        //     )),
        //   );
        // }
        $requirements += advagg_check_missing_handler();
    }
    return $requirements;
}