You are here

function _ds_block_list in Display Suite 6.2

Same name and namespace in other branches
  1. 6.3 includes/ds.registry.inc \_ds_block_list()
  2. 6 includes/ds.registry.inc \_ds_block_list()

Return blocks.

1 call to _ds_block_list()
ds_block in ./ds.module
Implements hook_block().

File

includes/ds.registry.inc, line 585
Registry functions.

Code

function _ds_block_list() {
  $blocks = array();
  $all_blocks = array();
  foreach (module_implements('ds_api') as $module) {
    $plugins = variable_get($module . '_plugin_settings', array());
    if (!empty($plugins)) {
      foreach ($plugins as $key => $data) {
        if (isset($data['filename']) && isset($data['class'])) {
          require_once $data['filename'];
          $class = $data['class'];
          $plugin = new $class();
          if (method_exists($plugin, 'block_list')) {
            $plugin
              ->block_list($module, $all_blocks, $data);
          }
        }
      }
    }
  }
  if (!empty($all_blocks)) {
    $i = 0;
    $ds_blocks = array();
    foreach ($all_blocks as $key => $block) {
      if (isset($block['info']) && isset($block['key']) && isset($block['data'])) {

        // Calculating the md5 from the key is effective here, because we'll
        // get back an int which is exactly 32 characters long, the length
        // of the delta field of the blocks table.
        $hash = md5($block['key']);
        $blocks[$hash] = array(
          'info' => $block['info'],
        );
        $ds_blocks[$hash] = $block;
      }
    }
    variable_set('ds_blocks', $ds_blocks);
  }
  return $blocks;
}