From d84094362165524ce64fb2f0a588a376efa96c68 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Jan 2012 16:30:32 -0800 Subject: [PATCH] use reltoabs - primarily for github activity feeds --- include/items.php | 7 +++++++ include/text.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/include/items.php b/include/items.php index 0bd77582a5..a939bfc88b 100644 --- a/include/items.php +++ b/include/items.php @@ -295,6 +295,11 @@ function get_atom_elements($feed,$item) { $res['body'] = unxmlify($item->get_content()); $res['plink'] = unxmlify($item->get_link(0)); + if($res['plink']) + $base_url = implode('/', array_slice(explode('/',$res['plink']),0,3)); + else + $base_url = ''; + // look for a photo. We should check media size and find the best one, // but for now let's just find any author photo @@ -414,6 +419,8 @@ function get_atom_elements($feed,$item) { if((strpos($res['body'],'<') !== false) || (strpos($res['body'],'>') !== false)) { + $res['body'] = reltoabs($res['body'],$base_url); + $res['body'] = html2bb_video($res['body']); $res['body'] = oembed_html2bbcode($res['body']); diff --git a/include/text.php b/include/text.php index 1db88ca2c8..416e19927c 100644 --- a/include/text.php +++ b/include/text.php @@ -1065,3 +1065,37 @@ function array_xmlify($val){ if (is_array($val)) return array_map('array_xmlify', $val); return xmlify((string) $val); } + + +function reltoabs($text, $base) +{ + if (empty($base)) + return $text; + + $base = rtrim($base,'/'); + + $base2 = $base . "/"; + + // Replace links + $pattern = "/]*) href=\"(?!http|https|\/)([^\"]*)\"/"; + $replace = "