use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
+use Friendica\Model\Profile;
use Friendica\Object\Thread;
use Friendica\Object\Post;
function item_extract_images($body) {
- $saved_image = array();
+ $saved_image = [];
$orig_body = $body;
$new_body = '';
$new_body = $new_body . $orig_body;
- return array('body' => $new_body, 'images' => $saved_image);
+ return ['body' => $new_body, 'images' => $saved_image];
}
function item_redir_and_replace_images($body, $images, $cid) {
default:
if ($obj['resource-id']) {
$post_type = t('photo');
- $m = array();
+ $m = [];
preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1];
} else {
}
}
- $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
+ $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
if ($Bphoto != "") {
- $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
+ $Bphoto = '[url=' . Profile::zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
}
$item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto;
}
}
- $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
+ $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
if ($Bphoto != "") {
- $Bphoto = '[url=' . zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
+ $Bphoto = '[url=' . Profile::zrl($Blink) . '][img=80x80]' . $Bphoto . '[/img][/url]';
}
/*
$obj = $r[0];
- $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
- $objauthor = '[url=' . zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
+ $author = '[url=' . Profile::zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
+ $objauthor = '[url=' . Profile::zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
switch ($obj['verb']) {
case ACTIVITY_POST:
default:
if ($obj['resource-id']) {
$post_type = t('photo');
- $m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
+ $m=[]; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1];
} else {
$post_type = t('status');
$target = $r[0];
$Bname = $target['author-name'];
$Blink = $target['author-link'];
- $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
- $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
+ $A = '[url=' . Profile::zrl($Alink) . ']' . $Aname . '[/url]';
+ $B = '[url=' . Profile::zrl($Blink) . ']' . $Bname . '[/url]';
$P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]';
$item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n";
}
if (preg_match_all('/@\[url=(.*?)\]/is', $item['body'], $matches, PREG_SET_ORDER)) {
foreach ($matches as $mtch) {
if (! strpos($mtch[1], 'zrl=')) {
- $item['body'] = str_replace($mtch[0], '@[url=' . zrl($mtch[1]) . ']', $item['body']);
+ $item['body'] = str_replace($mtch[0], '@[url=' . Profile::zrl($mtch[1]) . ']', $item['body']);
}
}
}
// add zrl's to public images
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
if (preg_match($photo_pattern, $item['body'])) {
- $photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
+ $photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
$item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']);
}
* 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_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE);
+ $hidden_activities = [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE];
foreach ($hidden_activities as $act) {
if (activity_match($item['verb'], $act)) {
return false;
$_SESSION['return_url'] = $a->query_string;
}
- $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview);
+ $cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview];
call_hooks('conversation_start',$cb);
$items = $cb['items'];
- $conv_responses = array(
- 'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','title')),
- 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title'))
- );
+ $conv_responses = [
+ 'like' => ['title' => t('Likes','title')], 'dislike' => ['title' => t('Dislikes','title')],
+ 'attendyes' => ['title' => t('Attending','title')], 'attendno' => ['title' => t('Not attending','title')], 'attendmaybe' => ['title' => t('Might attend','title')]
+ ];
// array with html for each thread (parent+comments)
- $threads = array();
+ $threads = [];
$threadsid = -1;
$page_template = get_markup_template("conversation.tpl");
$community_readonly = false;
$writable = true;
} else {
- $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN));
+ $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]);
}
} else {
$writable = false;
$profile_name = $item['author-link'];
}
- $tags = array();
- $hashtags = array();
- $mentions = array();
+ $tags = [];
+ $hashtags = [];
+ $mentions = [];
$searchpath = System::baseUrl()."/search?tag=";
- $taglist = dba::select('term', array('type', 'term', 'url'),
- array("`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION),
- array('order' => array('tid')));
+ $taglist = dba::select('term', ['type', 'term', 'url'],
+ ["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION],
+ ['order' => ['tid']]);
while ($tag = dba::fetch($taglist)) {
if ($tag["url"] == "") {
if ($sp) {
$sparkle = ' sparkle';
} else {
- $profile_link = zrl($profile_link);
+ $profile_link = Profile::zrl($profile_link);
}
if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) {
}
}
- $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
+ $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
call_hooks('render_location',$locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
$dropping = false;
}
- $drop = array(
+ $drop = [
'dropping' => $dropping,
'pagedrop' => $page_dropping,
'select' => t('Select'),
'delete' => t('Delete'),
- );
+ ];
$star = false;
$isstarred = "unstarred";
$item['item_network'] = $item['network'];
}
- $tmp_item = array(
+ $tmp_item = [
'template' => $tpl,
'id' => (($preview) ? 'P0' : $item['item_id']),
'guid' => (($preview) ? 'Q0' : $item['guid']),
'like' => '',
'dislike' => '',
'comment' => '',
- 'conv' => (($preview) ? '' : array('href'=> 'display/'.$item['guid'], 'title'=> t('View in context'))),
+ 'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> t('View in context')]),
'previewing' => $previewing,
'wait' => t('Please wait'),
'thread_level' => 1,
- );
+ ];
- $arr = array('item' => $item, 'output' => $tmp_item);
+ $arr = ['item' => $item, 'output' => $tmp_item];
call_hooks('display_item', $arr);
$threads[$threadsid]['id'] = $item['item_id'];
$threads[$threadsid]['network'] = $item['item_network'];
- $threads[$threadsid]['items'] = array($arr['output']);
+ $threads[$threadsid]['items'] = [$arr['output']];
}
} else {
$threads = $conv->getTemplateData($conv_responses);
if (!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
- $threads = array();
+ $threads = [];
}
}
}
- $o = replace_macros($page_template, array(
+ $o = replace_macros($page_template, [
'$baseurl' => System::baseUrl($ssl_state),
'$return_path' => $a->query_string,
'$live_update' => $live_update_div,
'$user' => $a->user,
'$threads' => $threads,
'$dropping' => ($page_dropping && Feature::isEnabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False),
- ));
+ ]);
return $o;
}
function community_add_items($parents) {
$max_comments = Config::get("system", "max_comments", 100);
- $items = array();
+ $items = [];
foreach ($parents AS $parent) {
$thread_items = dba::p(item_query()." AND `item`.`uid` = ?
}
}
if (!$parent_found) {
- $comments = array();
+ $comments = [];
}
}
$clean_url = normalise_link($item['author-link']);
if (local_user()) {
- $r = dba::selectOne('contact', ['id'],
- ['network' => NETWORK_DFRN, 'uid' => local_user(), 'nurl' => normalise_link($clean_url), 'pending' => false]);
- if (DBM::is_result($r)) {
- $best_url = 'redir/' . $r['id'];
+ $condition = [
+ 'network' => NETWORK_DFRN,
+ 'uid' => local_user(),
+ 'nurl' => normalise_link($clean_url),
+ 'pending' => false
+ ];
+ $contact = dba::selectFirst('contact', ['id'], $condition);
+ if (DBM::is_result($contact)) {
+ $best_url = 'redir/' . $contact['id'];
$sparkle = true;
if ($url != '') {
$hostname = get_app()->get_hostname();
$cid = 0;
$network = '';
$rel = 0;
- $r = dba::selectOne('contact', array('id', 'network', 'rel'), array('uid' => local_user(), 'nurl' => normalise_link($item['author-link'])));
- if (DBM::is_result($r)) {
- $cid = $r['id'];
- $network = $r['network'];
- $rel = $r['rel'];
+ $condition = ['uid' => local_user(), 'nurl' => normalise_link($item['author-link'])];
+ $contact = dba::selectFirst('contact', ['id', 'network', 'rel'], $condition);
+ if (DBM::is_result($contact)) {
+ $cid = $contact['id'];
+ $network = $contact['network'];
+ $rel = $contact['rel'];
}
if ($sparkle) {
$photos_link = $profile_link . '?url=photos';
$profile_link = $profile_link . '?url=profile';
} else {
- $profile_link = zrl($profile_link);
+ $profile_link = Profile::zrl($profile_link);
}
if ($cid && !$item['self']) {
$contact_url = 'contacts/' . $cid;
$posts_link = 'contacts/' . $cid . '/posts';
- if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA))) {
+ if (in_array($network, [NETWORK_DFRN, NETWORK_DIASPORA])) {
$pm_url = 'message/new/' . $cid;
}
}
if (local_user()) {
- $menu = array(
+ $menu = [
t('Follow Thread') => $sub_link,
t('View Status') => $status_link,
t('View Profile') => $profile_link,
t('Network Posts') => $posts_link,
t('View Contact') => $contact_url,
t('Send PM') => $pm_url
- );
+ ];
if ($network == NETWORK_DFRN) {
$menu[t("Poke")] = $poke_link;
}
if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) &&
- in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
+ in_array($item['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
$menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
}
} else {
- $menu = array(t('View Profile') => $item['author-link']);
+ $menu = [t('View Profile') => $item['author-link']];
}
- $args = array('item' => $item, 'menu' => $menu);
+ $args = ['item' => $item, 'menu' => $menu];
call_hooks('item_photo_menu', $args);
$url = 'redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" ';
} else {
- $url = zrl($url);
+ $url = Profile::zrl($url);
}
$url = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))
&& (is_array($conv_responses[$mode][$item['thr-parent'] . '-l'])))) {
- $conv_responses[$mode][$item['thr-parent'] . '-l'] = array();
+ $conv_responses[$mode][$item['thr-parent'] . '-l'] = [];
}
// only list each unique author once
}
$phrase .= EOL ;
- $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array(
+ $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), [
'$phrase' => $phrase,
'$type' => $type,
'$id' => $id
- ));
+ ]);
$o .= $expanded;
return $o;
{
$o = '';
- $geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '';
+ $geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), []) : '';
$tpl = get_markup_template('jot-header.tpl');
- $a->page['htmlhead'] .= replace_macros($tpl, array(
+ $a->page['htmlhead'] .= replace_macros($tpl, [
'$newpost' => 'true',
'$baseurl' => System::baseUrl(true),
'$geotag' => $geotag,
'$fileas' => t('Save to Folder:'),
'$whereareu' => t('Where are you right now?'),
'$delitems' => t('Delete item(s)?')
- ));
+ ]);
$tpl = get_markup_template('jot-end.tpl');
- $a->page['end'] .= replace_macros($tpl, array(
+ $a->page['end'] .= replace_macros($tpl, [
'$newpost' => 'true',
'$baseurl' => System::baseUrl(true),
'$geotag' => $geotag,
'$term' => t('Tag term:'),
'$fileas' => t('Save to Folder:'),
'$whereareu' => t('Where are you right now?')
- ));
+ ]);
$jotplugins = '';
call_hooks('jot_tool', $jotplugins);
$query_str = $a->query_string;
if (strpos($query_str, 'public=1') !== false) {
- $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
+ $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str);
}
/*
// $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$tpl = get_markup_template("jot.tpl");
- $o .= replace_macros($tpl,array(
+ $o .= replace_macros($tpl,[
'$return_path' => $query_str,
'$action' => 'item',
'$share' => defaults($x, 'button', t('Share')),
//jot nav tab (used in some themes)
'$message' => t('Message'),
'$browser' => t('Browser'),
- ));
+ ]);
if ($popup == true) {
/// @TODO Add type-hint
function get_responses($conv_responses, $response_verbs, $ob, $item) {
- $ret = array();
+ $ret = [];
foreach ($response_verbs as $v) {
- $ret[$v] = array();
+ $ret[$v] = [];
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], '');
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', '');
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');