~ubuntu-drupal-devs/ubuntu-drupal-countdown/6.x

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// $Id$

/**
 * @file
 * Module Settings
 */

/**
 * Core settings function.
 */
function udcountdown_admin_settings() {

  // Standard Settings
  $form['standard'] = array(
    '#type' => 'fieldset',
    '#title' => t('Standard Settings'),
    '#tree' => FALSE,
  );
  $form['standard']['udcountdown_option'] = array(
    '#type' => 'radios',
    '#title' => t('Display Option'),
    '#default_value' =>  t(variable_get('udcountdown_option', 1)),
    '#options' => udcountdown_list_options(),
    '#description' => t('Which options from the !link to use.', array( '!link' => l(t('coundown collection'), 'http://www.ubuntu.com/getubuntu/countdown'))),
    '#required' => TRUE,
  );
  $form['standard']['udcountdown_custom'] = array(
    '#type' => 'textarea',
    '#title' => t('Custom Code'),
    '#default_value' => t(variable_get('udcountdown_custom', '')),
    '#description' => t("Use this area to create your custom block of code."),
    '#required' => FALSE,
  );

  return system_settings_form($form);
}

/**
 * Build list of available options
 */
function udcountdown_list_options() {
  $opts = array();

  $opt = t('Custom Code');
  $opts[] = $opt;

  $handle = fopen(file_directory_path() . '/countdown/data/desc.csv', 'r');
  if ($handle !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
      $opt = t('Option ' . $data[0] . ' - ' . $data[1]);
      $opts[] = $opt;
    }
  }

  return $opts;
}