public function parse(&$postdata)
{
# Use the parent parse
$ret =& parent::parse($postdata);
# gonna pick a case
if (!empty($ret['ID'])) {
$ret['id'] =& $ret['ID'];
unset($ret['ID']);
}
# Take only the fields we need, put them in a temp array
# TODO: current_blog may not be correct
$ret['blogid'] = get_current_blog_id();
# Fill up the meta attribute with post meta
$ret['post_meta'] = array();
$meta_keys = get_post_custom_keys($ret['id']);
if (is_array($meta_keys)) {
foreach ($meta_keys as $key) {
$ret['post_meta'][$key] = get_post_meta($ret['id'], $key, true);
}
}
if ($ret['post_type'] == 'post') {
$ret['post_format'] = get_post_format($ret['id']);
}
return $ret;
}
public function parse(&$postdata) { # Use the parent parse $ret =& parent::parse($postdata); # If this isn't an attachment, we haven't found what we're looking for if ($ret['post_type'] != "attachment") { throw new ModelParseException(__("Post is not an attachment", 'mtv')); } # Add some special fields depending on the post type $ret['url'] = wp_get_attachment_url($ret['id']); $ret['thumb_url'] = wp_get_attachment_thumb_url($ret['id']); return $ret; }