You are here

function system_block in Drupal 6

Implementation of hook_block().

Generate a block with a promotional link to Drupal.org.

File

modules/system/system.module, line 580
Configuration system that lets administrators modify the workings of the site.

Code

function system_block($op = 'list', $delta = 0, $edit = NULL) {
  switch ($op) {
    case 'list':
      $blocks[0] = array(
        'info' => t('Powered by Drupal'),
        'weight' => '10',
        // Not worth caching.
        'cache' => BLOCK_NO_CACHE,
      );
      return $blocks;
    case 'configure':

      // Compile a list of fields to show
      $form['wrapper']['color'] = array(
        '#type' => 'select',
        '#title' => t('Badge color'),
        '#default_value' => variable_get('drupal_badge_color', 'powered-blue'),
        '#options' => array(
          'powered-black' => t('Black'),
          'powered-blue' => t('Blue'),
          'powered-gray' => t('Gray'),
        ),
      );
      $form['wrapper']['size'] = array(
        '#type' => 'select',
        '#title' => t('Badge size'),
        '#default_value' => variable_get('drupal_badge_size', '80x15'),
        '#options' => array(
          '80x15' => t('Small'),
          '88x31' => t('Medium'),
          '135x42' => t('Large'),
        ),
      );
      return $form;
    case 'save':
      variable_set('drupal_badge_color', $edit['color']);
      variable_set('drupal_badge_size', $edit['size']);
      break;
    case 'view':
      $image_path = 'misc/' . variable_get('drupal_badge_color', 'powered-blue') . '-' . variable_get('drupal_badge_size', '80x15') . '.png';
      $block['subject'] = NULL;

      // Don't display a title
      $block['content'] = theme('system_powered_by', $image_path);
      return $block;
  }
}