You are here

function sharedblocks_publish_block in Shared Blocks 6

Same name and namespace in other branches
  1. 7.2 sharedblocks.publish.inc \sharedblocks_publish_block()
  2. 7 sharedblocks.module \sharedblocks_publish_block()

Page callback for block publish callback.

1 string reference to 'sharedblocks_publish_block'
sharedblocks_menu in ./sharedblocks.module
Implementation of hook_menu().

File

./sharedblocks.module, line 328

Code

function sharedblocks_publish_block($module, $delta) {
  $blocks = variable_get('sharedblocks_publish', array());
  if ($blocks[$module][$delta]) {

    // Load the block.
    $block = module_invoke($module, 'block', 'view', $delta);
    if (is_array($block)) {

      // Translate relative URLs into absolute ones.
      // NOTE: Only works with double quotes..
      // @todo: see about capturing ('|") and then matching %2 at end
      $regex = '~(href|src|HREF|SRC)="(\\/.+?)"~';
      $block['content'] = preg_replace($regex, '\\1="' . $GLOBALS['base_url'] . '\\2"', $block['content']);
      drupal_json($block);
      return;
    }
  }

  // If you get here, something has gone wrong.
  return drupal_not_found();
}