/**
  * Turn a post into a media-doc
  */
 protected function set_doc_data()
 {
     parent::set_doc_data();
     // set profile link
     $profile = $this->post_profile_type();
     $this->doc->links->profile = $this->get_profile_links($profile);
     // media fields
     if (!empty($this->post->post_excerpt)) {
         $this->doc->attributes->description = $this->post->post_excerpt;
     }
     if (!empty($this->post_meta['pmp_byline'])) {
         $this->doc->attributes->byline = $this->post_meta['pmp_byline'];
     }
     $this->doc->links->alternate = array((object) array('href' => get_permalink($this->post->ID), 'type' => 'text/html'));
     // media sub-profile fields
     if ($profile == 'image') {
         $alt_text = get_post_meta($this->post->ID, '_wp_attachment_image_alt', true);
         if (!empty($alt_text)) {
             $this->doc->attributes->title = $alt_text;
         }
         $this->doc->links->enclosure = pmp_enclosures_for_media($this->post->ID);
     } else {
         if ($profile == 'audio') {
             $this->doc->links->enclosure = pmp_enclosures_for_audio($this->post->ID);
         }
     }
 }
 /**
  * Turn a post into a story-doc
  */
 protected function set_doc_data()
 {
     parent::set_doc_data();
     // story-specific fields
     if (!empty($this->post->post_excerpt)) {
         $this->doc->attributes->teaser = $this->post->post_excerpt;
     }
     if (!empty($this->post->post_content)) {
         $this->doc->attributes->description = pmp_sanitize_content($this->post->post_content, true);
         $this->doc->attributes->contentencoded = pmp_sanitize_content($this->post->post_content);
         $this->doc->attributes->wpcontent = apply_filters('the_content', $this->post->post_content);
     }
     $this->doc->links->profile = $this->get_profile_links('story');
     $this->doc->links->alternate = array((object) array('href' => get_permalink($this->post->ID), 'type' => 'text/html'));
     // use the custom byline, if it exists - otherwise post author
     if (!empty($this->post_meta['pmp_byline'])) {
         $this->doc->attributes->byline = $this->post_meta['pmp_byline'];
     } else {
         $author = get_user_by('id', $this->post->post_author);
         if ($author && !empty($author->display_name)) {
             $this->doc->attributes->byline = $author->display_name;
         }
     }
     // tags!
     $tags = wp_get_post_tags($this->post->ID);
     if (!empty($tags)) {
         $this->doc->attributes->tags = array();
         foreach ($tags as $tagObj) {
             $this->doc->attributes->tags[] = $tagObj->name;
         }
     }
     // items (push them first!)
     $this->doc->links->item = array();
     foreach ($this->attachment_syncers as $syncer) {
         $success = $syncer->push();
         if ($success) {
             $rels = array();
             if (in_array($syncer->doc->getProfileAlias(), array('image', 'audio', 'video'))) {
                 $rels[] = 'urn:collectiondoc:' . $syncer->doc->getProfileAlias();
             }
             if ($syncer->doc->getProfileAlias() == 'image' && get_post_thumbnail_id($this->post->ID) == $syncer->post->ID) {
                 $rels[] = 'urn:collectiondoc:image:featured';
             }
             $this->doc->links->item[] = (object) array('href' => $syncer->doc->href, 'rels' => $rels);
         }
     }
 }