function template_preprocess_author_pane in Author Pane 6
Same name and namespace in other branches
- 5 author_pane.module \template_preprocess_author_pane()
- 6.2 author_pane.module \template_preprocess_author_pane()
- 7.2 author_pane.module \template_preprocess_author_pane()
Preprocesses template variables for the author info template.
File
- ./
author_pane.module, line 150 - Gathers information from user related contrib modules into one template.
Code
function template_preprocess_author_pane(&$variables) {
if (!empty($variables['template_suggestion'])) {
// Allow the calling function to suggest a template file.
// This allows AF to set a seperate template from APK.
$variables['template_files'][] = $variables['template_suggestion'];
}
// Set the image path
if (empty($variables['image_path'])) {
// Default images
$variables['image_path'] = drupal_get_path('module', 'author_pane') . '/images';
}
else {
$path_to_theme = author_pane_path_to_theme();
// Replace [theme_path] token with actual path to theme.
$variables['image_path'] = str_replace('[theme_path]', $path_to_theme, $variables['image_path']);
}
$image_path = $variables['image_path'];
// Give it some basic formatting.
drupal_add_css(drupal_get_path('module', 'author_pane') . '/author_pane.css');
// Load up all the integration files from other modules.
author_pane_include('author-pane.inc');
// --- Set some basic variables not related to any module. ---
// This $account refers to the user who's info is in the pane.
$account = $variables['account'];
$account_id = $account->uid;
// Username
$variables['account_name'] = theme('username', $account);
$variables['account_id'] = $account_id;
// Avatar
$block_template = variable_get('author_pane_block_template', 'author-pane-block');
if ($variables['template_suggestion'] == $block_template) {
// Imagecache'd resizing is only available for the block
$sized_picture = theme('author_pane_block_user_picture', $variables['account']);
if (!empty($sized_picture)) {
$variables['picture'] = $sized_picture;
}
}
if (empty($variables['picture'])) {
$variables['picture'] = theme('user_picture', $account);
}
if ($account_id != 0) {
// Join date / since
$just_date = str_replace(array(
'H:i',
'g:ia',
' - ',
), '', variable_get('date_format_short', 'm/d/Y - H:i'));
$variables['joined'] = format_date($account->created, 'custom', $just_date);
$variables['joined_ago'] = format_interval(time() - $account->created);
// Online status
$variables['last_active'] = format_interval(time() - $account->access);
if (round((time() - $account->access) / 60) < 15) {
$variables['online_icon'] = theme('image', "{$image_path}/user-online.png", t('User is online'), t('User is online'));
$variables['online_status'] = t('Online');
}
else {
$variables['online_icon'] = theme('image', "{$image_path}/user-offline.png", t('User offline. Last seen @time ago.', array(
'@time' => $variables['last_active'],
)), t('User offline. Last seen @time ago.', array(
'@time' => $variables['last_active'],
)));
$variables['online_status'] = t('Offline');
}
}
}