protected static function AcquiaLiftAgent::buildOptionsForm in Acquia Lift Connector 7
Builds the options to display for a campaign form.
Parameters
$agent_data: The existing campaign data.
bool $simplified: Indicates if the form should be shown in simplified format or with all advanced options.
Return value
array The form render array.
2 calls to AcquiaLiftAgent::buildOptionsForm()
- AcquiaLiftAgent::optionsForm in plugins/
agent_types/ AcquiaLiftAgent.inc - Implements PersonalizeAgentInterface::optionsForm().
- AcquiaLiftSimpleAB::simplifiedForm in plugins/
agent_types/ AcquiaLiftAgent.inc - Implements PersonalizeAgentInterface::optionsForm().
File
- plugins/
agent_types/ AcquiaLiftAgent.inc, line 298 - Provides an agent type for Acquia Lift
Class
Code
protected static function buildOptionsForm($agent_data, $simplified = FALSE, $option_parents = array()) {
$account_info = variable_get('acquia_lift_account_info', array());
if (empty($account_info)) {
drupal_set_message(t('Your Acquia Lift account info has not been configured. Any Acquia Lift campaigns you create here will not work until you configure your account info !here', array(
'!here' => l('here', 'admin/config/content/personalize/acquia_lift'),
)), 'error');
}
$form = array();
$form['#attached'] = array(
'css' => array(
drupal_get_path('module', 'acquia_lift') . '/css/personalize_acquia_lift_admin.css',
drupal_get_path('module', 'acquia_lift') . '/css/acquia_lift.admin.css',
),
'js' => array(
drupal_get_path('module', 'acquia_lift') . '/js/acquia_lift.agent.admin.js',
),
);
if (empty($option_parents)) {
$option_parents = array(
'agent_basic_info',
'options',
'acquia_lift',
);
}
$control_rate = isset($agent_data->data['control_rate']) ? $agent_data->data['control_rate'] : 10;
if ($simplified) {
$form['control_rate'] = array(
'#type' => 'value',
'#value' => $control_rate,
);
}
else {
$form['control'] = array(
'#type' => 'fieldset',
'#tree' => FALSE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Control (@control_rate%)', array(
'@control_rate' => $control_rate,
)),
);
$control_rate_parents = $option_parents;
$control_rate_parents[] = 'control_rate';
$form['control']['control_rate'] = array(
'#type' => 'acquia_lift_percentage',
'#parents' => $control_rate_parents,
'#title' => t('Control Group'),
'#field_suffix' => '%',
'#size' => 3,
'#description' => t('A fixed baseline variation will be shown, by default the first variation in the set.'),
'#default_value' => $control_rate,
'#rest_title' => t('Test Group'),
'#rest_description' => t('Personalized variations will be shown.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
}
$decision_style = isset($agent_data->data['decision_style']) ? $agent_data->data['decision_style'] : 'adaptive';
if ($simplified) {
$form['decision_style'] = array(
'#type' => 'value',
'#value' => $decision_style,
);
}
else {
$form['decision_style'] = array(
'#type' => 'radios',
'#title' => t('Decision Style'),
'#options' => array(
'adaptive' => t('Auto-personalize'),
'random' => t('Test only'),
),
'#default_value' => $decision_style,
'#title_display' => 'invisible',
);
$form['decision_style']['adaptive'] = array(
'#description' => t('Adapts to users and chooses the best option over time.'),
);
$form['decision_style']['random'] = array(
'#description' => t('Tests variations and reports results.'),
);
}
$explore_rate = isset($agent_data->data['explore_rate']) ? $agent_data->data['explore_rate'] : 20;
if ($simplified) {
$form['distribution'] = array(
'#type' => 'value',
'#value' => $explore_rate,
);
}
else {
$decision_style_parents = $option_parents;
$decision_style_parents[] = 'decision_style';
$decision_style_form_element = '';
foreach ($decision_style_parents as $i => $parent_name) {
$decision_style_form_element .= $i ? '[' . $parent_name . ']' : $parent_name;
}
$form['distribution'] = array(
'#type' => 'fieldset',
'#tree' => FALSE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Distribution (@explore_rate/@rest)', array(
'@explore_rate' => $explore_rate,
'@rest' => 100 - $explore_rate,
)),
'#states' => array(
'visible' => array(
':input[name="' . $decision_style_form_element . '"]' => array(
'value' => 'adaptive',
),
),
),
);
$explore_rate_parents = $option_parents;
$explore_rate_parents[] = 'explore_rate';
$form['distribution']['explore_rate'] = array(
'#type' => 'acquia_lift_percentage',
'#parents' => $explore_rate_parents,
'#title' => t('Random Group'),
'#field_suffix' => '%',
'#description' => t('Variations will be shown randomly and tracked to adjust for false positives.'),
'#size' => 3,
'#default_value' => isset($agent_data->data['explore_rate']) ? $agent_data->data['explore_rate'] : 20,
'#rest_title' => t('Personalized Group'),
'#rest_description' => t('The "best" variation will be shown for each visitor based on our algorithm.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
}
// This will get overridden by the 'campaign_end' dropdown.
$form['auto_stop'] = array(
'#type' => 'value',
'#value' => 0,
);
return $form;
}