You are here

function pm_icon in Drupal PM (Project Management) 7

Same name and namespace in other branches
  1. 8 pm.module \pm_icon()
  2. 7.3 includes/pm.icon.inc \pm_icon()
  3. 7.2 pm.module \pm_icon()

Provides a Project Management icon.

3 calls to pm_icon()
pminvoice_handler_field_invoice_status::render in pminvoice/pminvoice_handler_field_invoice_status.inc
Override render method.
pm_handler_field_attributes_domain::render in ./pm_handler_field_attributes_domain.inc
Alters views render to show attribute values rather than keys.
pm_icon_l in ./pm.module
Provides an icon link.

File

./pm.module, line 815
Main module file for the Project Management module.

Code

function pm_icon($icon, $title) {

  // Running checkplain on these variables means that we can call pm_icon without further sanitising
  $icon = check_plain($icon);
  $title = check_plain($title);
  $icon = str_replace(' ', '_', $icon);
  if (variable_get('pm_icons_display', TRUE) == TRUE) {
    $available = cache_get('pm:icons');
    if (!is_object($available)) {

      // Cache miss
      $available = pm_icon_recache();
    }

    // Normal situation - display icon image
    if (in_array($icon . '.png', $available->data)) {

      // Construct path relative to folder stored in settings
      $img_src = variable_get('pm_icons_path', drupal_get_path('module', 'pm') . '/icons') . '/' . $icon . '.png';

      // Return the icon
      return theme('image', array(
        'path' => $img_src,
        'alt' => $title,
        'title' => $title,
      ));
    }
    else {

      // Icon not found
      return pm_icon_default($icon, $title);
    }
  }
  else {

    // Icons set to not display
    return $title;
  }
}