You are here

function clock_block_configure in Clock 7.2

Same name and namespace in other branches
  1. 7 clock.module \clock_block_configure()

Implements hook_block_configure().

File

./clock.module, line 35
Display clocks on your site.

Code

function clock_block_configure($delta = '') {
  if ($delta == 'clock') {
    $form['add_clock'] = array(
      '#type' => 'links',
      '#attributes' => array(
        'class' => array(
          'action-links',
        ),
      ),
      'add-clock' => array(
        '#type' => 'link',
        '#title' => t('Add clock'),
        '#href' => 'admin/structure/block/manage/clock/clock/configure/add',
      ),
    );
    $form['clocks'] = array(
      '#type' => 'table',
      '#header' => array(
        t('Display'),
        t('Time zone'),
        t('Date type'),
        t('Operations'),
        t('Weight'),
      ),
      '#tree' => TRUE,
      '#attributes' => array(
        'id' => 'clock-settings-table',
      ),
      '#tabledrag' => array(
        array(
          'order',
          'sibling',
          'clock-settings-weight',
        ),
      ),
    );
    $table =& $form['clocks'];

    // To save space, the time zone types are displayed in the time zone cell,
    // but in italics to differentiate them from the actual time zones that are
    // displayed in case a custom time zone is being used.
    $time_zone_types = array(
      'user' => t('User time zone'),
      'site' => t('Site time zone'),
      'local' => t('Local time zone'),
    );
    $date_types = system_get_date_types();
    foreach (clock_info() as $cid => $clock) {
      $row = array();
      $row['#weight'] = $clock->weight;
      $row['#attributes']['class'][] = 'draggable';
      $row['display'] = array(
        '#theme' => 'clock',
        '#clock' => $clock,
      );
      if ($clock->time_zone_type == 'custom') {
        $row['time_zone']['#markup'] = '<em>' . $clock->custom_time_zone . '</em>';
      }
      else {
        $row['time_zone']['#markup'] = $time_zone_types[$clock->time_zone_type];
      }
      $row['date_type'] = array(
        '#markup' => $date_types[$clock->date_type]['title'],
      );
      $row['operations'] = array(
        '#type' => 'links',
        '#attributes' => array(
          'class' => array(
            'inline',
          ),
        ),
        'edit' => array(
          '#type' => 'link',
          '#title' => t('Edit'),
          '#href' => "admin/structure/block/manage/clock/clock/configure/{$cid}/edit",
        ),
        'delete' => array(
          '#type' => 'link',
          '#title' => t('Delete'),
          '#href' => "admin/structure/block/manage/clock/clock/configure/{$cid}/delete",
        ),
      );
      $row['weight'] = array(
        '#type' => 'weight',
        '#title' => t('Weight'),
        '#title_display' => 'invisible',
        '#default_value' => $clock->weight,
        '#attributes' => array(
          'class' => array(
            'clock-settings-weight',
          ),
        ),
      );
      $table[$cid] = $row;
    }
    return $form;
  }
}