You are here

function icon_block_preprocess_block in Icon API 7

Same name and namespace in other branches
  1. 8 modules/icon_block/icon_block.module \icon_block_preprocess_block()

Implements hook_preprocess_block().

Add icon to blocks if necessary.

File

modules/icon_block/icon_block.module, line 55
icon_block.module Provides icon integration with blocks.

Code

function icon_block_preprocess_block(&$variables) {
  $block =& $variables['block'];
  $settings = icon_block_get_settings($block);
  if (!empty($settings['bundle']) && !empty($settings['icon'])) {
    if ($icon = theme('icon', $settings)) {
      $variables['classes_array'][] = 'has-icon';
      switch ($settings['position']) {
        case 'title_before':
          $variables['title_prefix'][] = array(
            '#markup' => $icon,
          );
          break;
        case 'title_after':
          $variables['title_suffix'][] = array(
            '#markup' => $icon,
          );
          break;
        case 'title_inside_before':
          $block->subject = $icon . $block->subject;
          break;
        case 'title_inside_after':
          $block->subject .= $icon;
          break;
        case 'content_before':
          $variables['content'] = $icon . $variables['content'];
          break;
        case 'content_after':
          $variables['content'] .= $icon;
          break;
      }
    }
  }
}