function fb_graph_nodeapi in Drupal for Facebook 6.3
Implements hook_nodeapi().
File
- ./
fb_graph.module, line 307 - Open Graph Helpers
Code
function fb_graph_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'view' && $a4) {
// Full page view
// Some tags might come from taxonomy.
if (!empty($node->taxonomy)) {
foreach ($node->taxonomy as $tid => $term) {
if (variable_get('fb_graph_is_metadata_' . $term->vid, FALSE)) {
// Treat this tag as metadata.
unset($node->taxonomy[$tid]);
$v = taxonomy_vocabulary_load($term->vid);
fb_graph_set_tag($v->name, $term->name, FALSE);
// @TODO support multiple terms concatinated together.
}
}
}
// Some tags might come from content type.
if ($fb_graph_type = variable_get(FB_GRAPH_VAR_OBJECT_TYPE . '_' . $node->type, '')) {
if ($app_label = variable_get(FB_GRAPH_VAR_OBJECT_TYPE_APP . '_' . $node->type, 0)) {
if (!empty($GLOBALS['_fb_app']) && $GLOBALS['_fb_app']->label == $app_label) {
// Custom type applies only when app is currently active.
fb_graph_set_tag('og:type', $GLOBALS['_fb_app']->canvas . ':' . $fb_graph_type, FALSE);
}
}
else {
fb_graph_set_tag('og:type', $fb_graph_type, FALSE);
}
}
// Add additional "smart" tags.
$tags = fb_graph_get_tags();
fb_graph_set_tag('og:url', url('node/' . $node->nid, array(
'absolute' => TRUE,
)), FALSE);
fb_graph_set_tag('og:title', t($node->title), FALSE);
if (isset($tags['og:type']) && variable_get(FB_GRAPH_VAR_SMART_TAGS, TRUE)) {
if ($tags['og:type'] == 'article') {
fb_graph_set_tag('article:published_time', format_date($node->created, 'custom', 'Y-m-dTH:iZ'), FALSE);
fb_graph_set_tag('article:modified_time', format_date($node->changed, 'custom', 'Y-m-dTH:iZ'), FALSE);
// Only include URL to author if facebook's server will be able to view it.
if (user_access('access user profiles', drupal_anonymous_user())) {
// @TODO also test author profile is active.
fb_graph_set_tag('article:author', url('user/' . $node->uid, array(
'absolute' => TRUE,
)), FALSE);
}
}
}
}
}