function recommender_command_form in Recommender API 7.6
1 string reference to 'recommender_command_form'
- recommender_computing_data in ./
recommender.module - Implements hook_computing_data(). Expose recommender commands to computing.module.
File
- ./
recommender.module, line 127
Code
function recommender_command_form($form, &$form_state, $data) {
// checking data should be deferred to sub modules to provide detailed info.
// if (@$data['data structure']['preference']['type'] == 'table') {
// $preference_table = @$data['data structure']['preference']['name'];
// $count = @db_query("SELECT COUNT(*) FROM $preference_table")->fetchField();
// if ($count < 10000) {
// drupal_set_message(t('Not enough preference data to compute recommendations. Refer to the module\'s documentation for more details.'), 'warning');
// }
// }
// 1. process $form data. make them into $form['input']
$form['options'] = array(
'#type' => 'fieldset',
'#title' => t('Configure additional parameters for %command', array(
'%command' => $data['title'],
)),
//'#weight' => 5,
'#collapsible' => FALSE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
if (isset($data['form elements callback']) && function_exists($data['form elements callback'])) {
$form['options'] = $form['options'] + call_user_func($data['form elements callback']);
}
else {
$form['options']['no_options_message'] = array(
'#markup' => t('No extra parameters defined.'),
);
}
// 2. add other command data.
$form['common'] = array(
'#type' => 'fieldset',
'#title' => t('Configure generic parameters'),
//'#weight' => 5,
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
$form['common']['data'] = array(
'#type' => 'value',
'#value' => $data,
);
$form['common']['label'] = array(
'#type' => 'textfield',
'#title' => 'Label',
'#description' => 'The human-readable name of this command.',
'#default_value' => $data['title'],
'#required' => TRUE,
);
if (variable_get('recommender_show_database_option', FALSE)) {
$form['common']['database'] = array(
'#type' => 'select',
'#title' => t('Include database access info?'),
'#description' => t('Specifies whether to add database access info defined in settings.php into the computing record. Use this option only for development purpose when you use a remote agent to compute recommendations. Remove this option from admin interface by setting "recommender_show_database_option" to FALSE. See more in documentations.'),
'#options' => _recommender_database_options(),
'#empty_value' => '',
'#required' => FALSE,
);
}
// $form['common']['weight'] = array(
// '#type' => 'textfield',
// '#title' => 'Weight',
// '#description' => 'Command execution weight. Low number has higher priority.',
// '#default_value' => 0,
// '#element_validation' => 'element_validate_integer',
// '#required' => TRUE,
// );
// 3. add code from system_settings_form().
$form['actions'] = array(
'#type' => 'actions',
'submit' => array(
'#type' => 'submit',
'#value' => t('Add Command'),
),
);
return $form;
}