Index: teaser_block.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/teaser_block/teaser_block.module,v
retrieving revision 1.1
diff -u -p -r1.1 teaser_block.module
--- teaser_block.module 9 Apr 2008 19:34:18 -0000 1.1
+++ teaser_block.module 9 Apr 2008 23:28:15 -0000
@@ -67,7 +67,7 @@ function teaser_block_list() {
* Return the block requested by $bid.
*/
function teaser_block_view($bid) {
- $sql = 'SELECT t.nid, t.title, t.body AS teaser_block_body, t.format AS teaser_block_format FROM {teaser_block} t INNER JOIN {node} n ON n.nid = t.nid WHERE t.bid = %d AND n.status = 1';
+ $sql = 'SELECT t.nid, t.title, t.body, t.format FROM {teaser_block} t INNER JOIN {node} n ON n.nid = t.nid WHERE t.bid = %d AND n.status = 1';
if ($data = db_fetch_object(db_query($sql, $bid))) {
// Translatable support.
if (function_exists('tobject')) {
@@ -85,14 +85,14 @@ function teaser_block_view($bid) {
* @ingroup themeable
*/
function theme_teaser_block_read_more_link($data) {
- $content = trim(check_markup($data->teaser_block_body, $data->teaser_block_format, FALSE));
+ $content = trim(check_markup($data->body, $data->format, FALSE));
$link = '';
$link .= l(t('Read more'), 'node/'. $data->nid, array('title' => t('Read the rest of this posting.')), NULL, NULL, FALSE, TRUE);
$link .= '';
// Insert read more link before an image at the end of block content.
$stripped = trim(strip_tags($content));
- $last_chars = substr($stripped, -30);
+ $last_chars = substr($stripped, -60);
if (strpos($content, $last_chars) !== FALSE) {
$content = preg_replace('/('. $last_chars .')/', '$1'. $link, $content);
}
@@ -109,7 +109,7 @@ function theme_teaser_block_read_more_li
}
function teaser_block_form($delta = 0) {
- $teaser_block = db_fetch_array(db_query('SELECT tb.bid, tb.nid, tb.title, tb.body, tb.format FROM {teaser_block} tb WHERE tb.bid = %d', $delta));
+ $teaser_block = db_fetch_array(db_query('SELECT bid, nid, title, body, format FROM {teaser_block} WHERE bid = %d', $delta));
$form['delta'] = array(
'#type' => 'value',
@@ -128,7 +128,7 @@ function teaser_block_form($delta = 0) {
while ($node = db_fetch_object($result)) {
$options[$node->nid] = $node->title;
}
- $form['teaser_block_node'] = array(
+ $form['nid'] = array(
'#type' => 'select',
'#title' => t('Link read more to'),
'#default_value' => $teaser_block['nid'],
@@ -136,7 +136,7 @@ function teaser_block_form($delta = 0) {
'#options' => $options,
);
- $form['teaser_block_body'] = array(
+ $form['body'] = array(
'#type' => 'textarea',
'#title' => t('Teaser text'),
'#default_value' => $teaser_block['body'],
@@ -144,7 +144,7 @@ function teaser_block_form($delta = 0) {
'#rows' => 10,
'#description' => t('Enter a teaser text to display within the block. It will be displayed along with a read more link which links to this content. Leave empty to automatically extract the teaser from this content.')
);
- $form['teaser_block_format'] = filter_form(!empty($teaser_block['format']) ? $teaser_block['format'] : FILTER_FORMAT_DEFAULT, NULL, array('teaser_block_format'));
+ $form['format'] = filter_form(!empty($teaser_block['format']) ? $teaser_block['format'] : FILTER_FORMAT_DEFAULT, NULL, array('format'));
$form['submit'] = array(
'#type' => 'submit',
@@ -164,13 +164,13 @@ function teaser_block_form_submit($form_
if ($form_values['op'] == t('Save')) {
// Insert node title if teaser block title was left empty.
if (trim($form_values['title']) == '') {
- $node = node_load($form_values['teaser_block_node']);
+ $node = node_load($form_values['nid']);
$form_values['title'] = $node->title;
}
// Insert node teaser if teaser block body was left empty.
- if (trim($form_values['teaser_block_body']) == '') {
- $node = node_load($form_values['teaser_block_node']);
- $form_values['teaser_block_body'] = node_teaser($node->body);
+ if (trim($form_values['body']) == '') {
+ $node = node_load($form_values['nid']);
+ $form_values['body'] = node_teaser($node->body);
}
}
@@ -178,9 +178,9 @@ function teaser_block_form_submit($form_
$block = new stdClass;
$block->delta = $form_values['delta'];
$block->title = $form_values['title'];
- $block->nid = $form_values['teaser_block_node'];
- $block->body = $form_values['teaser_block_body'];
- $block->format = $form_values['teaser_block_format'];
+ $block->nid = $form_values['nid'];
+ $block->body = $form_values['body'];
+ $block->format = $form_values['format'];
if ($form_values['op'] == t('Save')) {
teaser_block_update($block->delta ? 'update' : 'insert', $block);
}