public function OpenGraphMeta::save_node_data in Open Graph meta tags 7
Same name and namespace in other branches
- 6 opengraph_meta.common.inc \OpenGraphMeta::save_node_data()
Save FB meta tag data for the given node.
Parameters
$data key-value pairs:
File
- ./
opengraph_meta.common.inc, line 200
Class
Code
public function save_node_data($nid, $data) {
$ret = $this->data_obj
->load_tags($nid);
if (FALSE === $ret) {
$row = new stdClass();
$row->nid = $nid;
}
else {
$row = $ret;
}
// collapse data tree into 1-D array
$collapsed_data = new stdClass();
// needed to work around pass-by-reference deprecation warning for array_walk_recursive
$collapsed_data->keys = array();
$collapsed_data->values = array();
array_walk_recursive($data, create_function('$val, $key, $obj', 'array_push($obj->keys, $key); array_push($obj->values, $val);'), $collapsed_data);
$collapsed_data = array_combine($collapsed_data->keys, $collapsed_data->values);
foreach ($this
->get_og_tag_defaults() as $field => $_d) {
$row->{$field} = isset($collapsed_data[$field]) ? $collapsed_data[$field] : '';
}
$this->data_obj
->update_tags($row, FALSE !== $ret ? 'nid' : array());
}