function theme_acquia_lift_card in Acquia Lift Connector 7.2
Theme function to show a card element.
Parameters
$variables: An associate array of variables including the "element" to be themed.
4 theme calls to theme_acquia_lift_card()
- acquia_lift_personalize_campaign_wizard_goals_alter in ./
acquia_lift.admin.wizard.inc - Alter the goals form.
- acquia_lift_personalize_campaign_wizard_review_alter in ./
acquia_lift.admin.wizard.inc - Alter hook for the review portion of the campaign wizard.
- acquia_lift_personalize_campaign_wizard_targeting_alter in ./
acquia_lift.admin.wizard.inc - Alter hook for the targeting portion of the campaign wizard.
- acquia_lift_personalize_campaign_wizard_variations_alter in ./
acquia_lift.admin.wizard.inc - Alter hook for the variations portions of the campaign wizard.
File
- theme/
acquia_lift.wizard.theme.inc, line 14 - acquia_lift.wizard.theme.inc Provides theme functions for Acquia Lift's version of the campaign creation wizard workflow.
Code
function theme_acquia_lift_card($variables) {
$element = $variables['element'];
$footer_children = empty($element['footer']) ? array() : element_children($element['footer']);
foreach ($footer_children as $key) {
$footer_elements[] = $element['footer'][$key];
}
$card_label = isset($element['#title']) ? $element['#title'] : '';
$header_children = isset($element['header']) ? element_children($element['header']) : array();
$title_attributes = isset($element['#title_attributes']) ? $element['#title_attributes'] : array();
$card_flag = isset($element['#flag']) ? $element['#flag'] : '';
$card_flag_attributes = array(
'class' => array(
'el-card__flag',
),
);
if (isset($element['#flag_visible']) && $element['#flag_visible'] === FALSE) {
$card_flag_attributes['class'][] = 'is-hidden';
}
if (isset($element['card_flag_attributes'])) {
$card_flag_attributes = array_merge_recursive($card_flag_attributes, $element['card_flag_attributes']);
}
unset($element['footer']);
// Set default values
$element['#collapsible'] = isset($element['#collapsible']) ? $element['#collapsible'] : TRUE;
$element['#collapsed'] = isset($element['#collapsed']) ? $element['#collapsed'] : TRUE;
$element['#sortable'] = isset($element['#sortable']) ? $element['#sortable'] : FALSE;
$element['#disabled'] = isset($element['#disabled']) ? $element['#disabled'] : FALSE;
$element['#attributes']['data-card-collapsible'] = $element['#collapsible'] ? 'true' : 'false';
$element['#attributes']['data-card-collapsed'] = $element['#collapsed'] ? 'true' : 'false';
$element['#attributes']['data-card-footer-visible'] = empty($footer_children) ? 'false' : 'true';
$element['#attributes']['data-card-sortable'] = $element['#sortable'] ? 'true' : 'false';
$element['#attributes']['data-card-enabled'] = $element['#disabled'] ? 'false' : 'true';
$element['#attributes']['class'][] = 'el-card';
// The ID will also be on the form wrapper for the card so we need to update
// it to make it unique.
if (!empty($element['#attributes']['id'])) {
$element['#attributes']['id'] .= '-card';
}
drupal_add_library('acquia_lift', 'acquia_lift.card');
$html = '';
$html .= '<div ' . drupal_attributes($element['#attributes']) . '>';
$html .= '<div class="el-card__header">';
$html .= '<div class="el-card__dragger"></div>';
$title_attributes['class'][] = 'el-card__title';
$html .= '<h2 ' . drupal_attributes($title_attributes) . '>' . $card_label . '</h2>';
if (!empty($header_children)) {
$html .= '<ul class="el-card__actions">';
foreach ($header_children as $action) {
$element['header'][$action]['#attributes']['class'][] = 'el-card__action__link';
$html .= '<li class="el-card__action">' . drupal_render($element['header'][$action]) . '</li>';
}
$html .= '</ul>';
}
$html .= '</div>';
$html .= '<div class="el-card__content">';
if (!empty($card_flag)) {
$html .= '<div ' . drupal_attributes($card_flag_attributes) . '><span class="el-card__flag__label">' . t('Status') . ':</span> <span class="el-card__flag__content">' . $card_flag . '</span></div>';
}
$html .= drupal_render_children($element);
$html .= '</div>';
// Close content.
if (!empty($footer_elements)) {
$html .= '<div class="el-card__footer">' . drupal_render($footer_elements) . '</div>';
}
$html .= '</div>';
// Close card.
return $html;
}