function fc_progress_preprocess_fc_progress_next in Field Complete 7
File
- fc_progress/
fc_progress.blocks.inc, line 66 - Field Complete Progress - Provides blocks to display a progress bar of Field completion - blocks.
Code
function fc_progress_preprocess_fc_progress_next(&$variables) {
$entity_type = $variables['entity_type'];
$entity_info = entity_get_info($entity_type);
$entity = $variables['entity'];
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
if (empty($entity->fc)) {
$entity->fc = fcComplete::load($entity_type, $entity);
}
if ($field_name = array_search(FALSE, $entity->fc->completeness)) {
$instance = field_info_instance($entity_type, $field_name, $bundle);
$variables['field_label'] = $instance['label'];
$variables['entity_title'] = entity_label($entity_type, $entity);
$interval = 100 / count($entity->fc->completeness);
$numfields = count(array_filter($entity->fc->completeness)) + 1;
$variables['new_percentage'] = (int) ($interval * $numfields);
$args = array(
'%field_label' => $variables['field_label'],
'!entity_title' => $variables['entity_title'],
'!new_percentage' => $variables['new_percentage'],
);
$variables['next_message'] = t('Completing %field_label will bring !entity_title to !new_percentage%.', $args);
if ($variables['new_percentage'] >= 100) {
$variables['classes_array'][] = "fc-progress-next-100";
}
}
else {
$variables['field_label'] = '';
$variables['new_precentage'] = '';
$variables['next_message'] = '';
$variables['classes_array'][] = "fc-progress-next-none";
}
$variables['classes_array'][] = "fc-progress-next-{$entity_type}";
$variables['classes_array'][] = "fc-progress-next-{$entity_type}-{$bundle}";
$variables['theme_hook_suggestions'][] = "fc-progress-next";
$variables['theme_hook_suggestions'][] = "fc-progress-next--{$entity_type}";
$variables['theme_hook_suggestions'][] = "fc-progress-next--{$entity_type}--{$bundle}";
$variables['theme_hook_suggestions'][] = "fc-progress-next--{$entity_type}--{$id}";
}