Пример #1
0
/**
 * Adds CSS classes based on user roles
 * Implements template_preprocess_html().
 *
 */
function foundation_access_preprocess_html(&$variables)
{
    // loop through our system specific colors
    $colors = array('primary', 'secondary', 'required', 'optional');
    $css = '';
    foreach ($colors as $current) {
        $color = theme_get_setting('foundation_access_' . $current . '_color');
        // allow other projects to override the FA colors
        drupal_alter('foundation_access_colors', $color, $current);
        // see if we have something that could be valid hex
        if (strlen($color) == 6 || strlen($color) == 3) {
            $complement = '#' . _foundation_access_complement($color);
            $color = '#' . $color;
            $css .= '.foundation_access-' . $current . "_color{color:{$color};}";
            // specialized additions for each wheel value
            switch ($current) {
                case 'primary':
                    $css .= ".etb-book h1,.etb-book h2 {color: {$color};}";
                    break;
                case 'secondary':
                    $css .= ".etb-book h3,.etb-book h4,.etb-book h5 {color: {$color};}";
                    break;
                case 'required':
                    $css .= "div.textbook_box_required li:hover:before{border-color: {$color};} div.textbook_box_required li:before {color: {$complement}; background: {$color};} div.textbook_box_required { border: 2px solid {$color};} .textbook_box_required h3 {color: {$color};}";
                    break;
                case 'optional':
                    $css .= "div.textbook_box_optional li:hover:before{border-color: {$color};} div.textbook_box_optional li:before {color: {$complement}; background: {$color};} div.textbook_box_optional { border: 2px solid {$color};} .textbook_box_optional h3 {color: {$color};}";
                    break;
            }
        }
    }
    drupal_add_css($css, array('type' => 'inline', 'group' => CSS_THEME, 'weight' => 1000));
    drupal_add_css('//fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic|Open+Sans:300,600,700)', array('type' => 'external', 'group' => CSS_THEME));
    // theme path shorthand should be handled here
    $variables['theme_path'] = base_path() . drupal_get_path('theme', 'foundation_access');
    foreach ($variables['user']->roles as $role) {
        $variables['classes_array'][] = 'role-' . drupal_html_class($role);
    }
    // add page level variables into scope for the html tpl file
    $variables['site_name'] = check_plain(variable_get('site_name', 'ELMSLN'));
    $variables['logo'] = theme_get_setting('logo');
    $variables['logo_img'] = '';
    // make sure we have a logo before trying to render a real one to screen
    if (!empty($variables['logo'])) {
        $variables['logo_img'] = l(theme('image', array('path' => $variables['logo'], 'alt' => strip_tags($variables['site_name']) . ' ' . t('logo'), 'title' => strip_tags($variables['site_name']) . ' ' . t('Home'), 'attributes' => array('class' => array('logo__img')))), '<front>', array('html' => TRUE));
    }
    // add logo style classes to the logo element
    $logo_classes = array();
    $logo_option = theme_get_setting('foundation_access_logo_options');
    if (isset($logo_option) && !is_null($logo_option)) {
        $logo_classes[] = 'logo--' . $logo_option;
    }
    $variables['logo_classes'] = implode(' ', $logo_classes);
    // support in-domain XSS exceptions
    if (module_exists('cis_connector')) {
        $variables['parent_origin'] = _cis_connector_parent_domain();
    }
}
Пример #2
0
/**
 * Adds CSS classes based on user roles
 * Implements template_preprocess_html().
 *
 */
function foundation_access_preprocess_html(&$variables)
{
    // find the name of the install profile
    $variables['install_profile'] = elmsln_core_get_profile_key();
    $settings = _cis_connector_build_registry($variables['install_profile']);
    $address = explode('.', $settings['address']);
    $variables['iconsizes'] = array('16', '32', '64', '96', '160', '192', '310');
    $variables['appleiconsizes'] = array('60', '72', '76', '114', '120', '144', '152', '180');
    $variables['system_icon'] = array_shift($address);
    $variables['system_title'] = isset($settings['default_title']) ? $settings['default_title'] : $variables['distro'];
    // loop through our system specific colors
    $colors = array('primary', 'secondary', 'required', 'optional');
    $css = '';
    foreach ($colors as $current) {
        $color = theme_get_setting('foundation_access_' . $current . '_color');
        // allow other projects to override the FA colors
        drupal_alter('foundation_access_colors', $color, $current);
        // see if we have something that could be valid hex
        if (strlen($color) == 6 || strlen($color) == 3) {
            $complement = '#' . _foundation_access_complement($color);
            $color = '#' . $color;
            $css .= '.foundation_access-' . $current . "_color{color:{$color};}";
            // specialized additions for each wheel value
            switch ($current) {
                case 'primary':
                    $css .= ".etb-book h1,.etb-book h2 {color: {$color};}";
                    break;
                case 'secondary':
                    $css .= ".etb-book h3,.etb-book h4,.etb-book h5 {color: {$color};}";
                    break;
                case 'required':
                    $css .= "div.textbook_box_required li:hover:before{border-color: {$color};} div.textbook_box_required li:before {color: {$complement}; background: {$color};} div.textbook_box_required { border: 2px solid {$color};} .textbook_box_required h3 {color: {$color};}";
                    break;
                case 'optional':
                    $css .= "div.textbook_box_optional li:hover:before{border-color: {$color};} div.textbook_box_optional li:before {color: {$complement}; background: {$color};} div.textbook_box_optional { border: 2px solid {$color};} .textbook_box_optional h3 {color: {$color};}";
                    break;
            }
        }
    }
    $variables['theme_path'] = base_path() . drupal_get_path('theme', 'foundation_access');
    drupal_add_css($css, array('type' => 'inline', 'group' => CSS_THEME, 'weight' => 999));
    // elmsln icons
    drupal_add_css(drupal_get_path('theme', 'foundation_access') . '/fonts/elmsln/elmsln-font-styles.css', array('group' => CSS_THEME, 'weight' => -1000));
    // google font / icons from google
    drupal_add_css('//fonts.googleapis.com/css?family=Material+Icons|Droid+Serif:400,700,400italic,700italic|Open+Sans:300,600,700)', array('type' => 'external', 'group' => CSS_THEME, 'weight' => 1000));
    $libraries = libraries_get_libraries();
    if (isset($libraries['jquery.vibrate.js'])) {
        drupal_add_js($libraries['jquery.vibrate.js'] . '/jquery.vibrate.min.js');
        drupal_add_js(drupal_get_path('theme', 'foundation_access') . '/legacy/js/vibrate-enable.js');
    }
    // gifs need to be done as a player for accessibility reasons
    if (isset($libraries['jquery.vibrate.js'])) {
        drupal_add_js($libraries['freezeframe.js'] . '/src/js/vendor/imagesloaded.pkgd.js');
        drupal_add_js($libraries['freezeframe.js'] . '/build/js/freezeframe.js');
        drupal_add_css($libraries['freezeframe.js'] . '/build/css/freezeframe_styles.min.css');
        drupal_add_js(drupal_get_path('theme', 'foundation_access') . '/legacy/js/freezeframe-enable.js');
    }
    // bring in materialize
    $libraries = libraries_get_libraries();
    // see if we have it locally before serviing CDN
    // This allows EASY CDN module to switch to CDN later if that's the intention
    if (isset($libraries['materialize'])) {
        drupal_add_css($libraries['materialize'] . '/css/materialize.css', array('weight' => -1000));
        drupal_add_js($libraries['materialize'] . '/js/materialize.js', array('scope' => 'footer', 'weight' => 1000));
    } else {
        drupal_add_css('//cdnjs.cloudflare.com/ajax/libs/materialize/' . FOUNDATION_ACCESS_MATERIALIZE_VERSION . '/css/materialize.min.css', array('type' => 'external', 'weight' => -1000));
        drupal_add_js('//cdnjs.cloudflare.com/ajax/libs/materialize/' . FOUNDATION_ACCESS_MATERIALIZE_VERSION . '/js/materialize.min.js', array('type' => 'external', 'scope' => 'footer', 'weight' => 1000));
    }
    // support for our legacy; adding in css/js for foundation; this requires a forcible override in shared_settings.php
    if (variable_get('foundation_access_legacy', FALSE)) {
        drupal_add_css(drupal_get_path('theme', 'foundation_access') . '/legacy_zurb/css/foundation.min.css', array('weight' => -1000));
        drupal_add_js(drupal_get_path('theme', 'foundation_access') . '/legacy_zurb/js/modernizr.js', array('scope' => 'footer', 'weight' => 1000));
        drupal_add_js(drupal_get_path('theme', 'foundation_access') . '/legacy_zurb/js/foundation.min.js', array('scope' => 'footer', 'weight' => 1001));
        drupal_add_js(drupal_get_path('theme', 'foundation_access') . '/legacy_zurb/js/enable-foundation.js', array('scope' => 'footer', 'weight' => 2000));
    }
    // theme path shorthand should be handled here
    foreach ($variables['user']->roles as $role) {
        $variables['classes_array'][] = 'role-' . drupal_html_class($role);
    }
    // support for class to render in a modal
    if (isset($_GET['modal'])) {
        $variables['classes_array'][] = 'modal-rendered';
    }
    // pull in the lmsless classes / colors
    $variables['lmsless_classes'] = _cis_lmsless_get_distro_classes(elmsln_core_get_profile_key());
    // add page level variables into scope for the html tpl file
    $variables['site_name'] = check_plain(variable_get('site_name', 'ELMSLN'));
    $variables['logo'] = theme_get_setting('logo');
    $variables['banner_image'] = '';
    // build the remote banner URI, this is the best solution for an image
    $uri = 'elmslnauthority://cis/banners/' . _cis_connector_course_context() . '.jpg';
    if (file_exists(_elmsln_core_realpath($uri))) {
        $variables['banner_image'] = theme('image', array('path' => $uri, 'alt' => '', 'attributes' => array('class' => array('logo__img'))));
    } elseif (!empty($variables['logo'])) {
        $logopath = drupal_get_path('theme', 'foundation_access') . '/logo.jpg';
        $variables['banner_image'] = theme('image', array('path' => $logopath, 'alt' => '', 'attributes' => array('class' => array('logo__img'))));
    }
}