You are here

function copyright_block_block in Copyright Block module 6

Implementation of hook_block().

File

./copyright_block.module, line 11
Creates a dynamic customisable copyright message block.

Code

function copyright_block_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks[0] = array(
      'info' => t('Copyright statement'),
      'cache' => DRUPAL_CACHE_GLOBAL,
    );
    return $blocks;
  }
  elseif ($op == 'configure' && $delta == 0) {
    $form['start_year'] = array(
      '#title' => t('Start year'),
      '#type' => 'textfield',
      '#required' => TRUE,
      '#default_value' => variable_get('copyright_block_start_year', date('Y')),
      '#element_validate' => array(
        'copyright_block_validate_start_year',
      ),
    );
    $form['text'] = array(
      '#title' => t('Copyright message'),
      '#type' => 'textarea',
      '#required' => TRUE,
      '#default_value' => variable_get('copyright_block_message', t('Copyright © [site-name], [copyright-block-dates].')),
    );
    $form['view']['token_help'] = array(
      '#title' => t('Replacement patterns'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['view']['token_help']['help'] = array(
      '#value' => theme('token_help', 'global'),
    );
    return $form;
  }
  elseif ($op == 'save' && $delta == 0) {
    variable_set('copyright_block_start_year', filter_xss($edit['start_year']));
    variable_set('copyright_block_message', filter_xss($edit['text']));
  }
  elseif ($op == 'view') {
    $block = array();
    switch ($delta) {
      case 0:
        $block['subject'] = t('Copyright statement');
        $block['content'] = copyright_block_block_1_content();
        break;
    }
    return $block;
  }
}