function quotes_block_view in Quotes 6
Same name and namespace in other branches
- 7 quotes.module \quotes_block_view()
Build Quotes blocks.
1 call to quotes_block_view()
- quotes_block in ./
quotes.module - Implementation of hook_block().
File
- ./
quotes.module, line 661 - The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.
Code
function quotes_block_view($delta) {
$block = db_fetch_array(db_query('SELECT qb.* FROM {quotes_blocks} qb WHERE qb.bid=%d', $delta));
if (!$block) {
return NULL;
}
if ($block['cron_interval'] > 0) {
if (!$block['vid'] || $block['cron_last'] + $block['cron_interval'] * $block['cron_step'] < time()) {
$block['vid'] = quotes_get_quote($block, TRUE, 1);
db_query('UPDATE {quotes_blocks} SET vid=%d, cron_last=%d WHERE bid=%d', $block['vid'][0], time(), $delta);
cache_clear_all();
}
else {
$block['vid'] = array(
$block['vid'],
);
}
}
else {
$block['vid'] = quotes_get_quote($block, TRUE, $block['count']);
}
if (!$block['vid']) {
return NULL;
}
$view_text = $block['view_text'];
// $link_weight = $block['view_weight'];
$more_text = $block['more_text'];
$rand_freq = $block['rand_freq'];
$output = NULL;
unset($blk_title);
$quote = '';
foreach ($block['vid'] as $nid) {
$node = node_load($nid);
// Save first node title for possible block title below
if (!isset($blk_title)) {
$blk_title = filter_xss($node->title);
$blk_nid = $node->nid;
$blk_uid = $node->uid;
}
// See if we don't want the citation shown.
if (!$block['show_citation']) {
unset($node->quotes_citation);
}
// We don't want bios in a block.
unset($node->quotes_bio);
// Quotes_view builds $node->content['body'].
// Set $teaser to false so the length is properly processed.
$node->max_length = $block['max_length'];
$node->in_block = TRUE;
$node->show_titles = $block['show_titles'];
$node->more_text = $more_text;
$node->view_text = $view_text;
$quote .= node_view($node, TRUE, FALSE, TRUE);
}
$_quotes_subs = array(
'%' . t('interval') => format_interval($block['cron_interval'] * $block['cron_step'], 1),
'%' . t('bid') => $block['bid'],
'%' . t('title') => $blk_title,
'%' . t('nid') => $blk_nid,
'%' . t('user') => theme('username', user_load(array(
'uid' => $blk_uid,
))),
);
$subject = strtr($block['name'], $_quotes_subs);
return array(
'subject' => $subject,
'content' => $quote,
);
}