Implements hook_requirements().

Fichier

advagg_js_cdn/advagg_js_cdn.install, line 16

Code

function advagg_js_cdn_requirements($phase) {
    $requirements = array();
    // Ensure translations don't break at install time.
    $t = get_t();
    // If not at runtime, return here.
    if ($phase !== 'runtime') {
        return $requirements;
    }
    if (module_exists('jquery_update')) {
        $jquery_cdn = variable_get('jquery_update_jquery_cdn', 'none');
        if ($jquery_cdn === 'none') {
            $jquery_description = $t('The jquery update module has support for CDNs. Go to the <a href="@settings">jquery update settings page</a> and select a CDN instead of using this module.', array(
                '@settings' => url('admin/config/development/jquery_update', array(
                    'fragment' => 'edit-jquery-update-jquery-cdn',
                )),
            ));
        }
        else {
            $jquery_description = $t('The jquery update module is already configured to use the external CDN "@cdn".', array(
                '@cdn' => $jquery_cdn,
            ));
        }
        $requirements['advagg_js_cdn_jquery_update'] = array(
            'title' => $t('Adv JS CDN - jquery update'),
            'severity' => REQUIREMENT_WARNING,
            'value' => $t('Duplicate Functionality: Use jquery update instead of the advagg_js_cdn sub module.'),
            'description' => $jquery_description . ' ' . $t('You should go to the <a href="@modules">modules page</a> and disable the "AdvAgg CDN JS" module.', array(
                '@modules' => url('admin/modules', array(
                    'fragment' => 'edit-modules-advanced-cssjs-aggregation',
                )),
            )),
        );
    }
    if (empty($requirements)) {
        $description = '';
        if (variable_get('advagg_cache_level', ADVAGG_CACHE_LEVEL) < 0) {
            $description = $t('Will be using the unminified version due to AdvAgg being in Development mode.');
        }
        $requirements['advagg_js_cdn'] = array(
            'title' => $t('Adv JS CDN'),
            'severity' => REQUIREMENT_OK,
            'value' => $t('OK'),
            'description' => $t('jQuery and jQuery UI JS should be coming from a CDN.') . ' ' . $description,
        );
    }
    return $requirements;
}