You are here

function dfp_block_info in Doubleclick for Publishers (DFP) 7.2

Same name and namespace in other branches
  1. 7 dfp.module \dfp_block_info()

Implements hook_block_info().

File

./dfp.module, line 111

Code

function dfp_block_info() {
  $tags = dfp_tag_load_all();
  $blocks = array();
  $hashes = array();
  foreach ($tags as $tag) {
    if ($tag->block) {

      // The block table chokes when the delta is more than 32 characters. To
      // solve this we create a hash of the machine name when needed.
      if (drupal_strlen($tag->machinename) >= 32) {
        $delta = md5($tag->machinename);
        $hashes[$delta] = $tag->machinename;
      }
      else {
        $delta = $tag->machinename;
      }
      $blocks[$delta]['info'] = t('DFP tag: @slotname', array(
        '@slotname' => $tag->slot,
      ));
      $blocks[$delta]['cache'] = DRUPAL_CACHE_PER_PAGE;
    }
  }

  // Only save hashes if they have changed.
  $old_hashes = variable_get('dfp_block_hashes', array());
  if ($hashes != $old_hashes) {
    variable_set('dfp_block_hashes', $hashes);
  }
  return $blocks;
}