You are here

class OGMDrupalData in Open Graph meta tags 6

Same name and namespace in other branches
  1. 7 opengraph_meta.common.inc \OGMDrupalData

Hierarchy

Expanded class hierarchy of OGMDrupalData

File

./opengraph_meta.common.inc, line 397

View source
class OGMDrupalData implements OGMData {
  public function load_tags($nid) {
    $ret = OpenGraphMetaDrupalLayer::load_tags($nid);
    if (!empty($ret)) {

      // get optional field value as array
      $optional_db_field_name = OpenGraphMeta::__OPTIONAL_DB_FIELD;
      $optionals = !empty($ret->{$optional_db_field_name}) ? unserialize($ret->{$optional_db_field_name}) : array();

      // extract optional fields
      foreach (OpenGraphMeta::instance()
        ->get_og_optional_tag_defaults() as $tag => $dv) {
        $ret->{$tag} = !empty($optionals[$tag]) ? $optionals[$tag] : $dv;
      }
    }
    return $ret;
  }
  public function delete_tags($nid) {
    OpenGraphMetaDrupalLayer::delete_tags($nid);
  }
  public function update_tags($field_data_including_nid, $primary_key = array()) {

    // push optional fields into special db field
    $optionals = array();
    foreach (OpenGraphMeta::instance()
      ->get_og_optional_tag_defaults() as $tag => $dv) {
      if (!empty($field_data_including_nid->{$tag})) {
        $optionals[$tag] = $field_data_including_nid->{$tag};
      }
    }
    $optional_db_field_name = OpenGraphMeta::__OPTIONAL_DB_FIELD;
    $field_data_including_nid->{$optional_db_field_name} = $optionals;
    drupal_write_record(OPENGRAPH_META_TABLE, $field_data_including_nid, $primary_key);
  }

}

Members