You are here

function panels_content_block in Panels 5

Same name and namespace in other branches
  1. 5.2 content_types/block.inc \panels_content_block()
  2. 6.2 content_types/block.inc \panels_content_block()

Output function for the 'block' content type. Outputs a block based on the module and delta supplied in the configuration.

1 string reference to 'panels_content_block'
panels_block_panels_content_types in content_types/block.inc
Callback function to supply a list of content types.

File

content_types/block.inc, line 17

Code

function panels_content_block($conf) {
  $block = (object) module_invoke($conf['module'], 'block', 'view', $conf['delta']);
  $block->module = $conf['module'];
  $block->delta = $conf['delta'];
  if ($conf['override_title']) {
    $block->subject = check_plain($conf['override_title_text']);
  }

  // Test for block visibility
  $result = db_query("SELECT pages, visibility FROM {blocks} WHERE module = '%s' AND delta = %d", $block->module, $block->delta);
  $block_visibility = db_fetch_object($result);
  if ($block_visibility && $block_visibility->pages) {
    if ($block_visibility->visibility < 2) {
      $path = drupal_get_path_alias($_GET['q']);
      $regexp = '/^(' . preg_replace(array(
        '/(\\r\\n?|\\n)/',
        '/\\\\\\*/',
        '/(^|\\|)\\\\<front\\\\>($|\\|)/',
      ), array(
        '|',
        '.*',
        '\\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\\2',
      ), preg_quote($block->pages, '/')) . ')$/';
      $page_match = !($block->visibility xor preg_match($regexp, $path));
    }
    else {
      $page_match = drupal_eval($block->pages);
    }
  }
  else {
    $page_match = TRUE;
  }
  if ($page_match) {
    return theme('block', $block);
  }
}