summaryrefslogtreecommitdiff
path: root/modules/block
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-23 16:12:15 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-23 16:12:15 +0000
commitb44b2c6a97af4c8d865e724b139c6a26cbcadc33 (patch)
treeb5e70ff704ad45e58d09d1a83687293a9cc09d5b /modules/block
parent17c6ce8078487575393bf4f1ac1ebe200aa257a0 (diff)
downloadbrdo-b44b2c6a97af4c8d865e724b139c6a26cbcadc33.tar.gz
brdo-b44b2c6a97af4c8d865e724b139c6a26cbcadc33.tar.bz2
#126070 follow-up by David_Rothstein: Rollback of previous patch; needs discussion/deferrment until D8.
Diffstat (limited to 'modules/block')
-rw-r--r--modules/block/block.api.php10
-rw-r--r--modules/block/block.module24
-rw-r--r--modules/block/block.test4
3 files changed, 11 insertions, 27 deletions
diff --git a/modules/block/block.api.php b/modules/block/block.api.php
index 9cc2f602e..7b2ce0571 100644
--- a/modules/block/block.api.php
+++ b/modules/block/block.api.php
@@ -193,9 +193,11 @@ function hook_block_save($delta = '', $edit = array()) {
* within the module, defined in hook_block_info().
*
* @return
- * An array containing required elements 'subject' (the block's localized
- * title) and 'content' (the block's body). The 'content' element may be a
- * renderable array (preferable) or rendered HTML content.
+ * An array containing the following elements:
+ * - subject: The default localized title of the block. If the block does not
+ * have a default title, this should be set to NULL.
+ * - content: The content of the block's body. This may be a renderable array
+ * (preferable) or a string containing rendered HTML content.
*
* For a detailed usage example, see block_example.module.
*
@@ -242,7 +244,7 @@ function hook_block_view($delta = '') {
* @param $data
* An array of data, as returned from the hook_block_view() implementation of
* the module that defined the block:
- * - subject: The localized title of the block.
+ * - subject: The default localized title of the block.
* - content: Either a string or a renderable array representing the content
* of the block. You should check that the content is an array before trying
* to modify parts of the renderable structure.
diff --git a/modules/block/block.module b/modules/block/block.module
index 5cb0447d6..db63be8b8 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -241,27 +241,9 @@ function block_block_save($delta = 0, $edit = array()) {
* Generates the administrator-defined blocks for display.
*/
function block_block_view($delta = '') {
- $query = db_select('block_custom', 'bc');
- $query->join('block', 'b', 'bc.bid = b.delta');
- $block = $query
- ->addTag('translatable')
- ->addTag('block_load')
- ->fields('b', array('title'))
- ->fields('bc', array('body', 'format'))
- ->condition('bc.bid', $delta)
- ->range(0, 1)
- ->execute()
- ->fetchObject();
-
- $data = array(
- // Only module-generated block titles are allowed to output any HTML markup.
- // Custom block titles are always user input and therefore always escaped.
- // @see _block_render_blocks()
- 'subject' => $block->title == '<none>' ? '' : check_plain($block->title),
- 'content' => array(
- '#markup' => check_markup($block->body, $block->format),
- ),
- );
+ $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
+ $data['subject'] = NULL;
+ $data['content'] = check_markup($block->body, $block->format, '', TRUE);
return $data;
}
diff --git a/modules/block/block.test b/modules/block/block.test
index 7c92a357d..30e91f617 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -81,8 +81,8 @@ class BlockTestCase extends DrupalWebTestCase {
// Check that block_block_view() returns the correct title and content.
$data = block_block_view($bid);
$format = db_query("SELECT format FROM {block_custom} WHERE bid = :bid", array(':bid' => $bid))->fetchField();
- $this->assertEqual($custom_block['title'], $data['subject'], t('block_block_view() provides correct block title.'));
- $this->assertEqual(check_markup($custom_block['body[value]'], $format), $data['content']['#markup'], t('block_block_view() provides correct block content.'));
+ $this->assertTrue(array_key_exists('subject', $data) && empty($data['subject']), t('block_block_view() provides an empty block subject, since custom blocks do not have default titles.'));
+ $this->assertEqual(check_markup($custom_block['body[value]'], $format), $data['content'], t('block_block_view() provides correct block content.'));
// Check if the block can be moved to all availble regions.
$custom_block['module'] = 'block';