profile embeds (still needs a bit of work)

This commit is contained in:
redmatrix 2016-02-01 21:09:50 -08:00
parent 723a49ccee
commit 5edbc00865
3 changed files with 87 additions and 0 deletions

View File

@ -1781,3 +1781,45 @@ function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_
return $output;
}
function get_zcard($channel,$observer_hash = '',$args = array()) {
logger('get_zcard');
$channel['channel_addr'] = $channel['channel_address'] . '@' . get_app()->get_hostname();
$r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d",
intval($channel['channel_id']),
intval(PHOTO_RES_COVER_1200),
intval(PHOTO_COVER)
);
if($r) {
$cover = $r[0];
$cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale'];
}
$pphoto = array('type' => $channel['xchan_photo_mimetype'],
'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
$maxwidth = (($args['width']) ? intval($args['width']) : 0);
$maxheight = (($args['height']) ? intval($args['height']) : 0);
$zcard = array('chan' => $channel);
if(($maxwidth > 1200) || ($maxwidth < 1))
$maxwidth = 1200;
$scale = (float) $maxwidth / 1200;
$translate = intval(($scale / 1.0) * 100);
$o .= replace_macros(get_markup_template('zcard.tpl'),array(
'$scale' => $scale,
'$translate' => $translate,
'$cover' => $cover,
'$pphoto' => $pphoto,
'$zcard' => $zcard
));
return $o;
}

View File

@ -165,6 +165,50 @@ function oep_mid_reply($args) {
function oep_profile_reply($args) {
require_once('include/identity.php');
require_once('include/Contact.php');
$url = $args['url'];
if(preg_match('#//(.*?)/(.*?)/(.*?)(/|\?|&|$)#',$url,$matches)) {
$chn = $matches[3];
}
if(! $chn)
return;
$c = channelx_by_nick($chn);
if(! $c)
return;
$maxwidth = intval($args['maxwidth']);
$maxheight = intval($args['maxheight']);
$width = 800;
$height = 375;
if($maxwidth) {
$width = $maxwidth;
$height = (375 / 800) * $width;
}
if($maxheight) {
if($maxheight < $height) {
$width = (800 / 375) * $maxheight;
$height = $maxheight;
}
}
$ret = array();
$ret['type'] = 'rich';
$ret['width'] = intval($width);
$ret['height'] = intval($height);
$ret['html'] = get_zcard($c,get_observer_hash(),array('width' => $width, 'height' => $height));
return $ret;
}
function oep_album_reply($args) {

View File

@ -75,6 +75,7 @@ function profile_content(&$a, $update = 0) {
$o .= profile_tabs($a, $is_owner, $a->profile['channel_address']);
$a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->query_string) . '" title="oembed" />' . "\r\n";
$o .= advanced_profile($a);
call_hooks('profile_advanced',$o);