Merge remote-tracking branch 'mike/master' into dev

This commit is contained in:
Mario Vavti 2018-04-18 08:19:56 +02:00
commit 440ccf19d1
8 changed files with 144 additions and 11 deletions

View File

@ -355,6 +355,7 @@ class Cover_photo extends \Zotlabs\Web\Controller {
$o .= replace_macros($tpl,array(
'$user' => \App::$channel['channel_address'],
'$existing' => get_cover_photo(local_channel(),'array',PHOTO_RES_COVER_850),
'$lbl_upfile' => t('Upload File:'),
'$lbl_profiles' => t('Select a profile:'),
'$title' => t('Change Cover Photo'),

View File

@ -34,6 +34,8 @@ class Pubstream extends \Zotlabs\Web\Controller {
}
$mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : '');
$hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : '');
if(strpos($mid,'b64.') === 0)
$decoded = @base64url_decode(substr($mid,4));
@ -133,7 +135,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
'$order' => 'comment',
'$file' => '',
'$cats' => '',
'$tags' => '',
'$tags' => $hashtags,
'$dend' => '',
'$mid' => $mid,
'$verb' => '',
@ -170,6 +172,10 @@ class Pubstream extends \Zotlabs\Web\Controller {
$page_mode = 'client';
if(x($hashtags)) {
$sql_extra .= protect_sprintf(term_query('item', $hashtags, TERM_HASHTAG, TERM_COMMUNITYTAG));
}
$net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : '');
$net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : '');

View File

@ -0,0 +1,41 @@
<?php
namespace Zotlabs\Widget;
class Pubtagcloud {
function widget($arr) {
$trending = ((array_key_exists('trending',$arr)) ? intval($arr['trending']) : 0);
if((observer_prohibited(true))) {
return EMPTY_STR;
}
if(! intval(get_config('system','open_pubstream',1))) {
if(! get_observer_hash()) {
return EMPTY_STR;
}
}
$site_firehose = ((intval(get_config('system','site_firehose',0))) ? true : false);
$net_firehose = ((get_config('system','disable_discover_tab',1)) ? false : true);
if(! ($site_firehose || $net_firehose)) {
return EMPTY_STR;
}
if($net_firehose) {
$site_firehose = false;
}
$safemode = get_xconfig(get_observer_hash(),'directory','safemode',1);
$limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 75);
return pubtagblock($net_firehose,$site_firehose, $limit, $trending, $safemode);
return '';
}
}

View File

@ -174,8 +174,7 @@ function tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0, $re
if(! is_array($authors))
$authors = array($authors);
stringify_array_elms($authors,true);
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
$sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
}
if($owner) {
@ -227,8 +226,7 @@ function card_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags = 0
if(! is_array($authors))
$authors = array($authors);
stringify_array_elms($authors,true);
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
$sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
}
if($owner) {
@ -280,8 +278,7 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
if(! is_array($authors))
$authors = array($authors);
stringify_array_elms($authors,true);
$sql_options .= " and author_xchan in (" . implode(',',$authors) . ") ";
$sql_options .= " and author_xchan in (" . stringify_array($authors,true) . ") ";
}
if($owner) {
@ -312,6 +309,69 @@ function article_tagadelic($uid, $count = 0, $authors = '', $owner = '', $flags
function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_HASHTAG) {
$o = '';
$r = pub_tagadelic($net,$site,$limit,$since,$safemode,$type);
$link = z_root() . '/pubstream';
if($r) {
$o = '<div class="tagblock widget"><h3>' . (($recent) ? t('Trending') : t('Tags')) . '</h3><div class="tags" align="center">';
foreach($r as $rr) {
$o .= '<span class="tag'.$rr[2].'">#</span><a href="'.$link .'/' . '?f=&tag=' . urlencode($rr[0]).'" class="tag'.$rr[2].'">'.$rr[0].'</a> ' . "\r\n";
}
$o .= '</div></div>';
}
return $o;
}
function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) {
$item_normal = item_normal();
$count = intval($limit);
if($site) {
$uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 ";
}
else {
$sys = get_sys_channel();
$uids = " and item.uid = " . intval($sys['channel_id']) . " ";
$sql_extra = item_permissions_sql($sys['channel_id']);
}
if($recent)
$sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' ";
if($safemode) {
$unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]);
if($unsafetags) {
$sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") ";
}
}
// Fetch tags
$r = q("select term, count(term) as total from term left join item on term.oid = item.id
where term.ttype = %d
and otype = %d and item_type = %d
$sql_extra $uids $item_normal
group by term order by total desc %s",
intval($type),
intval(TERM_OBJ_POST),
intval(ITEM_TYPE_POST),
((intval($count)) ? "limit $count" : '')
);
if(! $r)
return array();
return Zotlabs\Text\Tagadelic::calc($r);
}
function dir_tagadelic($count = 0, $hub = '') {
@ -557,9 +617,8 @@ function get_things($profile_hash,$uid) {
if(! in_array($rr['obj_obj'],$profile_hashes))
$profile_hashes[] = $rr['obj_obj'];
}
stringify_array_elms($profile_hashes);
if(! $profile_hash) {
$exp = explode(',',$profile_hashes);
$exp = stringify_array($profile_hashes,true);
$p = q("select profile_guid as hash, profile_name as name from profile where profile_guid in ( $exp ) ");
if($p) {
foreach($r as $rr) {

View File

@ -2324,6 +2324,23 @@ function stringify_array_elms(&$arr, $escape = false) {
$arr[$x] = "'" . (($escape) ? dbesc($arr[$x]) : $arr[$x]) . "'";
}
/**
* @brief Similar to stringify_array_elms but returns a string. If $escape is true, dbesc() each element before adding quotes.
*
* @param array $arr
* @param boolean $escape (optional) default false
* @return string
*/
function stringify_array($arr, $escape = false) {
if($arr) {
stringify_array_elms($arr);
return(implode(',',$arr));
}
return EMPTY_STR;
}
/**
* @brief Indents a flat JSON string to make it more human-readable.
*

View File

@ -1,3 +1,7 @@
[region=aside]
[widget=pubtagcloud][var=trending]8[/var][var=limit]20[/var][/widget]
[widget=pubtagcloud][/widget]
[/region]
[region=right_aside]
[widget=notifications][/widget]
[widget=newmember][/widget]

View File

@ -1795,3 +1795,7 @@ dl.bb-dl > dd > li {
position: absolute;
text-shadow: -2px 0 1px #fff, 0 2px 1px#fff, 2px 0 1px #fff, 0 -2px 1px #fff;
}
.cover-photo-review {
margin-bottom: 10px;
}

View File

@ -86,10 +86,11 @@
<h2>{{$title}}</h2>
</div>
<div class="section-content-wrapper">
{{if $existing}}
<img class="cover-photo-review" style="max-width: 100%;" src="{{$existing.url}}" alt="{{t('Cover Photo')}}" />
{{/if}}
<form enctype="multipart/form-data" action="cover_photo" method="post">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
<div id="profile-photo-upload-wrapper">
<label id="profile-photo-upload-label" class="form-label" for="profile-photo-upload">{{$lbl_upfile}}</label>