You are here

function mostpopular_blocks in Drupal Most Popular 7

Gets the configured Most Popular blocks.

Parameters

integer $bid Optionally, the block ID of an individual block to get.:

Return value

mixed If a $bid was provided, returns just the matching block. Otherwise, returns a list of all the configured blocks.

6 calls to mostpopular_blocks()
mostpopular_blocks_admin_form in ./mostpopular.blocks.inc
@file Provides an admin GUI for configuring most popular blocks.
mostpopular_block_info in ./mostpopular.module
Implements hook_block_info().
mostpopular_block_save in ./mostpopular.module
Implements hook_block_save().
mostpopular_block_view in ./mostpopular.module
Implements hook_block_view().
mostpopular_form_block_admin_configure_alter in ./mostpopular.blocks.inc
Implements form_FORM_ID_alter().

... See full list

File

./mostpopular.module, line 678
The main file for the Most Popular module.

Code

function mostpopular_blocks($bid = NULL) {
  $blocks =& drupal_static(__FUNCTION__);
  if (!isset($blocks)) {
    $blocks = db_select('mostpopular_block', 'b')
      ->fields('b')
      ->execute()
      ->fetchAllAssoc('bid');
    foreach ($blocks as $b => $block) {
      $blocks[$b]->data = unserialize($block->data);
      if (!$blocks[$b]->data) {
        $blocks[$b]->data = array();
      }
    }
  }
  if (!empty($bid)) {
    if (isset($blocks[$bid])) {
      return $blocks[$bid];
    }
    return FALSE;
  }
  return $blocks;
}