function authcache_flag_entity_view_alter in Authenticated User Page Caching (Authcache) 7.2
Implements hook_flag_view_alter().
See also
File
- modules/
authcache_flag/ authcache_flag.module, line 39 - Provide personalization for the flag module.
Code
function authcache_flag_entity_view_alter(&$build, $type) {
if (authcache_page_is_cacheable()) {
$entity = _authcache_flag_extract_entity_from_build($build);
list($id) = entity_extract_ids($type, $entity);
$flags = flag_get_flags($type);
foreach ($flags as $flag) {
// Substitute link.
if (isset($build['links']['flag']['#links']['flag-' . $flag->name])) {
$build['links']['flag']['#links']['flag-' . $flag->name] = array(
'title' => theme('authcache_p13n_partial', array(
'assembly' => 'flags',
'partial' => _authcache_flag_partial_id($flag),
'param' => $id,
'fallback' => 'cancel',
'original' => $build['links']['flag']['#links']['flag-' . $flag->name]['title'],
)),
'html' => TRUE,
);
}
// Substitute pseudo field.
if (isset($build['flag_' . $flag->name])) {
$flag_name_css = str_replace('_', '-', $flag->name);
$wrapper_attrs = array(
'class' => array(
'flag-outer',
$flag_name_css,
),
);
authcache_p13n_attach($build['flag_' . $flag->name], array(
'#theme' => 'authcache_p13n_partial',
'#assembly' => 'flags',
'#partial' => _authcache_flag_partial_id($flag),
'#param' => $id,
'#fallback' => 'cancel',
'#prefix' => '<div ' . drupal_attributes($wrapper_attrs) . '>',
'#suffix' => '</div>',
));
}
}
}
}