You are here

function fonts_com_preprocess_page in @font-your-face 7

Same name and namespace in other branches
  1. 6.2 modules/fonts_com/fonts_com.module \fonts_com_preprocess_page()

Implements template_preprocess_page().

File

modules/fonts_com/fonts_com.module, line 82

Code

function fonts_com_preprocess_page(&$vars) {
  if (!empty($vars['fontyourface'])) {
    $projects = array();
    foreach ($vars['fontyourface'] as $used_font) {
      if ($used_font->provider == 'fonts_com') {
        $metadata = unserialize($used_font->metadata);
        $projects[$metadata['project_id']] = TRUE;
      }

      // if
    }

    // foreach
    if (count($projects) > 0) {
      $base = 'http://fast.fonts.com/jsapi/';
      if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
        $base = 'https://fast.fonts.com/jsapi/';
      }

      // if
      foreach (array_keys($projects) as $project) {
        drupal_add_js($base . $project . '.js', array(
          'type' => 'external',
        ));
        $variables['scripts'] = drupal_get_js();
      }

      // foreach
    }

    // if
  }

  // if
}