function prepare_body(&$item, $attach = false) { call_hooks('prepare_body_init', $item); $s = ''; $photo = ''; $is_photo = $item['verb'] === ACTIVITY_POST && $item['obj_type'] === ACTIVITY_OBJ_PHOTO ? true : false; if ($is_photo) { $object = json_decode($item['obj'], true); // if original photo width is <= 640px prepend it to item body if ($object['link'][0]['width'] && $object['link'][0]['width'] <= 640) { $s .= '<div class="inline-photo-item-wrapper"><a href="' . zid(rawurldecode($object['id'])) . '" target="_blank"><img class="inline-photo-item" style="max-width:' . $object['link'][0]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][0]['href'])) . '"></a></div>' . $s; } // if original photo width is > 640px make it a cover photo if ($object['link'][0]['width'] && $object['link'][0]['width'] > 640) { $scale = $object['link'][1]['width'] == 1024 || $object['link'][1]['height'] == 1024 ? 1 : 0; $photo = '<a href="' . zid(rawurldecode($object['id'])) . '" target="_blank"><img style="max-width:' . $object['link'][$scale]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][$scale]['href'])) . '"></a>'; } } $s .= prepare_text($item['body'], $item['mimetype'], false); $event = $item['obj_type'] === ACTIVITY_OBJ_EVENT ? format_event_obj($item['obj']) : false; $prep_arr = array('item' => $item, 'html' => $event ? $event['content'] : $s, 'event' => $event['header'], 'photo' => $photo); call_hooks('prepare_body', $prep_arr); $s = $prep_arr['html']; $photo = $prep_arr['photo']; $event = $prep_arr['event']; // q("update item set html = '%s' where id = %d", // dbesc($s), // intval($item['id']) // ); if (!$attach) { return $s; } if (strpos($s, '<div class="map">') !== false && $item['coord']) { $x = generate_map(trim($item['coord'])); if ($x) { $s = preg_replace('/\\<div class\\=\\"map\\"\\>/', '$0' . $x, $s); } } $attachments = theme_attachments($item); $writeable = get_observer_hash() == $item['owner_xchan'] ? true : false; $tags = format_hashtags($item); if ($item['resource_type']) { $mentions = format_mentions($item); } $categories = format_categories($item, $writeable); if (local_channel() == $item['uid']) { $filer = format_filer($item); } $s = sslify($s); $prep_arr = array('item' => $item, 'photo' => $photo, 'html' => $s, 'event' => $event, 'categories' => $categories, 'folders' => $filer, 'tags' => $tags, 'mentions' => $mentions, 'attachments' => $attachments); call_hooks('prepare_body_final', $prep_arr); unset($prep_arr['item']); return $prep_arr; }
function prepare_body(&$item, $attach = false) { require_once 'include/identity.php'; // if($item['html']) { // $s = bb_observer($item['html']); // } // else { call_hooks('prepare_body_init', $item); // unobscure($item); $s = prepare_text($item['body'], $item['mimetype'], false); // } $photo = ''; $is_photo = $item['obj_type'] === ACTIVITY_OBJ_PHOTO ? true : false; if ($is_photo) { $object = json_decode($item['object'], true); // if original photo width is <= 640px prepend it to item body if ($object['link'][0]['width'] && $object['link'][0]['width'] <= 640) { $s = '<div class="inline-photo-item-wrapper"><a href="' . zid(rawurldecode($object['id'])) . '" target="_newwin"><img class="inline-photo-item" style="max-width:' . $object['link'][0]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][0]['href'])) . '"></a></div>' . $s; } // if original photo width is > 640px make it a cover photo if ($object['link'][0]['width'] && $object['link'][0]['width'] > 640) { $scale = $object['link'][1]['width'] == 1024 || $object['link'][1]['height'] == 1024 ? 1 : 0; $photo = '<a href="' . zid(rawurldecode($object['id'])) . '" target="_newwin"><img style="max-width:' . $object['link'][$scale]['width'] . 'px; width:100%; height:auto;" src="' . zid(rawurldecode($object['link'][$scale]['href'])) . '"></a>'; } } $prep_arr = array('item' => $item, 'html' => $s, 'photo' => $photo); call_hooks('prepare_body', $prep_arr); $s = $prep_arr['html']; $photo = $prep_arr['photo']; // q("update item set html = '%s' where id = %d", // dbesc($s), // intval($item['id']) // ); if (!$attach) { return $s; } if (strpos($s, '<div class="map">') !== false && $item['coord']) { $x = generate_map(trim($item['coord'])); if ($x) { $s = preg_replace('/\\<div class\\=\\"map\\"\\>/', '$0' . $x, $s); } } $attachments = theme_attachments($item); $writeable = get_observer_hash() == $item['owner_xchan'] ? true : false; $tags = format_hashtags($item); if ($item['resource_type']) { $mentions = format_mentions($item); } $categories = format_categories($item, $writeable); if (local_channel() == $item['uid']) { $filer = format_filer($item); } $s = sslify($s); // Look for spoiler $spoilersearch = '<blockquote class="spoiler">'; // Remove line breaks before the spoiler while (strpos($s, "\n" . $spoilersearch) !== false) { $s = str_replace("\n" . $spoilersearch, $spoilersearch, $s); } while (strpos($s, "<br />" . $spoilersearch) !== false) { $s = str_replace("<br />" . $spoilersearch, $spoilersearch, $s); } while (strpos($s, $spoilersearch) !== false) { $pos = strpos($s, $spoilersearch); $rnd = random_string(8); $spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">'; $s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch)); } // Look for quote with author $authorsearch = '<blockquote class="author">'; while (strpos($s, $authorsearch) !== false) { $pos = strpos($s, $authorsearch); $rnd = random_string(8); $authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="author" id="author-' . $rnd . '" style="display: block;">'; $s = substr($s, 0, $pos) . $authorreplace . substr($s, $pos + strlen($authorsearch)); } $prep_arr = array('item' => $item, 'photo' => $photo, 'html' => $s, 'categories' => $categories, 'folders' => $filer, 'tags' => $tags, 'mentions' => $mentions, 'attachments' => $attachments); call_hooks('prepare_body_final', $prep_arr); unset($prep_arr['item']); return $prep_arr; }
function prepare_body(&$item, $attach = false) { call_hooks('prepare_body_init', $item); unobscure($item); $s = prepare_text($item['body'], $item['mimetype']); $prep_arr = array('item' => $item, 'html' => $s); call_hooks('prepare_body', $prep_arr); $s = $prep_arr['html']; if (!$attach) { return $s; } if (strpos($s, '<div class="map">') !== false && $item['coord']) { $x = generate_map(trim($item['coord'])); if ($x) { $s = preg_replace('/\\<div class\\=\\"map\\"\\>/', '$0' . $x, $s); } } $s .= theme_attachments($item); $writeable = get_observer_hash() == $item['owner_xchan'] ? true : false; $s .= format_hashtags($item); if ($item['resource_type']) { $s .= format_mentions($item); } $s .= format_categories($item, $writeable); if (local_channel() == $item['uid']) { $s .= format_filer($item); } $s = sslify($s); // Look for spoiler $spoilersearch = '<blockquote class="spoiler">'; // Remove line breaks before the spoiler while (strpos($s, "\n" . $spoilersearch) !== false) { $s = str_replace("\n" . $spoilersearch, $spoilersearch, $s); } while (strpos($s, "<br />" . $spoilersearch) !== false) { $s = str_replace("<br />" . $spoilersearch, $spoilersearch, $s); } while (strpos($s, $spoilersearch) !== false) { $pos = strpos($s, $spoilersearch); $rnd = random_string(8); $spoilerreplace = '<br /> <span id="spoiler-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'spoiler-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="spoiler" id="spoiler-' . $rnd . '" style="display: none;">'; $s = substr($s, 0, $pos) . $spoilerreplace . substr($s, $pos + strlen($spoilersearch)); } // Look for quote with author $authorsearch = '<blockquote class="author">'; while (strpos($s, $authorsearch) !== false) { $pos = strpos($s, $authorsearch); $rnd = random_string(8); $authorreplace = '<br /> <span id="author-wrap-' . $rnd . '" style="white-space:nowrap;" class="fakelink" onclick="openClose(\'author-' . $rnd . '\');">' . sprintf(t('Click to open/close')) . '</span>' . '<blockquote class="author" id="author-' . $rnd . '" style="display: block;">'; $s = substr($s, 0, $pos) . $authorreplace . substr($s, $pos + strlen($authorsearch)); } $prep_arr = array('item' => $item, 'html' => $s); call_hooks('prepare_body_final', $prep_arr); return $prep_arr['html']; }