private function map_data($rawData, $type = "posts") { $data = array(); foreach ($rawData['posts'] as $entry) { $source = ""; $id = $entry["id"]; $link = $entry["post_url"]; self::$post_format = $entry["type"]; switch ($entry["type"]) { case 'text': self::$post_format = 'article'; break; case 'answer': self::$post_format = 'aside'; break; case 'photo': self::$post_format = 'image'; break; } $tags = $entry['tags']; $tags[] = $entry['blog_name']; //$content = self::construct_content($entry,$id,$image_url,$title); // ! if ($type == "posts") { // text posts and links // $title = $entry['title']; $category = array(get_option($this->shortname . '_category')); //$post_content = $content['constructed']; $post_content = $entry['body']; // no image for text posts $image_url = ''; if ($entry['type'] == 'photo') { $title = wp_strip_all_tags($entry['caption']); $post_content = '[gallery size="large" columns="' . $columns . '" link="file"]' . $entry['caption']; $images = array(); $i = 0; foreach ($entry['photos'] as $image) { $images[$i]['link_url'] = ''; $images[$i]['image_url'] = $image['original_size']['url']; $images[$i]['title'] = $image['caption']; $i++; } $image_url = $images; // source_url":"http:\/\/hebig.org\/","source_title":"hebig.org" if ($entry['source_url']) { $source = sprintf(__(', source: <a href="%s">%s</a>', 'reclaim'), $entry['source_url'], $entry['source_title']); } } if ($entry['type'] == 'quote') { $title = parent::short_title(wp_strip_all_tags($entry['text']), ' …', 10); $post_content = '<blockquote>' . $entry['text'] . '</blockquote>'; $post_content .= $entry['source']; $post_meta["_format_quote_source_name"] = $entry['source_url']; $post_meta["_format_quote_source_url"] = $entry['source_title']; } if ($entry['type'] == 'link') { $post_content = $entry['description']; // links have the original url $post_meta["_format_link_url"] = $entry['url']; } if ($entry['type'] == 'chat') { // save the dialogue in a meta field or render dialogue? // "dialogue":[{"name":"","label":"","phrase":"Baasal warataa kono na tampina"},{"name":"","label":"","phrase":"Poverty does not kill but makes one tired"},{"name":"","label":"","phrase":"***"},{"name":"","label":"","phrase":"Si bahe cum\u0257i gooto fof \u00f1ifata ko waare mum"},{"name":"","label":"","phrase":"If the beards are all on fire, each person must put out his own beard"},{"name":"","label":"","phrase":"***"},{"name":"","label":"","phrase":"\u0253e nengasa \u0253e ne nguuba yaajay kono luggidtaa"},{"name":"","label":"","phrase":"If some are digging and some are burying it will be wide but never deep"},{"name":"","label":"","phrase":"***"},{"name":"","label":"","phrase":"Maw\u0257o ina joo\u0257oo yi\u0027ii cukalel \u0257aroo ro\u014bku yi\u0027ude"},{"name":"","label":"","phrase":"A seated elder sees what a standing child misses"}] $post_content = $entry['body']; } if ($entry['type'] == 'audio') { $title = parent::short_title(wp_strip_all_tags($entry['id3_title']), ' …', 10); $post_content = $entry['caption'] . $entry['player']; $embed_code = $entry['player']; $post_meta["_format_link_url"] = $entry['source_url']; } if ($entry['type'] == 'video') { $title = $entry['source_title'] == '' ? parent::short_title(wp_strip_all_tags($entry['caption']), ' …', 10) : $entry['source_title']; $post_content = $entry['caption'] . '[embed_code]'; $embed_code = $entry['player'][2]['embed_code']; $post_meta["_format_link_url"] = $entry['permalink_url']; // source_url $image_url = $entry['thumbnail_url']; } // todo: answer type $post_content .= ' <p class="viewpost-tumblr">(<a rel="syndication" href="' . $link . '">' . sprintf(__('View on %s', 'reclaim'), $entry['blog_name'] . '.tumblr.com') . '</a>' . $source . ')</p>'; } else { // todo: get tumblr favs $title = sprintf(__('I faved an Tumblr from %s', 'reclaim'), '@' . $entry['user']['username']); $category = array(get_option($this->shortname . '_favs_category')); $post_content = "[embed_code]"; $image_url = ''; } $post_meta["_" . $this->shortname . "_link_id"] = $entry["id"]; $post_meta["_post_generator"] = $this->shortname; $post_meta["_reclaim_post_type"] = $type; $data[] = array('post_author' => get_option($this->shortname . '_author'), 'post_category' => $category, 'post_format' => self::$post_format, 'post_date' => get_date_from_gmt(date('Y-m-d H:i:s', $entry["timestamp"])), 'post_content' => $post_content, 'post_title' => $title, 'post_type' => 'post', 'post_status' => 'publish', 'tags_input' => $tags, 'ext_permalink' => $link, 'ext_image' => $image_url, 'ext_embed_code' => $embed_code, 'ext_guid' => $id, 'post_meta' => $post_meta); } return $data; }