'select', '#title' => t('Calculate statistics for'), '#options' => array( t('Today'), t('Current week'), t('Current month'), t('Current year'), t('All time'), ), '#default_value' => 2, '#description' => t('The length of time that should be taken into consideration for download statistics'), ); $form['download_statistics'] = array( '#type' => 'fieldset', '#title' => t('Download statistics'), ); $messages = array( 10 => t('one of our most popular'), 8 => t('frequently downloaded'), 6 => t('fairly popular'), 4 => t('not very popular'), 2 => t('rarely downloaded'), ); $form['download_statistics']['tiers'] = array( '#type' => 'item', '#title' => t('Download tiers'), '#value' => t('Any projects with the number of downloads greater than or equal to the value under "number of downloads" will get the message specified in the "message to display" column.'), '#theme' => 'download_statistics_tiers', ); for ($i = 10; $i > 0; $i = $i - 2) { $form['download_statistics']['tiers'][$i]['downloads'] = array( '#type' => 'textfield', '#default_value' => $i * 1000, '#size' => 10, ); $form['download_statistics']['tiers'][$i]['description'] = array( '#type' => 'textfield', '#default_value' => $messages[$i], '#size' => 40, ); } $form['maintainer_statistics'] = array( '#type' => 'fieldset', '#title' => t('Maintainer statistics'), ); $messages = array( 10 => t('extremely active'), 8 => t('very active'), 6 => t('fairly active'), 4 => t('somewhat active'), 2 => t('not very active'), 0 => t('inactive'), ); $form['maintainer_statistics']['tiers'] = array( '#type' => 'item', '#title' => t('Maintainer tiers'), '#value' => t('Any projects with the number of commits greater than or equal to the value under "number of commits" will get the message specified in the "message to display" column.'), '#theme' => 'maintainer_statistics_tiers', ); for ($i = 10; $i >= 0; $i = $i - 2) { $form['maintainer_statistics']['tiers'][$i]['commits'] = array( '#type' => 'textfield', '#default_value' => $i * 10, '#size' => 10, ); $form['maintainer_statistics']['tiers'][$i]['description'] = array( '#type' => 'textfield', '#default_value' => $messages[$i], '#size' => 40, ); } return $form; } function theme_download_statistics_tiers($form) { $header = array( array('data' => t('Number of downloads')), array('data' => t('Message to display')), ); foreach (element_children($form) as $key) { $row = array(); $row[] = form_render($form[$key]['downloads']); $row[] = form_render($form[$key]['description']); $rows[] = $row; } return theme('table', $header, $rows); } function theme_maintainer_statistics_tiers($form) { $header = array( array('data' => t('Number of commits')), array('data' => t('Message to display')), ); foreach (element_children($form) as $key) { $row = array(); $row[] = form_render($form[$key]['commits']); $row[] = form_render($form[$key]['description']); $rows[] = $row; } return theme('table', $header, $rows); }