You are here

countryicons.theme.inc in Country Icons 6.2

Same filename and directory in other branches
  1. 7.2 countryicons.theme.inc

Theme functions for the countryicons module.

File

countryicons.theme.inc
View source
<?php

/**
 * @file
 * Theme functions for the countryicons module.
 */

/**
 * Theme a country icon.
 *
 * @param $code
 *   A two letter ISO3166 country code.
 * @param $iconset
 *   The icon set to use.
 * @param $alt
 *   The alternative text for text-based browsers (the two letter ISO3166 country code is the default).
 * @param $title
 *   The title text is displayed when the image is hovered in some popular browsers.
 * @param $attributes
 *   Associative array of attributes to be placed in the img tag.
 * @param $display_unknown
 *   If set to TRUE, if a icon don't exists it tries to return a transparant image instead.
 * @return
 *   A string containing the image tag.
 */
function theme_countryicons_icon($code, $iconset, $alt = '', $title = '', $attributes = NULL, $display_unknown = TRUE) {
  $icon_path = countryicons_get_icon_path($code, $iconset);
  if (!empty($icon_path)) {
    $alt = $alt ? $alt : $code;
    $attributes = $attributes ? $attributes : array();
    $attributes['class'] = 'countryicon iconset-' . $iconset . ' countrycode-' . drupal_strtolower($code) . (empty($attributes['class']) ? '' : ' ' . $attributes['class']);
    return theme('image', $icon_path, $alt, $title, $attributes);
  }
  elseif ($display_unknown) {
    return theme('countryicons_icon', 'unknown', $iconset, $alt, $title, $attributes, FALSE);
  }
}

/**
 * Theme a country icon with CSS sprite.
 *
 * @param $code
 *   A two letter ISO3166 country code.
 * @param $iconset
 *   The icon set to use.
 * @return
 *   A string containing a image tag rendered using a css sprite techniquie.
 */
function theme_countryicons_icon_sprite($code, $iconset) {
  $iconset = countryicons_get_iconset($iconset);
  if (!empty($iconset) && $iconset->css_sprite && !empty($code)) {
    drupal_add_css($iconset->css_sprite);
    return '<div class="countryicon-sprite iconset-' . $iconset->key . ' countrycode-' . drupal_strtolower($code) . '"></div>';
  }
}

Functions

Namesort descending Description
theme_countryicons_icon Theme a country icon.
theme_countryicons_icon_sprite Theme a country icon with CSS sprite.