function copyright_block_block_view in Copyright Block module 7
Same name and namespace in other branches
- 7.2 copyright_block.module \copyright_block_block_view()
Implements hook_block_view().
Renders a HTML-span containing the copyright information.
File
- ./
copyright_block.module, line 26 - Module file for "Copyright block".
Code
function copyright_block_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'copyright':
// Check if an inception year is given.
$year = variable_get('copyright_block_inceptionyear');
$currentYear = date('Y', REQUEST_TIME);
if ($year) {
// Show something like 2003 - 2011, if not current year.
if ($year != $currentYear) {
// Load the template for displaying spacer between the copyright year.
$spacer = variable_get('copyright_block_spacertemplate');
if (!$spacer) {
// No template set, set default fallback.
$spacer = ' - ';
}
else {
// Assure that we don't put out unescaped HTML.
$spacer = check_plain($spacer);
}
$year .= $spacer . $currentYear;
}
}
else {
// Show only the current year.
$year = $currentYear;
}
// Check if there is a name for the copyright holder.
$holder = variable_get('copyright_block_copyrightholder');
if (!$holder) {
// No holder given, default to site name.
$holder = variable_get('site_name', '');
}
// Load the template for displaying the copyright.
$template = variable_get('copyright_block_template');
if (!$template) {
// No template set, set default fallback.
$template = '[holder] [year]';
}
else {
// Assure that we don't put out unescaped HTML.
$template = check_plain($template);
}
// Replace the placeholders in the template to calculate the output text.
$copyright_text = str_replace('[holder]', check_plain($holder), str_replace('[year]', $year, $template));
// Create the block.
$block['subject'] = t('Copyright');
$block['content'] = '<span class="copyright">© ' . $copyright_text . '</span>';
break;
}
return $block;
}