summaryrefslogtreecommitdiff
path: root/modules/block
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-22 08:11:49 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-22 08:11:49 +0000
commit3974c6c4f05102e1b2a2f932763fccac1054c544 (patch)
treeabb57105872d7a1c86d4ef445cbe98b62aaa638a /modules/block
parentc0c4aeeb6611088b63d91e55b53d1ed02a2df0ca (diff)
downloadbrdo-3974c6c4f05102e1b2a2f932763fccac1054c544.tar.gz
brdo-3974c6c4f05102e1b2a2f932763fccac1054c544.tar.bz2
#126070 by RobRoy, JohnAlbin, manarth, et al: Fixed module_invoke('block', 'view', ...) doesn't return subject
Diffstat (limited to 'modules/block')
-rw-r--r--modules/block/block.module25
-rw-r--r--modules/block/block.test8
2 files changed, 29 insertions, 4 deletions
diff --git a/modules/block/block.module b/modules/block/block.module
index 72c3c5c56..5cb0447d6 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -240,9 +240,28 @@ function block_block_save($delta = 0, $edit = array()) {
*
* Generates the administrator-defined blocks for display.
*/
-function block_block_view($delta = 0, $edit = array()) {
- $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject();
- $data['content'] = check_markup($block->body, $block->format, '', TRUE);
+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),
+ ),
+ );
return $data;
}
diff --git a/modules/block/block.test b/modules/block/block.test
index 1a52cb23b..7c92a357d 100644
--- a/modules/block/block.test
+++ b/modules/block/block.test
@@ -75,9 +75,15 @@ class BlockTestCase extends DrupalWebTestCase {
$this->assertText(t('The block has been created.'), t('Custom block successfully created.'));
$bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
- // Check to see if the custom block was created by checking that it's in the database..
+ // Check to see if the custom block was created by checking that it's in the database.
$this->assertNotNull($bid, t('Custom block found in database'));
+ // 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.'));
+
// Check if the block can be moved to all availble regions.
$custom_block['module'] = 'block';
$custom_block['delta'] = $bid;