aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2016-02-03 22:46:54 +0100
committermrjive <mrjive@mrjive.it>2016-02-03 22:46:54 +0100
commite527a52f6a123b695775a24fdeb64d0a5ab00df9 (patch)
tree7f72feb65e8f8790d6d80f631d1e608bfed1dd48 /include
parent337735094b944fd31ed96e36c869227a0d63e5d1 (diff)
parenta7ed50ecd4b4defbc1d5fdf0bb4fd7d65d08a0fd (diff)
downloadvolse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.tar.gz
volse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.tar.bz2
volse-hubzilla-e527a52f6a123b695775a24fdeb64d0a5ab00df9.zip
Merge pull request #21 from redmatrix/master
updating from original codebase
Diffstat (limited to 'include')
-rw-r--r--include/identity.php67
-rwxr-xr-xinclude/items.php1
-rwxr-xr-xinclude/oembed.php33
-rw-r--r--include/taxonomy.php7
4 files changed, 97 insertions, 11 deletions
diff --git a/include/identity.php b/include/identity.php
index e1e79394a..4f58d7dc5 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -1267,7 +1267,7 @@ function advanced_profile(&$a) {
$profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun');
if($likers) {
foreach($likers as $l)
- $profile['likers'][] = array('name' => $l['xchan_name'],'url' => zid($l['xchan_url']));
+ $profile['likers'][] = array('name' => $l['xchan_name'],'photo' => zid($l['xchan_photo_s']), 'url' => zid($l['xchan_url']));
}
if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) {
@@ -1781,3 +1781,68 @@ 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');
+
+ $maxwidth = (($args['width']) ? intval($args['width']) : 0);
+ $maxheight = (($args['height']) ? intval($args['height']) : 0);
+
+
+ if(($maxwidth > 1200) || ($maxwidth < 1))
+ $maxwidth = 1200;
+
+ if($maxwidth <= 425) {
+ $width = 425;
+ $size = 'hz_small';
+ $cover_size = PHOTO_RES_COVER_425;
+ $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
+ }
+ elseif($maxwidth <= 850) {
+ $width = 850;
+ $size = 'hz_medium';
+ $cover_size = PHOTO_RES_COVER_850;
+ $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
+ }
+ elseif($maxwidth <= 1200) {
+ $width = 1200;
+ $size = 'hz_large';
+ $cover_size = PHOTO_RES_COVER_1200;
+ $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
+ }
+
+// $scale = (float) $maxwidth / $width;
+// $translate = intval(($scale / 1.0) * 100);
+
+
+ $channel['channel_addr'] = $channel['channel_address'] . '@' . get_app()->get_hostname();
+ $zcard = array('chan' => $channel);
+
+ $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($cover_size),
+ intval(PHOTO_COVER)
+ );
+
+ if($r) {
+ $cover = $r[0];
+ $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale'];
+ }
+ else {
+ // @fixme remove this when we have a fallback cover photo and use that instead.
+ return;
+ }
+
+ $o .= replace_macros(get_markup_template('zcard.tpl'),array(
+ '$scale' => $scale,
+ '$translate' => $translate,
+ '$size' => $size,
+ '$cover' => $cover,
+ '$pphoto' => $pphoto,
+ '$zcard' => $zcard
+ ));
+
+ return $o;
+
+} \ No newline at end of file
diff --git a/include/items.php b/include/items.php
index b38049e70..5361a5fde 100755
--- a/include/items.php
+++ b/include/items.php
@@ -3438,6 +3438,7 @@ function check_item_source($uid, $item) {
if(! $r[0]['src_patt'])
return true;
+
require_once('include/html2plain.php');
$text = prepare_text($item['body'],$item['mimetype']);
$text = html2plain($text);
diff --git a/include/oembed.php b/include/oembed.php
index 2d3e0d3f9..7c577b6c2 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -53,6 +53,10 @@ function oembed_fetch_url($embedurl){
$a = get_app();
+ $embedurl = str_replace('&amp;','&', $embedurl);
+
+// logger('fetch: ' . $embedurl);
+
$txt = Cache::get($a->videowidth . $embedurl);
if(strstr($txt,'youtu') && strstr(z_root(),'https:')) {
@@ -120,20 +124,29 @@ function oembed_fetch_url($embedurl){
if ($txt[0]!="{") $txt='{"type":"error"}';
//save in cache
- Cache::set($a->videowidth . $embedurl,$txt);
+
+ if(! get_config('system','oembed_cache_disable'))
+ Cache::set($a->videowidth . $embedurl,$txt);
}
$j = json_decode($txt);
$j->embedurl = $embedurl;
+
+// logger('fetch return: ' . print_r($j,true));
+
return $j;
+
+
}
function oembed_format_object($j){
$a = get_app();
$embedurl = $j->embedurl;
+// logger('format: ' . print_r($j,true));
+
$jhtml = oembed_iframe($j->embedurl,(isset($j->width) ? $j->width : null), (isset($j->height) ? $j->height : null));
$ret="<span class='oembed ".$j->type."'>";
@@ -191,23 +204,29 @@ function oembed_format_object($j){
// add link to source if not present in "rich" type
if ( $j->type!='rich' || !strpos($j->html,$embedurl) ){
$embedlink = (isset($j->title))?$j->title:$embedurl;
- $ret .= '<span class="bookmark-identifier">#^</span>' . "<a href='$embedurl' rel='oembed'>$embedlink</a>";
- $ret .= "<br>";
+ $ret .= '<br /><span class="bookmark-identifier">#^</span>' . "<a href='$embedurl' rel='oembed'>$embedlink</a>";
+ $ret .= "<br />";
if (isset($j->author_name)) $ret.=" by ".$j->author_name;
if (isset($j->provider_name)) $ret.=" on ".$j->provider_name;
} else {
// add <a> for html2bbcode conversion
- $ret .= "<a href='$embedurl' rel='oembed'/>";
+ $ret .= "<br /><a href='$embedurl' rel='oembed'>$embedurl</a>";
}
$ret.="<br style='clear:left'></span>";
return mb_convert_encoding($ret, 'HTML-ENTITIES', mb_detect_encoding($ret));
}
function oembed_iframe($src,$width,$height) {
- if(! $width || strstr($width,'%'))
+ $scroll = ' scrolling="no" ';
+ if(! $width || strstr($width,'%')) {
$width = '640';
- if(! $height || strstr($height,'%'))
+ $scroll = ' scrolling="auto" ';
+ }
+ if(! $height || strstr($height,'%')) {
$height = '300';
+ $scroll = ' scrolling="auto" ';
+ }
+
// try and leave some room for the description line.
$height = intval($height) + 80;
$width = intval($width) + 40;
@@ -216,7 +235,7 @@ function oembed_iframe($src,$width,$height) {
// Make sure any children are sandboxed within their own iframe.
- return '<iframe height="' . $height . '" width="' . $width . '" src="' . $s . '" frameborder="no" >'
+ return '<iframe ' . $scroll . 'height="' . $height . '" width="' . $width . '" src="' . $s . '" frameborder="no" >'
. t('Embedded content') . '</iframe>';
}
diff --git a/include/taxonomy.php b/include/taxonomy.php
index 0bf89a7c1..5ef106938 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -398,16 +398,17 @@ function get_things($profile_hash,$uid) {
$things[$k] = null;
foreach($r as $rr) {
- $l = q("select xchan_name, xchan_url from likes left join xchan on likee = xchan_hash where
+ $l = q("select xchan_name, xchan_photo_s, xchan_url from likes left join xchan on likee = xchan_hash where
target_type = '%s' and target_id = '%s' and channel_id = %d",
dbesc(ACTIVITY_OBJ_THING),
dbesc($rr['obj_obj']),
intval($uid)
);
- for($x = 0; $x < count($l); $x ++)
+ for($x = 0; $x < count($l); $x ++) {
$l[$x]['xchan_url'] = zid($l[$x]['xchan_url']);
-
+ $l[$x]['xchan_photo_s'] = zid($l[$x]['xchan_photo_s']);
+ }
if(! $things[$rr['obj_verb']])
$things[$rr['obj_verb']] = array();