You are here

function fontyourface_ui_views_pre_render in @font-your-face 7.2

Implements hook_views_pre_render().

File

modules/fontyourface_ui/fontyourface_ui.module, line 133

Code

function fontyourface_ui_views_pre_render(&$view) {
  if ($view->name == 'fontyourface_browse' || $view->name == 'google_fonts_api_browse') {
    $view->display_handler->handlers['header']['area']->options['format'] = 'full_html';
    $view->display_handler->handlers['header']['area']->options['content'] = '<div><p>' . fontyourface_ui_enabled_count() . '</p></div>' . fontyourface_ui_browse_tabs();
    drupal_add_css(drupal_get_path('module', 'fontyourface_ui') . '/css/fontyourface_ui.css');
    drupal_add_js(drupal_get_path('module', 'fontyourface_ui') . '/js/browse.js');
    $providers = module_implements('fontyourface_info');
    if (count($providers) == 0) {
      drupal_set_message(t('No font providers enabled. !enable before browsing fonts.', array(
        '!enable' => l(t('Enable font provider modules'), 'admin/modules'),
      )), 'error');
    }

    // if
    $selected_provider = arg(4);

    // Work around overlay bug with redirects.
    if ($selected_provider == '') {
      fontyourface_ui_browse_page();
    }

    // if
    $has_fonts = db_query_range("SELECT fid FROM {fontyourface_font} WHERE provider = :provider", 0, 1, array(
      ':provider' => $selected_provider,
    ))
      ->fetchObject();
    $function = $selected_provider . '_fontyourface_info';
    if (function_exists($function)) {
      $info = $function();
    }
    else {
      $info = FALSE;
    }

    // else
    if ($info) {
      drupal_set_title(t('Browse fonts: @provider', array(
        '@provider' => $info['name'],
      )));
      $breadcrumb = drupal_get_breadcrumb();
      $breadcrumb[] = $info['name'];
      drupal_set_breadcrumb($breadcrumb);
    }

    // if
    if (!$has_fonts) {
      if ($info) {
        drupal_set_message(t('@provider currently has no fonts. This is probably because the import has not been run yet. !import to add fonts.', array(
          '@provider' => $info['name'],
          '!import' => l(t('Run import'), 'admin/config/user-interface/fontyourface'),
        )), 'error');
      }

      // if
    }

    // if
  }

  // if
}