You are here

function theme_pcp_profile_percent_complete in Profile Complete Percent 6.2

Same name and namespace in other branches
  1. 5 pcp.module \theme_pcp_profile_percent_complete()
  2. 6 pcp.module \theme_pcp_profile_percent_complete()

Block Theme function that displays the default output of a users profile complete percent. Use this theme function to override the output / display of this block.

Parameters

- assoc array $complete_data: ['uid'] - int - The user ID of the user viewing the page. ['percent'] - int - A number that represents the total percent complete (ie 50). ['completed'] - int - How many fields total that have been completed (filled out) by $user. ['incomplete'] - int - How many fields still need to be filled out. ['total'] - int - The count of all tagged profile fields. ['nextfield'] - str - The next field to fill out that is currently empty. ['nextfield_fid'] - int or str - The fid identifier of the field being passed in. ['nextpercent'] - int - What the users total percent complete value will be when ['nextfield'] is complete. ['nextcategory] - str - The category the next field falls under for targeting with a link. ['nextname'] - str - The field name of the next field for field focus after linked to the profile field.

1 theme call to theme_pcp_profile_percent_complete()
pcp_block in ./pcp.module
Implementation of hook_block()

File

./pcp.module, line 511
Allows users with valid permissions to tag profile fields created from the profile module as required fields for a users profile to be considered complete.

Code

function theme_pcp_profile_percent_complete($complete_data) {
  $output = '<style type="text/css">';
  $output .= '#pcp-percent-bar-wrapper {width: 100%; border: 1px solid #000; padding: 1px;}';
  $output .= '#pcp-percent-bar { width: ' . $complete_data['percent'] . '%; height: 10px; background-color: #777777;}';
  $output .= '</style>';
  $output .= '<div id="pcp-wrapper">';
  $output .= t('!complete% Complete', array(
    '!complete' => $complete_data['percent'],
  ));
  $output .= '<div id="pcp-percent-bar-wrapper">';
  $output .= '<div id="pcp-percent-bar"></div>';
  $output .= '</div>';
  $output .= '</div>';
  if ($complete_data['nextfield'] && $complete_data['nextpercent']) {
    if ($complete_data['nextcategory'] == 'Default') {
      $nextpath = 'user/' . $complete_data['uid'] . '/edit';
    }
    else {
      $nextpath = 'user/' . $complete_data['uid'] . '/edit/' . $complete_data['nextcategory'];
    }
    $element_id = 'edit-' . str_replace('_', '-', $complete_data['nextname']);
    $output .= t('Filling out <em>!empty-field</em> will bring your profile to !complete% Complete', array(
      '!empty-field' => l($complete_data['nextfield'], $nextpath, array(
        'query' => 'fieldname=' . $complete_data['nextname'],
        'fragment' => $element_id,
      )),
      '!complete' => $complete_data['nextpercent'],
    ));
  }
  return $output;
}