function mostpopular_intervals_form in Drupal Most Popular 6
1 string reference to 'mostpopular_intervals_form'
- mostpopular_menu in ./
mostpopular.module - Implements hook_menu().
File
- ./
mostpopular.admin.inc, line 151 - Defines all the administration forms for the Most Popular module.
Code
function mostpopular_intervals_form() {
$form = array();
// Get all of the intervals, and add an empty interval to the end
$intervals = MostPopularInterval::fetchAll();
$intervals[] = MostPopularInterval::create(count($intervals));
$form['description'] = array(
'#type' => 'markup',
'#value' => '<p>' . t("\nThe interval field for each row must contain a string that can be understood by\n<a href='@strtotime' target='php'>strtotime()</a>. You must specify each as a\nnegative interval relative to today.", array(
'@strtotime' => 'http://php.net/manual/en/function.strtotime.php',
)) . '</p>' . '<p>' . t('To remove an interval, clear both the title and interval values.') . '</p>' . '<p>' . t("If you make changes to the intervals, any custom service throttles you may\nhave set up will be reset to their default values.") . '</p>',
);
$form['intervals'] = array(
'#tree' => TRUE,
'#theme' => 'mostpopular_config_intervals_form',
);
foreach ($intervals as $key => $interval) {
$form['intervals'][$key] = array(
'title' => array(
'#type' => 'textfield',
'#size' => 32,
'#default_value' => $interval->title,
),
'string' => array(
'#type' => 'textfield',
'#size' => 10,
'#default_value' => $interval->string,
),
'weight' => array(
'#type' => 'weight',
'#delta' => count($intervals),
'#default_value' => $interval->weight,
),
'object' => array(
'#type' => 'value',
'#value' => $interval,
),
);
}
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save Configuration'),
);
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to Default Configuration'),
'#attributes' => array(
'onclick' => 'javascript:return confirm("' . t("This will reset all the intervals and all the cached most popular data as\nwell as any custom service throttles. Are you sure you want to do this?") . '");',
),
);
return $form;
}