summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.15/sites/all/modules/ctools/plugins/content_types/block/block.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.15/sites/all/modules/ctools/plugins/content_types/block/block.inc')
-rw-r--r--kolab.org/www/drupal-7.15/sites/all/modules/ctools/plugins/content_types/block/block.inc70
1 files changed, 62 insertions, 8 deletions
diff --git a/kolab.org/www/drupal-7.15/sites/all/modules/ctools/plugins/content_types/block/block.inc b/kolab.org/www/drupal-7.15/sites/all/modules/ctools/plugins/content_types/block/block.inc
index 866f72e..f5b0063 100644
--- a/kolab.org/www/drupal-7.15/sites/all/modules/ctools/plugins/content_types/block/block.inc
+++ b/kolab.org/www/drupal-7.15/sites/all/modules/ctools/plugins/content_types/block/block.inc
@@ -78,21 +78,72 @@ function _ctools_block_content_type_content_type($module, $delta, $block) {
}
/**
+ * Load block info from the database.
+ *
+ * This is copied from _block_load_blocks(). It doesn't use that
+ * function because _block_load_blocks sorts by region, and it
+ * doesn't cache its results anyway.
+ */
+function _ctools_block_load_blocks() {
+ $blocks = &drupal_static(__FUNCTION__, NULL);
+ if (!isset($blocks)) {
+ global $theme_key;
+
+ $query = db_select('block', 'b');
+ $result = $query
+ ->fields('b')
+ ->condition('b.theme', $theme_key)
+ ->orderBy('b.region')
+ ->orderBy('b.weight')
+ ->orderBy('b.module')
+ ->addTag('block_load')
+ ->addTag('translatable')
+ ->execute();
+
+ $block_info = $result->fetchAllAssoc('bid');
+ // Allow modules to modify the block list.
+ drupal_alter('block_list', $block_info);
+
+ $blocks = array();
+ foreach ($block_info as $block) {
+ $blocks["{$block->module}_{$block->delta}"] = $block;
+ }
+ }
+
+ return $blocks;
+}
+
+/**
+ * Fetch the stored info for a block.
+ *
+ * The primary reason to use this is so that modules which perform alters
+ * can have their alters make it to the block.
+ */
+function _ctools_get_block_info($module, $delta) {
+ $blocks = _ctools_block_load_blocks();
+
+ $key = $module . '_' . $delta;
+ if (isset($blocks[$key])) {
+ return $blocks[$key];
+ }
+}
+
+/**
* Output function for the 'block' content type. Outputs a block
* based on the module and delta supplied in the configuration.
*/
function ctools_block_content_type_render($subtype, $conf) {
list($module, $delta) = _ctools_block_get_module_delta($subtype, $conf);
- $info = new stdClass;
- $info->module = $module;
- $info->delta = $delta;
+ $info = _ctools_get_block_info($module, $delta);
$block = module_invoke($module, 'block_view', $delta);
- // Allow modules to modify the block before it is viewed, via either
- // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
- drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $block, $info);
- $block = (object) $block;
+ if (!empty($info)) {
+ // Allow modules to modify the block before it is viewed, via either
+ // hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
+ drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $block, $info);
+ $block = (object) $block;
+ }
if (empty($block)) {
return;
@@ -101,7 +152,10 @@ function ctools_block_content_type_render($subtype, $conf) {
$block->module = $module;
$block->delta = $delta;
- if (isset($block->subject)) {
+ if ($module == 'block') {
+ $block->title = $info->title;
+ }
+ else if (isset($block->subject)) {
$block->title = $block->subject;
}
else {