mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:55:19 +00:00
Fixed an exit of a loop in builtin_activity_puller().
There was a "$return", but I think it should be "return".
This commit is contained in:
parent
daed7fbead
commit
9d143e3f2d
1 changed files with 132 additions and 128 deletions
|
@ -207,18 +207,18 @@ function localize_item(&$item){
|
|||
|
||||
if (stristr($item['verb'], ACTIVITY_POKE)) {
|
||||
|
||||
// FIXME for obscured private posts, until then leave untranslated
|
||||
/** @FIXME for obscured private posts, until then leave untranslated */
|
||||
return;
|
||||
|
||||
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
||||
if(! $verb)
|
||||
return;
|
||||
|
||||
if ($item['obj_type']=="" || $item['obj_type']!== ACTIVITY_OBJ_PERSON) return;
|
||||
|
||||
$Aname = $item['author']['xchan_name'];
|
||||
$Alink = $item['author']['xchan_url'];
|
||||
|
||||
|
||||
$obj= json_decode_plus($item['object']);
|
||||
|
||||
$Blink = $Bphoto = '';
|
||||
|
@ -246,7 +246,6 @@ function localize_item(&$item){
|
|||
|
||||
$item['body'] = $item['localize'] = sprintf($txt, $A, $B);
|
||||
$item['body'] .= "\n\n\n" . $Bphoto;
|
||||
|
||||
}
|
||||
if (stristr($item['verb'],ACTIVITY_MOOD)) {
|
||||
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
|
||||
|
@ -376,11 +375,14 @@ function localize_item(&$item){
|
|||
$item['body'] = json_encode(crypto_encapsulate($item['body'],get_config('system','pubkey')));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the total of comments on this item and its desendants
|
||||
* @brief Count the total of comments on this item and its desendants.
|
||||
*
|
||||
* @param array $item an assoziative item-array which provides:
|
||||
* * \e array \b children
|
||||
* @return number
|
||||
*/
|
||||
function count_descendants($item) {
|
||||
|
||||
|
@ -390,6 +392,7 @@ function count_descendants($item) {
|
|||
foreach ($item['children'] as $child) {
|
||||
if (! visible_activity($child))
|
||||
$total --;
|
||||
|
||||
$total += count_descendants($child);
|
||||
}
|
||||
}
|
||||
|
@ -397,32 +400,46 @@ function count_descendants($item) {
|
|||
return $total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if the activity of the item is visible.
|
||||
*
|
||||
* likes (etc.) can apply to other things besides posts. Check if they are post
|
||||
* children, in which case we handle them specially.
|
||||
*
|
||||
* @param array $item
|
||||
* @return boolean
|
||||
*/
|
||||
function visible_activity($item) {
|
||||
|
||||
// likes (etc.) can apply to other things besides posts. Check if they are post children,
|
||||
// in which case we handle them specially
|
||||
|
||||
$hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
|
||||
|
||||
foreach ($hidden_activities as $act) {
|
||||
if ((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* "Render" a conversation or list of items for HTML display.
|
||||
* @brief "Render" a conversation or list of items for HTML display.
|
||||
*
|
||||
* There are two major forms of display:
|
||||
* - Sequential or unthreaded ("New Item View" or search results)
|
||||
* - conversation view
|
||||
*
|
||||
* The $mode parameter decides between the various renderings and also
|
||||
* figures out how to determine page owner and other contextual items
|
||||
* that are based on unique features of the calling module.
|
||||
*
|
||||
* @param App &$a
|
||||
* @param array $items
|
||||
* @param string $mode
|
||||
* @param boolean $update
|
||||
* @param string $page_mode default traditional
|
||||
* @param string $prepared_item
|
||||
* @return string
|
||||
*/
|
||||
|
||||
|
||||
function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $prepared_item = '') {
|
||||
|
||||
$content_html = '';
|
||||
|
@ -451,7 +468,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
$arr_blocked[$x] = trim($arr_blocked[$x]);
|
||||
}
|
||||
|
||||
|
||||
$profile_owner = 0;
|
||||
$page_writeable = false;
|
||||
$live_update_div = '';
|
||||
|
@ -637,7 +653,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
else
|
||||
$dropping = false;
|
||||
|
||||
|
||||
$drop = array(
|
||||
'pagedropping' => $page_dropping,
|
||||
'dropping' => $dropping,
|
||||
|
@ -659,17 +674,14 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
$verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature validated') : '');
|
||||
$forged = ((($item['sig']) && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message signature incorrect') : '');
|
||||
|
||||
|
||||
$unverified = '';
|
||||
|
||||
|
||||
$tags=array();
|
||||
$terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN));
|
||||
if(count($terms))
|
||||
foreach($terms as $tag)
|
||||
$tags[] = format_term_for_display($tag);
|
||||
|
||||
|
||||
$body = prepare_body($item,true);
|
||||
|
||||
$tmp_item = array(
|
||||
|
@ -731,12 +743,9 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
|
||||
// $threads[$threadsid]['id'] = $item['item_id'];
|
||||
$threads[] = $arr['output'];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
|
||||
// Normal View
|
||||
// logger('conv: items: ' . print_r($items,true));
|
||||
|
@ -751,7 +760,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
if($mode === 'display' && $items)
|
||||
$conv->set_profile_owner($items[0]['uid']);
|
||||
|
||||
|
||||
// get all the topmost parents
|
||||
// this shouldn't be needed, as we should have only them in our array
|
||||
// But for now, this array respects the old style, just in case
|
||||
|
@ -844,7 +852,6 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
|
|||
));
|
||||
|
||||
return $o;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -892,7 +899,6 @@ function item_photo_menu($item){
|
|||
$vsrc_link = "";
|
||||
$follow_url = "";
|
||||
|
||||
|
||||
$local_channel = local_channel();
|
||||
|
||||
if($local_channel) {
|
||||
|
@ -927,7 +933,6 @@ function item_photo_menu($item){
|
|||
$posts_link = $a->get_baseurl($ssl_state) . '/network/?cid=' . $contact['abook_id'];
|
||||
|
||||
$clean_url = normalise_link($item['author-link']);
|
||||
|
||||
}
|
||||
|
||||
$menu = Array(
|
||||
|
@ -943,7 +948,6 @@ function item_photo_menu($item){
|
|||
t("Poke") => $poke_link
|
||||
);
|
||||
|
||||
|
||||
$args = array('item' => $item, 'menu' => $menu);
|
||||
|
||||
call_hooks('item_photo_menu', $args);
|
||||
|
@ -958,17 +962,17 @@ function item_photo_menu($item){
|
|||
}
|
||||
elseif ($v!="") $o .= "<li><a href=\"$v\">$k</a></li>\n";
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks item to see if it is one of the builtin activities (like/dislike, event attendance, consensus items, etc.)
|
||||
*
|
||||
* Increments the count of each matching activity and adds a link to the author as needed.
|
||||
*
|
||||
* @param array $a (not used)
|
||||
* @param array $item
|
||||
* @param array &$conv_responses (already created with builtin activity structure)
|
||||
* @return void
|
||||
*/
|
||||
function builtin_activity_puller($item, &$conv_responses) {
|
||||
|
||||
|
@ -1011,11 +1015,7 @@ function builtin_activity_puller($item, &$conv_responses) {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if((activity_match($item['verb'], $verb)) && ($item['id'] != $item['parent'])) {
|
||||
|
||||
|
||||
$name = (($item['author']['xchan_name']) ? $item['author']['xchan_name'] : t('Unknown'));
|
||||
$url = (($item['author']['xchan_url'])
|
||||
? '<a href="' . chanlink_url($item['author']['xchan_url']) . '">' . $name . '</a>'
|
||||
|
@ -1041,25 +1041,27 @@ function builtin_activity_puller($item, &$conv_responses) {
|
|||
$conv_responses[$mode][$item['thr_parent'] . '-l'][] = $url;
|
||||
|
||||
// there can only be one activity verb per item so if we found anything, we can stop looking
|
||||
$return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Format the like/dislike text for a profile item
|
||||
// $cnt = number of people who like/dislike the item
|
||||
// $arr = array of pre-linked names of likers/dislikers
|
||||
// $type = one of 'like, 'dislike'
|
||||
// $id = item id
|
||||
// returns formatted text
|
||||
|
||||
|
||||
/**
|
||||
* @brief Format the like/dislike text for a profile item.
|
||||
*
|
||||
* @param int $cnt number of people who like/dislike the item
|
||||
* @param array $arr array of pre-linked names of likers/dislikers
|
||||
* @param string $typ eone of 'like, 'dislike'
|
||||
* @param int $id item id
|
||||
* @return string formatted text
|
||||
*/
|
||||
function format_like($cnt, $arr, $type, $id) {
|
||||
$o = '';
|
||||
if($cnt == 1)
|
||||
if ($cnt == 1) {
|
||||
$o .= (($type === 'like') ? sprintf( t('%s likes this.'), $arr[0]) : sprintf( t('%s doesn\'t like this.'), $arr[0])) . EOL ;
|
||||
else {
|
||||
} else {
|
||||
$spanatts = 'class="fakelink" onclick="openClose(\'' . $type . 'list-' . $id . '\');"';
|
||||
$o .= (($type === 'like') ?
|
||||
sprintf( tt('<span %1$s>%2$d people</span> like this.','<span %1$s>%2$d people</span> like this.',$cnt), $spanatts, $cnt)
|
||||
|
@ -1077,6 +1079,7 @@ function format_like($cnt,$arr,$type,$id) {
|
|||
$str = (($type === 'like') ? sprintf( t('%s like this.'), $str) : sprintf( t('%s don\'t like this.'), $str));
|
||||
$o .= "\t" . '<div id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>';
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1379,6 @@ function render_location_default($item) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
function prepare_page($item) {
|
||||
$a = get_app();
|
||||
$naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0);
|
||||
|
@ -1446,7 +1448,6 @@ function network_tabs() {
|
|||
$public_active = 'active';
|
||||
}
|
||||
|
||||
|
||||
if (($new_active == '')
|
||||
&& ($starred_active == '')
|
||||
&& ($conv_active == '')
|
||||
|
@ -1538,12 +1539,17 @@ function network_tabs() {
|
|||
return replace_macros($tpl, array('$tabs' => $arr['tabs']));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function profile_tabs($a, $is_owner=False, $nickname=Null){
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param App $a
|
||||
* @param boolean $is_owner default false
|
||||
* @param string $nickname default null
|
||||
* @return void|string
|
||||
*/
|
||||
function profile_tabs($a, $is_owner = false, $nickname = null){
|
||||
|
||||
// Don't provide any profile tabs if we're running as the sys channel
|
||||
|
||||
if ($a->is_sys)
|
||||
return;
|
||||
|
||||
|
@ -1629,7 +1635,6 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
if ($is_owner && feature_enabled($uid,'webpages')) {
|
||||
$tabs[] = array(
|
||||
'label' => t('Webpages'),
|
||||
|
@ -1638,11 +1643,11 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
|
|||
'title' => t('Manage Webpages'),
|
||||
'id' => 'webpages-tab',
|
||||
);
|
||||
}
|
||||
else {
|
||||
// FIXME
|
||||
// we probably need a listing of events that were created by
|
||||
// this channel and are visible to the observer
|
||||
} else {
|
||||
/**
|
||||
* @FIXME we probably need a listing of events that were created by
|
||||
* this channel and are visible to the observer
|
||||
*/
|
||||
}
|
||||
|
||||
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
|
||||
|
@ -1665,8 +1670,7 @@ function get_responses($conv_responses,$response_verbs,$ob,$item) {
|
|||
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
|
||||
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
|
||||
. (($ob) ? $ob->get_id() : $item['id']) . '"><b>' . t('View all') . '</b></a>');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$ret[$v]['list_part'] = '';
|
||||
}
|
||||
$ret[$v]['button'] = get_response_button_text($v,$ret[$v]['count']);
|
||||
|
|
Loading…
Reference in a new issue