You are here

public static function OpenGraphMetaDrupalLayer::get_node_body in Open Graph meta tags 6

Same name and namespace in other branches
  1. 7 opengraph_meta.common.inc \OpenGraphMetaDrupalLayer::get_node_body()

Get contents of node body.

Parameters

$node the node object.:

Return value

empty string if no body found.

4 calls to OpenGraphMetaDrupalLayer::get_node_body()
OGMTBasicTest::testNodeOverrideDefaultImage in tests/Basic.test
OGMTBasicTest::testNodeOverridesEmptyValues in tests/Basic.test
OpenGraphMeta::get_og_tag_defaults in ./opengraph_meta.common.inc
Get default values for all meta tags (including optional ones).
OpenGraphMeta::harvest_images_from_node in ./opengraph_meta.common.inc
Harvest all images from the given node.

File

./opengraph_meta.common.inc, line 508

Class

OpenGraphMetaDrupalLayer
Drupal compatibility layer.

Code

public static function get_node_body($node) {
  $body = '';
  switch (OPENGRAPH_META_DRUPAL_VERSION) {
    case 6:

      // check if we have an alternative field from which to grab description.
      $description_cck_field = variable_get(OPENGRAPH_META_VAR_CONTENT_TYPE_CCK_ . $node->type, '');
      if (!empty($description_cck_field) && !empty($node->{$description_cck_field})) {
        $v = $node->{$description_cck_field};
        if (is_array($v[0]) && !empty($v[0]['value'])) {
          $body = $v[0]['value'];
        }
      }
      if (empty($body) && !empty($node->body)) {
        $body = $node->body;
      }
      break;
    default:
      $lang = field_language('node', $node, 'body');
      if (!empty($node) && !empty($node->body) && !empty($node->body[$lang]) && !empty($node->body[$lang]['0']) && !empty($node->body[$lang]['0']['value'])) {
        $body = $node->body[$lang]['0']['value'];
      }
      break;
  }
  return $body;
}