function acquia_lift_personalize_campaign_wizard_review_alter in Acquia Lift Connector 7.2
Alter hook for the review portion of the campaign wizard.
File
- ./
acquia_lift.admin.wizard.inc, line 1173 - acquia_lift.admin.wizard.inc Functions specific to the Acquia Lift alteration of the campaign creation wizard.
Code
function acquia_lift_personalize_campaign_wizard_review_alter(&$form, &$form_state, $agent_data, $editable) {
module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');
// Take over the form validation and submit handling.
$form['#validate'] = array(
'acquia_lift_personalize_campaign_wizard_validate',
);
$form['#submit'] = array(
'acquia_lift_personalize_campaign_wizard_submit',
);
// Make the overview a card.
$form['review']['summary_column']['summary']['#type'] = 'container';
$form['review']['summary_column']['summary']['#theme'] = 'acquia_lift_card';
// Add audiences to the summary section.
// Add MVT and audience counts to the overview.
$is_mvt = isset($agent_data->data['variation_set_handling']) && $agent_data->data['variation_set_handling'] == ACQUIA_LIFT_DECISION_MULTIVARIATE;
if ($is_mvt) {
// Show the summary data for the MVT tests.
$form['review']['summary_column']['summary']['option_sets'] = array(
'#markup' => theme('personalize_wizard_summary_count', array(
'count' => 1,
'details' => theme('html_tag', array(
'element' => array(
'#tag' => 'h3',
'#value' => t('Multivariate Test'),
),
)),
)),
);
}
else {
$option_set = acquia_lift_get_option_set_for_targeting($agent_data->machine_name);
if (!empty($agent_data->data['lift_targeting'])) {
// Read audience information from the agent if changes have been made.
$targeting = $agent_data->data['lift_targeting'];
}
else {
// Otherwise read audience information from the option set targeting.
$targeting = acquia_lift_get_structure_from_targeting($option_set);
}
// Loop through the audiences and determine the label and variation count
// to display as summary data.
$items = array();
if (!empty($option_set->targeting)) {
foreach ($option_set->targeting as $audience_id => $audience) {
$num_variations = isset($targeting[$audience_id]) ? count($targeting[$audience_id]) : 0;
$items[] = $audience['label'] . ' (' . $num_variations . ' ' . format_plural($num_variations, 'variation', 'variations') . ')';
}
}
$count_audiences = count($items);
$form['review']['summary_column']['summary']['audiences'] = array(
'#markup' => theme('personalize_wizard_summary_count', array(
'count' => $count_audiences,
'details' => theme('item_list', array(
'title' => format_plural($count_audiences, 'Audience', 'Audiences'),
'items' => $items,
)),
)),
);
}
// Move the scheduling summary element to the bottom.
$form['review']['summary_column']['summary']['scheduling']['#weight'] = 10;
// Move the warnings into a card.
if (!empty($form['review']['messages']['warnings'])) {
$form['review']['messages']['warnings']['#type'] = 'container';
$form['review']['messages']['warnings']['#theme'] = 'acquia_lift_card';
}
// Provide summary data only available after a personalization has been
// started.
if (empty($agent_data->started)) {
return;
}
// Generate next steps.
$option_sets = personalize_option_set_load_by_agent($agent_data->machine_name);
$next_links = array(
'blocks' => array(),
'elements' => array(),
'fields' => array(),
);
$destination = 'admin/structure/personalize/manage/' . $agent_data->machine_name . '/review';
$total_next_steps = 0;
foreach ($option_sets as $option_set) {
switch ($option_set->plugin) {
case 'block':
$next_links['blocks'][] = l(check_plain($option_set->label), 'admin/structure/block', array(
'query' => array(
'destination' => $destination,
),
));
break;
case 'elements':
$pages = $option_set->data['pages'];
if (!empty($pages)) {
$pages = preg_split('~[\\r\\n]+~', $pages);
$url = reset($pages);
$next_links['elements'][] = l(check_plain($option_set->label), $url);
}
break;
case 'fields':
$url = _personalize_fields_get_entity_link_from_option_set($option_set);
$next_links['fields'][] = l(check_plain($option_set->label), $url, array(
'query' => array(
'destination' => $destination,
),
));
break;
}
}
$total_next_steps = array_reduce($next_links, function ($total, $type) {
$total += count($type);
return $total;
}, 0);
if ($total_next_steps > 0) {
$form['review']['messages']['next'] = array(
'#type' => 'container',
'#title' => format_plural($total_next_steps, 'Next step', 'Next steps'),
'#theme' => 'acquia_lift_card',
'#collapsible' => FALSE,
'#attributes' => array(
'class' => array(
'acquia-lift-review-next-steps',
),
),
);
}
if (!empty($next_links['blocks'])) {
$form['review']['messages']['next']['blocks'] = array(
'#markup' => theme('item_list', array(
'items' => $next_links['blocks'],
'title' => format_plural(count($next_links['blocks']), 'Place your personalized block on your website', 'Place your personalized blocks on your website'),
)),
);
}
if (!empty($next_links['elements'])) {
$form['review']['messages']['next']['elements'] = array(
'#markup' => theme('item_list', array(
'items' => $next_links['elements'],
'title' => format_plural(count($next_links['elements']), 'View your element variation set page', 'View your element variation set pages'),
)),
);
}
if (!empty($next_links['fields'])) {
$form['review']['messages']['next']['fields'] = array(
'#markup' => theme('item_list', array(
'items' => $next_links['fields'],
'title' => format_plural(count($next_links['fields']), 'View your field variation set page', 'View your field variation set pages'),
)),
);
}
// Show resources for further troubleshooting.
$form['review']['messages']['resources'] = array(
'#type' => 'container',
'#title' => t('Need help?'),
'#theme' => 'acquia_lift_card',
'#collapsible' => FALSE,
'#attributes' => array(
'class' => array(
'acquia-lift-review-next-steps',
),
),
);
$url_options = array(
'external' => TRUE,
'attributes' => array(
'target' => 'acquia_lift_resources',
),
);
$form['review']['messages']['resources']['links'] = array(
'#markup' => theme('item_list', array(
'items' => array(
l(t('Learn how to utilize your personalization\'s reports'), ACQUIA_LIFT_DOCUMENTATION . '/campaign/report', $url_options),
l(t('Read more Acquia Lift documentation'), ACQUIA_LIFT_DOCUMENTATION, $url_options),
l(t('Find answers to common questions'), ACQUIA_LIFT_DOCUMENTATION . '/troubleshooting', $url_options),
),
'title' => t('Still having trouble with your personalization?'),
)),
);
}