You are here

function fieldable_panels_panes_block_info in Fieldable Panels Panes (FPP) 7

Implements hook_block_info().

File

./fieldable_panels_panes.module, line 840
Maintains an entity that appears as panel pane content.

Code

function fieldable_panels_panes_block_info() {
  $blocks = array();

  // Get array of exposed FPP bundles.
  $bundles = fieldable_panels_panes_exposed_bundles();
  if (variable_get('fpp_blocks_expose', FALSE) == TRUE) {

    // Get all reusable entities if $bundles array is empty.
    if (empty($bundles)) {
      $ids = db_query('SELECT fpid FROM {fieldable_panels_panes} WHERE reusable = 1')
        ->fetchCol();
    }
    else {
      $ids = array();
      foreach ($bundles as $bundle => $info) {
        $bundle_ids = db_query('SELECT fpid FROM {fieldable_panels_panes} WHERE reusable = 1 AND bundle = :bundle', array(
          ':bundle' => $bundle,
        ))
          ->fetchCol();
        $ids = array_merge($ids, $bundle_ids);
      }
    }
    $entities = fieldable_panels_panes_load_multiple($ids);
    foreach ($entities as $entity) {
      $blocks[$entity->fpid]['info'] = 'FPP (' . $entity->bundle . '): ' . entity_label('fieldable_panels_pane', $entity);
    }
  }
  return $blocks;
}