Merge pull request #4243 from MrPetovan/task/switch-to-array-new-style

Use short form array syntax everywhere
This commit is contained in:
Michael Vogel 2018-01-15 22:51:57 +01:00 committed by GitHub
commit 26b335ef3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
212 changed files with 5161 additions and 5161 deletions

View file

@ -288,7 +288,7 @@ define('NETWORK_PHANTOM', 'unkn'); // Place holder
* and existing allocations MUST NEVER BE CHANGED * and existing allocations MUST NEVER BE CHANGED
* OR RE-ASSIGNED! You may only add to them. * OR RE-ASSIGNED! You may only add to them.
*/ */
$netgroup_ids = array( $netgroup_ids = [
NETWORK_DFRN => (-1), NETWORK_DFRN => (-1),
NETWORK_ZOT => (-2), NETWORK_ZOT => (-2),
NETWORK_OSTATUS => (-3), NETWORK_OSTATUS => (-3),
@ -310,7 +310,7 @@ $netgroup_ids = array(
NETWORK_PNUT => (-20), NETWORK_PNUT => (-20),
NETWORK_PHANTOM => (-127), NETWORK_PHANTOM => (-127),
); ];
/** /**
* Maximum number of "people who like (or don't like) this" that we will list by name * Maximum number of "people who like (or don't like) this" that we will list by name
@ -504,7 +504,7 @@ function startup()
ini_set('pcre.backtrack_limit', 500000); ini_set('pcre.backtrack_limit', 500000);
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); $process = [&$_GET, &$_POST, &$_COOKIE, &$_REQUEST];
while (list($key, $val) = each($process)) { while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) { foreach ($val as $k => $v) {
unset($process[$key][$k]); unset($process[$key][$k]);
@ -817,11 +817,11 @@ function check_plugins(App $a)
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$installed = $r; $installed = $r;
} else { } else {
$installed = array(); $installed = [];
} }
$plugins = Config::get('system', 'addon'); $plugins = Config::get('system', 'addon');
$plugins_arr = array(); $plugins_arr = [];
if ($plugins) { if ($plugins) {
$plugins_arr = explode(',', str_replace(' ', '', $plugins)); $plugins_arr = explode(',', str_replace(' ', '', $plugins));
@ -829,7 +829,7 @@ function check_plugins(App $a)
$a->plugins = $plugins_arr; $a->plugins = $plugins_arr;
$installed_arr = array(); $installed_arr = [];
if (count($installed)) { if (count($installed)) {
foreach ($installed as $i) { foreach ($installed as $i) {
@ -966,7 +966,7 @@ function notice($s)
{ {
$a = get_app(); $a = get_app();
if (!x($_SESSION, 'sysmsg')) { if (!x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array(); $_SESSION['sysmsg'] = [];
} }
if ($a->interactive) { if ($a->interactive) {
$_SESSION['sysmsg'][] = $s; $_SESSION['sysmsg'][] = $s;
@ -989,7 +989,7 @@ function info($s)
} }
if (!x($_SESSION, 'sysmsg_info')) { if (!x($_SESSION, 'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array(); $_SESSION['sysmsg_info'] = [];
} }
if ($a->interactive) { if ($a->interactive) {
$_SESSION['sysmsg_info'][] = $s; $_SESSION['sysmsg_info'][] = $s;
@ -1010,7 +1010,7 @@ function get_max_import_size()
function current_theme() function current_theme()
{ {
$app_base_themes = array('duepuntozero', 'dispy', 'quattro'); $app_base_themes = ['duepuntozero', 'dispy', 'quattro'];
$a = get_app(); $a = get_app();
@ -1238,10 +1238,10 @@ function explode_querystring($query)
$args = array_values($args); $args = array_values($args);
} }
return array( return [
'base' => $base, 'base' => $base,
'args' => $args, 'args' => $args,
); ];
} }
/** /**
@ -1571,7 +1571,7 @@ function infinite_scroll_data($module)
$reload_uri .= "&offset=" . urlencode($a->page_offset); $reload_uri .= "&offset=" . urlencode($a->page_offset);
} }
$arr = array("pageno" => $pageno, "reload_uri" => $reload_uri); $arr = ["pageno" => $pageno, "reload_uri" => $reload_uri];
return $arr; return $arr;
} }

View file

@ -86,7 +86,7 @@ $a->config['system']['no_regfullname'] = true;
$a->config['system']['directory'] = 'https://dir.friendica.social'; $a->config['system']['directory'] = 'https://dir.friendica.social';
// Allowed protocols in link URLs; HTTP protocols always are accepted // Allowed protocols in link URLs; HTTP protocols always are accepted
$a->config['system']['allowed_link_protocols'] = array('ftp', 'ftps', 'mailto', 'cid', 'gopher'); $a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher'];
// Authentication cookie lifetime, in days // Authentication cookie lifetime, in days
$a->config['system']['auth_cookie_lifetime'] = 7; $a->config['system']['auth_cookie_lifetime'] = 7;

View file

@ -28,7 +28,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
); );
$arr = array('group' => $r, 'entry' => $o); $arr = ['group' => $r, 'entry' => $o];
// e.g. 'network_pre_group_deny', 'profile_pre_group_allow' // e.g. 'network_pre_group_deny', 'profile_pre_group_allow'
@ -87,20 +87,20 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
if (x($options, 'networks')) { if (x($options, 'networks')) {
switch ($options['networks']) { switch ($options['networks']) {
case 'DFRN_ONLY': case 'DFRN_ONLY':
$networks = array(NETWORK_DFRN); $networks = [NETWORK_DFRN];
break; break;
case 'PRIVATE': case 'PRIVATE':
if (is_array($a->user) && $a->user['prvnets']) { if (is_array($a->user) && $a->user['prvnets']) {
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA); $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
} else { } else {
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA); $networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA];
} }
break; break;
case 'TWO_WAY': case 'TWO_WAY':
if (is_array($a->user) && $a->user['prvnets']) { if (is_array($a->user) && $a->user['prvnets']) {
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA); $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
} else { } else {
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS); $networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS];
} }
break; break;
default: /// @TODO Maybe log this call? default: /// @TODO Maybe log this call?
@ -109,7 +109,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
} }
} }
$x = array('options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks); $x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks];
call_hooks('contact_select_options', $x); call_hooks('contact_select_options', $x);
@ -150,7 +150,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
); );
$arr = array('contact' => $r, 'entry' => $o); $arr = ['contact' => $r, 'entry' => $o];
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
@ -228,13 +228,13 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
); );
$arr = array('contact' => $r, 'entry' => $o); $arr = ['contact' => $r, 'entry' => $o];
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
call_hooks($a->module . '_pre_' . $selname, $arr); call_hooks($a->module . '_pre_' . $selname, $arr);
$receiverlist = array(); $receiverlist = [];
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
@ -270,7 +270,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
function fixacl(&$item) { function fixacl(&$item) {
$item = intval(str_replace(array('<', '>'), array('', ''), $item)); $item = intval(str_replace(['<', '>'], ['', ''], $item));
} }
function prune_deadguys($arr) { function prune_deadguys($arr) {
@ -284,14 +284,14 @@ function prune_deadguys($arr) {
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 "); $r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$ret = array(); $ret = [];
foreach ($r as $rr) { foreach ($r as $rr) {
$ret[] = intval($rr['id']); $ret[] = intval($rr['id']);
} }
return $ret; return $ret;
} }
return array(); return [];
} }
@ -300,13 +300,13 @@ function get_acl_permissions($user = null) {
if (is_array($user)) { if (is_array($user)) {
$allow_cid = ((strlen($user['allow_cid'])) $allow_cid = ((strlen($user['allow_cid']))
? explode('><', $user['allow_cid']) : array() ); ? explode('><', $user['allow_cid']) : [] );
$allow_gid = ((strlen($user['allow_gid'])) $allow_gid = ((strlen($user['allow_gid']))
? explode('><', $user['allow_gid']) : array() ); ? explode('><', $user['allow_gid']) : [] );
$deny_cid = ((strlen($user['deny_cid'])) $deny_cid = ((strlen($user['deny_cid']))
? explode('><', $user['deny_cid']) : array() ); ? explode('><', $user['deny_cid']) : [] );
$deny_gid = ((strlen($user['deny_gid'])) $deny_gid = ((strlen($user['deny_gid']))
? explode('><', $user['deny_gid']) : array() ); ? explode('><', $user['deny_gid']) : [] );
array_walk($allow_cid,'fixacl'); array_walk($allow_cid,'fixacl');
array_walk($allow_gid,'fixacl'); array_walk($allow_gid,'fixacl');
array_walk($deny_cid,'fixacl'); array_walk($deny_cid,'fixacl');
@ -315,12 +315,12 @@ function get_acl_permissions($user = null) {
$allow_cid = prune_deadguys($allow_cid); $allow_cid = prune_deadguys($allow_cid);
return array( return [
'allow_cid' => $allow_cid, 'allow_cid' => $allow_cid,
'allow_gid' => $allow_gid, 'allow_gid' => $allow_gid,
'deny_cid' => $deny_cid, 'deny_cid' => $deny_cid,
'deny_gid' => $deny_gid, 'deny_gid' => $deny_gid,
); ];
} }
@ -361,7 +361,7 @@ function populate_acl($user = null, $show_jotnets = false) {
} }
$tpl = get_markup_template("acl_selector.tpl"); $tpl = get_markup_template("acl_selector.tpl");
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$showall'=> t("Visible to everybody"), '$showall'=> t("Visible to everybody"),
'$show' => t("show"), '$show' => t("show"),
'$hide' => t("don't show"), '$hide' => t("don't show"),
@ -375,10 +375,10 @@ function populate_acl($user = null, $show_jotnets = false) {
'$jotnets' => $jotnets, '$jotnets' => $jotnets,
'$aclModalTitle' => t('Permissions'), '$aclModalTitle' => t('Permissions'),
'$aclModalDismiss' => t('Close'), '$aclModalDismiss' => t('Close'),
'$features' => array( '$features' => [
'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "false") 'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "false")
), ],
)); ]);
return $o; return $o;
@ -475,8 +475,8 @@ function acl_lookup(App $a, $out_type = 'json')
$tot = $group_count + $contact_count; $tot = $group_count + $contact_count;
$groups = array(); $groups = [];
$contacts = array(); $contacts = [];
if ($type == '' || $type == 'g') { if ($type == '' || $type == 'g') {
/// @todo We should cache this query. /// @todo We should cache this query.
@ -495,7 +495,7 @@ function acl_lookup(App $a, $out_type = 'json')
); );
foreach ($r as $g) { foreach ($r as $g) {
$groups[] = array( $groups[] = [
"type" => "g", "type" => "g",
"photo" => "images/twopeople.png", "photo" => "images/twopeople.png",
"name" => htmlentities($g['name']), "name" => htmlentities($g['name']),
@ -503,10 +503,10 @@ function acl_lookup(App $a, $out_type = 'json')
"uids" => array_map("intval", explode(",",$g['uids'])), "uids" => array_map("intval", explode(",",$g['uids'])),
"link" => '', "link" => '',
"forum" => '0' "forum" => '0'
); ];
} }
if ((count($groups) > 0) && ($search == "")) { if ((count($groups) > 0) && ($search == "")) {
$groups[] = array("separator" => true); $groups[] = ["separator" => true];
} }
} }
@ -558,34 +558,34 @@ function acl_lookup(App $a, $out_type = 'json')
} elseif ($type == 'x') { } elseif ($type == 'x') {
// autocomplete for global contact search (e.g. navbar search) // autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a); $r = navbar_complete($a);
$contacts = array(); $contacts = [];
if ($r) { if ($r) {
foreach ($r as $g) { foreach ($r as $g) {
$contacts[] = array( $contacts[] = [
'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
'name' => $g['name'], 'name' => $g['name'],
'nick' => (x($g['addr']) ? $g['addr'] : $g['url']), 'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
'network' => $g['network'], 'network' => $g['network'],
'link' => $g['url'], 'link' => $g['url'],
'forum' => (x($g['community']) ? 1 : 0), 'forum' => (x($g['community']) ? 1 : 0),
); ];
} }
} }
$o = array( $o = [
'start' => $start, 'start' => $start,
'count' => $count, 'count' => $count,
'items' => $contacts, 'items' => $contacts,
); ];
echo json_encode($o); echo json_encode($o);
killme(); killme();
} else { } else {
$r = array(); $r = [];
} }
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$forums = array(); $forums = [];
foreach ($r as $g) { foreach ($r as $g) {
$entry = array( $entry = [
'type' => 'c', 'type' => 'c',
'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
'name' => htmlentities($g['name']), 'name' => htmlentities($g['name']),
@ -595,7 +595,7 @@ function acl_lookup(App $a, $out_type = 'json')
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']), 'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']), 'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']),
'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0), 'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0),
); ];
if ($entry['forum']) { if ($entry['forum']) {
$forums[] = $entry; $forums[] = $entry;
} else { } else {
@ -604,7 +604,7 @@ function acl_lookup(App $a, $out_type = 'json')
} }
if (count($forums) > 0) { if (count($forums) > 0) {
if ($search == "") { if ($search == "") {
$forums[] = array("separator" => true); $forums[] = ["separator" => true];
} }
$contacts = array_merge($forums, $contacts); $contacts = array_merge($forums, $contacts);
} }
@ -623,7 +623,7 @@ function acl_lookup(App $a, $out_type = 'json')
} }
, $contacts); , $contacts);
$unknown_contacts = array(); $unknown_contacts = [];
$r = q("SELECT `author-link` $r = q("SELECT `author-link`
FROM `item` WHERE `parent` = %d FROM `item` WHERE `parent` = %d
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%') AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
@ -641,7 +641,7 @@ function acl_lookup(App $a, $out_type = 'json')
$contact = Contact::getDetailsByURL($row['author-link']); $contact = Contact::getDetailsByURL($row['author-link']);
if (count($contact) > 0) { if (count($contact) > 0) {
$unknown_contacts[] = array( $unknown_contacts[] = [
'type' => 'c', 'type' => 'c',
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO), 'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
'name' => htmlentities($contact['name']), 'name' => htmlentities($contact['name']),
@ -651,7 +651,7 @@ function acl_lookup(App $a, $out_type = 'json')
'nick' => htmlentities($contact['nick'] ? : $contact['addr']), 'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']), 'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']),
'forum' => $contact['forum'] 'forum' => $contact['forum']
); ];
} }
} }
} }
@ -660,7 +660,7 @@ function acl_lookup(App $a, $out_type = 'json')
$tot += count($unknown_contacts); $tot += count($unknown_contacts);
} }
$results = array( $results = [
'tot' => $tot, 'tot' => $tot,
'start' => $start, 'start' => $start,
'count' => $count, 'count' => $count,
@ -669,27 +669,27 @@ function acl_lookup(App $a, $out_type = 'json')
'items' => $items, 'items' => $items,
'type' => $type, 'type' => $type,
'search' => $search, 'search' => $search,
); ];
call_hooks('acl_lookup_end', $results); call_hooks('acl_lookup_end', $results);
if ($out_type === 'html') { if ($out_type === 'html') {
$o = array( $o = [
'tot' => $results['tot'], 'tot' => $results['tot'],
'start' => $results['start'], 'start' => $results['start'],
'count' => $results['count'], 'count' => $results['count'],
'groups' => $results['groups'], 'groups' => $results['groups'],
'contacts' => $results['contacts'], 'contacts' => $results['contacts'],
); ];
return $o; return $o;
} }
$o = array( $o = [
'tot' => $results['tot'], 'tot' => $results['tot'],
'start' => $results['start'], 'start' => $results['start'],
'count' => $results['count'], 'count' => $results['count'],
'items' => $results['items'], 'items' => $results['items'],
); ];
echo json_encode($o); echo json_encode($o);
@ -717,7 +717,7 @@ function navbar_complete(App $a) {
// don't search if search term has less than 2 characters // don't search if search term has less than 2 characters
if (! $search || mb_strlen($search) < 2) { if (! $search || mb_strlen($search) < 2) {
return array(); return [];
} }
if (substr($search,0,1) === '@') { if (substr($search,0,1) === '@') {

File diff suppressed because it is too large Load diff

View file

@ -51,7 +51,7 @@ function diaspora2bb($s) {
$s = preg_replace('/^([^\*]+)\*([^\*]*)$/im', '$1\*$2', $s); $s = preg_replace('/^([^\*]+)\*([^\*]*)$/im', '$1\*$2', $s);
// The parser cannot handle paragraphs correctly // The parser cannot handle paragraphs correctly
$s = str_replace(array('</p>', '<p>', '<p dir="ltr">'), array('<br>', '<br>', '<br>'), $s); $s = str_replace(['</p>', '<p>', '<p dir="ltr">'], ['<br>', '<br>', '<br>'], $s);
// Escaping the hash tags // Escaping the hash tags
$s = preg_replace('/\#([^\s\#])/', '&#35;$1', $s); $s = preg_replace('/\#([^\s\#])/', '&#35;$1', $s);
@ -178,11 +178,11 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
} }
// mask some special HTML chars from conversation to markdown // mask some special HTML chars from conversation to markdown
$Text = str_replace(array('&lt;', '&gt;', '&amp;'), array('&_lt_;', '&_gt_;', '&_amp_;'), $Text); $Text = str_replace(['&lt;', '&gt;', '&amp;'], ['&_lt_;', '&_gt_;', '&_amp_;'], $Text);
// If a link is followed by a quote then there should be a newline before it // If a link is followed by a quote then there should be a newline before it
// Maybe we should make this newline at every time before a quote. // Maybe we should make this newline at every time before a quote.
$Text = str_replace(array("</a><blockquote>"), array("</a><br><blockquote>"), $Text); $Text = str_replace(["</a><blockquote>"], ["</a><br><blockquote>"], $Text);
$stamp1 = microtime(true); $stamp1 = microtime(true);
@ -191,12 +191,12 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
$Text = $converter->convert($Text); $Text = $converter->convert($Text);
// unmask the special chars back to HTML // unmask the special chars back to HTML
$Text = str_replace(array('&\_lt\_;', '&\_gt\_;', '&\_amp\_;'), array('&lt;', '&gt;', '&amp;'), $Text); $Text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['&lt;', '&gt;', '&amp;'], $Text);
$a->save_timestamp($stamp1, "parser"); $a->save_timestamp($stamp1, "parser");
// Libertree has a problem with escaped hashtags. // Libertree has a problem with escaped hashtags.
$Text = str_replace(array('\#'), array('#'), $Text); $Text = str_replace(['\#'], ['#'], $Text);
// Remove any leading or trailing whitespace, as this will mess up // Remove any leading or trailing whitespace, as this will mess up
// the Diaspora signature verification and cause the item to disappear // the Diaspora signature verification and cause the item to disappear

View file

@ -60,7 +60,7 @@ function bb_attachment($return, $simplehtml = false, $tryoembed = true)
if (isset($data["title"])) { if (isset($data["title"])) {
$data["title"] = strip_tags($data["title"]); $data["title"] = strip_tags($data["title"]);
$data["title"] = str_replace(array("http://", "https://"), "", $data["title"]); $data["title"] = str_replace(["http://", "https://"], "", $data["title"]);
} }
if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && ($data["image"] != "")) { if (((strpos($data["text"], "[img=") !== false) || (strpos($data["text"], "[img]") !== false) || Config::get('system', 'always_show_preview')) && ($data["image"] != "")) {
@ -280,7 +280,7 @@ function bb_find_open_close($s, $open, $close, $occurence = 1) {
return false; return false;
} }
$res = array( 'start' => $start_pos, 'end' => $end_pos ); $res = [ 'start' => $start_pos, 'end' => $end_pos ];
return $res; return $res;
} }
@ -316,16 +316,16 @@ function get_bb_tag_pos($s, $name, $occurence = 1) {
return false; return false;
} }
$res = array( $res = [
'start' => array( 'start' => [
'open' => $start_open, 'open' => $start_open,
'close' => $start_close 'close' => $start_close
), ],
'end' => array( 'end' => [
'open' => $end_open, 'open' => $end_open,
'close' => $end_open + strlen('[/' . $name . ']') 'close' => $end_open + strlen('[/' . $name . ']')
), ],
); ];
if ($start_equal !== false) { if ($start_equal !== false) {
$res['start']['equal'] = $start_equal + 1; $res['start']['equal'] = $start_equal + 1;
@ -360,7 +360,7 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) {
function bb_extract_images($body) { function bb_extract_images($body) {
$saved_image = array(); $saved_image = [];
$orig_body = $body; $orig_body = $body;
$new_body = ''; $new_body = '';
@ -398,7 +398,7 @@ function bb_extract_images($body) {
$new_body = $new_body . $orig_body; $new_body = $new_body . $orig_body;
return array('body' => $new_body, 'images' => $saved_image); return ['body' => $new_body, 'images' => $saved_image];
} }
function bb_replace_images($body, $images) { function bb_replace_images($body, $images) {
@ -595,14 +595,14 @@ function bb_ShareAttributes($share, $simplehtml)
$avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB); $avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB);
$tpl = get_markup_template('shared_content.tpl'); $tpl = get_markup_template('shared_content.tpl');
$text .= replace_macros($tpl, array( $text .= replace_macros($tpl, [
'$profile' => $profile, '$profile' => $profile,
'$avatar' => $avatar, '$avatar' => $avatar,
'$author' => $author, '$author' => $author,
'$link' => $link, '$link' => $link,
'$posted' => $posted, '$posted' => $posted,
'$content' => trim($share[3]) '$content' => trim($share[3])
)); ]);
} }
break; break;
} }
@ -752,7 +752,7 @@ function bb_RemovePictureLinks($match) {
$xpath = new DomXPath($doc); $xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]"); $list = $xpath->query("//meta[@name]");
foreach ($list as $node) { foreach ($list as $node) {
$attr = array(); $attr = [];
if ($node->attributes->length) if ($node->attributes->length)
foreach ($node->attributes as $attribute) foreach ($node->attributes as $attribute)
@ -809,7 +809,7 @@ function bb_CleanPictureLinksSub($match) {
$xpath = new DomXPath($doc); $xpath = new DomXPath($doc);
$list = $xpath->query("//meta[@name]"); $list = $xpath->query("//meta[@name]");
foreach ($list as $node) { foreach ($list as $node) {
$attr = array(); $attr = [];
if ($node->attributes->length) if ($node->attributes->length)
foreach ($node->attributes as $attribute) foreach ($node->attributes as $attribute)
@ -951,10 +951,10 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// removing multiplicated newlines // removing multiplicated newlines
if (Config::get("system", "remove_multiplicated_lines")) { if (Config::get("system", "remove_multiplicated_lines")) {
$search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n", $search = ["\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]", "[/li]\n", "\n[li]", "\n[ul]", "[/ul]\n", "\n\n[share ", "[/attachment]\n",
"\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"); "\n[h1]", "[/h1]\n", "\n[h2]", "[/h2]\n", "\n[h3]", "[/h3]\n", "\n[h4]", "[/h4]\n", "\n[h5]", "[/h5]\n", "\n[h6]", "[/h6]\n"];
$replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]", $replace = ["\n\n", "\n", "\n", "[/quote]\n", "[/quote]", "[/li]", "[li]", "[ul]", "[/ul]", "\n[share ", "[/attachment]",
"[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]"); "[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]"];
do { do {
$oldtext = $Text; $oldtext = $Text;
$Text = str_replace($search, $replace, $Text); $Text = str_replace($search, $replace, $Text);
@ -986,14 +986,14 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
// Handle attached links or videos // Handle attached links or videos
$Text = bb_attachment($Text, $simplehtml, $tryoembed); $Text = bb_attachment($Text, $simplehtml, $tryoembed);
$Text = str_replace(array("\r","\n"), array('<br />', '<br />'), $Text); $Text = str_replace(["\r","\n"], ['<br />', '<br />'], $Text);
if ($preserve_nl) { if ($preserve_nl) {
$Text = str_replace(array("\n", "\r"), array('', ''), $Text); $Text = str_replace(["\n", "\r"], ['', ''], $Text);
} }
// Remove all hashtag addresses // Remove all hashtag addresses
if ((!$tryoembed || $simplehtml) && !in_array($simplehtml, array(3, 7))) { if ((!$tryoembed || $simplehtml) && !in_array($simplehtml, [3, 7])) {
$Text = preg_replace("/([#@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text); $Text = preg_replace("/([#@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
} elseif ($simplehtml == 3) { } elseif ($simplehtml == 3) {
$Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
@ -1015,7 +1015,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$Text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i", $Text = preg_replace("/#\[url\=[$URLSearchString]*\]\^\[\/url\]\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/i",
"[bookmark=$1]$2[/bookmark]", $Text); "[bookmark=$1]$2[/bookmark]", $Text);
if (in_array($simplehtml, array(2, 6, 7, 8, 9))) { if (in_array($simplehtml, [2, 6, 7, 8, 9])) {
$Text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "bb_expand_links", $Text); $Text = preg_replace_callback("/([^#@!])\[url\=([^\]]*)\](.*?)\[\/url\]/ism", "bb_expand_links", $Text);
//$Text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $Text); //$Text = preg_replace("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/ism", ' $2 [url]$1[/url]', $Text);
$Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]',$Text); $Text = preg_replace("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", ' $2 [url]$1[/url]',$Text);
@ -1353,13 +1353,13 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
$Text = preg_replace('/\<([^>]*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism', '<$1$2=$3&$4>', $Text); $Text = preg_replace('/\<([^>]*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism', '<$1$2=$3&$4>', $Text);
// sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails) // sanitizes src attributes (http and redir URLs for displaying in a web page, cid used for inline images in emails)
static $allowed_src_protocols = array('http', 'redir', 'cid'); static $allowed_src_protocols = ['http', 'redir', 'cid'];
$Text = preg_replace('#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism', $Text = preg_replace('#<([^>]*?)(src)="(?!' . implode('|', $allowed_src_protocols) . ')(.*?)"(.*?)>#ism',
'<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . t('Invalid source protocol') . '">', $Text); '<$1$2=""$4 data-original-src="$3" class="invalid-src" title="' . t('Invalid source protocol') . '">', $Text);
// sanitize href attributes (only whitelisted protocols URLs) // sanitize href attributes (only whitelisted protocols URLs)
// default value for backward compatibility // default value for backward compatibility
$allowed_link_protocols = Config::get('system', 'allowed_link_protocols', array('ftp', 'mailto', 'gopher', 'cid')); $allowed_link_protocols = Config::get('system', 'allowed_link_protocols', ['ftp', 'mailto', 'gopher', 'cid']);
// Always allowed protocol even if config isn't set or not including it // Always allowed protocol even if config isn't set or not including it
$allowed_link_protocols[] = 'http'; $allowed_link_protocols[] = 'http';
@ -1386,7 +1386,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
@$doc->loadHTML($encoding.$doctype."<html><body>".$Text."</body></html>"); @$doc->loadHTML($encoding.$doctype."<html><body>".$Text."</body></html>");
$doc->encoding = 'UTF-8'; $doc->encoding = 'UTF-8';
$Text = $doc->saveHTML(); $Text = $doc->saveHTML();
$Text = str_replace(array("<html><body>", "</body></html>", $doctype, $encoding), array("", "", "", ""), $Text); $Text = str_replace(["<html><body>", "</body></html>", $doctype, $encoding], ["", "", "", ""], $Text);
$Text = str_replace('<br></li>', '</li>', $Text); $Text = str_replace('<br></li>', '</li>', $Text);
@ -1427,7 +1427,7 @@ function remove_abstract($text) {
*/ */
function fetch_abstract($text, $addon = "") { function fetch_abstract($text, $addon = "") {
$abstract = ""; $abstract = "";
$abstracts = array(); $abstracts = [];
$addon = strtolower($addon); $addon = strtolower($addon);
if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism",$text, $results, PREG_SET_ORDER)) if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism",$text, $results, PREG_SET_ORDER))

View file

@ -19,7 +19,7 @@ require_once "include/acl_selectors.php";
function item_extract_images($body) { function item_extract_images($body) {
$saved_image = array(); $saved_image = [];
$orig_body = $body; $orig_body = $body;
$new_body = ''; $new_body = '';
@ -57,7 +57,7 @@ function item_extract_images($body) {
$new_body = $new_body . $orig_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) { function item_redir_and_replace_images($body, $images, $cid) {
@ -145,7 +145,7 @@ function localize_item(&$item) {
default: default:
if ($obj['resource-id']) { if ($obj['resource-id']) {
$post_type = t('photo'); $post_type = t('photo');
$m = array(); $m = [];
preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1]; $rr['plink'] = $m[1];
} else { } else {
@ -283,7 +283,7 @@ function localize_item(&$item) {
default: default:
if ($obj['resource-id']) { if ($obj['resource-id']) {
$post_type = t('photo'); $post_type = t('photo');
$m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); $m=[]; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
$rr['plink'] = $m[1]; $rr['plink'] = $m[1];
} else { } else {
$post_type = t('status'); $post_type = t('status');
@ -382,7 +382,7 @@ function visible_activity($item) {
* likes (etc.) can apply to other things besides posts. Check if they are post children, * likes (etc.) can apply to other things besides posts. Check if they are post children,
* in which case we handle them specially * 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) { foreach ($hidden_activities as $act) {
if (activity_match($item['verb'], $act)) { if (activity_match($item['verb'], $act)) {
return false; return false;
@ -595,18 +595,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$_SESSION['return_url'] = $a->query_string; $_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); call_hooks('conversation_start',$cb);
$items = $cb['items']; $items = $cb['items'];
$conv_responses = array( $conv_responses = [
'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','title')), 'like' => ['title' => t('Likes','title')], 'dislike' => ['title' => t('Dislikes','title')],
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','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) // array with html for each thread (parent+comments)
$threads = array(); $threads = [];
$threadsid = -1; $threadsid = -1;
$page_template = get_markup_template("conversation.tpl"); $page_template = get_markup_template("conversation.tpl");
@ -620,7 +620,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$community_readonly = false; $community_readonly = false;
$writable = true; $writable = true;
} else { } 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 { } else {
$writable = false; $writable = false;
@ -673,15 +673,15 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$profile_name = $item['author-link']; $profile_name = $item['author-link'];
} }
$tags = array(); $tags = [];
$hashtags = array(); $hashtags = [];
$mentions = array(); $mentions = [];
$searchpath = System::baseUrl()."/search?tag="; $searchpath = System::baseUrl()."/search?tag=";
$taglist = dba::select('term', array('type', 'term', 'url'), $taglist = dba::select('term', ['type', 'term', 'url'],
array("`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION), ["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION],
array('order' => array('tid'))); ['order' => ['tid']]);
while ($tag = dba::fetch($taglist)) { while ($tag = dba::fetch($taglist)) {
if ($tag["url"] == "") { if ($tag["url"] == "") {
@ -731,7 +731,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
} }
} }
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => ''); $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
call_hooks('render_location',$locate); call_hooks('render_location',$locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
@ -743,12 +743,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$dropping = false; $dropping = false;
} }
$drop = array( $drop = [
'dropping' => $dropping, 'dropping' => $dropping,
'pagedrop' => $page_dropping, 'pagedrop' => $page_dropping,
'select' => t('Select'), 'select' => t('Select'),
'delete' => t('Delete'), 'delete' => t('Delete'),
); ];
$star = false; $star = false;
$isstarred = "unstarred"; $isstarred = "unstarred";
@ -773,7 +773,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$item['item_network'] = $item['network']; $item['item_network'] = $item['network'];
} }
$tmp_item = array( $tmp_item = [
'template' => $tpl, 'template' => $tpl,
'id' => (($preview) ? 'P0' : $item['item_id']), 'id' => (($preview) ? 'P0' : $item['item_id']),
'guid' => (($preview) ? 'Q0' : $item['guid']), 'guid' => (($preview) ? 'Q0' : $item['guid']),
@ -814,18 +814,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'like' => '', 'like' => '',
'dislike' => '', 'dislike' => '',
'comment' => '', '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, 'previewing' => $previewing,
'wait' => t('Please wait'), 'wait' => t('Please wait'),
'thread_level' => 1, 'thread_level' => 1,
); ];
$arr = array('item' => $item, 'output' => $tmp_item); $arr = ['item' => $item, 'output' => $tmp_item];
call_hooks('display_item', $arr); call_hooks('display_item', $arr);
$threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['id'] = $item['item_id'];
$threads[$threadsid]['network'] = $item['item_network']; $threads[$threadsid]['network'] = $item['item_network'];
$threads[$threadsid]['items'] = array($arr['output']); $threads[$threadsid]['items'] = [$arr['output']];
} }
} else { } else {
@ -878,12 +878,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$threads = $conv->getTemplateData($conv_responses); $threads = $conv->getTemplateData($conv_responses);
if (!$threads) { if (!$threads) {
logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); 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), '$baseurl' => System::baseUrl($ssl_state),
'$return_path' => $a->query_string, '$return_path' => $a->query_string,
'$live_update' => $live_update_div, '$live_update' => $live_update_div,
@ -892,7 +892,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'$user' => $a->user, '$user' => $a->user,
'$threads' => $threads, '$threads' => $threads,
'$dropping' => ($page_dropping && Feature::isEnabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False), '$dropping' => ($page_dropping && Feature::isEnabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False),
)); ]);
return $o; return $o;
} }
@ -910,7 +910,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
function community_add_items($parents) { function community_add_items($parents) {
$max_comments = Config::get("system", "max_comments", 100); $max_comments = Config::get("system", "max_comments", 100);
$items = array(); $items = [];
foreach ($parents AS $parent) { foreach ($parents AS $parent) {
$thread_items = dba::p(item_query()." AND `item`.`uid` = ? $thread_items = dba::p(item_query()." AND `item`.`uid` = ?
@ -932,7 +932,7 @@ function community_add_items($parents) {
} }
} }
if (!$parent_found) { if (!$parent_found) {
$comments = array(); $comments = [];
} }
} }
@ -1046,13 +1046,13 @@ function item_photo_menu($item) {
$contact_url = 'contacts/' . $cid; $contact_url = 'contacts/' . $cid;
$posts_link = 'contacts/' . $cid . '/posts'; $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; $pm_url = 'message/new/' . $cid;
} }
} }
if (local_user()) { if (local_user()) {
$menu = array( $menu = [
t('Follow Thread') => $sub_link, t('Follow Thread') => $sub_link,
t('View Status') => $status_link, t('View Status') => $status_link,
t('View Profile') => $profile_link, t('View Profile') => $profile_link,
@ -1060,21 +1060,21 @@ function item_photo_menu($item) {
t('Network Posts') => $posts_link, t('Network Posts') => $posts_link,
t('View Contact') => $contact_url, t('View Contact') => $contact_url,
t('Send PM') => $pm_url t('Send PM') => $pm_url
); ];
if ($network == NETWORK_DFRN) { if ($network == NETWORK_DFRN) {
$menu[t("Poke")] = $poke_link; $menu[t("Poke")] = $poke_link;
} }
if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) && 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']); $menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']);
} }
} else { } 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); call_hooks('item_photo_menu', $args);
@ -1142,7 +1142,7 @@ function builtin_activity_puller($item, &$conv_responses) {
if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l'])) if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l']))
&& (is_array($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 // only list each unique author once
@ -1250,11 +1250,11 @@ function format_like($cnt, array $arr, $type, $id) {
} }
$phrase .= EOL ; $phrase .= EOL ;
$o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array( $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), [
'$phrase' => $phrase, '$phrase' => $phrase,
'$type' => $type, '$type' => $type,
'$id' => $id '$id' => $id
)); ]);
$o .= $expanded; $o .= $expanded;
return $o; return $o;
@ -1264,10 +1264,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
{ {
$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'); $tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, [
'$newpost' => 'true', '$newpost' => 'true',
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$geotag' => $geotag, '$geotag' => $geotag,
@ -1280,10 +1280,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$fileas' => t('Save to Folder:'), '$fileas' => t('Save to Folder:'),
'$whereareu' => t('Where are you right now?'), '$whereareu' => t('Where are you right now?'),
'$delitems' => t('Delete item(s)?') '$delitems' => t('Delete item(s)?')
)); ]);
$tpl = get_markup_template('jot-end.tpl'); $tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, [
'$newpost' => 'true', '$newpost' => 'true',
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$geotag' => $geotag, '$geotag' => $geotag,
@ -1295,7 +1295,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$term' => t('Tag term:'), '$term' => t('Tag term:'),
'$fileas' => t('Save to Folder:'), '$fileas' => t('Save to Folder:'),
'$whereareu' => t('Where are you right now?') '$whereareu' => t('Where are you right now?')
)); ]);
$jotplugins = ''; $jotplugins = '';
call_hooks('jot_tool', $jotplugins); call_hooks('jot_tool', $jotplugins);
@ -1308,7 +1308,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
$query_str = $a->query_string; $query_str = $a->query_string;
if (strpos($query_str, 'public=1') !== false) { 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);
} }
/* /*
@ -1325,7 +1325,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
// $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); // $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$tpl = get_markup_template("jot.tpl"); $tpl = get_markup_template("jot.tpl");
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$return_path' => $query_str, '$return_path' => $query_str,
'$action' => 'item', '$action' => 'item',
'$share' => defaults($x, 'button', t('Share')), '$share' => defaults($x, 'button', t('Share')),
@ -1379,7 +1379,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
//jot nav tab (used in some themes) //jot nav tab (used in some themes)
'$message' => t('Message'), '$message' => t('Message'),
'$browser' => t('Browser'), '$browser' => t('Browser'),
)); ]);
if ($popup == true) { if ($popup == true) {
@ -1636,9 +1636,9 @@ function render_location_dummy($item) {
/// @TODO Add type-hint /// @TODO Add type-hint
function get_responses($conv_responses, $response_verbs, $ob, $item) { function get_responses($conv_responses, $response_verbs, $ob, $item) {
$ret = array(); $ret = [];
foreach ($response_verbs as $v) { foreach ($response_verbs as $v) {
$ret[$v] = array(); $ret[$v] = [];
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], ''); $ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], '');
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', ''); $ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', '');
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0'); $ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');

View file

@ -102,9 +102,9 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
$options = str_replace('</select>','', $options); $options = str_replace('</select>','', $options);
$tpl = get_markup_template('field_select_raw.tpl'); $tpl = get_markup_template('field_select_raw.tpl');
return replace_macros($tpl, array( return replace_macros($tpl, [
'$field' => array($name, $label, $current, $help, $options), '$field' => [$name, $label, $current, $help, $options],
)); ]);
} }
@ -189,16 +189,16 @@ function dob($dob)
$age = ((intval($value)) ? age($value, $a->user["timezone"], $a->user["timezone"]) : ""); $age = ((intval($value)) ? age($value, $a->user["timezone"], $a->user["timezone"]) : "");
$o = replace_macros(get_markup_template("field_input.tpl"), array( $o = replace_macros(get_markup_template("field_input.tpl"), [
'$field' => array( '$field' => [
'dob', 'dob',
t('Birthday:'), t('Birthday:'),
$value, $value,
(((intval($age)) > 0 ) ? t('Age: ') . $age : ""), (((intval($age)) > 0 ) ? t('Age: ') . $age : ""),
'', '',
'placeholder="' . t('YYYY-MM-DD or MM-DD') . '"' 'placeholder="' . t('YYYY-MM-DD or MM-DD') . '"'
) ]
)); ]);
/// @TODO Old-lost code? /// @TODO Old-lost code?
// if ($dob && $dob > '0001-01-01') // if ($dob && $dob > '0001-01-01')
@ -279,7 +279,7 @@ function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pick
$lang = substr(get_browser_language(), 0, 2); $lang = substr(get_browser_language(), 0, 2);
// Check if the detected language is supported by the picker // Check if the detected language is supported by the picker
if (!in_array($lang, array("ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu"))) { if (!in_array($lang, ["ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu"])) {
$lang = Config::get('system', 'language', 'en'); $lang = Config::get('system', 'language', 'en');
} }
@ -327,9 +327,9 @@ function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pick
$readable_format = str_replace('i','MM',$readable_format); $readable_format = str_replace('i','MM',$readable_format);
$tpl = get_markup_template('field_input.tpl'); $tpl = get_markup_template('field_input.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$field' => array($id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'), '$field' => [$id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'],
)); ]);
$o .= "<script type='text/javascript'>"; $o .= "<script type='text/javascript'>";
$o .= "\$(function () {var picker = \$('#id_$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})"; $o .= "\$(function () {var picker = \$('#id_$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
@ -368,14 +368,14 @@ function relative_date($posted_date, $format = null) {
return t('less than a second ago'); return t('less than a second ago');
} }
$a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')), $a = [ 12 * 30 * 24 * 60 * 60 => [ t('year'), t('years')],
30 * 24 * 60 * 60 => array( t('month'), t('months')), 30 * 24 * 60 * 60 => [ t('month'), t('months')],
7 * 24 * 60 * 60 => array( t('week'), t('weeks')), 7 * 24 * 60 * 60 => [ t('week'), t('weeks')],
24 * 60 * 60 => array( t('day'), t('days')), 24 * 60 * 60 => [ t('day'), t('days')],
60 * 60 => array( t('hour'), t('hours')), 60 * 60 => [ t('hour'), t('hours')],
60 => array( t('minute'), t('minutes')), 60 => [ t('minute'), t('minutes')],
1 => array( t('second'), t('seconds')) 1 => [ t('second'), t('seconds')]
); ];
foreach ($a as $secs => $str) { foreach ($a as $secs => $str) {
$d = $etime / $secs; $d = $etime / $secs;
@ -449,9 +449,9 @@ function age($dob, $owner_tz = '', $viewer_tz = '') {
*/ */
function get_dim($y, $m) { function get_dim($y, $m) {
$dim = array( 0, $dim = [ 0,
31, 28, 31, 30, 31, 30, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31); 31, 31, 30, 31, 30, 31];
if ($m != 2) { if ($m != 2) {
return $dim[$m]; return $dim[$m];
@ -498,12 +498,12 @@ function get_first_dim($y,$m) {
function cal($y = 0, $m = 0, $links = null, $class = '') function cal($y = 0, $m = 0, $links = null, $class = '')
{ {
// month table - start at 1 to match human usage. // month table - start at 1 to match human usage.
$mtab = array(' ', $mtab = [' ',
'January', 'February', 'March', 'January', 'February', 'March',
'April' , 'May' , 'June', 'April' , 'May' , 'June',
'July' , 'August' , 'September', 'July' , 'August' , 'September',
'October', 'November', 'December' 'October', 'November', 'December'
); ];
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y'); $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm'); $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
@ -515,7 +515,7 @@ function cal($y = 0, $m = 0, $links = null, $class = '')
$m = intval($thismonth); $m = intval($thismonth);
} }
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); $dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
$f = get_first_dim($y, $m); $f = get_first_dim($y, $m);
$l = get_dim($y, $m); $l = get_dim($y, $m);
$d = 1; $d = 1;

View file

@ -21,7 +21,7 @@ class dba {
private static $errorno = 0; private static $errorno = 0;
private static $affected_rows = 0; private static $affected_rows = 0;
private static $in_transaction = false; private static $in_transaction = false;
private static $relation = array(); private static $relation = [];
public static function connect($serveraddr, $user, $pass, $db, $install = false) { public static function connect($serveraddr, $user, $pass, $db, $install = false) {
if (!is_null(self::$db)) { if (!is_null(self::$db)) {
@ -157,7 +157,7 @@ class dba {
} }
// Only do the explain on "select", "update" and "delete" // Only do the explain on "select", "update" and "delete"
if (!in_array(strtolower(substr($query, 0, 6)), array("select", "update", "delete"))) { if (!in_array(strtolower(substr($query, 0, 6)), ["select", "update", "delete"])) {
return; return;
} }
@ -253,8 +253,8 @@ class dba {
* @return string The input SQL string modified if necessary. * @return string The input SQL string modified if necessary.
*/ */
public static function clean_query($sql) { public static function clean_query($sql) {
$search = array("\t", "\n", "\r", " "); $search = ["\t", "\n", "\r", " "];
$replace = array(' ', ' ', ' ', ' '); $replace = [' ', ' ', ' ', ' '];
do { do {
$oldsql = $sql; $oldsql = $sql;
$sql = str_replace($search, $replace, $sql); $sql = str_replace($search, $replace, $sql);
@ -324,7 +324,7 @@ class dba {
// Renumber the array keys to be sure that they fit // Renumber the array keys to be sure that they fit
$i = 0; $i = 0;
$args = array(); $args = [];
foreach ($params AS $param) { foreach ($params AS $param) {
// Avoid problems with some MySQL servers and boolean values. See issue #3645 // Avoid problems with some MySQL servers and boolean values. See issue #3645
if (is_bool($param)) { if (is_bool($param)) {
@ -408,7 +408,7 @@ class dba {
// There are SQL statements that cannot be executed with a prepared statement // There are SQL statements that cannot be executed with a prepared statement
$parts = explode(' ', $orig_sql); $parts = explode(' ', $orig_sql);
$command = strtolower($parts[0]); $command = strtolower($parts[0]);
$can_be_prepared = in_array($command, array('select', 'update', 'insert', 'delete')); $can_be_prepared = in_array($command, ['select', 'update', 'insert', 'delete']);
// The fallback routine is called as well when there are no arguments // The fallback routine is called as well when there are no arguments
if (!$can_be_prepared || (count($args) == 0)) { if (!$can_be_prepared || (count($args) == 0)) {
@ -437,7 +437,7 @@ class dba {
} }
$params = ''; $params = '';
$values = array(); $values = [];
foreach ($args AS $param => $value) { foreach ($args AS $param => $value) {
if (is_int($args[$param])) { if (is_int($args[$param])) {
$params .= 'i'; $params .= 'i';
@ -453,7 +453,7 @@ class dba {
if (count($values) > 0) { if (count($values) > 0) {
array_unshift($values, $params); array_unshift($values, $params);
call_user_func_array(array($stmt, 'bind_param'), $values); call_user_func_array([$stmt, 'bind_param'], $values);
} }
if (!$stmt->execute()) { if (!$stmt->execute()) {
@ -564,12 +564,12 @@ class dba {
return false; return false;
} }
$fields = array(); $fields = [];
$array_element = each($condition); $array_element = each($condition);
$array_key = $array_element['key']; $array_key = $array_element['key'];
if (!is_int($array_key)) { if (!is_int($array_key)) {
$fields = array($array_key); $fields = [$array_key];
} }
$stmt = self::select($table, $fields, $condition, ['limit' => 1]); $stmt = self::select($table, $fields, $condition, ['limit' => 1]);
@ -678,14 +678,14 @@ class dba {
// This code works, but is slow // This code works, but is slow
// Bind the result to a result array // Bind the result to a result array
$cols = array(); $cols = [];
$cols_num = array(); $cols_num = [];
for ($x = 0; $x < $stmt->field_count; $x++) { for ($x = 0; $x < $stmt->field_count; $x++) {
$cols[] = &$cols_num[$x]; $cols[] = &$cols_num[$x];
} }
call_user_func_array(array($stmt, 'bind_result'), $cols); call_user_func_array([$stmt, 'bind_result'], $cols);
if (!$stmt->fetch()) { if (!$stmt->fetch()) {
return false; return false;
@ -697,7 +697,7 @@ class dba {
$result = $stmt->result_metadata(); $result = $stmt->result_metadata();
$fields = $result->fetch_fields(); $fields = $result->fetch_fields();
$columns = array(); $columns = [];
foreach ($cols_num AS $param => $col) { foreach ($cols_num AS $param => $col) {
$columns[$fields[$param]->name] = $col; $columns[$fields[$param]->name] = $col;
} }
@ -901,7 +901,7 @@ class dba {
if ((count($conditions) == 1) && ($field == array_keys($conditions)[0])) { if ((count($conditions) == 1) && ($field == array_keys($conditions)[0])) {
foreach ($rel_def AS $rel_table => $rel_fields) { foreach ($rel_def AS $rel_table => $rel_fields) {
foreach ($rel_fields AS $rel_field) { foreach ($rel_fields AS $rel_field) {
$retval = self::delete($rel_table, array($rel_field => array_values($conditions)[0]), true, $callstack); $retval = self::delete($rel_table, [$rel_field => array_values($conditions)[0]], true, $callstack);
$commands = array_merge($commands, $retval); $commands = array_merge($commands, $retval);
} }
} }
@ -911,11 +911,11 @@ class dba {
$callstack[$qkey] = true; $callstack[$qkey] = true;
// Fetch all rows that are to be deleted // Fetch all rows that are to be deleted
$data = self::select($table, array($field), $conditions); $data = self::select($table, [$field], $conditions);
while ($row = self::fetch($data)) { while ($row = self::fetch($data)) {
// Now we accumulate the delete commands // Now we accumulate the delete commands
$retval = self::delete($table, array($field => $row[$field]), true, $callstack); $retval = self::delete($table, [$field => $row[$field]], true, $callstack);
$commands = array_merge($commands, $retval); $commands = array_merge($commands, $retval);
} }
@ -1027,7 +1027,7 @@ class dba {
* *
* @return boolean was the update successfull? * @return boolean was the update successfull?
*/ */
public static function update($table, $fields, $condition, $old_fields = array()) { public static function update($table, $fields, $condition, $old_fields = []) {
if (empty($table) || empty($fields) || empty($condition)) { if (empty($table) || empty($fields) || empty($condition)) {
logger('Table, fields and condition have to be set'); logger('Table, fields and condition have to be set');
@ -1054,7 +1054,7 @@ class dba {
$values = array_merge($condition, $fields); $values = array_merge($condition, $fields);
return self::insert($table, $values, $do_insert); return self::insert($table, $values, $do_insert);
} }
$old_fields = array(); $old_fields = [];
} }
} }
@ -1249,7 +1249,7 @@ class dba {
return $stmt; return $stmt;
} }
$data = array(); $data = [];
while ($row = self::fetch($stmt)) { while ($row = self::fetch($stmt)) {
$data[] = $row; $data[] = $row;
} }

View file

@ -54,7 +54,7 @@ function notification($params)
['uid' => $params['uid']]); ['uid' => $params['uid']]);
// There is no need to create notifications for forum accounts // There is no need to create notifications for forum accounts
if (!DBM::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) { if (!DBM::is_result($user) || in_array($user["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
return; return;
} }
} }
@ -386,7 +386,7 @@ function notification($params)
$subject .= " (".$nickname."@".$hostname.")"; $subject .= " (".$nickname."@".$hostname.")";
$h = array( $h = [
'params' => $params, 'params' => $params,
'subject' => $subject, 'subject' => $subject,
'preamble' => $preamble, 'preamble' => $preamble,
@ -396,7 +396,7 @@ function notification($params)
'tsitelink' => $tsitelink, 'tsitelink' => $tsitelink,
'hsitelink' => $hsitelink, 'hsitelink' => $hsitelink,
'itemlink' => $itemlink 'itemlink' => $itemlink
); ];
call_hooks('enotify', $h); call_hooks('enotify', $h);
@ -424,7 +424,7 @@ function notification($params)
} while ($dups == true); } while ($dups == true);
/// @TODO One statement is enough /// @TODO One statement is enough
$datarray = array(); $datarray = [];
$datarray['hash'] = $hash; $datarray['hash'] = $hash;
$datarray['name'] = $params['source_name']; $datarray['name'] = $params['source_name'];
$datarray['name_cache'] = strip_tags(bbcode($params['source_name'])); $datarray['name_cache'] = strip_tags(bbcode($params['source_name']));
@ -486,7 +486,7 @@ function notification($params)
); );
if ($p && (count($p) > 1)) { if ($p && (count($p) > 1)) {
for ($d = 1; $d < count($p); $d ++) { for ($d = 1; $d < count($p); $d ++) {
dba::delete('notify', array('id' => $p[$d]['id'])); dba::delete('notify', ['id' => $p[$d]['id']]);
} }
// only continue on if we stored the first one // only continue on if we stored the first one
@ -497,7 +497,7 @@ function notification($params)
} }
$itemlink = System::baseUrl().'/notify/view/'.$notify_id; $itemlink = System::baseUrl().'/notify/view/'.$notify_id;
$msg = replace_macros($epreamble, array('$itemlink' => $itemlink)); $msg = replace_macros($epreamble, ['$itemlink' => $itemlink]);
$msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg))); $msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg)));
q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d", q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d",
dbesc($msg), dbesc($msg),
@ -546,12 +546,12 @@ function notification($params)
} }
// textversion keeps linebreaks // textversion keeps linebreaks
$textversion = strip_tags(str_replace("<br>", "\n", html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", $textversion = strip_tags(str_replace("<br>", "\n", html_entity_decode(bbcode(stripslashes(str_replace(["\\r\\n", "\\r", "\\n"], "\n",
$body))),ENT_QUOTES, 'UTF-8'))); $body))),ENT_QUOTES, 'UTF-8')));
$htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"), $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(["\\r\\n", "\\r", "\\n\\n", "\\n"],
"<br />\n", $body))), ENT_QUOTES, 'UTF-8'); "<br />\n", $body))), ENT_QUOTES, 'UTF-8');
$datarray = array(); $datarray = [];
$datarray['banner'] = $banner; $datarray['banner'] = $banner;
$datarray['product'] = $product; $datarray['product'] = $product;
$datarray['preamble'] = $preamble; $datarray['preamble'] = $preamble;
@ -584,7 +584,7 @@ function notification($params)
// load the template for private message notifications // load the template for private message notifications
$tpl = get_markup_template('email_notify_html.tpl'); $tpl = get_markup_template('email_notify_html.tpl');
$email_html_body = replace_macros($tpl, array( $email_html_body = replace_macros($tpl, [
'$banner' => $datarray['banner'], '$banner' => $datarray['banner'],
'$product' => $datarray['product'], '$product' => $datarray['product'],
'$preamble' => str_replace("\n", "<br>\n", $datarray['preamble']), '$preamble' => str_replace("\n", "<br>\n", $datarray['preamble']),
@ -601,11 +601,11 @@ function notification($params)
'$title' => $datarray['title'], '$title' => $datarray['title'],
'$htmlversion' => $datarray['htmlversion'], '$htmlversion' => $datarray['htmlversion'],
'$content_allowed' => $content_allowed, '$content_allowed' => $content_allowed,
)); ]);
// load the template for private message notifications // load the template for private message notifications
$tpl = get_markup_template('email_notify_text.tpl'); $tpl = get_markup_template('email_notify_text.tpl');
$email_text_body = replace_macros($tpl, array( $email_text_body = replace_macros($tpl, [
'$banner' => $datarray['banner'], '$banner' => $datarray['banner'],
'$product' => $datarray['product'], '$product' => $datarray['product'],
'$preamble' => $datarray['preamble'], '$preamble' => $datarray['preamble'],
@ -622,11 +622,11 @@ function notification($params)
'$title' => $datarray['title'], '$title' => $datarray['title'],
'$textversion' => $datarray['textversion'], '$textversion' => $datarray['textversion'],
'$content_allowed' => $content_allowed, '$content_allowed' => $content_allowed,
)); ]);
// use the Emailer class to send the message // use the Emailer class to send the message
return Emailer::send( return Emailer::send(
array( [
'uid' => $params['uid'], 'uid' => $params['uid'],
'fromName' => $sender_name, 'fromName' => $sender_name,
'fromEmail' => $sender_email, 'fromEmail' => $sender_email,
@ -635,7 +635,7 @@ function notification($params)
'messageSubject' => $datarray['subject'], 'messageSubject' => $datarray['subject'],
'htmlVersion' => $email_html_body, 'htmlVersion' => $email_html_body,
'textVersion' => $email_text_body, 'textVersion' => $email_text_body,
'additionalMailHeader' => $datarray['headers']) 'additionalMailHeader' => $datarray['headers']]
); );
} }
@ -666,7 +666,7 @@ function check_user_notification($itemid) {
* @param str $defaulttype (Optional) Forces a notification with this type. * @param str $defaulttype (Optional) Forces a notification with this type.
*/ */
function check_item_notification($itemid, $uid, $defaulttype = "") { function check_item_notification($itemid, $uid, $defaulttype = "") {
$notification_data = array("uid" => $uid, "profiles" => array()); $notification_data = ["uid" => $uid, "profiles" => []];
call_hooks('check_item_notification', $notification_data); call_hooks('check_item_notification', $notification_data);
$profiles = $notification_data["profiles"]; $profiles = $notification_data["profiles"];
@ -688,7 +688,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
// Notifications from Diaspora are often with an URL in the Diaspora format // Notifications from Diaspora are often with an URL in the Diaspora format
$profiles[] = System::baseUrl()."/u/".$user["nickname"]; $profiles[] = System::baseUrl()."/u/".$user["nickname"];
$profiles2 = array(); $profiles2 = [];
foreach ($profiles AS $profile) { foreach ($profiles AS $profile) {
// Check for invalid profile urls. 13 should be the shortest possible profile length: // Check for invalid profile urls. 13 should be the shortest possible profile length:
@ -732,7 +732,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
return false; return false;
// Generate the notification array // Generate the notification array
$params = array(); $params = [];
$params["uid"] = $uid; $params["uid"] = $uid;
$params["notify_flags"] = $user["notify-flags"]; $params["notify_flags"] = $user["notify-flags"];
$params["language"] = $user["language"]; $params["language"] = $user["language"];

View file

@ -150,7 +150,7 @@ function bbtovcal($s) {
*/ */
function bbtoevent($s) { function bbtoevent($s) {
$ev = array(); $ev = [];
$match = ''; $match = '';
if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $s, $match)) { if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $s, $match)) {
@ -219,7 +219,7 @@ function event_delete($event_id) {
return; return;
} }
dba::delete('event', array('id' => $event_id)); dba::delete('event', ['id' => $event_id]);
logger("Deleted event ".$event_id, LOGGER_DEBUG); logger("Deleted event ".$event_id, LOGGER_DEBUG);
} }
@ -364,7 +364,7 @@ function event_store($arr) {
$event = $r[0]; $event = $r[0];
} }
$item_arr = array(); $item_arr = [];
$item_arr['uid'] = $arr['uid']; $item_arr['uid'] = $arr['uid'];
$item_arr['contact-id'] = $arr['cid']; $item_arr['contact-id'] = $arr['cid'];
@ -423,7 +423,7 @@ function get_event_strings() {
// First day of the week (0 = Sunday). // First day of the week (0 = Sunday).
$firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0); $firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0);
$i18n = array( $i18n = [
"firstDay" => $firstDay, "firstDay" => $firstDay,
"allday" => t("all-day"), "allday" => t("all-day"),
@ -479,7 +479,7 @@ function get_event_strings() {
"dtstart_label" => t("Starts:"), "dtstart_label" => t("Starts:"),
"dtend_label" => t("Finishes:"), "dtend_label" => t("Finishes:"),
"location_label" => t("Location:") "location_label" => t("Location:")
); ];
return $i18n; return $i18n;
} }
@ -493,7 +493,7 @@ function get_event_strings() {
* @todo We should replace this with a separate update function if there is some time left. * @todo We should replace this with a separate update function if there is some time left.
*/ */
function event_remove_duplicates($dates) { function event_remove_duplicates($dates) {
$dates2 = array(); $dates2 = [];
foreach ($dates as $date) { foreach ($dates as $date) {
if ($date['type'] == 'birthday') { if ($date['type'] == 'birthday') {
@ -585,7 +585,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
* @return array Event array for the template. * @return array Event array for the template.
*/ */
function process_events($arr) { function process_events($arr) {
$events=array(); $events=[];
$last_date = ''; $last_date = '';
$fmt = t('l, F j'); $fmt = t('l, F j');
@ -612,9 +612,9 @@ function process_events($arr) {
$copy = null; $copy = null;
$drop = null; $drop = null;
if (local_user() && local_user() == $rr['uid'] && $rr['type'] == 'event') { if (local_user() && local_user() == $rr['uid'] && $rr['type'] == 'event') {
$edit = ((! $rr['cid']) ? array(System::baseUrl() . '/events/event/' . $rr['id'], t('Edit event'), '', '') : null); $edit = ((! $rr['cid']) ? [System::baseUrl() . '/events/event/' . $rr['id'], t('Edit event'), '', ''] : null);
$copy = ((! $rr['cid']) ? array(System::baseUrl() . '/events/copy/' . $rr['id'], t('Duplicate event'), '', '') : null); $copy = ((! $rr['cid']) ? [System::baseUrl() . '/events/copy/' . $rr['id'], t('Duplicate event'), '', ''] : null);
$drop = array(System::baseUrl() . '/events/drop/' . $rr['id'], t('Delete event'), '', ''); $drop = [System::baseUrl() . '/events/drop/' . $rr['id'], t('Delete event'), '', ''];
} }
$title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8')); $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
@ -626,7 +626,7 @@ function process_events($arr) {
$html = format_event_html($rr); $html = format_event_html($rr);
$rr['desc'] = bbcode($rr['desc']); $rr['desc'] = bbcode($rr['desc']);
$rr['location'] = bbcode($rr['location']); $rr['location'] = bbcode($rr['location']);
$events[] = array( $events[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'start' => $start, 'start' => $start,
'end' => $end, 'end' => $end,
@ -641,8 +641,8 @@ function process_events($arr) {
'is_first' => $is_first, 'is_first' => $is_first,
'item' => $rr, 'item' => $rr,
'html' => $html, 'html' => $html,
'plink' => array($rr['plink'], t('link to source'), '', ''), 'plink' => [$rr['plink'], t('link to source'), '', ''],
); ];
} }
} }
@ -849,12 +849,12 @@ function event_export($uid, $format = 'ical') {
$file_ext = ""; $file_ext = "";
} }
$arr = array( $arr = [
'success' => $process, 'success' => $process,
'format' => $format, 'format' => $format,
'extension' => $file_ext, 'extension' => $file_ext,
'content' => $res, 'content' => $res,
); ];
return $arr; return $arr;
} }
@ -900,12 +900,12 @@ function widget_events() {
return; return;
} }
return replace_macros(get_markup_template("events_aside.tpl"), array( return replace_macros(get_markup_template("events_aside.tpl"), [
'$etitle' => t("Export"), '$etitle' => t("Export"),
'$export_ical' => t("Export calendar as ical"), '$export_ical' => t("Export calendar as ical"),
'$export_csv' => t("Export calendar as csv"), '$export_csv' => t("Export calendar as csv"),
'$user' => $user '$user' => $user
)); ]);
} }
/** /**
@ -948,7 +948,7 @@ function format_event_item($item) {
// Format the event location. // Format the event location.
$evloc = event_location2array($item['event-location']); $evloc = event_location2array($item['event-location']);
$location = array(); $location = [];
if (isset($evloc['name'])) { if (isset($evloc['name'])) {
$location['name'] = prepare_text($evloc['name']); $location['name'] = prepare_text($evloc['name']);
@ -968,7 +968,7 @@ function format_event_item($item) {
$profile_link = Profile::zrl($profile_link); $profile_link = Profile::zrl($profile_link);
} }
$event = replace_macros(get_markup_template('event_stream_item.tpl'), array( $event = replace_macros(get_markup_template('event_stream_item.tpl'), [
'$id' => $item['event-id'], '$id' => $item['event-id'],
'$title' => prepare_text($item['event-summary']), '$title' => prepare_text($item['event-summary']),
'$dtstart_label' => t('Starts:'), '$dtstart_label' => t('Starts:'),
@ -994,7 +994,7 @@ function format_event_item($item) {
'$hide_map_label' => t('Hide map'), '$hide_map_label' => t('Hide map'),
'$map_btn_label' => t('Show map'), '$map_btn_label' => t('Show map'),
'$location' => $location '$location' => $location
)); ]);
return $event; return $event;
} }
@ -1017,7 +1017,7 @@ function event_location2array($s = '') {
return; return;
} }
$location = array('name' => $s); $location = ['name' => $s];
// Map tag with location name - e.g. [map]Paris[/map]. // Map tag with location name - e.g. [map]Paris[/map].
if (strpos($s, '[/map]') !== false) { if (strpos($s, '[/map]') !== false) {

View file

@ -19,10 +19,10 @@ class FriendicaSmarty extends Smarty
// setTemplateDir can be set to an array, which Smarty will parse in order. // setTemplateDir can be set to an array, which Smarty will parse in order.
// The order is thus very important here // The order is thus very important here
$template_dirs = array('theme' => "view/theme/$theme/" . SMARTY3_TEMPLATE_FOLDER . "/"); $template_dirs = ['theme' => "view/theme/$theme/" . SMARTY3_TEMPLATE_FOLDER . "/"];
if (x($a->theme_info, "extends")) if (x($a->theme_info, "extends"))
$template_dirs = $template_dirs + array('extends' => "view/theme/" . $a->theme_info["extends"] . "/" . SMARTY3_TEMPLATE_FOLDER . "/"); $template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . SMARTY3_TEMPLATE_FOLDER . "/"];
$template_dirs = $template_dirs + array('base' => "view/" . SMARTY3_TEMPLATE_FOLDER . "/"); $template_dirs = $template_dirs + ['base' => "view/" . SMARTY3_TEMPLATE_FOLDER . "/"];
$this->setTemplateDir($template_dirs); $this->setTemplateDir($template_dirs);
$this->setCompileDir('view/smarty3/compiled/'); $this->setCompileDir('view/smarty3/compiled/');
@ -70,10 +70,10 @@ class FriendicaSmartyEngine implements ITemplateEngine
$r['$APP'] = get_app(); $r['$APP'] = get_app();
// "middleware": inject variables into templates // "middleware": inject variables into templates
$arr = array( $arr = [
"template" => basename($s->filename), "template" => basename($s->filename),
"vars" => $r "vars" => $r
); ];
call_hooks("template_vars", $arr); call_hooks("template_vars", $arr);
$r = $arr['vars']; $r = $arr['vars'];

View file

@ -26,7 +26,7 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
$list = $xpath->query("//".$oldnode); $list = $xpath->query("//".$oldnode);
foreach ($list as $oldNode) { foreach ($list as $oldNode) {
$attr = array(); $attr = [];
if ($oldNode->attributes->length) { if ($oldNode->attributes->length) {
foreach ($oldNode->attributes as $attribute) { foreach ($oldNode->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value; $attr[$attribute->name] = $attribute->value;
@ -102,14 +102,14 @@ function html2bbcode($message, $basepath = '')
); );
$message = str_replace( $message = str_replace(
array( [
"<li><p>", "<li><p>",
"</p></li>", "</p></li>",
), ],
array( [
"<li>", "<li>",
"</li>", "</li>",
), ],
$message $message
); );
@ -138,23 +138,23 @@ function html2bbcode($message, $basepath = '')
} }
$message = $doc->saveHTML(); $message = $doc->saveHTML();
$message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br />", " ", ""), $message); $message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br />", " ", ""], $message);
$message = preg_replace('= [\s]*=i', " ", $message); $message = preg_replace('= [\s]*=i', " ", $message);
@$doc->loadHTML($message); @$doc->loadHTML($message);
node2bbcode($doc, 'html', array(), "", ""); node2bbcode($doc, 'html', [], "", "");
node2bbcode($doc, 'body', array(), "", ""); node2bbcode($doc, 'body', [], "", "");
// Outlook-Quote - Variant 1 // Outlook-Quote - Variant 1
node2bbcode($doc, 'p', array('class'=>'MsoNormal', 'style'=>'margin-left:35.4pt'), '[quote]', '[/quote]'); node2bbcode($doc, 'p', ['class'=>'MsoNormal', 'style'=>'margin-left:35.4pt'], '[quote]', '[/quote]');
// Outlook-Quote - Variant 2 // Outlook-Quote - Variant 2
node2bbcode($doc, 'div', array('style'=>'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'), '[quote]', '[/quote]'); node2bbcode($doc, 'div', ['style'=>'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'], '[quote]', '[/quote]');
// MyBB-Stuff // MyBB-Stuff
node2bbcode($doc, 'span', array('style'=>'text-decoration: underline;'), '[u]', '[/u]'); node2bbcode($doc, 'span', ['style'=>'text-decoration: underline;'], '[u]', '[/u]');
node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '[i]', '[/i]'); node2bbcode($doc, 'span', ['style'=>'font-style: italic;'], '[i]', '[/i]');
node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '[b]', '[/b]'); node2bbcode($doc, 'span', ['style'=>'font-weight: bold;'], '[b]', '[/b]');
/*node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]'); /*node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]');
node2bbcode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]'); node2bbcode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]');
@ -169,7 +169,7 @@ function html2bbcode($message, $basepath = '')
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)[,;].*/'), '[size=$1]', '[/size]'); //node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)[,;].*/'), '[size=$1]', '[/size]');
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*/'), '[size=$1]', '[/size]'); //node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*/'), '[size=$1]', '[/size]');
node2bbcode($doc, 'span', array('style'=>'/.*color:\s*(.+?)[,;].*/'), '[color="$1"]', '[/color]'); node2bbcode($doc, 'span', ['style'=>'/.*color:\s*(.+?)[,;].*/'], '[color="$1"]', '[/color]');
//node2bbcode($doc, 'span', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]'); //node2bbcode($doc, 'span', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
@ -180,42 +180,42 @@ function html2bbcode($message, $basepath = '')
// Importing the classes - interesting for importing of posts from third party networks that were exported from friendica // Importing the classes - interesting for importing of posts from third party networks that were exported from friendica
// Test // Test
//node2bbcode($doc, 'span', array('class'=>'/([\w ]+)/'), '[class=$1]', '[/class]'); //node2bbcode($doc, 'span', array('class'=>'/([\w ]+)/'), '[class=$1]', '[/class]');
node2bbcode($doc, 'span', array('class'=>'type-link'), '[class=type-link]', '[/class]'); node2bbcode($doc, 'span', ['class'=>'type-link'], '[class=type-link]', '[/class]');
node2bbcode($doc, 'span', array('class'=>'type-video'), '[class=type-video]', '[/class]'); node2bbcode($doc, 'span', ['class'=>'type-video'], '[class=type-video]', '[/class]');
node2bbcode($doc, 'strong', array(), '[b]', '[/b]'); node2bbcode($doc, 'strong', [], '[b]', '[/b]');
node2bbcode($doc, 'em', array(), '[i]', '[/i]'); node2bbcode($doc, 'em', [], '[i]', '[/i]');
node2bbcode($doc, 'b', array(), '[b]', '[/b]'); node2bbcode($doc, 'b', [], '[b]', '[/b]');
node2bbcode($doc, 'i', array(), '[i]', '[/i]'); node2bbcode($doc, 'i', [], '[i]', '[/i]');
node2bbcode($doc, 'u', array(), '[u]', '[/u]'); node2bbcode($doc, 'u', [], '[u]', '[/u]');
node2bbcode($doc, 'big', array(), "[size=large]", "[/size]"); node2bbcode($doc, 'big', [], "[size=large]", "[/size]");
node2bbcode($doc, 'small', array(), "[size=small]", "[/size]"); node2bbcode($doc, 'small', [], "[size=small]", "[/size]");
node2bbcode($doc, 'blockquote', array(), '[quote]', '[/quote]'); node2bbcode($doc, 'blockquote', [], '[quote]', '[/quote]');
node2bbcode($doc, 'br', array(), "\n", ''); node2bbcode($doc, 'br', [], "\n", '');
node2bbcode($doc, 'p', array('class'=>'MsoNormal'), "\n", ""); node2bbcode($doc, 'p', ['class'=>'MsoNormal'], "\n", "");
node2bbcode($doc, 'div', array('class'=>'MsoNormal'), "\r", ""); node2bbcode($doc, 'div', ['class'=>'MsoNormal'], "\r", "");
node2bbcode($doc, 'span', array(), "", ""); node2bbcode($doc, 'span', [], "", "");
node2bbcode($doc, 'span', array(), "", ""); node2bbcode($doc, 'span', [], "", "");
node2bbcode($doc, 'pre', array(), "", ""); node2bbcode($doc, 'pre', [], "", "");
node2bbcode($doc, 'div', array(), "\r", "\r"); node2bbcode($doc, 'div', [], "\r", "\r");
node2bbcode($doc, 'p', array(), "\n", "\n"); node2bbcode($doc, 'p', [], "\n", "\n");
node2bbcode($doc, 'ul', array(), "[list]", "[/list]"); node2bbcode($doc, 'ul', [], "[list]", "[/list]");
node2bbcode($doc, 'ol', array(), "[list=1]", "[/list]"); node2bbcode($doc, 'ol', [], "[list=1]", "[/list]");
node2bbcode($doc, 'li', array(), "[*]", ""); node2bbcode($doc, 'li', [], "[*]", "");
node2bbcode($doc, 'hr', array(), "[hr]", ""); node2bbcode($doc, 'hr', [], "[hr]", "");
node2bbcode($doc, 'table', array(), "", ""); node2bbcode($doc, 'table', [], "", "");
node2bbcode($doc, 'tr', array(), "\n", ""); node2bbcode($doc, 'tr', [], "\n", "");
node2bbcode($doc, 'td', array(), "\t", ""); node2bbcode($doc, 'td', [], "\t", "");
//node2bbcode($doc, 'table', array(), "[table]", "[/table]"); //node2bbcode($doc, 'table', array(), "[table]", "[/table]");
//node2bbcode($doc, 'th', array(), "[th]", "[/th]"); //node2bbcode($doc, 'th', array(), "[th]", "[/th]");
//node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]"); //node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]");
@ -228,26 +228,26 @@ function html2bbcode($message, $basepath = '')
//node2bbcode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n"); //node2bbcode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n");
//node2bbcode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n"); //node2bbcode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n");
node2bbcode($doc, 'h1', array(), "\n\n[h1]", "[/h1]\n"); node2bbcode($doc, 'h1', [], "\n\n[h1]", "[/h1]\n");
node2bbcode($doc, 'h2', array(), "\n\n[h2]", "[/h2]\n"); node2bbcode($doc, 'h2', [], "\n\n[h2]", "[/h2]\n");
node2bbcode($doc, 'h3', array(), "\n\n[h3]", "[/h3]\n"); node2bbcode($doc, 'h3', [], "\n\n[h3]", "[/h3]\n");
node2bbcode($doc, 'h4', array(), "\n\n[h4]", "[/h4]\n"); node2bbcode($doc, 'h4', [], "\n\n[h4]", "[/h4]\n");
node2bbcode($doc, 'h5', array(), "\n\n[h5]", "[/h5]\n"); node2bbcode($doc, 'h5', [], "\n\n[h5]", "[/h5]\n");
node2bbcode($doc, 'h6', array(), "\n\n[h6]", "[/h6]\n"); node2bbcode($doc, 'h6', [], "\n\n[h6]", "[/h6]\n");
node2bbcode($doc, 'a', array('href'=>'/mailto:(.+)/'), '[mail=$1]', '[/mail]'); node2bbcode($doc, 'a', ['href'=>'/mailto:(.+)/'], '[mail=$1]', '[/mail]');
node2bbcode($doc, 'a', array('href'=>'/(.+)/'), '[url=$1]', '[/url]'); node2bbcode($doc, 'a', ['href'=>'/(.+)/'], '[url=$1]', '[/url]');
node2bbcode($doc, 'img', array('src'=>'/(.+)/', 'width'=>'/(\d+)/', 'height'=>'/(\d+)/'), '[img=$2x$3]$1', '[/img]'); node2bbcode($doc, 'img', ['src'=>'/(.+)/', 'width'=>'/(\d+)/', 'height'=>'/(\d+)/'], '[img=$2x$3]$1', '[/img]');
node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]'); node2bbcode($doc, 'img', ['src'=>'/(.+)/'], '[img]$1', '[/img]');
node2bbcode($doc, 'video', array('src'=>'/(.+)/'), '[video]$1', '[/video]'); node2bbcode($doc, 'video', ['src'=>'/(.+)/'], '[video]$1', '[/video]');
node2bbcode($doc, 'audio', array('src'=>'/(.+)/'), '[audio]$1', '[/audio]'); node2bbcode($doc, 'audio', ['src'=>'/(.+)/'], '[audio]$1', '[/audio]');
node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), '[iframe]$1', '[/iframe]'); node2bbcode($doc, 'iframe', ['src'=>'/(.+)/'], '[iframe]$1', '[/iframe]');
node2bbcode($doc, 'key', array(), '[code]', '[/code]'); node2bbcode($doc, 'key', [], '[code]', '[/code]');
node2bbcode($doc, 'code', array(), '[code]', '[/code]'); node2bbcode($doc, 'code', [], '[code]', '[/code]');
$message = $doc->saveHTML(); $message = $doc->saveHTML();
@ -267,7 +267,7 @@ function html2bbcode($message, $basepath = '')
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
$message = str_replace(array("<"), array("&lt;"), $message); $message = str_replace(["<"], ["&lt;"], $message);
// remove quotes if they don't make sense // remove quotes if they don't make sense
$message = preg_replace('=\[/quote\][\s]*\[quote\]=i', "\n", $message); $message = preg_replace('=\[/quote\][\s]*\[quote\]=i', "\n", $message);
@ -288,7 +288,7 @@ function html2bbcode($message, $basepath = '')
do { do {
$oldmessage = $message; $oldmessage = $message;
$message = str_replace( $message = str_replace(
array( [
"[/size]\n\n", "[/size]\n\n",
"\n[hr]", "\n[hr]",
"[hr]\n", "[hr]\n",
@ -297,8 +297,8 @@ function html2bbcode($message, $basepath = '')
"\n[/", "\n[/",
"[list]\n", "[list]\n",
"[list=1]\n", "[list=1]\n",
"\n[*]"), "\n[*]"],
array( [
"[/size]\n", "[/size]\n",
"[hr]", "[hr]",
"[hr]", "[hr]",
@ -307,14 +307,14 @@ function html2bbcode($message, $basepath = '')
"[/", "[/",
"[list]", "[list]",
"[list=1]", "[list=1]",
"[*]"), "[*]"],
$message $message
); );
} while ($message != $oldmessage); } while ($message != $oldmessage);
$message = str_replace( $message = str_replace(
array('[b][b]', '[/b][/b]', '[i][i]', '[/i][/i]'), ['[b][b]', '[/b][/b]', '[i][i]', '[/i][/i]'],
array('[b]', '[/b]', '[i]', '[/i]'), ['[b]', '[/b]', '[i]', '[/i]'],
$message $message
); );
@ -378,7 +378,7 @@ function addHostname($body, $basepath)
{ {
$URLSearchString = "^\[\]"; $URLSearchString = "^\[\]";
$matches = array("/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism", $matches = ["/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
"/\[url\]([$URLSearchString]*)\[\/url\]/ism", "/\[url\]([$URLSearchString]*)\[\/url\]/ism",
"/\[img\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism", "/\[img\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
"/\[img\](.*?)\[\/img\]/ism", "/\[img\](.*?)\[\/img\]/ism",
@ -386,7 +386,7 @@ function addHostname($body, $basepath)
"/\[zmg\](.*?)\[\/zmg\]/ism", "/\[zmg\](.*?)\[\/zmg\]/ism",
"/\[video\](.*?)\[\/video\]/ism", "/\[video\](.*?)\[\/video\]/ism",
"/\[audio\](.*?)\[\/audio\]/ism", "/\[audio\](.*?)\[\/audio\]/ism",
); ];
foreach ($matches as $match) { foreach ($matches as $match) {
$body = preg_replace_callback( $body = preg_replace_callback(

View file

@ -10,7 +10,7 @@ function breaklines($line, $level, $wraplength = 75)
$wraplen = $wraplength - $level; $wraplen = $wraplength - $level;
$newlines = array(); $newlines = [];
do { do {
$oldline = $line; $oldline = $line;
@ -47,7 +47,7 @@ function quotelevel($message, $wraplength = 75)
{ {
$lines = explode("\n", $message); $lines = explode("\n", $message);
$newlines = array(); $newlines = [];
$level = 0; $level = 0;
foreach ($lines as $line) { foreach ($lines as $line) {
$line = trim($line); $line = trim($line);
@ -84,13 +84,13 @@ function collecturls($message)
$pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is'; $pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
preg_match_all($pattern, $message, $result, PREG_SET_ORDER); preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
$urls = array(); $urls = [];
foreach ($result as $treffer) { foreach ($result as $treffer) {
$ignore = false; $ignore = false;
// A list of some links that should be ignored // A list of some links that should be ignored
$list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/", $list = ["/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
"//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/"); "//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/"];
foreach ($list as $listitem) { foreach ($list as $listitem) {
if (strpos($treffer[1], $listitem) !== false) { if (strpos($treffer[1], $listitem) !== false) {
$ignore = true; $ignore = true;
@ -137,7 +137,7 @@ function html2plain($html, $wraplength = 75, $compact = false)
} }
$message = $doc->saveHTML(); $message = $doc->saveHTML();
$message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br>", " ", ""), $message); $message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br>", " ", ""], $message);
$message = preg_replace('= [\s]*=i', " ", $message); $message = preg_replace('= [\s]*=i', " ", $message);
// Collecting all links // Collecting all links
@ -145,8 +145,8 @@ function html2plain($html, $wraplength = 75, $compact = false)
@$doc->loadHTML($message); @$doc->loadHTML($message);
node2bbcode($doc, 'html', array(), '', ''); node2bbcode($doc, 'html', [], '', '');
node2bbcode($doc, 'body', array(), '', ''); node2bbcode($doc, 'body', [], '', '');
// MyBB-Auszeichnungen // MyBB-Auszeichnungen
/* /*
@ -161,33 +161,33 @@ function html2plain($html, $wraplength = 75, $compact = false)
*/ */
if ($compact) { if ($compact) {
node2bbcode($doc, 'blockquote', array(), "»", "«"); node2bbcode($doc, 'blockquote', [], "»", "«");
} else { } else {
node2bbcode($doc, 'blockquote', array(), '[quote]', "[/quote]\n"); node2bbcode($doc, 'blockquote', [], '[quote]', "[/quote]\n");
} }
node2bbcode($doc, 'br', array(), "\n", ''); node2bbcode($doc, 'br', [], "\n", '');
node2bbcode($doc, 'span', array(), "", ""); node2bbcode($doc, 'span', [], "", "");
node2bbcode($doc, 'pre', array(), "", ""); node2bbcode($doc, 'pre', [], "", "");
node2bbcode($doc, 'div', array(), "\r", "\r"); node2bbcode($doc, 'div', [], "\r", "\r");
node2bbcode($doc, 'p', array(), "\n", "\n"); node2bbcode($doc, 'p', [], "\n", "\n");
//node2bbcode($doc, 'ul', array(), "\n[list]", "[/list]\n"); //node2bbcode($doc, 'ul', array(), "\n[list]", "[/list]\n");
//node2bbcode($doc, 'ol', array(), "\n[list=1]", "[/list]\n"); //node2bbcode($doc, 'ol', array(), "\n[list=1]", "[/list]\n");
node2bbcode($doc, 'li', array(), "\n* ", "\n"); node2bbcode($doc, 'li', [], "\n* ", "\n");
node2bbcode($doc, 'hr', array(), "\n" . str_repeat("-", 70) . "\n", ""); node2bbcode($doc, 'hr', [], "\n" . str_repeat("-", 70) . "\n", "");
node2bbcode($doc, 'tr', array(), "\n", ""); node2bbcode($doc, 'tr', [], "\n", "");
node2bbcode($doc, 'td', array(), "\t", ""); node2bbcode($doc, 'td', [], "\t", "");
node2bbcode($doc, 'h1', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h1', [], "\n\n*", "*\n");
node2bbcode($doc, 'h2', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h2', [], "\n\n*", "*\n");
node2bbcode($doc, 'h3', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h3', [], "\n\n*", "*\n");
node2bbcode($doc, 'h4', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h4', [], "\n\n*", "*\n");
node2bbcode($doc, 'h5', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h5', [], "\n\n*", "*\n");
node2bbcode($doc, 'h6', array(), "\n\n*", "*\n"); node2bbcode($doc, 'h6', [], "\n\n*", "*\n");
// Problem: there is no reliable way to detect if it is a link to a tag or profile // Problem: there is no reliable way to detect if it is a link to a tag or profile
//node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', ' ', true); //node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', ' ', true);
@ -196,12 +196,12 @@ function html2plain($html, $wraplength = 75, $compact = false)
//node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', ''); //node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', '');
//node2bbcode($doc, 'img', array(), '', ''); //node2bbcode($doc, 'img', array(), '', '');
if (!$compact) { if (!$compact) {
node2bbcode($doc, 'img', array('src' => '/(.+)/'), ' [img]$1', '[/img] '); node2bbcode($doc, 'img', ['src' => '/(.+)/'], ' [img]$1', '[/img] ');
} else { } else {
node2bbcode($doc, 'img', array('src' => '/(.+)/'), ' ', ' '); node2bbcode($doc, 'img', ['src' => '/(.+)/'], ' ', ' ');
} }
node2bbcode($doc, 'iframe', array('src' => '/(.+)/'), ' $1 ', ''); node2bbcode($doc, 'iframe', ['src' => '/(.+)/'], ' $1 ', '');
$message = $doc->saveHTML(); $message = $doc->saveHTML();

View file

@ -133,12 +133,12 @@ function title_is_body($title, $body) {
$title = strip_tags($title); $title = strip_tags($title);
$title = trim($title); $title = trim($title);
$title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
$title = str_replace(array("\n", "\r", "\t", " "), array("", "", "", ""), $title); $title = str_replace(["\n", "\r", "\t", " "], ["", "", "", ""], $title);
$body = strip_tags($body); $body = strip_tags($body);
$body = trim($body); $body = trim($body);
$body = html_entity_decode($body, ENT_QUOTES, 'UTF-8'); $body = html_entity_decode($body, ENT_QUOTES, 'UTF-8');
$body = str_replace(array("\n", "\r", "\t", " "), array("", "", "", ""), $body); $body = str_replace(["\n", "\r", "\t", " "], ["", "", "", ""], $body);
if (strlen($title) < strlen($body)) { if (strlen($title) < strlen($body)) {
$body = substr($body, 0, strlen($title)); $body = substr($body, 0, strlen($title));
@ -174,8 +174,8 @@ function add_page_info_data($data) {
} }
// Escape some bad characters // Escape some bad characters
$data["url"] = str_replace(array("[", "]"), array("&#91;", "&#93;"), htmlentities($data["url"], ENT_QUOTES, 'UTF-8', false)); $data["url"] = str_replace(["[", "]"], ["&#91;", "&#93;"], htmlentities($data["url"], ENT_QUOTES, 'UTF-8', false));
$data["title"] = str_replace(array("[", "]"), array("&#91;", "&#93;"), htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false)); $data["title"] = str_replace(["[", "]"], ["&#91;", "&#93;"], htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false));
$text = "[attachment type='".$data["type"]."'"; $text = "[attachment type='".$data["type"]."'";
@ -196,7 +196,7 @@ function add_page_info_data($data) {
} }
if (sizeof($data["images"]) > 0) { if (sizeof($data["images"]) > 0) {
$preview = str_replace(array("[", "]"), array("&#91;", "&#93;"), htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false)); $preview = str_replace(["[", "]"], ["&#91;", "&#93;"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
// if the preview picture is larger than 500 pixels then show it in a larger mode // if the preview picture is larger than 500 pixels then show it in a larger mode
// But only, if the picture isn't higher than large (To prevent huge posts) // But only, if the picture isn't higher than large (To prevent huge posts)
if (!Config::get('system', 'always_show_preview') && ($data["images"][0]["width"] >= 500) if (!Config::get('system', 'always_show_preview') && ($data["images"][0]["width"] >= 500)
@ -214,8 +214,8 @@ function add_page_info_data($data) {
$hashtags = "\n"; $hashtags = "\n";
foreach ($data["keywords"] AS $keyword) { foreach ($data["keywords"] AS $keyword) {
/// @todo make a positive list of allowed characters /// @todo make a positive list of allowed characters
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "", "`", "(", ")", "", ""), $hashtag = str_replace([" ", "+", "/", ".", "#", "'", "", "`", "(", ")", "", ""],
array("", "", "", "", "", "", "", "", "", "", "", ""), $keyword); ["", "", "", "", "", "", "", "", "", "", "", ""], $keyword);
$hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url] "; $hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url] ";
} }
} }
@ -257,8 +257,8 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
$tags = ""; $tags = "";
if (isset($data["keywords"]) && count($data["keywords"])) { if (isset($data["keywords"]) && count($data["keywords"])) {
foreach ($data["keywords"] AS $keyword) { foreach ($data["keywords"] AS $keyword) {
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"), $hashtag = str_replace([" ", "+", "/", ".", "#", "'"],
array("", "", "", "", "", ""), $keyword); ["", "", "", "", "", ""], $keyword);
if ($tags != "") { if ($tags != "") {
$tags .= ", "; $tags .= ", ";
@ -317,7 +317,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
$body = $removedlink; $body = $removedlink;
} }
$url = str_replace(array('/', '.'), array('\/', '\.'), $matches[1]); $url = str_replace(['/', '.'], ['\/', '\.'], $matches[1]);
$removedlink = preg_replace("/\[url\=" . $url . "\](.*?)\[\/url\]/ism", '', $body); $removedlink = preg_replace("/\[url\=" . $url . "\](.*?)\[\/url\]/ism", '', $body);
if (($removedlink == "") || strstr($body, $removedlink)) { if (($removedlink == "") || strstr($body, $removedlink)) {
$body = $removedlink; $body = $removedlink;
@ -419,8 +419,8 @@ function uri_to_guid($uri, $host = "") {
* @return array Item array with removed conversation data * @return array Item array with removed conversation data
*/ */
function store_conversation($arr) { function store_conversation($arr) {
if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)) && !empty($arr['uri'])) { if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && !empty($arr['uri'])) {
$conversation = array('item-uri' => $arr['uri'], 'received' => DBM::date()); $conversation = ['item-uri' => $arr['uri'], 'received' => DBM::date()];
if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) { if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
$conversation['reply-to-uri'] = $arr['parent-uri']; $conversation['reply-to-uri'] = $arr['parent-uri'];
@ -458,7 +458,7 @@ function store_conversation($arr) {
unset($conversation['protocol']); unset($conversation['protocol']);
unset($conversation['source']); unset($conversation['source']);
} }
if (!dba::update('conversation', $conversation, array('item-uri' => $conversation['item-uri']), $old_conv)) { if (!dba::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) {
logger('Conversation: update for '.$conversation['item-uri'].' from '.$conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG); logger('Conversation: update for '.$conversation['item-uri'].' from '.$conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG);
} }
} else { } else {
@ -581,7 +581,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
* We have to check several networks since Friendica posts could be repeated * We have to check several networks since Friendica posts could be repeated
* via OStatus (maybe Diasporsa as well) * via OStatus (maybe Diasporsa as well)
*/ */
if (in_array($arr['network'], array(NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""))) { if (in_array($arr['network'], [NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""])) {
$r = q("SELECT `id`, `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` IN ('%s', '%s', '%s') LIMIT 1", $r = q("SELECT `id`, `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` IN ('%s', '%s', '%s') LIMIT 1",
dbesc(trim($arr['uri'])), dbesc(trim($arr['uri'])),
intval($uid), intval($uid),
@ -740,11 +740,11 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
* On comments the author is the better choice. * On comments the author is the better choice.
*/ */
if ($arr['parent-uri'] === $arr['uri']) { if ($arr['parent-uri'] === $arr['uri']) {
$arr["gcontact-id"] = GContact::getId(array("url" => $arr['owner-link'], "network" => $arr['network'], $arr["gcontact-id"] = GContact::getId(["url" => $arr['owner-link'], "network" => $arr['network'],
"photo" => $arr['owner-avatar'], "name" => $arr['owner-name'])); "photo" => $arr['owner-avatar'], "name" => $arr['owner-name']]);
} else { } else {
$arr["gcontact-id"] = GContact::getId(array("url" => $arr['author-link'], "network" => $arr['network'], $arr["gcontact-id"] = GContact::getId(["url" => $arr['author-link'], "network" => $arr['network'],
"photo" => $arr['author-avatar'], "name" => $arr['author-name'])); "photo" => $arr['author-avatar'], "name" => $arr['author-name']]);
} }
} }
@ -855,7 +855,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
$self = normalise_link(System::baseUrl() . '/profile/' . $u[0]['nickname']); $self = normalise_link(System::baseUrl() . '/profile/' . $u[0]['nickname']);
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG); logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) { if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) {
dba::update('thread', array('mention' => true), array('iid' => $parent_id)); dba::update('thread', ['mention' => true], ['iid' => $parent_id]);
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG); logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
} }
} }
@ -890,7 +890,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
} }
// On Friendica and Diaspora the GUID is unique // On Friendica and Diaspora the GUID is unique
if (in_array($arr['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) { if (in_array($arr['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
$r = q("SELECT `id` FROM `item` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($arr['guid']), dbesc($arr['guid']),
intval($arr['uid']) intval($arr['uid'])
@ -919,7 +919,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
$arr["global"] = true; $arr["global"] = true;
// Set the global flag on all items if this was a global item entry // Set the global flag on all items if this was a global item entry
dba::update('item', array('global' => true), array('uri' => $arr["uri"])); dba::update('item', ['global' => true], ['uri' => $arr["uri"]]);
} else { } else {
$isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"])); $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"]));
@ -1030,7 +1030,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
logger('Duplicated post occurred. uri = ' . $arr['uri'] . ' uid = ' . $arr['uid']); logger('Duplicated post occurred. uri = ' . $arr['uri'] . ' uid = ' . $arr['uid']);
// Yes, we could do a rollback here - but we are having many users with MyISAM. // Yes, we could do a rollback here - but we are having many users with MyISAM.
dba::delete('item', array('id' => $current_post)); dba::delete('item', ['id' => $current_post]);
dba::commit(); dba::commit();
return 0; return 0;
} elseif ($r[0]["entries"] == 0) { } elseif ($r[0]["entries"] == 0) {
@ -1048,7 +1048,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
} }
// Set parent id // Set parent id
dba::update('item', array('parent' => $parent_id), array('id' => $current_post)); dba::update('item', ['parent' => $parent_id], ['id' => $current_post]);
$arr['id'] = $current_post; $arr['id'] = $current_post;
$arr['parent'] = $parent_id; $arr['parent'] = $parent_id;
@ -1056,9 +1056,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
// update the commented timestamp on the parent // update the commented timestamp on the parent
// Only update "commented" if it is really a comment // Only update "commented" if it is really a comment
if (($arr['verb'] == ACTIVITY_POST) || !Config::get("system", "like_no_comment")) { if (($arr['verb'] == ACTIVITY_POST) || !Config::get("system", "like_no_comment")) {
dba::update('item', array('commented' => datetime_convert(), 'changed' => datetime_convert()), array('id' => $parent_id)); dba::update('item', ['commented' => datetime_convert(), 'changed' => datetime_convert()], ['id' => $parent_id]);
} else { } else {
dba::update('item', array('changed' => datetime_convert()), array('id' => $parent_id)); dba::update('item', ['changed' => datetime_convert()], ['id' => $parent_id]);
} }
if ($dsprsig) { if ($dsprsig) {
@ -1072,8 +1072,8 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG); logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG);
} }
dba::insert('sign', array('iid' => $current_post, 'signed_text' => $dsprsig->signed_text, dba::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer)); 'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer]);
} }
$deleted = tag_deliver($arr['uid'], $current_post); $deleted = tag_deliver($arr['uid'], $current_post);
@ -1132,7 +1132,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
check_user_notification($current_post); check_user_notification($current_post);
if ($notify) { if ($notify) {
Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "Notifier", $notify_type, $current_post); Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", $notify_type, $current_post);
} }
return $current_post; return $current_post;
@ -1174,17 +1174,17 @@ function item_set_last_item($arr) {
} }
if ($update) { if ($update) {
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']), dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
array('id' => $arr['contact-id'])); ['id' => $arr['contact-id']]);
} }
// Now do the same for the system wide contacts with uid=0 // Now do the same for the system wide contacts with uid=0
if (!$arr['private']) { if (!$arr['private']) {
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']), dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
array('id' => $arr['owner-id'])); ['id' => $arr['owner-id']]);
if ($arr['owner-id'] != $arr['author-id']) { if ($arr['owner-id'] != $arr['author-id']) {
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']), dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
array('id' => $arr['author-id'])); ['id' => $arr['author-id']]);
} }
} }
} }
@ -1299,7 +1299,7 @@ function get_item_id($guid, $uid = 0) {
$nick = $r[0]["nickname"]; $nick = $r[0]["nickname"];
} }
} }
return array("nick" => $nick, "id" => $id); return ["nick" => $nick, "id" => $id];
} }
// return - test // return - test
@ -1369,13 +1369,13 @@ function tag_deliver($uid, $item_id)
// mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment) // mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment)
// delete it! // delete it!
logger("tag_deliver: no-mention top-level post to communuty or private group. delete."); logger("tag_deliver: no-mention top-level post to communuty or private group. delete.");
dba::delete('item', array('id' => $item_id)); dba::delete('item', ['id' => $item_id]);
return true; return true;
} }
return; return;
} }
$arr = array('item' => $item, 'user' => $u[0], 'contact' => $r[0]); $arr = ['item' => $item, 'user' => $u[0], 'contact' => $r[0]];
call_hooks('tagged', $arr); call_hooks('tagged', $arr);
@ -1421,7 +1421,7 @@ function tag_deliver($uid, $item_id)
); );
update_thread($item_id); update_thread($item_id);
Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), 'Notifier', 'tgroup', $item_id); Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', 'tgroup', $item_id);
} }
@ -1664,8 +1664,8 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
if (is_array($contact)) { if (is_array($contact)) {
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING) if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) { || ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true), dba::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
array('id' => $contact['id'], 'uid' => $importer['uid'])); ['id' => $contact['id'], 'uid' => $importer['uid']]);
} }
// send email notification to owner? // send email notification to owner?
} else { } else {
@ -1697,22 +1697,22 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
intval($importer['uid']) intval($importer['uid'])
); );
if (DBM::is_result($r) && !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { if (DBM::is_result($r) && !in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
// create notification // create notification
$hash = random_string(); $hash = random_string();
if (is_array($contact_record)) { if (is_array($contact_record)) {
dba::insert('intro', array('uid' => $importer['uid'], 'contact-id' => $contact_record['id'], dba::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
'blocked' => false, 'knowyou' => false, 'blocked' => false, 'knowyou' => false,
'hash' => $hash, 'datetime' => datetime_convert())); 'hash' => $hash, 'datetime' => datetime_convert()]);
} }
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']); Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
if (($r[0]['notify-flags'] & NOTIFY_INTRO) && if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
in_array($r[0]['page-flags'], array(PAGE_NORMAL))) { in_array($r[0]['page-flags'], [PAGE_NORMAL])) {
notification(array( notification([
'type' => NOTIFY_INTRO, 'type' => NOTIFY_INTRO,
'notify_flags' => $r[0]['notify-flags'], 'notify_flags' => $r[0]['notify-flags'],
'language' => $r[0]['language'], 'language' => $r[0]['language'],
@ -1725,10 +1725,10 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
'source_photo' => $contact_record['photo'], 'source_photo' => $contact_record['photo'],
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW), 'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
'otype' => 'intro' 'otype' => 'intro'
)); ]);
} }
} elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { } elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1", q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
intval($importer['uid']), intval($importer['uid']),
dbesc($url) dbesc($url)
@ -1738,19 +1738,19 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
} }
} }
function lose_follower($importer, $contact, array $datarray = array(), $item = "") { function lose_follower($importer, $contact, array $datarray = [], $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) { if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
dba::update('contact', array('rel' => CONTACT_IS_SHARING), array('id' => $contact['id'])); dba::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
} else { } else {
Contact::remove($contact['id']); Contact::remove($contact['id']);
} }
} }
function lose_sharer($importer, $contact, array $datarray = array(), $item = "") { function lose_sharer($importer, $contact, array $datarray = [], $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) { if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id'])); dba::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
} else { } else {
Contact::remove($contact['id']); Contact::remove($contact['id']);
} }
@ -1785,7 +1785,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token); logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) { if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
dba::update('contact', array('hub-verify' => $verify_token), array('id' => $contact['id'])); dba::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
} }
post_url($url, $params); post_url($url, $params);
@ -1830,7 +1830,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0)
// Only embed locally hosted photos // Only embed locally hosted photos
$replace = false; $replace = false;
$i = basename($image); $i = basename($image);
$i = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $i); $i = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $i);
$x = strpos($i, '-'); $x = strpos($i, '-');
if ($x) { if ($x) {
@ -1955,13 +1955,13 @@ function enumerate_permissions($obj) {
} }
function item_getfeedtags($item) { function item_getfeedtags($item) {
$ret = array(); $ret = [];
$matches = false; $matches = false;
$cnt = preg_match_all('|\#\[url\=(.*?)\](.*?)\[\/url\]|', $item['tag'], $matches); $cnt = preg_match_all('|\#\[url\=(.*?)\](.*?)\[\/url\]|', $item['tag'], $matches);
if ($cnt) { if ($cnt) {
for ($x = 0; $x < $cnt; $x ++) { for ($x = 0; $x < $cnt; $x ++) {
if ($matches[1][$x]) { if ($matches[1][$x]) {
$ret[$matches[2][$x]] = array('#', $matches[1][$x], $matches[2][$x]); $ret[$matches[2][$x]] = ['#', $matches[1][$x], $matches[2][$x]];
} }
} }
} }
@ -1970,7 +1970,7 @@ function item_getfeedtags($item) {
if ($cnt) { if ($cnt) {
for ($x = 0; $x < $cnt; $x ++) { for ($x = 0; $x < $cnt; $x ++) {
if ($matches[1][$x]) { if ($matches[1][$x]) {
$ret[] = array('@', $matches[1][$x], $matches[2][$x]); $ret[] = ['@', $matches[1][$x], $matches[2][$x]];
} }
} }
} }
@ -2052,7 +2052,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
drop_item($item['id'], false); drop_item($item['id'], false);
} }
Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "Notifier", "expire", $uid); Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "Notifier", "expire", $uid);
} }
/// @TODO type-hint is array /// @TODO type-hint is array
@ -2074,7 +2074,7 @@ function drop_items($items) {
// multiple threads may have been deleted, send an expire notification // multiple threads may have been deleted, send an expire notification
if ($uid) { if ($uid) {
Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "Notifier", "expire", $uid); Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "Notifier", "expire", $uid);
} }
} }
@ -2126,15 +2126,15 @@ function drop_item($id, $interactive = true) {
// <form> can't take arguments in its "action" parameter // <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs // so add any arguments as hidden inputs
$query = explode_querystring($a->query_string); $query = explode_querystring($a->query_string);
$inputs = array(); $inputs = [];
foreach ($query['args'] as $arg) { foreach ($query['args'] as $arg) {
if (strpos($arg, 'confirm=') === false) { if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg); $arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
} }
} }
return replace_macros(get_markup_template('confirm.tpl'), array( return replace_macros(get_markup_template('confirm.tpl'), [
'$method' => 'get', '$method' => 'get',
'$message' => t('Do you really want to delete this item?'), '$message' => t('Do you really want to delete this item?'),
'$extra_inputs' => $inputs, '$extra_inputs' => $inputs,
@ -2142,7 +2142,7 @@ function drop_item($id, $interactive = true) {
'$confirm_url' => $query['base'], '$confirm_url' => $query['base'],
'$confirm_name' => 'confirmed', '$confirm_name' => 'confirmed',
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
)); ]);
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if ($_REQUEST['canceled']) { if ($_REQUEST['canceled']) {
@ -2152,9 +2152,9 @@ function drop_item($id, $interactive = true) {
logger('delete item: ' . $item['id'], LOGGER_DEBUG); logger('delete item: ' . $item['id'], LOGGER_DEBUG);
// delete the item // delete the item
dba::update('item', array('deleted' => true, 'title' => '', 'body' => '', dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
'edited' => datetime_convert(), 'changed' => datetime_convert()), 'edited' => datetime_convert(), 'changed' => datetime_convert()],
array('id' => $item['id'])); ['id' => $item['id']]);
create_tags_from_item($item['id']); create_tags_from_item($item['id']);
Term::createFromItem($item['id']); Term::createFromItem($item['id']);
@ -2186,18 +2186,18 @@ function drop_item($id, $interactive = true) {
* generate a resource-id and therefore aren't intimately linked to the item. * generate a resource-id and therefore aren't intimately linked to the item.
*/ */
if (strlen($item['resource-id'])) { if (strlen($item['resource-id'])) {
dba::delete('photo', array('resource-id' => $item['resource-id'], 'uid' => $item['uid'])); dba::delete('photo', ['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
} }
// If item is a link to an event, nuke the event record. // If item is a link to an event, nuke the event record.
if (intval($item['event-id'])) { if (intval($item['event-id'])) {
dba::delete('event', array('id' => $item['event-id'], 'uid' => $item['uid'])); dba::delete('event', ['id' => $item['event-id'], 'uid' => $item['uid']]);
} }
// If item has attachments, drop them // If item has attachments, drop them
foreach (explode(", ", $item['attach']) as $attach) { foreach (explode(", ", $item['attach']) as $attach) {
preg_match("|attach/(\d+)|", $attach, $matches); preg_match("|attach/(\d+)|", $attach, $matches);
dba::delete('attach', array('id' => $matches[1], 'uid' => $item['uid'])); dba::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
} }
// The new code splits the queries since the mysql optimizer really has bad problems with subqueries // The new code splits the queries since the mysql optimizer really has bad problems with subqueries
@ -2225,9 +2225,9 @@ function drop_item($id, $interactive = true) {
// If it's the parent of a comment thread, kill all the kids // If it's the parent of a comment thread, kill all the kids
if ($item['uri'] == $item['parent-uri']) { if ($item['uri'] == $item['parent-uri']) {
dba::update('item', array('deleted' => true, 'title' => '', 'body' => '', dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
'edited' => datetime_convert(), 'changed' => datetime_convert()), 'edited' => datetime_convert(), 'changed' => datetime_convert()],
array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid'])); ['parent-uri' => $item['parent-uri'], 'uid' => $item['uid']]);
create_tags_from_itemuri($item['parent-uri'], $item['uid']); create_tags_from_itemuri($item['parent-uri'], $item['uid']);
Term::createFromItemURI($item['parent-uri'], $item['uid']); Term::createFromItemURI($item['parent-uri'], $item['uid']);
@ -2235,8 +2235,8 @@ function drop_item($id, $interactive = true) {
// ignore the result // ignore the result
} else { } else {
// ensure that last-child is set in case the comment that had it just got wiped. // ensure that last-child is set in case the comment that had it just got wiped.
dba::update('item', array('last-child' => false, 'changed' => datetime_convert()), dba::update('item', ['last-child' => false, 'changed' => datetime_convert()],
array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid'])); ['parent-uri' => $item['parent-uri'], 'uid' => $item['uid']]);
// who is the last child now? // who is the last child now?
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
@ -2244,7 +2244,7 @@ function drop_item($id, $interactive = true) {
intval($item['uid']) intval($item['uid'])
); );
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
dba::update('item', array('last-child' => true), array('id' => $r[0]['id'])); dba::update('item', ['last-child' => true], ['id' => $r[0]['id']]);
} }
} }
@ -2253,7 +2253,7 @@ function drop_item($id, $interactive = true) {
$drop_id = intval($item['id']); $drop_id = intval($item['id']);
$priority = ($interactive ? PRIORITY_HIGH : PRIORITY_LOW); $priority = ($interactive ? PRIORITY_HIGH : PRIORITY_LOW);
Worker::add(array('priority' => $priority, 'dont_fork' => true), "Notifier", "drop", $drop_id); Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", $drop_id);
if (! $interactive) { if (! $interactive) {
return $owner; return $owner;
@ -2293,14 +2293,14 @@ function list_post_dates($uid, $wall) {
$dthen = first_post_date($uid, $wall); $dthen = first_post_date($uid, $wall);
if (! $dthen) { if (! $dthen) {
return array(); return [];
} }
// Set the start and end date to the beginning of the month // Set the start and end date to the beginning of the month
$dnow = substr($dnow, 0, 8) . '01'; $dnow = substr($dnow, 0, 8) . '01';
$dthen = substr($dthen, 0, 8) . '01'; $dthen = substr($dthen, 0, 8) . '01';
$ret = array(); $ret = [];
/* /*
* Starting with the current month, get the first and last days of every * Starting with the current month, get the first and last days of every
@ -2314,9 +2314,9 @@ function list_post_dates($uid, $wall) {
$end_month = datetime_convert('', '', $dend, 'Y-m-d'); $end_month = datetime_convert('', '', $dend, 'Y-m-d');
$str = day_translate(datetime_convert('', '', $dnow, 'F')); $str = day_translate(datetime_convert('', '', $dnow, 'F'));
if (!$ret[$dyear]) { if (!$ret[$dyear]) {
$ret[$dyear] = array(); $ret[$dyear] = [];
} }
$ret[$dyear][] = array($str, $end_month, $start_month); $ret[$dyear][] = [$str, $end_month, $start_month];
$dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d'); $dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d');
} }
return $ret; return $ret;
@ -2327,14 +2327,14 @@ function posted_dates($uid, $wall) {
$dthen = first_post_date($uid, $wall); $dthen = first_post_date($uid, $wall);
if (! $dthen) { if (! $dthen) {
return array(); return [];
} }
// Set the start and end date to the beginning of the month // Set the start and end date to the beginning of the month
$dnow = substr($dnow, 0, 8) . '01'; $dnow = substr($dnow, 0, 8) . '01';
$dthen = substr($dthen, 0, 8) . '01'; $dthen = substr($dthen, 0, 8) . '01';
$ret = array(); $ret = [];
/* /*
* Starting with the current month, get the first and last days of every * Starting with the current month, get the first and last days of every
* month down to and including the month of the first post * month down to and including the month of the first post
@ -2345,7 +2345,7 @@ function posted_dates($uid, $wall) {
$start_month = datetime_convert('', '', $dstart, 'Y-m-d'); $start_month = datetime_convert('', '', $dstart, 'Y-m-d');
$end_month = datetime_convert('', '', $dend, 'Y-m-d'); $end_month = datetime_convert('', '', $dend, 'Y-m-d');
$str = day_translate(datetime_convert('', '', $dnow, 'F Y')); $str = day_translate(datetime_convert('', '', $dnow, 'F Y'));
$ret[] = array($str, $end_month, $start_month); $ret[] = [$str, $end_month, $start_month];
$dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d'); $dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d');
} }
return $ret; return $ret;
@ -2380,7 +2380,7 @@ function posted_date_widget($url, $uid, $wall) {
$cutoff_year = intval(datetime_convert('',date_default_timezone_get(), 'now', 'Y')) - $visible_years; $cutoff_year = intval(datetime_convert('',date_default_timezone_get(), 'now', 'Y')) - $visible_years;
$cutoff = ((array_key_exists($cutoff_year, $ret))? true : false); $cutoff = ((array_key_exists($cutoff_year, $ret))? true : false);
$o = replace_macros(get_markup_template('posted_date_widget.tpl'),array( $o = replace_macros(get_markup_template('posted_date_widget.tpl'),[
'$title' => t('Archives'), '$title' => t('Archives'),
'$size' => $visible_years, '$size' => $visible_years,
'$cutoff_year' => $cutoff_year, '$cutoff_year' => $cutoff_year,
@ -2389,6 +2389,6 @@ function posted_date_widget($url, $uid, $wall) {
'$dates' => $ret, '$dates' => $ret,
'$showmore' => t('show more') '$showmore' => t('show more')
)); ]);
return $o; return $o;
} }

View file

@ -168,7 +168,7 @@ function do_like($item_id, $verb) {
// Clean up the Diaspora signatures for this like // Clean up the Diaspora signatures for this like
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up // Go ahead and do it even if Diaspora support is disabled. We still want to clean up
// if it had been enabled in the past // if it had been enabled in the past
dba::delete('sign', array('iid' => $like_item['id'])); dba::delete('sign', ['iid' => $like_item['id']]);
$like_item_id = $like_item['id']; $like_item_id = $like_item['id'];
Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item_id); Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item_id);
@ -208,7 +208,7 @@ EOT;
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; $alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
$plink = '[url=' . System::baseUrl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]'; $plink = '[url=' . System::baseUrl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
$new_item = array( $new_item = [
'guid' => get_guid(32), 'guid' => get_guid(32),
'uri' => item_new_uri($a->get_hostname(), $item['uid']), 'uri' => item_new_uri($a->get_hostname(), $item['uid']),
'uid' => $item['uid'], 'uid' => $item['uid'],
@ -239,7 +239,7 @@ EOT;
'visible' => 1, 'visible' => 1,
'unseen' => 1, 'unseen' => 1,
'last-child' => 0 'last-child' => 0
); ];
$new_item_id = item_store($new_item); $new_item_id = item_store($new_item);

View file

@ -20,7 +20,7 @@ function nav(App $a) {
if (!(x($a->page,'nav'))) if (!(x($a->page,'nav')))
$a->page['nav'] = ''; $a->page['nav'] = '';
$a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array()); $a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), []);
/* /*
* Placeholder div for popup panel * Placeholder div for popup panel
@ -36,7 +36,7 @@ function nav(App $a) {
$tpl = get_markup_template('nav.tpl'); $tpl = get_markup_template('nav.tpl');
$a->page['nav'] .= replace_macros($tpl, array( $a->page['nav'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$sitelocation' => $nav_info['sitelocation'], '$sitelocation' => $nav_info['sitelocation'],
'$nav' => $nav_info['nav'], '$nav' => $nav_info['nav'],
@ -47,7 +47,7 @@ function nav(App $a) {
'$apps' => $a->apps, '$apps' => $a->apps,
'$clear_notifs' => t('Clear notifications'), '$clear_notifs' => t('Clear notifications'),
'$search_hint' => t('@name, !forum, #tags, content') '$search_hint' => t('@name, !forum, #tags, content')
)); ]);
call_hooks('page_header', $a->page['nav']); call_hooks('page_header', $a->page['nav']);
} }
@ -77,31 +77,31 @@ function nav_info(App $a)
$sitelocation = $myident . substr(System::baseUrl($ssl_state), strpos(System::baseUrl($ssl_state), '//') + 2 ); $sitelocation = $myident . substr(System::baseUrl($ssl_state), strpos(System::baseUrl($ssl_state), '//') + 2 );
// nav links: array of array('href', 'text', 'extra css classes', 'title') // nav links: array of array('href', 'text', 'extra css classes', 'title')
$nav = array(); $nav = [];
// Display login or logout // Display login or logout
$nav['usermenu'] = array(); $nav['usermenu'] = [];
$userinfo = null; $userinfo = null;
if (local_user()) { if (local_user()) {
$nav['logout'] = array('logout', t('Logout'), '', t('End this session')); $nav['logout'] = ['logout', t('Logout'), '', t('End this session')];
// user menu // user menu
$nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations')); $nav['usermenu'][] = ['profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations')];
$nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page')); $nav['usermenu'][] = ['profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page')];
$nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos')); $nav['usermenu'][] = ['photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos')];
$nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos')); $nav['usermenu'][] = ['videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos')];
$nav['usermenu'][] = array('events/', t('Events'), '', t('Your events')); $nav['usermenu'][] = ['events/', t('Events'), '', t('Your events')];
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes')); $nav['usermenu'][] = ['notes/', t('Personal notes'), '', t('Your personal notes')];
// user info // user info
$contact = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]); $contact = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
$userinfo = array( $userinfo = [
'icon' => (DBM::is_result($contact) ? $a->remove_baseurl($contact['micro']) : 'images/person-48.jpg'), 'icon' => (DBM::is_result($contact) ? $a->remove_baseurl($contact['micro']) : 'images/person-48.jpg'),
'name' => $a->user['username'], 'name' => $a->user['username'],
); ];
} else { } else {
$nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in')); $nav['login'] = ['login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in')];
} }
// "Home" should also take you home from an authenticated remote profile connection // "Home" should also take you home from an authenticated remote profile connection
@ -111,30 +111,30 @@ function nav_info(App $a)
} }
if (($a->module != 'home') && (! (local_user()))) { if (($a->module != 'home') && (! (local_user()))) {
$nav['home'] = array($homelink, t('Home'), '', t('Home Page')); $nav['home'] = [$homelink, t('Home'), '', t('Home Page')];
} }
if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) { if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
$nav['register'] = array('register', t('Register'), '', t('Create an account')); $nav['register'] = ['register', t('Register'), '', t('Create an account')];
} }
$help_url = 'help'; $help_url = 'help';
if (!Config::get('system', 'hide_help')) { if (!Config::get('system', 'hide_help')) {
$nav['help'] = array($help_url, t('Help'), '', t('Help and documentation')); $nav['help'] = [$help_url, t('Help'), '', t('Help and documentation')];
} }
if (count($a->apps) > 0) { if (count($a->apps) > 0) {
$nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games')); $nav['apps'] = ['apps', t('Apps'), '', t('Addon applications, utilities, games')];
} }
if (local_user() || !Config::get('system', 'local_search')) { if (local_user() || !Config::get('system', 'local_search')) {
$nav['search'] = array('search', t('Search'), '', t('Search site content')); $nav['search'] = ['search', t('Search'), '', t('Search site content')];
$nav['searchoption'] = array( $nav['searchoption'] = [
t('Full Text'), t('Full Text'),
t('Tags'), t('Tags'),
t('Contacts')); t('Contacts')];
if (Config::get('system', 'poco_local_search')) { if (Config::get('system', 'poco_local_search')) {
$nav['searchoption'][] = t('Forums'); $nav['searchoption'][] = t('Forums');
@ -151,62 +151,62 @@ function nav_info(App $a)
} }
if (local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) { if (local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) {
$nav['community'] = array('community', t('Community'), '', t('Conversations on this and other servers')); $nav['community'] = ['community', t('Community'), '', t('Conversations on this and other servers')];
} }
if (local_user()) { if (local_user()) {
$nav['events'] = array('events', t('Events'), '', t('Events and Calendar')); $nav['events'] = ['events', t('Events'), '', t('Events and Calendar')];
} }
$nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory')); $nav['directory'] = [$gdirpath, t('Directory'), '', t('People directory')];
$nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance')); $nav['about'] = ['friendica', t('Information'), '', t('Information about this friendica instance')];
// The following nav links are only show to logged in users // The following nav links are only show to logged in users
if (local_user()) { if (local_user()) {
$nav['network'] = array('network', t('Network'), '', t('Conversations from your friends')); $nav['network'] = ['network', t('Network'), '', t('Conversations from your friends')];
$nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters')); $nav['net_reset'] = ['network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters')];
$nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations')); $nav['home'] = ['profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations')];
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) { if (in_array($_SESSION['page_flags'], [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP])) {
// only show friend requests for normal pages. Other page types have automatic friendship. // only show friend requests for normal pages. Other page types have automatic friendship.
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) { if (in_array($_SESSION['page_flags'], [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP])) {
$nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests')); $nav['introductions'] = ['notifications/intros', t('Introductions'), '', t('Friend Requests')];
} }
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) { if (in_array($_SESSION['page_flags'], [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE])) {
$nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications')); $nav['notifications'] = ['notifications', t('Notifications'), '', t('Notifications')];
$nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', ''); $nav['notifications']['all'] = ['notifications/system', t('See all notifications'), '', ''];
$nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen')); $nav['notifications']['mark'] = ['', t('Mark as seen'), '', t('Mark all system notifications seen')];
} }
} }
$nav['messages'] = array('message', t('Messages'), '', t('Private mail')); $nav['messages'] = ['message', t('Messages'), '', t('Private mail')];
$nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox')); $nav['messages']['inbox'] = ['message', t('Inbox'), '', t('Inbox')];
$nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox')); $nav['messages']['outbox'] = ['message/sent', t('Outbox'), '', t('Outbox')];
$nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message')); $nav['messages']['new'] = ['message/new', t('New Message'), '', t('New Message')];
if (is_array($a->identities) && count($a->identities) > 1) { if (is_array($a->identities) && count($a->identities) > 1) {
$nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages')); $nav['manage'] = ['manage', t('Manage'), '', t('Manage other pages')];
} }
$nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management')); $nav['delegations'] = ['delegate', t('Delegations'), '', t('Delegate Page Management')];
$nav['settings'] = array('settings', t('Settings'), '', t('Account settings')); $nav['settings'] = ['settings', t('Settings'), '', t('Account settings')];
if (Feature::isEnabled(local_user(), 'multi_profiles')) { if (Feature::isEnabled(local_user(), 'multi_profiles')) {
$nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles')); $nav['profiles'] = ['profiles', t('Profiles'), '', t('Manage/Edit Profiles')];
} }
$nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts')); $nav['contacts'] = ['contacts', t('Contacts'), '', t('Manage/edit friends and contacts')];
} }
// Show the link to the admin configuration page if user is admin // Show the link to the admin configuration page if user is admin
if (is_site_admin()) { if (is_site_admin()) {
$nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration')); $nav['admin'] = ['admin/', t('Admin'), '', t('Site setup and configuration')];
} }
$nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map')); $nav['navigation'] = ['navigation/', t('Navigation'), '', t('Site map')];
// Provide a banner/logo/whatever // Provide a banner/logo/whatever
$banner = Config::get('system', 'banner'); $banner = Config::get('system', 'banner');
@ -216,12 +216,12 @@ function nav_info(App $a)
call_hooks('nav_info', $nav); call_hooks('nav_info', $nav);
return array( return [
'sitelocation' => $sitelocation, 'sitelocation' => $sitelocation,
'nav' => $nav, 'nav' => $nav,
'banner' => $banner, 'banner' => $banner,
'userinfo' => $userinfo, 'userinfo' => $userinfo,
); ];
} }
/** /**
@ -230,7 +230,7 @@ function nav_info(App $a)
*/ */
function nav_set_selected($item){ function nav_set_selected($item){
$a = get_app(); $a = get_app();
$a->nav_sel = array( $a->nav_sel = [
'global' => null, 'global' => null,
'community' => null, 'community' => null,
'network' => null, 'network' => null,
@ -245,6 +245,6 @@ function nav_set_selected($item){
'manage' => null, 'manage' => null,
'events' => null, 'events' => null,
'register' => null, 'register' => null,
); ];
$a->nav_sel[$item] = 'selected'; $a->nav_sel[$item] = 'selected';
} }

View file

@ -32,10 +32,10 @@ function fetch_url($url, $binary = false, &$redirects = 0, $timeout = 0, $accept
$url, $url,
$binary, $binary,
$redirects, $redirects,
array('timeout'=>$timeout, ['timeout'=>$timeout,
'accept_content'=>$accept_content, 'accept_content'=>$accept_content,
'cookiejar'=>$cookiejar 'cookiejar'=>$cookiejar
) ]
); );
return($ret['body']); return($ret['body']);
@ -63,9 +63,9 @@ function fetch_url($url, $binary = false, &$redirects = 0, $timeout = 0, $accept
* string 'header' => HTTP headers * string 'header' => HTTP headers
* string 'body' => fetched content * string 'body' => fetched content
*/ */
function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = [])
{ {
$ret = array('return_code' => 0, 'success' => false, 'header' => '', 'info' => '', 'body' => ''); $ret = ['return_code' => 0, 'success' => false, 'header' => '', 'info' => '', 'body' => ''];
$stamp1 = microtime(true); $stamp1 = microtime(true);
@ -97,7 +97,7 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array())
curl_setopt( curl_setopt(
$ch, $ch,
CURLOPT_HTTPHEADER, CURLOPT_HTTPHEADER,
array('Accept: ' . $opts['accept_content']) ['Accept: ' . $opts['accept_content']]
); );
} }
@ -213,7 +213,7 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array())
$newurl = $new_location_info['scheme'] . '://' . $new_location_info['host'] . $old_location_info['path']; $newurl = $new_location_info['scheme'] . '://' . $new_location_info['host'] . $old_location_info['path'];
} }
$matches = array(); $matches = [];
if (preg_match('/(Location:|URI:)(.*?)\n/i', $header, $matches)) { if (preg_match('/(Location:|URI:)(.*?)\n/i', $header, $matches)) {
$newurl = trim(array_pop($matches)); $newurl = trim(array_pop($matches));
@ -306,7 +306,7 @@ function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
if (defined('LIGHTTPD')) { if (defined('LIGHTTPD')) {
if (!is_array($headers)) { if (!is_array($headers)) {
$headers = array('Expect:'); $headers = ['Expect:'];
} else { } else {
if (!in_array('Expect:', $headers)) { if (!in_array('Expect:', $headers)) {
array_push($headers, 'Expect:'); array_push($headers, 'Expect:');
@ -361,7 +361,7 @@ function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
} }
if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) { if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
$matches = array(); $matches = [];
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
$newurl = trim(array_pop($matches)); $newurl = trim(array_pop($matches));
@ -397,7 +397,7 @@ function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
function xml_status($st, $message = '') function xml_status($st, $message = '')
{ {
$result = array('status' => $st); $result = ['status' => $st];
if ($message != '') { if ($message != '') {
$result['message'] = $message; $result['message'] = $message;
@ -409,7 +409,7 @@ function xml_status($st, $message = '')
header("Content-type: text/xml"); header("Content-type: text/xml");
$xmldata = array("result" => $result); $xmldata = ["result" => $result];
echo XML::fromArray($xmldata, $xml); echo XML::fromArray($xmldata, $xml);
@ -433,7 +433,7 @@ function xml_status($st, $message = '')
* 'title' => header title * 'title' => header title
* 'description' => optional message * 'description' => optional message
*/ */
function http_status_exit($val, $description = array()) function http_status_exit($val, $description = [])
{ {
$err = ''; $err = '';
if ($val >= 400) { if ($val >= 400) {
@ -452,9 +452,9 @@ function http_status_exit($val, $description = array())
$tpl = get_markup_template('http_status.tpl'); $tpl = get_markup_template('http_status.tpl');
echo replace_macros( echo replace_macros(
$tpl, $tpl,
array( [
'$title' => $description["title"], '$title' => $description["title"],
'$description' => $description["description"]) '$description' => $description["description"]]
); );
} }
@ -581,7 +581,7 @@ function blocked_url($url)
return true; return true;
} }
$domain_blocklist = Config::get('system', 'blocklist', array()); $domain_blocklist = Config::get('system', 'blocklist', []);
if (! $domain_blocklist) { if (! $domain_blocklist) {
return false; return false;
} }
@ -777,10 +777,10 @@ function fix_contact_ssl_policy(&$contact, $new_policy)
} }
if ($ssl_changed) { if ($ssl_changed) {
$fields = array('url' => $contact['url'], 'request' => $contact['request'], $fields = ['url' => $contact['url'], 'request' => $contact['request'],
'notify' => $contact['notify'], 'poll' => $contact['poll'], 'notify' => $contact['notify'], 'poll' => $contact['poll'],
'confirm' => $contact['confirm'], 'poco' => $contact['poco']); 'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
dba::update('contact', $fields, array('id' => $contact['id'])); dba::update('contact', $fields, ['id' => $contact['id']]);
} }
} }
@ -801,12 +801,12 @@ function strip_tracking_query_params($url)
foreach ($querydata as $param => $value) { foreach ($querydata as $param => $value) {
if (in_array( if (in_array(
$param, $param,
array( [
"utm_source", "utm_medium", "utm_term", "utm_content", "utm_campaign", "utm_source", "utm_medium", "utm_term", "utm_content", "utm_campaign",
"wt_mc", "pk_campaign", "pk_kwd", "mc_cid", "mc_eid", "wt_mc", "pk_campaign", "pk_kwd", "mc_cid", "mc_eid",
"fb_action_ids", "fb_action_types", "fb_ref", "fb_action_ids", "fb_action_types", "fb_ref",
"awesm", "wtrid", "awesm", "wtrid",
"woo_campaign", "woo_source", "woo_medium", "woo_content", "woo_term") "woo_campaign", "woo_source", "woo_medium", "woo_content", "woo_term"]
) )
) { ) {
$pair = $param . "=" . urlencode($value); $pair = $param . "=" . urlencode($value);
@ -820,7 +820,7 @@ function strip_tracking_query_params($url)
$pair = $param . "=" . $value; $pair = $param . "=" . $value;
$url = str_replace($pair, "", $url); $url = str_replace($pair, "", $url);
$url = str_replace(array("?&", "&&"), array("?", ""), $url); $url = str_replace(["?&", "&&"], ["?", ""], $url);
} }
} }
} }
@ -932,7 +932,7 @@ function original_url($url, $depth = 1, $fetchbody = false)
$list = $xpath->query("//meta[@content]"); $list = $xpath->query("//meta[@content]");
foreach ($list as $node) { foreach ($list as $node) {
$attr = array(); $attr = [];
if ($node->attributes->length) { if ($node->attributes->length) {
foreach ($node->attributes as $attribute) { foreach ($node->attributes as $attribute) {
$attr[$attribute->name] = $attribute->value; $attr[$attribute->name] = $attribute->value;
@ -967,12 +967,12 @@ function short_link($url)
$yourls->set('password', $yourls_password); $yourls->set('password', $yourls_password);
$yourls->set('ssl', $yourls_ssl); $yourls->set('ssl', $yourls_ssl);
$yourls->set('yourls-url', $yourls_url); $yourls->set('yourls-url', $yourls_url);
$slinky->set_cascade(array($yourls, new Slinky_Ur1ca(), new Slinky_TinyURL())); $slinky->set_cascade([$yourls, new Slinky_Ur1ca(), new Slinky_TinyURL()]);
} else { } else {
// setup a cascade of shortening services // setup a cascade of shortening services
// try to get a short link from these services // try to get a short link from these services
// in the order ur1.ca, tinyurl // in the order ur1.ca, tinyurl
$slinky->set_cascade(array(new Slinky_Ur1ca(), new Slinky_TinyURL())); $slinky->set_cascade([new Slinky_Ur1ca(), new Slinky_TinyURL()]);
} }
return $slinky->short(); return $slinky->short();
} }

View file

@ -69,7 +69,7 @@ function push_lang($language) {
if (isset($a->strings) && count($a->strings)) { if (isset($a->strings) && count($a->strings)) {
$a->stringsave = $a->strings; $a->stringsave = $a->strings;
} }
$a->strings = array(); $a->strings = [];
load_translation_table($language); load_translation_table($language);
$lang = $language; $lang = $language;
} }
@ -84,7 +84,7 @@ function pop_lang() {
if (isset($a->stringsave)) { if (isset($a->stringsave)) {
$a->strings = $a->stringsave; $a->strings = $a->stringsave;
} else { } else {
$a->strings = array(); $a->strings = [];
} }
$lang = $a->langsave; $lang = $a->langsave;
@ -102,9 +102,9 @@ function pop_lang() {
function load_translation_table($lang) { function load_translation_table($lang) {
$a = get_app(); $a = get_app();
$a->strings = array(); $a->strings = [];
// load enabled plugins strings // load enabled plugins strings
$plugins = dba::select('addon', array('name'), array('installed' => true)); $plugins = dba::select('addon', ['name'], ['installed' => true]);
while ($p = dba::fetch($plugins)) { while ($p = dba::fetch($plugins)) {
$name = $p['name']; $name = $p['name'];
if (file_exists("addon/$name/lang/$lang/strings.php")) { if (file_exists("addon/$name/lang/$lang/strings.php")) {
@ -217,7 +217,7 @@ function string_plural_select_default($n)
* @return array * @return array
*/ */
function get_available_languages() { function get_available_languages() {
$langs = array(); $langs = [];
$strings_file_paths = glob('view/lang/*/strings.php'); $strings_file_paths = glob('view/lang/*/strings.php');
if (is_array($strings_file_paths) && count($strings_file_paths)) { if (is_array($strings_file_paths) && count($strings_file_paths)) {

View file

@ -26,14 +26,14 @@ require_once "include/network.php";
*/ */
function get_old_attachment_data($body) { function get_old_attachment_data($body) {
$post = array(); $post = [];
// Simplify image codes // Simplify image codes
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body); $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
if (preg_match_all("(\[class=(.*?)\](.*?)\[\/class\])ism",$body, $attached, PREG_SET_ORDER)) { if (preg_match_all("(\[class=(.*?)\](.*?)\[\/class\])ism",$body, $attached, PREG_SET_ORDER)) {
foreach ($attached AS $data) { foreach ($attached AS $data) {
if (!in_array($data[1], array("type-link", "type-video", "type-photo"))) if (!in_array($data[1], ["type-link", "type-video", "type-photo"]))
continue; continue;
$post["type"] = substr($data[1], 5); $post["type"] = substr($data[1], 5);
@ -63,7 +63,7 @@ function get_old_attachment_data($body) {
$post["url"] = $matches[1]; $post["url"] = $matches[1];
$post["title"] = $matches[2]; $post["title"] = $matches[2];
} }
if (($post["url"] == "") && (in_array($post["type"], array("link", "video"))) if (($post["url"] == "") && (in_array($post["type"], ["link", "video"]))
&& preg_match("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) { && preg_match("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) {
$post["url"] = $matches[1]; $post["url"] = $matches[1];
} }
@ -195,7 +195,7 @@ function get_attachment_data($body)
return $data; return $data;
} }
function get_attached_data($body, $item = array()) { function get_attached_data($body, $item = []) {
/* /*
- text: - text:
- type: link, video, photo - type: link, video, photo

View file

@ -18,7 +18,7 @@ use Friendica\Database\DBM;
*/ */
function uninstall_plugin($plugin) { function uninstall_plugin($plugin) {
logger("Addons: uninstalling " . $plugin); logger("Addons: uninstalling " . $plugin);
dba::delete('addon', array('name' => $plugin)); dba::delete('addon', ['name' => $plugin]);
@include_once('addon/' . $plugin . '/' . $plugin . '.php'); @include_once('addon/' . $plugin . '/' . $plugin . '.php');
if (function_exists($plugin . '_uninstall')) { if (function_exists($plugin . '_uninstall')) {
@ -48,15 +48,15 @@ function install_plugin($plugin) {
$plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0); $plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0);
dba::insert('addon', array('name' => $plugin, 'installed' => true, dba::insert('addon', ['name' => $plugin, 'installed' => true,
'timestamp' => $t, 'plugin_admin' => $plugin_admin)); 'timestamp' => $t, 'plugin_admin' => $plugin_admin]);
// we can add the following with the previous SQL // we can add the following with the previous SQL
// once most site tables have been updated. // once most site tables have been updated.
// This way the system won't fall over dead during the update. // This way the system won't fall over dead during the update.
if (file_exists('addon/' . $plugin . '/.hidden')) { if (file_exists('addon/' . $plugin . '/.hidden')) {
dba::update('addon', array('hidden' => true), array('name' => $plugin)); dba::update('addon', ['hidden' => true], ['name' => $plugin]);
} }
return true; return true;
} else { } else {
@ -75,7 +75,7 @@ function reload_plugins() {
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$installed = $r; $installed = $r;
} else { } else {
$installed = array(); $installed = [];
} }
$parr = explode(',',$plugins); $parr = explode(',',$plugins);
@ -102,7 +102,7 @@ function reload_plugins() {
$func = $pl . '_install'; $func = $pl . '_install';
$func(); $func();
} }
dba::update('addon', array('timestamp' => $t), array('id' => $i['id'])); dba::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
} }
} }
} }
@ -119,7 +119,7 @@ function reload_plugins() {
* @return boolean * @return boolean
*/ */
function plugin_enabled($plugin) { function plugin_enabled($plugin) {
return dba::exists('addon', array('installed' => true, 'name' => $plugin)); return dba::exists('addon', ['installed' => true, 'name' => $plugin]);
} }
@ -133,13 +133,13 @@ function plugin_enabled($plugin) {
* @return mixed|bool * @return mixed|bool
*/ */
function register_hook($hook, $file, $function, $priority=0) { function register_hook($hook, $file, $function, $priority=0) {
$condition = array('hook' => $hook, 'file' => $file, 'function' => $function); $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
$exists = dba::exists('hook', $condition); $exists = dba::exists('hook', $condition);
if ($exists) { if ($exists) {
return true; return true;
} }
$r = dba::insert('hook', array('hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority)); $r = dba::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]);
return $r; return $r;
} }
@ -153,7 +153,7 @@ function register_hook($hook, $file, $function, $priority=0) {
* @return array * @return array
*/ */
function unregister_hook($hook, $file, $function) { function unregister_hook($hook, $file, $function) {
$condition = array('hook' => $hook, 'file' => $file, 'function' => $function); $condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
$r = dba::delete('hook', $condition); $r = dba::delete('hook', $condition);
return $r; return $r;
} }
@ -161,14 +161,14 @@ function unregister_hook($hook, $file, $function) {
function load_hooks() { function load_hooks() {
$a = get_app(); $a = get_app();
$a->hooks = array(); $a->hooks = [];
$r = dba::select('hook', array('hook', 'file', 'function'), array(), array('order' => array('priority' => 'desc', 'file'))); $r = dba::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
while ($rr = dba::fetch($r)) { while ($rr = dba::fetch($r)) {
if (! array_key_exists($rr['hook'],$a->hooks)) { if (! array_key_exists($rr['hook'],$a->hooks)) {
$a->hooks[$rr['hook']] = array(); $a->hooks[$rr['hook']] = [];
} }
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']); $a->hooks[$rr['hook']][] = [$rr['file'],$rr['function']];
} }
dba::close($r); dba::close($r);
} }
@ -211,7 +211,7 @@ function call_single_hook($a, $name, $hook, &$data = null) {
$func($a, $data); $func($a, $data);
} else { } else {
// remove orphan hooks // remove orphan hooks
$condition = array('hook' => $name, 'file' => $hook[0], 'function' => $hook[1]); $condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
dba::delete('hook', $condition); dba::delete('hook', $condition);
} }
} }
@ -251,13 +251,13 @@ function get_plugin_info($plugin) {
$a = get_app(); $a = get_app();
$info=Array( $info=[
'name' => $plugin, 'name' => $plugin,
'description' => "", 'description' => "",
'author' => array(), 'author' => [],
'version' => "", 'version' => "",
'status' => "" 'status' => ""
); ];
if (!is_file("addon/$plugin/$plugin.php")) return $info; if (!is_file("addon/$plugin/$plugin.php")) return $info;
@ -277,9 +277,9 @@ function get_plugin_info($plugin) {
if ($k == "author") { if ($k == "author") {
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) { if ($r) {
$info['author'][] = array('name'=>$m[1], 'link'=>$m[2]); $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]];
} else { } else {
$info['author'][] = array('name'=>$v); $info['author'][] = ['name'=>$v];
} }
} else { } else {
if (array_key_exists($k,$info)) { if (array_key_exists($k,$info)) {
@ -312,16 +312,16 @@ function get_plugin_info($plugin) {
*/ */
function get_theme_info($theme) { function get_theme_info($theme) {
$info=Array( $info=[
'name' => $theme, 'name' => $theme,
'description' => "", 'description' => "",
'author' => array(), 'author' => [],
'maintainer' => array(), 'maintainer' => [],
'version' => "", 'version' => "",
'credits' => "", 'credits' => "",
'experimental' => false, 'experimental' => false,
'unsupported' => false 'unsupported' => false
); ];
if (file_exists("view/theme/$theme/experimental")) if (file_exists("view/theme/$theme/experimental"))
$info['experimental'] = true; $info['experimental'] = true;
@ -348,16 +348,16 @@ function get_theme_info($theme) {
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) { if ($r) {
$info['author'][] = array('name'=>$m[1], 'link'=>$m[2]); $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]];
} else { } else {
$info['author'][] = array('name'=>$v); $info['author'][] = ['name'=>$v];
} }
} elseif ($k == "maintainer") { } elseif ($k == "maintainer") {
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) { if ($r) {
$info['maintainer'][] = array('name'=>$m[1], 'link'=>$m[2]); $info['maintainer'][] = ['name'=>$m[1], 'link'=>$m[2]];
} else { } else {
$info['maintainer'][] = array('name'=>$v); $info['maintainer'][] = ['name'=>$v];
} }
} else { } else {
if (array_key_exists($k,$info)) { if (array_key_exists($k,$info)) {
@ -381,7 +381,7 @@ function get_theme_info($theme) {
* @return string * @return string
*/ */
function get_theme_screenshot($theme) { function get_theme_screenshot($theme) {
$exts = array('.png','.jpg'); $exts = ['.png','.jpg'];
foreach ($exts as $ext) { foreach ($exts as $ext) {
if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) { if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext); return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext);
@ -450,11 +450,11 @@ function theme_include($file, $root = '') {
$theme = current_theme(); $theme = current_theme();
$thname = $theme; $thname = $theme;
$ext = substr($file,strrpos($file,'.')+1); $ext = substr($file,strrpos($file,'.')+1);
$paths = array( $paths = [
"{$root}view/theme/$thname/$ext/$file", "{$root}view/theme/$thname/$ext/$file",
"{$root}view/theme/$parent/$ext/$file", "{$root}view/theme/$parent/$ext/$file",
"{$root}view/$ext/$file", "{$root}view/$ext/$file",
); ];
foreach ($paths as $p) { foreach ($paths as $p) {
// strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php) // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php)
if (strpos($p,'NOPATH') !== false) { if (strpos($p,'NOPATH') !== false) {

View file

@ -64,18 +64,18 @@ function post_update_1192() {
return false; return false;
} }
$item_arr = array(); $item_arr = [];
foreach ($r AS $item) { foreach ($r AS $item) {
$index = $item["author-link"]."-".$item["uid"]; $index = $item["author-link"]."-".$item["uid"];
$item_arr[$index] = array("author-link" => $item["author-link"], $item_arr[$index] = ["author-link" => $item["author-link"],
"uid" => $item["uid"], "uid" => $item["uid"],
"network" => $item["network"]); "network" => $item["network"]];
} }
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed // Set the "gcontact-id" in the item table and add a new gcontact entry if needed
foreach ($item_arr AS $item) { foreach ($item_arr AS $item) {
$gcontact_id = GContact::getId(array("url" => $item['author-link'], "network" => $item['network'], $gcontact_id = GContact::getId(["url" => $item['author-link'], "network" => $item['network'],
"photo" => $item['author-avatar'], "name" => $item['author-name'])); "photo" => $item['author-avatar'], "name" => $item['author-name']]);
q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0", q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0",
intval($gcontact_id), intval($item["uid"]), dbesc($item["author-link"])); intval($gcontact_id), intval($item["uid"]), dbesc($item["author-link"]));
} }
@ -200,12 +200,12 @@ function post_update_1198() {
logger("Query done", LOGGER_DEBUG); logger("Query done", LOGGER_DEBUG);
$item_arr = array(); $item_arr = [];
foreach ($r AS $item) { foreach ($r AS $item) {
$index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"]; $index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"];
$item_arr[$index] = array("author-link" => $item["author-link"], $item_arr[$index] = ["author-link" => $item["author-link"],
"owner-link" => $item["owner-link"], "owner-link" => $item["owner-link"],
"uid" => $item["uid"]); "uid" => $item["uid"]];
} }
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed // Set the "gcontact-id" in the item table and add a new gcontact entry if needed

View file

@ -13,7 +13,7 @@ function update_queue_time($id) {
function remove_queue_item($id) { function remove_queue_item($id) {
logger('queue: remove queue item ' . $id); logger('queue: remove queue item ' . $id);
dba::delete('queue', array('id' => $id)); dba::delete('queue', ['id' => $id]);
} }
/** /**

View file

@ -27,16 +27,16 @@ function cookie_hash($user)
* @param int $time * @param int $time
* @param array $user Record from "user" table * @param array $user Record from "user" table
*/ */
function new_cookie($time, $user = array()) function new_cookie($time, $user = [])
{ {
if ($time != 0) { if ($time != 0) {
$time = $time + time(); $time = $time + time();
} }
if ($user) { if ($user) {
$value = json_encode(array("uid" => $user["uid"], $value = json_encode(["uid" => $user["uid"],
"hash" => cookie_hash($user), "hash" => cookie_hash($user),
"ip" => $_SERVER['REMOTE_ADDR'])); "ip" => $_SERVER['REMOTE_ADDR']]);
} else { } else {
$value = ""; $value = "";
} }
@ -102,12 +102,12 @@ function authenticate_success($user_record, $login_initial = false, $interactive
} }
} }
$r = dba::select('user', array('uid', 'username', 'nickname'), $r = dba::select('user', ['uid', 'username', 'nickname'],
array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false)); ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$a->identities = dba::inArray($r); $a->identities = dba::inArray($r);
} else { } else {
$a->identities = array(); $a->identities = [];
} }
$r = dba::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname` $r = dba::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
@ -137,11 +137,11 @@ function authenticate_success($user_record, $login_initial = false, $interactive
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"'); header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
if ($login_initial || $login_refresh) { if ($login_initial || $login_refresh) {
dba::update('user', array('login_date' => datetime_convert()), array('uid' => $_SESSION['uid'])); dba::update('user', ['login_date' => datetime_convert()], ['uid' => $_SESSION['uid']]);
// Set the login date for all identities of the user // Set the login date for all identities of the user
dba::update('user', array('login_date' => datetime_convert()), dba::update('user', ['login_date' => datetime_convert()],
array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false)); ['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
} }
if ($login_initial) { if ($login_initial) {

View file

@ -80,11 +80,11 @@ function ref_session_write($id, $data)
} }
if ($session_exists) { if ($session_exists) {
$fields = array('data' => $data, 'expire' => $expire); $fields = ['data' => $data, 'expire' => $expire];
$condition = array("`sid` = ? AND (`data` != ? OR `expire` != ?)", $id, $data, $expire); $condition = ["`sid` = ? AND (`data` != ? OR `expire` != ?)", $id, $data, $expire];
dba::update('session', $fields, $condition); dba::update('session', $fields, $condition);
} else { } else {
$fields = array('sid' => $id, 'expire' => $default_expire, 'data' => $data); $fields = ['sid' => $id, 'expire' => $default_expire, 'data' => $data];
dba::insert('session', $fields); dba::insert('session', $fields);
} }
@ -105,13 +105,13 @@ function ref_session_destroy($id)
return true; return true;
} }
dba::delete('session', array('sid' => $id)); dba::delete('session', ['sid' => $id]);
return true; return true;
} }
function ref_session_gc() function ref_session_gc()
{ {
dba::delete('session', array("`expire` < ?", time())); dba::delete('session', ["`expire` < ?", time()]);
return true; return true;
} }

View file

@ -51,7 +51,7 @@ function create_tags_from_item($itemid)
// ignore anything in a code block // ignore anything in a code block
$data = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $data); $data = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $data);
$tags = array(); $tags = [];
$pattern = '/\W\#([^\[].*?)[\s\'".,:;\?!\[\]\/]/ism'; $pattern = '/\W\#([^\[].*?)[\s\'".,:;\?!\[\]\/]/ism';
if (preg_match_all($pattern, $data, $matches)) { if (preg_match_all($pattern, $data, $matches)) {
@ -204,7 +204,7 @@ function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
TERM_OBJ_POST TERM_OBJ_POST
); );
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
return array(); return [];
} }
return tag_calc($r); return tag_calc($r);
@ -238,10 +238,10 @@ function wtagblock($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
} }
$tpl = get_markup_template('tagblock_widget.tpl'); $tpl = get_markup_template('tagblock_widget.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$title' => t('Tags'), '$title' => t('Tags'),
'$tags' => $tags '$tags' => $tags
)); ]);
} }
return $o; return $o;
} }
@ -254,13 +254,13 @@ function wtagblock($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
*/ */
function tag_calc($arr) function tag_calc($arr)
{ {
$tags = array(); $tags = [];
$min = 1e9; $min = 1e9;
$max = -1e9; $max = -1e9;
$x = 0; $x = 0;
if (!$arr) { if (!$arr) {
return array(); return [];
} }
foreach ($arr as $rr) { foreach ($arr as $rr) {

View file

@ -83,7 +83,7 @@ function random_string($size = 64)
* @return string Filtered string * @return string Filtered string
*/ */
function notags($string) { function notags($string) {
return str_replace(array("<", ">"), array('[', ']'), $string); return str_replace(["<", ">"], ['[', ']'], $string);
// High-bit filter no longer used // High-bit filter no longer used
// return str_replace(array("<",">","\xBA","\xBC","\xBE"), array('[',']','','',''), $string); // return str_replace(array("<",">","\xBA","\xBC","\xBE"), array('[',']','','',''), $string);
@ -113,12 +113,12 @@ function autoname($len) {
return ''; return '';
} }
$vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u'); $vowels = ['a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u'];
if (mt_rand(0, 5) == 4) { if (mt_rand(0, 5) == 4) {
$vowels[] = 'y'; $vowels[] = 'y';
} }
$cons = array( $cons = [
'b','bl','br', 'b','bl','br',
'c','ch','cl','cr', 'c','ch','cl','cr',
'd','dr', 'd','dr',
@ -139,13 +139,13 @@ function autoname($len) {
'w','wh', 'w','wh',
'x', 'x',
'z','zh' 'z','zh'
); ];
$midcons = array('ck','ct','gn','ld','lf','lm','lt','mb','mm', 'mn','mp', $midcons = ['ck','ct','gn','ld','lf','lm','lt','mb','mm', 'mn','mp',
'nd','ng','nk','nt','rn','rp','rt'); 'nd','ng','nk','nt','rn','rp','rt'];
$noend = array('bl', 'br', 'cl','cr','dr','fl','fr','gl','gr', $noend = ['bl', 'br', 'cl','cr','dr','fl','fr','gl','gr',
'kh', 'kl','kr','mn','pl','pr','rh','tr','qu','wh'); 'kh', 'kl','kr','mn','pl','pr','rh','tr','qu','wh'];
$start = mt_rand(0,2); $start = mt_rand(0,2);
if ($start == 0) { if ($start == 0) {
@ -280,14 +280,14 @@ function paginate_data(App $a, $count = null) {
} }
$url = $stripped; $url = $stripped;
$data = array(); $data = [];
function _l(&$d, $name, $url, $text, $class = '') { function _l(&$d, $name, $url, $text, $class = '') {
if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) { if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) {
$url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1); $url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1);
} }
$d[$name] = array('url' => $url, 'text' => $text, 'class' => $class); $d[$name] = ['url' => $url, 'text' => $text, 'class' => $class];
} }
if (!is_null($count)) { if (!is_null($count)) {
@ -313,7 +313,7 @@ function paginate_data(App $a, $count = null) {
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 8)); $numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 8));
} }
$pages = array(); $pages = [];
for ($i = $numstart; $i <= $numstop; $i++) { for ($i = $numstart; $i <= $numstop; $i++) {
if ($i == $a->pager['page']) { if ($i == $a->pager['page']) {
@ -362,7 +362,7 @@ function paginate(App $a) {
$data = paginate_data($a); $data = paginate_data($a);
$tpl = get_markup_template("paginate.tpl"); $tpl = get_markup_template("paginate.tpl");
return replace_macros($tpl, array("pager" => $data)); return replace_macros($tpl, ["pager" => $data]);
} }
@ -377,7 +377,7 @@ function alt_pager(App $a, $i) {
$data = paginate_data($a, $i); $data = paginate_data($a, $i);
$tpl = get_markup_template("paginate.tpl"); $tpl = get_markup_template("paginate.tpl");
return replace_macros($tpl, array('pager' => $data)); return replace_macros($tpl, ['pager' => $data]);
} }
@ -388,10 +388,10 @@ function alt_pager(App $a, $i) {
*/ */
function scroll_loader() { function scroll_loader() {
$tpl = get_markup_template("scroll_loader.tpl"); $tpl = get_markup_template("scroll_loader.tpl");
return replace_macros($tpl, array( return replace_macros($tpl, [
'wait' => t('Loading more entries...'), 'wait' => t('Loading more entries...'),
'end' => t('The end') 'end' => t('The end')
)); ]);
} }
@ -404,7 +404,7 @@ function scroll_loader() {
function expand_acl($s) { function expand_acl($s) {
// turn string array of angle-bracketed elements into numeric array // turn string array of angle-bracketed elements into numeric array
// e.g. "<1><2><3>" => array(1,2,3); // e.g. "<1><2><3>" => array(1,2,3);
$ret = array(); $ret = [];
if (strlen($s)) { if (strlen($s)) {
$t = str_replace('<', '', $s); $t = str_replace('<', '', $s);
@ -477,7 +477,7 @@ function item_new_uri($hostname, $uid, $guid = "") {
$uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash; $uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash;
$dups = dba::exists('item', array('uri' => $uri)); $dups = dba::exists('item', ['uri' => $uri]);
} while ($dups == true); } while ($dups == true);
return $uri; return $uri;
@ -663,7 +663,7 @@ function attribute_contains($attr, $s) {
/* setup int->string log level map */ /* setup int->string log level map */
$LOGGER_LEVELS = array(); $LOGGER_LEVELS = [];
/** /**
* @brief Logs the given message at the given log level * @brief Logs the given message at the given log level
@ -825,7 +825,7 @@ function activity_match($haystack,$needle) {
* @return array List of tag and person names * @return array List of tag and person names
*/ */
function get_tags($string) { function get_tags($string) {
$ret = array(); $ret = [];
// Convert hashtag links to hashtags // Convert hashtag links to hashtags
$string = preg_replace('/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism', '#$2', $string); $string = preg_replace('/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism', '#$2', $string);
@ -834,7 +834,7 @@ function get_tags($string) {
$string = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $string); $string = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $string);
// Force line feeds at bbtags // Force line feeds at bbtags
$string = str_replace(array('[', ']'), array("\n[", "]\n"), $string); $string = str_replace(['[', ']'], ["\n[", "]\n"], $string);
// ignore anything in a bbtag // ignore anything in a bbtag
$string = preg_replace('/\[(.*?)\]/sm', '', $string); $string = preg_replace('/\[(.*?)\]/sm', '', $string);
@ -942,7 +942,7 @@ function contact_block() {
intval($shown) intval($shown)
); );
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$contacts = array(); $contacts = [];
foreach ($r AS $contact) { foreach ($r AS $contact) {
$contacts[] = $contact["id"]; $contacts[] = $contact["id"];
} }
@ -951,7 +951,7 @@ function contact_block() {
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$contacts = sprintf(tt('%d Contact','%d Contacts', $total),$total); $contacts = sprintf(tt('%d Contact','%d Contacts', $total),$total);
$micropro = Array(); $micropro = [];
foreach ($r as $rr) { foreach ($r as $rr) {
$micropro[] = micropro($rr,true,'mpfriend'); $micropro[] = micropro($rr,true,'mpfriend');
} }
@ -960,14 +960,14 @@ function contact_block() {
} }
$tpl = get_markup_template('contact_block.tpl'); $tpl = get_markup_template('contact_block.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$contacts' => $contacts, '$contacts' => $contacts,
'$nickname' => $a->profile['nickname'], '$nickname' => $a->profile['nickname'],
'$viewcontacts' => t('View Contacts'), '$viewcontacts' => t('View Contacts'),
'$micropro' => $micropro, '$micropro' => $micropro,
)); ]);
$arr = array('contacts' => $r, 'output' => $o); $arr = ['contacts' => $r, 'output' => $o];
call_hooks('contact_block_end', $arr); call_hooks('contact_block_end', $arr);
return $o; return $o;
@ -1021,7 +1021,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
$url = ''; $url = '';
} }
return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array( return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),[
'$click' => defaults($contact, 'click', ''), '$click' => defaults($contact, 'click', ''),
'$class' => $class, '$class' => $class,
'$url' => $url, '$url' => $url,
@ -1031,7 +1031,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
'$parkle' => $sparkle, '$parkle' => $sparkle,
'$redir' => $redir, '$redir' => $redir,
)); ]);
} }
/** /**
@ -1054,7 +1054,7 @@ function search($s, $id = 'search-box', $url = 'search', $save = false, $aside =
} }
$save_label = $mode === 'text' ? t('Save') : t('Follow'); $save_label = $mode === 'text' ? t('Save') : t('Follow');
$values = array( $values = [
'$s' => htmlspecialchars($s), '$s' => htmlspecialchars($s),
'$id' => $id, '$id' => $id,
'$action_url' => $url, '$action_url' => $url,
@ -1063,13 +1063,13 @@ function search($s, $id = 'search-box', $url = 'search', $save = false, $aside =
'$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'), '$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'),
'$search_hint' => t('@name, !forum, #tags, content'), '$search_hint' => t('@name, !forum, #tags, content'),
'$mode' => $mode '$mode' => $mode
); ];
if (!$aside) { if (!$aside) {
$values['$searchoption'] = array( $values['$searchoption'] = [
t("Full Text"), t("Full Text"),
t("Tags"), t("Tags"),
t("Contacts")); t("Contacts")];
if (Config::get('system','poco_local_search')) { if (Config::get('system','poco_local_search')) {
$values['$searchoption'][] = t("Forums"); $values['$searchoption'][] = t("Forums");
@ -1115,14 +1115,14 @@ function get_poke_verbs() {
// index is present tense verb // index is present tense verb
// value is array containing past tense verb, translation of present, translation of past // value is array containing past tense verb, translation of present, translation of past
$arr = array( $arr = [
'poke' => array('poked', t('poke'), t('poked')), 'poke' => ['poked', t('poke'), t('poked')],
'ping' => array('pinged', t('ping'), t('pinged')), 'ping' => ['pinged', t('ping'), t('pinged')],
'prod' => array('prodded', t('prod'), t('prodded')), 'prod' => ['prodded', t('prod'), t('prodded')],
'slap' => array('slapped', t('slap'), t('slapped')), 'slap' => ['slapped', t('slap'), t('slapped')],
'finger' => array('fingered', t('finger'), t('fingered')), 'finger' => ['fingered', t('finger'), t('fingered')],
'rebuff' => array('rebuffed', t('rebuff'), t('rebuffed')), 'rebuff' => ['rebuffed', t('rebuff'), t('rebuffed')],
); ];
call_hooks('poke_verbs', $arr); call_hooks('poke_verbs', $arr);
return $arr; return $arr;
} }
@ -1134,12 +1134,12 @@ function get_poke_verbs() {
* @return string Translated string. * @return string Translated string.
*/ */
function day_translate($s) { function day_translate($s) {
$ret = str_replace(array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'), $ret = str_replace(['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
array(t('Monday'), t('Tuesday'), t('Wednesday'), t('Thursday'), t('Friday'), t('Saturday'), t('Sunday')), [t('Monday'), t('Tuesday'), t('Wednesday'), t('Thursday'), t('Friday'), t('Saturday'), t('Sunday')],
$s); $s);
$ret = str_replace(array('January','February','March','April','May','June','July','August','September','October','November','December'), $ret = str_replace(['January','February','March','April','May','June','July','August','September','October','November','December'],
array(t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December')), [t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December')],
$ret); $ret);
return $ret; return $ret;
@ -1152,11 +1152,11 @@ function day_translate($s) {
* @return string Translated string. * @return string Translated string.
*/ */
function day_short_translate($s) { function day_short_translate($s) {
$ret = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'), $ret = str_replace(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
array(t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'), t('Sun')), [t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'), t('Sun')],
$s); $s);
$ret = str_replace(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov','Dec'), $ret = str_replace(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov','Dec'],
array(t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), ('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec')), [t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), ('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec')],
$ret); $ret);
return $ret; return $ret;
} }
@ -1169,7 +1169,7 @@ function day_short_translate($s) {
* @return string * @return string
*/ */
function normalise_link($url) { function normalise_link($url) {
$ret = str_replace(array('https:', '//www.'), array('http:', '//'), $url); $ret = str_replace(['https:', '//www.'], ['http:', '//'], $url);
return rtrim($ret,'/'); return rtrim($ret,'/');
} }
@ -1235,8 +1235,8 @@ function put_item_in_cache(&$item, $update = false)
$item["body"] = $body; $item["body"] = $body;
if ($update && ($item["id"] > 0)) { if ($update && ($item["id"] > 0)) {
dba::update('item', array('rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]), dba::update('item', ['rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]],
array('id' => $item["id"]), false); ['id' => $item["id"]], false);
} }
} }
} }
@ -1259,9 +1259,9 @@ function prepare_body(&$item, $attach = false, $preview = false) {
$searchpath = System::baseUrl() . "/search?tag="; $searchpath = System::baseUrl() . "/search?tag=";
$tags = array(); $tags = [];
$hashtags = array(); $hashtags = [];
$mentions = array(); $mentions = [];
// In order to provide theme developers more possibilities, event items // In order to provide theme developers more possibilities, event items
// are treated differently. // are treated differently.
@ -1313,14 +1313,14 @@ function prepare_body(&$item, $attach = false, $preview = false) {
put_item_in_cache($item, $update); put_item_in_cache($item, $update);
$s = $item["rendered-html"]; $s = $item["rendered-html"];
$prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview); $prep_arr = ['item' => $item, 'html' => $s, 'preview' => $preview];
call_hooks('prepare_body', $prep_arr); call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html']; $s = $prep_arr['html'];
if (! $attach) { if (! $attach) {
// Replace the blockquotes with quotes that are used in mails. // Replace the blockquotes with quotes that are used in mails.
$mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">'; $mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">';
$s = str_replace(array('<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'), array($mailquote, $mailquote, $mailquote), $s); $s = str_replace(['<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'], [$mailquote, $mailquote, $mailquote], $s);
return $s; return $s;
} }
@ -1345,23 +1345,23 @@ function prepare_body(&$item, $attach = false, $preview = false) {
if (strpos($mime, 'video') !== false) { if (strpos($mime, 'video') !== false) {
if (!$vhead) { if (!$vhead) {
$vhead = true; $vhead = true;
$a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), array( $a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
)); ]);
$a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), array( $a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
)); ]);
} }
$id = end(explode('/', $the_url)); $id = end(explode('/', $the_url));
$as .= replace_macros(get_markup_template('video_top.tpl'), array( $as .= replace_macros(get_markup_template('video_top.tpl'), [
'$video' => array( '$video' => [
'id' => $id, 'id' => $id,
'title' => t('View Video'), 'title' => t('View Video'),
'src' => $the_url, 'src' => $the_url,
'mime' => $mime, 'mime' => $mime,
), ],
)); ]);
} }
$filetype = strtolower(substr($mime, 0, strpos($mime, '/'))); $filetype = strtolower(substr($mime, 0, strpos($mime, '/')));
@ -1431,7 +1431,7 @@ function prepare_body(&$item, $attach = false, $preview = false) {
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s); $s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
} }
$prep_arr = array('item' => $item, 'html' => $s); $prep_arr = ['item' => $item, 'html' => $s];
call_hooks('prepare_body_final', $prep_arr); call_hooks('prepare_body_final', $prep_arr);
return $prep_arr['html']; return $prep_arr['html'];
@ -1485,21 +1485,21 @@ function prepare_text($text) {
*/ */
function get_cats_and_terms($item) function get_cats_and_terms($item)
{ {
$categories = array(); $categories = [];
$folders = array(); $folders = [];
$matches = false; $matches = false;
$first = true; $first = true;
$cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER); $cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
if ($cnt) { if ($cnt) {
foreach ($matches as $mtch) { foreach ($matches as $mtch) {
$categories[] = array( $categories[] = [
'name' => xmlify(file_tag_decode($mtch[1])), 'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#", 'url' => "#",
'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""), 'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""),
'first' => $first, 'first' => $first,
'last' => false 'last' => false
); ];
$first = false; $first = false;
} }
} }
@ -1514,13 +1514,13 @@ function get_cats_and_terms($item)
$cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER); $cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
if ($cnt) { if ($cnt) {
foreach ($matches as $mtch) { foreach ($matches as $mtch) {
$folders[] = array( $folders[] = [
'name' => xmlify(file_tag_decode($mtch[1])), 'name' => xmlify(file_tag_decode($mtch[1])),
'url' => "#", 'url' => "#",
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) : ""), 'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) : ""),
'first' => $first, 'first' => $first,
'last' => false 'last' => false
); ];
$first = false; $first = false;
} }
} }
@ -1530,7 +1530,7 @@ function get_cats_and_terms($item)
$folders[count($folders) - 1]['last'] = true; $folders[count($folders) - 1]['last'] = true;
} }
return array($categories, $folders); return [$categories, $folders];
} }
@ -1543,13 +1543,13 @@ function get_plink($item) {
$a = get_app(); $a = get_app();
if ($a->user['nickname'] != "") { if ($a->user['nickname'] != "") {
$ret = array( $ret = [
//'href' => "display/" . $a->user['nickname'] . "/" . $item['id'], //'href' => "display/" . $a->user['nickname'] . "/" . $item['id'],
'href' => "display/" . $item['guid'], 'href' => "display/" . $item['guid'],
'orig' => "display/" . $item['guid'], 'orig' => "display/" . $item['guid'],
'title' => t('View on separate page'), 'title' => t('View on separate page'),
'orig_title' => t('view on separate page'), 'orig_title' => t('view on separate page'),
); ];
if (x($item, 'plink')) { if (x($item, 'plink')) {
$ret["href"] = $a->remove_baseurl($item['plink']); $ret["href"] = $a->remove_baseurl($item['plink']);
@ -1557,13 +1557,13 @@ function get_plink($item) {
} }
} elseif (x($item, 'plink') && ($item['private'] != 1)) { } elseif (x($item, 'plink') && ($item['private'] != 1)) {
$ret = array( $ret = [
'href' => $item['plink'], 'href' => $item['plink'],
'orig' => $item['plink'], 'orig' => $item['plink'],
'title' => t('link to source'), 'title' => t('link to source'),
); ];
} else { } else {
$ret = array(); $ret = [];
} }
return $ret; return $ret;
@ -1780,11 +1780,11 @@ function item_post_type($item) {
// To do this we need to escape these characters if they appear in our tag. // To do this we need to escape these characters if they appear in our tag.
function file_tag_encode($s) { function file_tag_encode($s) {
return str_replace(array('<','>','[',']'),array('%3c','%3e','%5b','%5d'),$s); return str_replace(['<','>','[',']'],['%3c','%3e','%5b','%5d'],$s);
} }
function file_tag_decode($s) { function file_tag_decode($s) {
return str_replace(array('%3c', '%3e', '%5b', '%5d'), array('<', '>', '[', ']'), $s); return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s);
} }
function file_tag_file_query($table,$s,$type = 'file') { function file_tag_file_query($table,$s,$type = 'file') {
@ -1866,7 +1866,7 @@ function file_tag_update_pconfig($uid, $file_old, $file_new, $type = 'file') {
$filetags_updated = $saved; $filetags_updated = $saved;
// check for new tags to be added as filetags in pconfig // check for new tags to be added as filetags in pconfig
$new_tags = array(); $new_tags = [];
$check_new_tags = explode(",",file_tag_file_to_list($file_new,$type)); $check_new_tags = explode(",",file_tag_file_to_list($file_new,$type));
foreach ($check_new_tags as $tag) { foreach ($check_new_tags as $tag) {
@ -1877,7 +1877,7 @@ function file_tag_update_pconfig($uid, $file_old, $file_new, $type = 'file') {
$filetags_updated .= file_tag_list_to_file(implode(",",$new_tags),$type); $filetags_updated .= file_tag_list_to_file(implode(",",$new_tags),$type);
// check for deleted tags to be removed from filetags in pconfig // check for deleted tags to be removed from filetags in pconfig
$deleted_tags = array(); $deleted_tags = [];
$check_deleted_tags = explode(",",file_tag_file_to_list($file_old,$type)); $check_deleted_tags = explode(",",file_tag_file_to_list($file_old,$type));
foreach ($check_deleted_tags as $tag) { foreach ($check_deleted_tags as $tag) {
@ -1984,7 +1984,7 @@ function file_tag_unsave_file($uid, $item, $file, $cat = false)
} }
function normalise_openid($s) { function normalise_openid($s) {
return trim(str_replace(array('http://', 'https://'), array('', ''), $s), '/'); return trim(str_replace(['http://', 'https://'], ['', ''], $s), '/');
} }
@ -2023,7 +2023,7 @@ function is_a_date_arg($s) {
function deindent($text, $chr = "[\t ]", $count = NULL) { function deindent($text, $chr = "[\t ]", $count = NULL) {
$lines = explode("\n", $text); $lines = explode("\n", $text);
if (is_null($count)) { if (is_null($count)) {
$m = array(); $m = [];
$k = 0; $k = 0;
while ($k < count($lines) && strlen($lines[$k]) == 0) { while ($k < count($lines) && strlen($lines[$k]) == 0) {
$k++; $k++;
@ -2039,7 +2039,7 @@ function deindent($text, $chr = "[\t ]", $count = NULL) {
} }
function formatBytes($bytes, $precision = 2) { function formatBytes($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB'); $units = ['B', 'KB', 'MB', 'GB', 'TB'];
$bytes = max($bytes, 0); $bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = floor(($bytes ? log($bytes) : 0) / log(1024));
@ -2087,10 +2087,10 @@ function text_highlight($s, $lang) {
// Autoload the library to make constants available // Autoload the library to make constants available
class_exists('Text_Highlighter_Renderer_Html'); class_exists('Text_Highlighter_Renderer_Html');
$options = array( $options = [
'numbers' => HL_NUMBERS_LI, 'numbers' => HL_NUMBERS_LI,
'tabsize' => 4, 'tabsize' => 4,
); ];
$tag_added = false; $tag_added = false;
$s = trim(html_entity_decode($s, ENT_COMPAT)); $s = trim(html_entity_decode($s, ENT_COMPAT));

View file

@ -54,7 +54,7 @@ function add_shadow_thread($itemid) {
} }
// is it an entry from a connector? Only add an entry for natively connected networks // is it an entry from a connector? Only add an entry for natively connected networks
if (!in_array($item["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""))) { if (!in_array($item["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
return; return;
} }
@ -106,7 +106,7 @@ function add_shadow_thread($itemid) {
$item[0]['wall'] = 0; $item[0]['wall'] = 0;
$item[0]['contact-id'] = Contact::getIdForURL($item[0]['author-link'], 0); $item[0]['contact-id'] = Contact::getIdForURL($item[0]['author-link'], 0);
if (in_array($item[0]['type'], array("net-comment", "wall-comment"))) { if (in_array($item[0]['type'], ["net-comment", "wall-comment"])) {
$item[0]['type'] = 'remote-comment'; $item[0]['type'] = 'remote-comment';
} elseif ($item[0]['type'] == 'wall') { } elseif ($item[0]['type'] == 'wall') {
$item[0]['type'] = 'remote'; $item[0]['type'] = 'remote';
@ -165,7 +165,7 @@ function add_shadow_entry($itemid) {
$item['wall'] = 0; $item['wall'] = 0;
$item['contact-id'] = Contact::getIdForURL($item['author-link'], 0); $item['contact-id'] = Contact::getIdForURL($item['author-link'], 0);
if (in_array($item['type'], array("net-comment", "wall-comment"))) { if (in_array($item['type'], ["net-comment", "wall-comment"])) {
$item['type'] = 'remote-comment'; $item['type'] = 'remote-comment';
} elseif ($item['type'] == 'wall') { } elseif ($item['type'] == 'wall') {
$item['type'] = 'remote'; $item['type'] = 'remote';
@ -203,7 +203,7 @@ function update_thread($itemid, $setmention = false) {
$sql = ""; $sql = "";
foreach ($item AS $field => $data) foreach ($item AS $field => $data)
if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) { if (!in_array($field, ["guid", "title", "body", "rendered-html", "rendered-hash"])) {
if ($sql != "") { if ($sql != "") {
$sql .= ", "; $sql .= ", ";
} }
@ -261,7 +261,7 @@ function delete_thread($itemid, $itemuri = "") {
intval($item["uid"]) intval($item["uid"])
); );
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
dba::delete('item', array('uri' => $itemuri, 'uid' => 0)); dba::delete('item', ['uri' => $itemuri, 'uid' => 0]);
logger("delete_thread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG); logger("delete_thread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG);
} }
} }
@ -270,7 +270,7 @@ function delete_thread($itemid, $itemuri = "") {
function update_threads() { function update_threads() {
logger("update_threads: start"); logger("update_threads: start");
$messages = dba::select('item', array('id'), array("`id` = `parent`")); $messages = dba::select('item', ['id'], ["`id` = `parent`"]);
logger("update_threads: fetched messages: ".dba::num_rows($messages)); logger("update_threads: fetched messages: ".dba::num_rows($messages));
@ -301,8 +301,8 @@ function update_shadow_copy() {
logger("start"); logger("start");
$condition = "`uid` != 0 AND `network` IN ('', ?, ?, ?) AND `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private`"; $condition = "`uid` != 0 AND `network` IN ('', ?, ?, ?) AND `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private`";
$messages = dba::select('thread', array('iid'), array($condition, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS), $messages = dba::select('thread', ['iid'], [$condition, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS],
array('order' => 'created')); ['order' => 'created']);
logger("fetched messages: ".dba::num_rows($messages)); logger("fetched messages: ".dba::num_rows($messages));
while ($message = dba::fetch($messages)) while ($message = dba::fetch($messages))

View file

@ -111,7 +111,7 @@ if (x($_SESSION, 'authenticated') && !x($_SESSION, 'language')) {
// we haven't loaded user data yet, but we need user language // we haven't loaded user data yet, but we need user language
$user = dba::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]); $user = dba::selectFirst('user', ['language'], ['uid' => $_SESSION['uid']]);
$_SESSION['language'] = $lang; $_SESSION['language'] = $lang;
if (DBM::is_result($r)) { if (DBM::is_result($user)) {
$_SESSION['language'] = $user['language']; $_SESSION['language'] = $user['language'];
} }
} }
@ -163,16 +163,16 @@ $a->page['end'] = '';
if (! x($_SESSION, 'sysmsg')) { if (! x($_SESSION, 'sysmsg')) {
$_SESSION['sysmsg'] = array(); $_SESSION['sysmsg'] = [];
} }
if (! x($_SESSION, 'sysmsg_info')) { if (! x($_SESSION, 'sysmsg_info')) {
$_SESSION['sysmsg_info'] = array(); $_SESSION['sysmsg_info'] = [];
} }
// Array for informations about last received items // Array for informations about last received items
if (! x($_SESSION, 'last_updated')) { if (! x($_SESSION, 'last_updated')) {
$_SESSION['last_updated'] = array(); $_SESSION['last_updated'] = [];
} }
/* /*
* check_config() is responsible for running update scripts. These automatically * check_config() is responsible for running update scripts. These automatically
@ -197,7 +197,7 @@ nav_set_selected('nothing');
//Don't populate apps_menu if apps are private //Don't populate apps_menu if apps are private
$privateapps = Config::get('config', 'private_addons'); $privateapps = Config::get('config', 'private_addons');
if ((local_user()) || (! $privateapps === "1")) { if ((local_user()) || (! $privateapps === "1")) {
$arr = array('app_menu' => $a->apps); $arr = ['app_menu' => $a->apps];
call_hooks('app_menu', $arr); call_hooks('app_menu', $arr);
@ -294,8 +294,8 @@ if (strlen($a->module)) {
$tpl = get_markup_template("404.tpl"); $tpl = get_markup_template("404.tpl");
$a->page['content'] = replace_macros( $a->page['content'] = replace_macros(
$tpl, $tpl,
array( [
'$message' => t('Page not found.')) '$message' => t('Page not found.')]
); );
} }
} }
@ -362,14 +362,14 @@ if ($a->module_loaded) {
} }
if (! $a->error) { if (! $a->error) {
$arr = array('content' => $a->page['content']); $arr = ['content' => $a->page['content']];
call_hooks($a->module . '_mod_content', $arr); call_hooks($a->module . '_mod_content', $arr);
$a->page['content'] = $arr['content']; $a->page['content'] = $arr['content'];
if ($a->module_class) { if ($a->module_class) {
$arr = array('content' => call_user_func([$a->module_class, 'content'])); $arr = ['content' => call_user_func([$a->module_class, 'content'])];
} else if (function_exists($a->module . '_content')) { } else if (function_exists($a->module . '_content')) {
$func = $a->module . '_content'; $func = $a->module . '_content';
$arr = array('content' => $func($a)); $arr = ['content' => $func($a)];
} }
call_hooks($a->module . '_mod_aftercontent', $arr); call_hooks($a->module . '_mod_aftercontent', $arr);
$a->page['content'] .= $arr['content']; $a->page['content'] .= $arr['content'];
@ -440,9 +440,9 @@ if ($a->is_mobile || $a->is_tablet) {
} }
$a->page['footer'] = replace_macros( $a->page['footer'] = replace_macros(
get_markup_template("toggle_mobile_footer.tpl"), get_markup_template("toggle_mobile_footer.tpl"),
array( [
'$toggle_link' => $link, '$toggle_link' => $link,
'$toggle_text' => t('toggle mobile')) '$toggle_text' => t('toggle mobile')]
); );
} }

View file

@ -39,7 +39,7 @@ function wk_social_relay()
$scope = SR_SCOPE_NONE; $scope = SR_SCOPE_NONE;
} }
$tags = array(); $tags = [];
if ($scope == SR_SCOPE_TAGS) { if ($scope == SR_SCOPE_TAGS) {
$server_tags = Config::get('system', 'relay_server_tags'); $server_tags = Config::get('system', 'relay_server_tags');
@ -59,16 +59,16 @@ function wk_social_relay()
} }
} }
$taglist = array(); $taglist = [];
foreach ($tags AS $tag) { foreach ($tags AS $tag) {
$taglist[] = $tag; $taglist[] = $tag;
} }
$relay = array( $relay = [
"subscribe" => $subscribe, "subscribe" => $subscribe,
"scope" => $scope, "scope" => $scope,
"tags" => $taglist "tags" => $taglist
); ];
header('Content-type: application/json; charset=utf-8'); header('Content-type: application/json; charset=utf-8');
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

View file

@ -158,46 +158,46 @@ function admin_content(App $a)
// apc_delete($toDelete); // apc_delete($toDelete);
//} //}
// Header stuff // Header stuff
$a->page['htmlhead'] .= replace_macros(get_markup_template('admin/settings_head.tpl'), array()); $a->page['htmlhead'] .= replace_macros(get_markup_template('admin/settings_head.tpl'), []);
/* /*
* Side bar links * Side bar links
*/ */
$aside_tools = array(); $aside_tools = [];
// array(url, name, extra css classes) // array(url, name, extra css classes)
// not part of $aside to make the template more adjustable // not part of $aside to make the template more adjustable
$aside_sub = array( $aside_sub = [
'site' => array("admin/site/" , t("Site") , "site"), 'site' => ["admin/site/" , t("Site") , "site"],
'users' => array("admin/users/" , t("Users") , "users"), 'users' => ["admin/users/" , t("Users") , "users"],
'plugins' => array("admin/plugins/" , t("Plugins") , "plugins"), 'plugins' => ["admin/plugins/" , t("Plugins") , "plugins"],
'themes' => array("admin/themes/" , t("Themes") , "themes"), 'themes' => ["admin/themes/" , t("Themes") , "themes"],
'features' => array("admin/features/" , t("Additional features") , "features"), 'features' => ["admin/features/" , t("Additional features") , "features"],
'dbsync' => array("admin/dbsync/" , t('DB updates') , "dbsync"), 'dbsync' => ["admin/dbsync/" , t('DB updates') , "dbsync"],
'queue' => array("admin/queue/" , t('Inspect Queue') , "queue"), 'queue' => ["admin/queue/" , t('Inspect Queue') , "queue"],
'contactblock' => array("admin/contactblock/", t('Contact Blocklist') , "contactblock"), 'contactblock' => ["admin/contactblock/", t('Contact Blocklist') , "contactblock"],
'blocklist' => array("admin/blocklist/" , t('Server Blocklist') , "blocklist"), 'blocklist' => ["admin/blocklist/" , t('Server Blocklist') , "blocklist"],
'federation' => array("admin/federation/" , t('Federation Statistics'), "federation"), 'federation' => ["admin/federation/" , t('Federation Statistics'), "federation"],
'deleteitem' => array("admin/deleteitem/" , t('Delete Item') , 'deleteitem'), 'deleteitem' => ["admin/deleteitem/" , t('Delete Item') , 'deleteitem'],
); ];
/* get plugins admin page */ /* get plugins admin page */
$r = q("SELECT `name` FROM `addon` WHERE `plugin_admin` = 1 ORDER BY `name`"); $r = q("SELECT `name` FROM `addon` WHERE `plugin_admin` = 1 ORDER BY `name`");
$aside_tools['plugins_admin'] = array(); $aside_tools['plugins_admin'] = [];
foreach ($r as $h) { foreach ($r as $h) {
$plugin = $h['name']; $plugin = $h['name'];
$aside_tools['plugins_admin'][] = array("admin/plugins/" . $plugin, $plugin, "plugin"); $aside_tools['plugins_admin'][] = ["admin/plugins/" . $plugin, $plugin, "plugin"];
// temp plugins with admin // temp plugins with admin
$a->plugins_admin[] = $plugin; $a->plugins_admin[] = $plugin;
} }
$aside_tools['logs'] = array("admin/logs/", t("Logs"), "logs"); $aside_tools['logs'] = ["admin/logs/", t("Logs"), "logs"];
$aside_tools['viewlogs'] = array("admin/viewlogs/", t("View Logs"), 'viewlogs'); $aside_tools['viewlogs'] = ["admin/viewlogs/", t("View Logs"), 'viewlogs'];
$aside_tools['diagnostics_probe'] = array('probe/', t('probe address'), 'probe'); $aside_tools['diagnostics_probe'] = ['probe/', t('probe address'), 'probe'];
$aside_tools['diagnostics_webfinger'] = array('webfinger/', t('check webfinger'), 'webfinger'); $aside_tools['diagnostics_webfinger'] = ['webfinger/', t('check webfinger'), 'webfinger'];
$t = get_markup_template('admin/aside.tpl'); $t = get_markup_template('admin/aside.tpl');
$a->page['aside'] .= replace_macros($t, array( $a->page['aside'] .= replace_macros($t, [
'$admin' => $aside_tools, '$admin' => $aside_tools,
'$subpages' => $aside_sub, '$subpages' => $aside_sub,
'$admtxt' => t('Admin'), '$admtxt' => t('Admin'),
@ -206,7 +206,7 @@ function admin_content(App $a)
'$diagnosticstxt' => t('diagnostics'), '$diagnosticstxt' => t('diagnostics'),
'$h_pending' => t('User registrations waiting for confirmation'), '$h_pending' => t('User registrations waiting for confirmation'),
'$admurl' => "admin/" '$admurl' => "admin/"
)); ]);
// Page content // Page content
$o = ''; $o = '';
@ -282,25 +282,25 @@ function admin_content(App $a)
function admin_page_blocklist(App $a) function admin_page_blocklist(App $a)
{ {
$blocklist = Config::get('system', 'blocklist'); $blocklist = Config::get('system', 'blocklist');
$blocklistform = array(); $blocklistform = [];
if (is_array($blocklist)) { if (is_array($blocklist)) {
foreach ($blocklist as $id => $b) { foreach ($blocklist as $id => $b) {
$blocklistform[] = array( $blocklistform[] = [
'domain' => array("domain[$id]", t('Blocked domain'), $b['domain'], '', t('The blocked domain'), 'required', '', ''), 'domain' => ["domain[$id]", t('Blocked domain'), $b['domain'], '', t('The blocked domain'), 'required', '', ''],
'reason' => array("reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this domain.') . '(' . $b['domain'] . ')', 'required', '', ''), 'reason' => ["reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this domain.') . '(' . $b['domain'] . ')', 'required', '', ''],
'delete' => array("delete[$id]", t("Delete domain") . ' (' . $b['domain'] . ')', False, t("Check to delete this entry from the blocklist")) 'delete' => ["delete[$id]", t("Delete domain") . ' (' . $b['domain'] . ')', False, t("Check to delete this entry from the blocklist")]
); ];
} }
} }
$t = get_markup_template('admin/blocklist.tpl'); $t = get_markup_template('admin/blocklist.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Server Blocklist'), '$page' => t('Server Blocklist'),
'$intro' => t('This page can be used to define a black list of servers from the federated network that are not allowed to interact with your node. For all entered domains you should also give a reason why you have blocked the remote server.'), '$intro' => t('This page can be used to define a black list of servers from the federated network that are not allowed to interact with your node. For all entered domains you should also give a reason why you have blocked the remote server.'),
'$public' => t('The list of blocked servers will be made publically available on the /friendica page so that your users and people investigating communication problems can find the reason easily.'), '$public' => t('The list of blocked servers will be made publically available on the /friendica page so that your users and people investigating communication problems can find the reason easily.'),
'$addtitle' => t('Add new entry to block list'), '$addtitle' => t('Add new entry to block list'),
'$newdomain' => array('newentry_domain', t('Server Domain'), '', t('The domain of the new server to add to the block list. Do not include the protocol.'), 'required', '', ''), '$newdomain' => ['newentry_domain', t('Server Domain'), '', t('The domain of the new server to add to the block list. Do not include the protocol.'), 'required', '', ''],
'$newreason' => array('newentry_reason', t('Block reason'), '', t('The reason why you blocked this domain.'), 'required', '', ''), '$newreason' => ['newentry_reason', t('Block reason'), '', t('The reason why you blocked this domain.'), 'required', '', ''],
'$submit' => t('Add Entry'), '$submit' => t('Add Entry'),
'$savechanges' => t('Save changes to the blocklist'), '$savechanges' => t('Save changes to the blocklist'),
'$currenttitle' => t('Current Entries in the Blocklist'), '$currenttitle' => t('Current Entries in the Blocklist'),
@ -311,7 +311,7 @@ function admin_page_blocklist(App $a)
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$confirm_delete' => t('Delete entry from blocklist?'), '$confirm_delete' => t('Delete entry from blocklist?'),
'$form_security_token' => get_form_security_token("admin_blocklist") '$form_security_token' => get_form_security_token("admin_blocklist")
)); ]);
} }
/** /**
@ -330,24 +330,24 @@ function admin_page_blocklist_post(App $a)
if (x($_POST['page_blocklist_save'])) { if (x($_POST['page_blocklist_save'])) {
// Add new item to blocklist // Add new item to blocklist
$blocklist = Config::get('system', 'blocklist'); $blocklist = Config::get('system', 'blocklist');
$blocklist[] = array( $blocklist[] = [
'domain' => notags(trim($_POST['newentry_domain'])), 'domain' => notags(trim($_POST['newentry_domain'])),
'reason' => notags(trim($_POST['newentry_reason'])) 'reason' => notags(trim($_POST['newentry_reason']))
); ];
Config::set('system', 'blocklist', $blocklist); Config::set('system', 'blocklist', $blocklist);
info(t('Server added to blocklist.') . EOL); info(t('Server added to blocklist.') . EOL);
} else { } else {
// Edit the entries from blocklist // Edit the entries from blocklist
$blocklist = array(); $blocklist = [];
foreach ($_POST['domain'] as $id => $domain) { foreach ($_POST['domain'] as $id => $domain) {
// Trimming whitespaces as well as any lingering slashes // Trimming whitespaces as well as any lingering slashes
$domain = notags(trim($domain, "\x00..\x1F/")); $domain = notags(trim($domain, "\x00..\x1F/"));
$reason = notags(trim($_POST['reason'][$id])); $reason = notags(trim($_POST['reason'][$id]));
if (!x($_POST['delete'][$id])) { if (!x($_POST['delete'][$id])) {
$blocklist[] = array( $blocklist[] = [
'domain' => $domain, 'domain' => $domain,
'reason' => $reason 'reason' => $reason
); ];
} }
} }
Config::set('system', 'blocklist', $blocklist); Config::set('system', 'blocklist', $blocklist);
@ -409,7 +409,7 @@ function admin_page_contactblock(App $a)
$contacts = dba::inArray($statement); $contacts = dba::inArray($statement);
$t = get_markup_template('admin/contactblock.tpl'); $t = get_markup_template('admin/contactblock.tpl');
$o = replace_macros($t, array( $o = replace_macros($t, [
// strings // // strings //
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Remote Contact Blocklist'), '$page' => t('Remote Contact Blocklist'),
@ -434,7 +434,7 @@ function admin_page_contactblock(App $a)
'$total_contacts' => tt('%s total blocked contact', '%s total blocked contacts', $total), '$total_contacts' => tt('%s total blocked contact', '%s total blocked contacts', $total),
'$paginate' => paginate($a), '$paginate' => paginate($a),
'$contacturl' => ['contact_url', t("Profile URL"), '', t("URL of the remote contact to block.")], '$contacturl' => ['contact_url', t("Profile URL"), '', t("URL of the remote contact to block.")],
)); ]);
return $o; return $o;
} }
@ -452,16 +452,16 @@ function admin_page_deleteitem(App $a)
{ {
$t = get_markup_template('admin/deleteitem.tpl'); $t = get_markup_template('admin/deleteitem.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Delete Item'), '$page' => t('Delete Item'),
'$submit' => t('Delete this Item'), '$submit' => t('Delete this Item'),
'$intro1' => t('On this page you can delete an item from your node. If the item is a top level posting, the entire thread will be deleted.'), '$intro1' => t('On this page you can delete an item from your node. If the item is a top level posting, the entire thread will be deleted.'),
'$intro2' => t('You need to know the GUID of the item. You can find it e.g. by looking at the display URL. The last part of http://example.com/display/123456 is the GUID, here 123456.'), '$intro2' => t('You need to know the GUID of the item. You can find it e.g. by looking at the display URL. The last part of http://example.com/display/123456 is the GUID, here 123456.'),
'$deleteitemguid' => array('deleteitemguid', t("GUID"), '', t("The GUID of the item you want to delete."), 'required', 'autofocus'), '$deleteitemguid' => ['deleteitemguid', t("GUID"), '', t("The GUID of the item you want to delete."), 'required', 'autofocus'],
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$form_security_token' => get_form_security_token("admin_deleteitem") '$form_security_token' => get_form_security_token("admin_deleteitem")
)); ]);
} }
/** /**
@ -490,7 +490,7 @@ function admin_page_deleteitem_post(App $a)
// Now that we have the GUID get all IDs of the associated entries in the // Now that we have the GUID get all IDs of the associated entries in the
// item table of the DB and drop those items, which will also delete the // item table of the DB and drop those items, which will also delete the
// associated threads. // associated threads.
$r = dba::select('item', array('id'), array('guid' => $guid)); $r = dba::select('item', ['id'], ['guid' => $guid]);
while ($row = dba::fetch($r)) { while ($row = dba::fetch($r)) {
drop_item($row['id'], false); drop_item($row['id'], false);
} }
@ -526,8 +526,8 @@ function admin_page_federation(App $a)
// off one % two of them are needed in the query // off one % two of them are needed in the query
// Add more platforms if you like, when one returns 0 known nodes it is not // Add more platforms if you like, when one returns 0 known nodes it is not
// displayed on the stats page. // displayed on the stats page.
$platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome'); $platforms = ['Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome'];
$colors = array( $colors = [
'Friendi%%a' => '#ffc018', // orange from the logo 'Friendi%%a' => '#ffc018', // orange from the logo
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray 'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
'%%red%%' => '#c50001', // fire red from the logo '%%red%%' => '#c50001', // fire red from the logo
@ -538,8 +538,8 @@ function admin_page_federation(App $a)
'Mastodon' => '#1a9df9', // blue from the Mastodon logo 'Mastodon' => '#1a9df9', // blue from the Mastodon logo
'Pleroma' => '#E46F0F', // Orange from the text that is used on Pleroma instances 'Pleroma' => '#E46F0F', // Orange from the text that is used on Pleroma instances
'socialhome' => '#52056b' // lilac from the Django Image used at the Socialhome homepage 'socialhome' => '#52056b' // lilac from the Django Image used at the Socialhome homepage
); ];
$counts = array(); $counts = [];
$total = 0; $total = 0;
$users = 0; $users = 0;
@ -567,15 +567,15 @@ function admin_page_federation(App $a)
// to the version string for the displayed list. // to the version string for the displayed list.
foreach ($v as $key => $value) { foreach ($v as $key => $value) {
if ($v[$key]['version'] == '') { if ($v[$key]['version'] == '') {
$v[$key] = array('total' => $v[$key]['total'], 'version' => t('unknown')); $v[$key] = ['total' => $v[$key]['total'], 'version' => t('unknown')];
} }
} }
// in the DB the Diaspora versions have the format x.x.x.x-xx the last // in the DB the Diaspora versions have the format x.x.x.x-xx the last
// part (-xx) should be removed to clean up the versions from the "head // part (-xx) should be removed to clean up the versions from the "head
// commit" information and combined into a single entry for x.x.x.x // commit" information and combined into a single entry for x.x.x.x
if ($p == 'Diaspora') { if ($p == 'Diaspora') {
$newV = array(); $newV = [];
$newVv = array(); $newVv = [];
foreach ($v as $vv) { foreach ($v as $vv) {
$newVC = $vv['total']; $newVC = $vv['total'];
$newVV = $vv['version']; $newVV = $vv['version'];
@ -590,7 +590,7 @@ function admin_page_federation(App $a)
} }
} }
foreach ($newV as $key => $value) { foreach ($newV as $key => $value) {
array_push($newVv, array('total' => $value, 'version' => $key)); array_push($newVv, ['total' => $value, 'version' => $key]);
} }
$v = $newVv; $v = $newVv;
} }
@ -599,8 +599,8 @@ function admin_page_federation(App $a)
// DB version stamp; those should be operated out and versions be // DB version stamp; those should be operated out and versions be
// conbined // conbined
if ($p == 'Friendi%%a') { if ($p == 'Friendi%%a') {
$newV = array(); $newV = [];
$newVv = array(); $newVv = [];
foreach ($v as $vv) { foreach ($v as $vv) {
$newVC = $vv['total']; $newVC = $vv['total'];
$newVV = $vv['version']; $newVV = $vv['version'];
@ -616,7 +616,7 @@ function admin_page_federation(App $a)
} }
} }
foreach ($newV as $key => $value) { foreach ($newV as $key => $value) {
array_push($newVv, array('total' => $value, 'version' => $key)); array_push($newVv, ['total' => $value, 'version' => $key]);
} }
$v = $newVv; $v = $newVv;
} }
@ -626,7 +626,7 @@ function admin_page_federation(App $a)
// the 3rd array item is needed for the JavaScript graphs as JS does // the 3rd array item is needed for the JavaScript graphs as JS does
// not like some characters in the names of variables... // not like some characters in the names of variables...
$counts[$p] = array($c[0], $v, str_replace(array(' ', '%'), '', $p), $colors[$p]); $counts[$p] = [$c[0], $v, str_replace([' ', '%'], '', $p), $colors[$p]];
} }
// some helpful text // some helpful text
@ -635,7 +635,7 @@ function admin_page_federation(App $a)
// load the template, replace the macros and return the page content // load the template, replace the macros and return the page content
$t = get_markup_template('admin/federation.tpl'); $t = get_markup_template('admin/federation.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Federation Statistics'), '$page' => t('Federation Statistics'),
'$intro' => $intro, '$intro' => $intro,
@ -645,7 +645,7 @@ function admin_page_federation(App $a)
'$version' => FRIENDICA_VERSION, '$version' => FRIENDICA_VERSION,
'$legendtext' => t('Currently this node is aware of %d nodes with %d registered users from the following platforms:', $total, $users), '$legendtext' => t('Currently this node is aware of %d nodes with %d registered users from the following platforms:', $total, $users),
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
)); ]);
} }
/** /**
@ -670,7 +670,7 @@ function admin_page_queue(App $a)
ORDER BY `q`.`cid`, `q`.`created`;"); ORDER BY `q`.`cid`, `q`.`created`;");
$t = get_markup_template('admin/queue.tpl'); $t = get_markup_template('admin/queue.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Inspect Queue'), '$page' => t('Inspect Queue'),
'$count' => count($r), '$count' => count($r),
@ -682,7 +682,7 @@ function admin_page_queue(App $a)
'$last_header' => t('Last Tried'), '$last_header' => t('Last Tried'),
'$info' => t('This page lists the content of the queue for outgoing postings. These are postings the initial delivery failed for. They will be resend later and eventually deleted if the delivery fails permanently.'), '$info' => t('This page lists the content of the queue for outgoing postings. These are postings the initial delivery failed for. They will be resend later and eventually deleted if the delivery fails permanently.'),
'$entries' => $r, '$entries' => $r,
)); ]);
} }
/** /**
@ -701,7 +701,7 @@ function admin_page_summary(App $a)
// are there MyISAM tables in the DB? If so, trigger a warning message // are there MyISAM tables in the DB? If so, trigger a warning message
$r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", dbesc(dba::database_name())); $r = q("SELECT `engine` FROM `information_schema`.`tables` WHERE `engine` = 'myisam' AND `table_schema` = '%s' LIMIT 1", dbesc(dba::database_name()));
$showwarning = false; $showwarning = false;
$warningtext = array(); $warningtext = [];
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$showwarning = true; $showwarning = true;
$warningtext[] = t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php scripts/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html'); $warningtext[] = t('Your DB still runs with MyISAM tables. You should change the engine type to InnoDB. As Friendica will use InnoDB only features in the future, you should change this! See <a href="%s">here</a> for a guide that may be helpful converting the table engines. You may also use the command <tt>php scripts/dbstructure.php toinnodb</tt> of your Friendica installation for an automatic conversion.<br />', 'https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html');
@ -734,14 +734,14 @@ function admin_page_summary(App $a)
} }
$r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`"); $r = q("SELECT `page-flags`, COUNT(`uid`) AS `count` FROM `user` GROUP BY `page-flags`");
$accounts = array( $accounts = [
array(t('Normal Account'), 0), [t('Normal Account'), 0],
array(t('Automatic Follower Account'), 0), [t('Automatic Follower Account'), 0],
array(t('Public Forum Account'), 0), [t('Public Forum Account'), 0],
array(t('Automatic Friend Account'), 0), [t('Automatic Friend Account'), 0],
array(t('Blog Account'), 0), [t('Blog Account'), 0],
array(t('Private Forum Account'), 0) [t('Private Forum Account'), 0]
); ];
$users = 0; $users = 0;
foreach ($r as $u) { foreach ($r as $u) {
@ -762,26 +762,26 @@ function admin_page_summary(App $a)
// We can do better, but this is a quick queue status // We can do better, but this is a quick queue status
$queues = array('label' => t('Message queues'), 'queue' => $queue, 'workerq' => $workerqueue); $queues = ['label' => t('Message queues'), 'queue' => $queue, 'workerq' => $workerqueue];
$t = get_markup_template('admin/summary.tpl'); $t = get_markup_template('admin/summary.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Summary'), '$page' => t('Summary'),
'$queues' => $queues, '$queues' => $queues,
'$users' => array(t('Registered users'), $users), '$users' => [t('Registered users'), $users],
'$accounts' => $accounts, '$accounts' => $accounts,
'$pending' => array(t('Pending registrations'), $pending), '$pending' => [t('Pending registrations'), $pending],
'$version' => array(t('Version'), FRIENDICA_VERSION), '$version' => [t('Version'), FRIENDICA_VERSION],
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$platform' => FRIENDICA_PLATFORM, '$platform' => FRIENDICA_PLATFORM,
'$codename' => FRIENDICA_CODENAME, '$codename' => FRIENDICA_CODENAME,
'$build' => Config::get('system', 'build'), '$build' => Config::get('system', 'build'),
'$plugins' => array(t('Active plugins'), $a->plugins), '$plugins' => [t('Active plugins'), $a->plugins],
'$showwarning' => $showwarning, '$showwarning' => $showwarning,
'$warningtext' => $warningtext '$warningtext' => $warningtext
)); ]);
} }
/** /**
@ -831,7 +831,7 @@ function admin_page_site_post(App $a)
$dbold = dbesc($old_url); $dbold = dbesc($old_url);
$dbnew = dbesc($new_url); $dbnew = dbesc($new_url);
$upd = array(); $upd = [];
foreach ($fields as $f) { foreach ($fields as $f) {
$upd[] = "`$f` = REPLACE(`$f`, '$dbold', '$dbnew')"; $upd[] = "`$f` = REPLACE(`$f`, '$dbold', '$dbnew')";
} }
@ -846,15 +846,15 @@ function admin_page_site_post(App $a)
} }
// update tables // update tables
// update profile links in the format "http://server.tld" // update profile links in the format "http://server.tld"
update_table("profile", array('photo', 'thumb'), $old_url, $new_url); update_table("profile", ['photo', 'thumb'], $old_url, $new_url);
update_table("term", array('url'), $old_url, $new_url); update_table("term", ['url'], $old_url, $new_url);
update_table("contact", array('photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'), $old_url, $new_url); update_table("contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
update_table("gcontact", array('url', 'nurl', 'photo', 'server_url', 'notify', 'alias'), $old_url, $new_url); update_table("gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url);
update_table("item", array('owner-link', 'owner-avatar', 'author-link', 'author-avatar', 'body', 'plink', 'tag'), $old_url, $new_url); update_table("item", ['owner-link', 'owner-avatar', 'author-link', 'author-avatar', 'body', 'plink', 'tag'], $old_url, $new_url);
// update profile addresses in the format "user@server.tld" // update profile addresses in the format "user@server.tld"
update_table("contact", array('addr'), $old_host, $new_host); update_table("contact", ['addr'], $old_host, $new_host);
update_table("gcontact", array('connect', 'addr'), $old_host, $new_host); update_table("gcontact", ['connect', 'addr'], $old_host, $new_host);
// update config // update config
$a->set_baseurl($new_url); $a->set_baseurl($new_url);
@ -1135,8 +1135,8 @@ function admin_page_site(App $a)
} }
/* Installed themes */ /* Installed themes */
$theme_choices = array(); $theme_choices = [];
$theme_choices_mobile = array(); $theme_choices_mobile = [];
$theme_choices_mobile["---"] = t("No special theme for mobile devices"); $theme_choices_mobile["---"] = t("No special theme for mobile devices");
$files = glob('view/theme/*'); $files = glob('view/theme/*');
if (is_array($files)) { if (is_array($files)) {
@ -1165,29 +1165,29 @@ function admin_page_site(App $a)
} }
/* Community page style */ /* Community page style */
$community_page_style_choices = array( $community_page_style_choices = [
CP_NO_COMMUNITY_PAGE => t("No community page"), CP_NO_COMMUNITY_PAGE => t("No community page"),
CP_USERS_ON_SERVER => t("Public postings from users of this site"), CP_USERS_ON_SERVER => t("Public postings from users of this site"),
CP_GLOBAL_COMMUNITY => t("Public postings from the federated network"), CP_GLOBAL_COMMUNITY => t("Public postings from the federated network"),
CP_USERS_AND_GLOBAL => t("Public postings from local users and the federated network") CP_USERS_AND_GLOBAL => t("Public postings from local users and the federated network")
); ];
$poco_discovery_choices = array( $poco_discovery_choices = [
"0" => t("Disabled"), "0" => t("Disabled"),
"1" => t("Users"), "1" => t("Users"),
"2" => t("Users, Global Contacts"), "2" => t("Users, Global Contacts"),
"3" => t("Users, Global Contacts/fallback"), "3" => t("Users, Global Contacts/fallback"),
); ];
$poco_discovery_since_choices = array( $poco_discovery_since_choices = [
"30" => t("One month"), "30" => t("One month"),
"91" => t("Three months"), "91" => t("Three months"),
"182" => t("Half a year"), "182" => t("Half a year"),
"365" => t("One year"), "365" => t("One year"),
); ];
/* get user names to make the install a personal install of X */ /* get user names to make the install a personal install of X */
$user_names = array(); $user_names = [];
$user_names['---'] = t('Multi user instance'); $user_names['---'] = t('Multi user instance');
$users = q("SELECT `username`, `nickname` FROM `user`"); $users = q("SELECT `username`, `nickname` FROM `user`");
foreach ($users as $user) { foreach ($users as $user) {
@ -1210,23 +1210,23 @@ function admin_page_site(App $a)
//echo "<pre>"; var_dump($lang_choices); die("</pre>"); //echo "<pre>"; var_dump($lang_choices); die("</pre>");
/* Register policy */ /* Register policy */
$register_choices = array( $register_choices = [
REGISTER_CLOSED => t("Closed"), REGISTER_CLOSED => t("Closed"),
REGISTER_APPROVE => t("Requires approval"), REGISTER_APPROVE => t("Requires approval"),
REGISTER_OPEN => t("Open") REGISTER_OPEN => t("Open")
); ];
$ssl_choices = array( $ssl_choices = [
SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"), SSL_POLICY_NONE => t("No SSL policy, links will track page SSL state"),
SSL_POLICY_FULL => t("Force all links to use SSL"), SSL_POLICY_FULL => t("Force all links to use SSL"),
SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)") SSL_POLICY_SELFSIGN => t("Self-signed certificate, use SSL for local links only (discouraged)")
); ];
$check_git_version_choices = array( $check_git_version_choices = [
"none" => t("Don't check"), "none" => t("Don't check"),
"master" => t("check the stable version"), "master" => t("check the stable version"),
"develop" => t("check the development version") "develop" => t("check the development version")
); ];
if ($a->config['hostname'] == "") { if ($a->config['hostname'] == "") {
$a->config['hostname'] = $a->get_hostname(); $a->config['hostname'] = $a->get_hostname();
@ -1244,7 +1244,7 @@ function admin_page_site(App $a)
} }
$t = get_markup_template('admin/site.tpl'); $t = get_markup_template('admin/site.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Site'), '$page' => t('Site'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
@ -1259,91 +1259,91 @@ function admin_page_site(App $a)
'$relocate' => t('Relocate - WARNING: advanced function. Could make this server unreachable.'), '$relocate' => t('Relocate - WARNING: advanced function. Could make this server unreachable.'),
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
'$sitename' => array('sitename', t("Site name"), $a->config['sitename'],''), '$sitename' => ['sitename', t("Site name"), $a->config['sitename'],''],
'$hostname' => array('hostname', t("Host name"), $a->config['hostname'], ""), '$hostname' => ['hostname', t("Host name"), $a->config['hostname'], ""],
'$sender_email' => array('sender_email', t("Sender Email"), $a->config['sender_email'], t("The email address your server shall use to send notification emails from."), "", "", "email"), '$sender_email' => ['sender_email', t("Sender Email"), $a->config['sender_email'], t("The email address your server shall use to send notification emails from."), "", "", "email"],
'$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$banner' => ['banner', t("Banner/Logo"), $banner, ""],
'$shortcut_icon' => array('shortcut_icon', t("Shortcut icon"), Config::get('system','shortcut_icon'), t("Link to an icon that will be used for browsers.")), '$shortcut_icon' => ['shortcut_icon', t("Shortcut icon"), Config::get('system','shortcut_icon'), t("Link to an icon that will be used for browsers.")],
'$touch_icon' => array('touch_icon', t("Touch icon"), Config::get('system','touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")), '$touch_icon' => ['touch_icon', t("Touch icon"), Config::get('system','touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")],
'$info' => array('info', t('Additional Info'), $info, t('For public servers: you can add additional information here that will be listed at %s/servers.', get_server())), '$info' => ['info', t('Additional Info'), $info, t('For public servers: you can add additional information here that will be listed at %s/servers.', get_server())],
'$language' => array('language', t("System language"), Config::get('system','language'), "", $lang_choices), '$language' => ['language', t("System language"), Config::get('system','language'), "", $lang_choices],
'$theme' => array('theme', t("System theme"), Config::get('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices), '$theme' => ['theme', t("System theme"), Config::get('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices],
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), Config::get('system', 'mobile-theme', '---'), t("Theme for mobile devices"), $theme_choices_mobile), '$theme_mobile' => ['theme_mobile', t("Mobile system theme"), Config::get('system', 'mobile-theme', '---'), t("Theme for mobile devices"), $theme_choices_mobile],
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(Config::get('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices), '$ssl_policy' => ['ssl_policy', t("SSL link policy"), (string) intval(Config::get('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices],
'$force_ssl' => array('force_ssl', t("Force SSL"), Config::get('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")), '$force_ssl' => ['force_ssl', t("Force SSL"), Config::get('system','force_ssl'), t("Force all Non-SSL requests to SSL - Attention: on some systems it could lead to endless loops.")],
'$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), Config::get('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")), '$hide_help' => ['hide_help', t("Hide help entry from navigation menu"), Config::get('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")],
'$singleuser' => array('singleuser', t("Single user instance"), Config::get('system', 'singleuser', '---'), t("Make this instance multi-user or single-user for the named user"), $user_names), '$singleuser' => ['singleuser', t("Single user instance"), Config::get('system', 'singleuser', '---'), t("Make this instance multi-user or single-user for the named user"), $user_names],
'$maximagesize' => array('maximagesize', t("Maximum image size"), Config::get('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")), '$maximagesize' => ['maximagesize', t("Maximum image size"), Config::get('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")],
'$maximagelength' => array('maximagelength', t("Maximum image length"), Config::get('system','max_image_length'), t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")), '$maximagelength' => ['maximagelength', t("Maximum image length"), Config::get('system','max_image_length'), t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")],
'$jpegimagequality' => array('jpegimagequality', t("JPEG image quality"), Config::get('system','jpeg_quality'), t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")), '$jpegimagequality' => ['jpegimagequality', t("JPEG image quality"), Config::get('system','jpeg_quality'), t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")],
'$register_policy' => array('register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices), '$register_policy' => ['register_policy', t("Register policy"), $a->config['register_policy'], "", $register_choices],
'$daily_registrations' => array('max_daily_registrations', t("Maximum Daily Registrations"), Config::get('system', 'max_daily_registrations'), t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.")), '$daily_registrations' => ['max_daily_registrations', t("Maximum Daily Registrations"), Config::get('system', 'max_daily_registrations'), t("If registration is permitted above, this sets the maximum number of new user registrations to accept per day. If register is set to closed, this setting has no effect.")],
'$register_text' => array('register_text', t("Register text"), $a->config['register_text'], t("Will be displayed prominently on the registration page.")), '$register_text' => ['register_text', t("Register text"), $a->config['register_text'], t("Will be displayed prominently on the registration page.")],
'$abandon_days' => array('abandon_days', t('Accounts abandoned after x days'), Config::get('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')), '$abandon_days' => ['abandon_days', t('Accounts abandoned after x days'), Config::get('system','account_abandon_days'), t('Will not waste system resources polling external sites for abandonded accounts. Enter 0 for no time limit.')],
'$allowed_sites' => array('allowed_sites', t("Allowed friend domains"), Config::get('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")), '$allowed_sites' => ['allowed_sites', t("Allowed friend domains"), Config::get('system','allowed_sites'), t("Comma separated list of domains which are allowed to establish friendships with this site. Wildcards are accepted. Empty to allow any domains")],
'$allowed_email' => array('allowed_email', t("Allowed email domains"), Config::get('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")), '$allowed_email' => ['allowed_email', t("Allowed email domains"), Config::get('system','allowed_email'), t("Comma separated list of domains which are allowed in email addresses for registrations to this site. Wildcards are accepted. Empty to allow any domains")],
'$no_oembed_rich_content' => array('no_oembed_rich_content', t("No OEmbed rich content"), Config::get('system','no_oembed_rich_content'), t("Don't show the rich content (e.g. embedded PDF), except from the domains listed below.")), '$no_oembed_rich_content' => ['no_oembed_rich_content', t("No OEmbed rich content"), Config::get('system','no_oembed_rich_content'), t("Don't show the rich content (e.g. embedded PDF), except from the domains listed below.")],
'$allowed_oembed' => array('allowed_oembed', t("Allowed OEmbed domains"), Config::get('system','allowed_oembed'), t("Comma separated list of domains which oembed content is allowed to be displayed. Wildcards are accepted.")), '$allowed_oembed' => ['allowed_oembed', t("Allowed OEmbed domains"), Config::get('system','allowed_oembed'), t("Comma separated list of domains which oembed content is allowed to be displayed. Wildcards are accepted.")],
'$block_public' => array('block_public', t("Block public"), Config::get('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")), '$block_public' => ['block_public', t("Block public"), Config::get('system','block_public'), t("Check to block public access to all otherwise public personal pages on this site unless you are currently logged in.")],
'$force_publish' => array('publish_all', t("Force publish"), Config::get('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")), '$force_publish' => ['publish_all', t("Force publish"), Config::get('system','publish_all'), t("Check to force all profiles on this site to be listed in the site directory.")],
'$global_directory' => array('directory', t("Global directory URL"), Config::get('system','directory'), t("URL to the global directory. If this is not set, the global directory is completely unavailable to the application.")), '$global_directory' => ['directory', t("Global directory URL"), Config::get('system','directory'), t("URL to the global directory. If this is not set, the global directory is completely unavailable to the application.")],
'$newuser_private' => array('newuser_private', t("Private posts by default for new users"), Config::get('system','newuser_private'), t("Set default post permissions for all new members to the default privacy group rather than public.")), '$newuser_private' => ['newuser_private', t("Private posts by default for new users"), Config::get('system','newuser_private'), t("Set default post permissions for all new members to the default privacy group rather than public.")],
'$enotify_no_content' => array('enotify_no_content', t("Don't include post content in email notifications"), Config::get('system','enotify_no_content'), t("Don't include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.")), '$enotify_no_content' => ['enotify_no_content', t("Don't include post content in email notifications"), Config::get('system','enotify_no_content'), t("Don't include the content of a post/comment/private message/etc. in the email notifications that are sent out from this site, as a privacy measure.")],
'$private_addons' => array('private_addons', t("Disallow public access to addons listed in the apps menu."), Config::get('config','private_addons'), t("Checking this box will restrict addons listed in the apps menu to members only.")), '$private_addons' => ['private_addons', t("Disallow public access to addons listed in the apps menu."), Config::get('config','private_addons'), t("Checking this box will restrict addons listed in the apps menu to members only.")],
'$disable_embedded' => array('disable_embedded', t("Don't embed private images in posts"), Config::get('system','disable_embedded'), t("Don't replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.")), '$disable_embedded' => ['disable_embedded', t("Don't embed private images in posts"), Config::get('system','disable_embedded'), t("Don't replace locally-hosted private photos in posts with an embedded copy of the image. This means that contacts who receive posts containing private photos will have to authenticate and load each image, which may take a while.")],
'$allow_users_remote_self' => array('allow_users_remote_self', t('Allow Users to set remote_self'), Config::get('system','allow_users_remote_self'), t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')), '$allow_users_remote_self' => ['allow_users_remote_self', t('Allow Users to set remote_self'), Config::get('system','allow_users_remote_self'), t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
'$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), Config::get('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")), '$no_multi_reg' => ['no_multi_reg', t("Block multiple registrations"), Config::get('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")],
'$no_openid' => array('no_openid', t("OpenID support"), !Config::get('system','no_openid'), t("OpenID support for registration and logins.")), '$no_openid' => ['no_openid', t("OpenID support"), !Config::get('system','no_openid'), t("OpenID support for registration and logins.")],
'$no_regfullname' => array('no_regfullname', t("Fullname check"), !Config::get('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")), '$no_regfullname' => ['no_regfullname', t("Fullname check"), !Config::get('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")],
'$community_page_style' => array('community_page_style', t("Community pages for visitors"), Config::get('system','community_page_style'), t("Which community pages should be available for visitors. Local users always see both pages."), $community_page_style_choices), '$community_page_style' => ['community_page_style', t("Community pages for visitors"), Config::get('system','community_page_style'), t("Which community pages should be available for visitors. Local users always see both pages."), $community_page_style_choices],
'$max_author_posts_community_page' => array('max_author_posts_community_page', t("Posts per user on community page"), Config::get('system','max_author_posts_community_page'), t("The maximum number of posts per user on the community page. (Not valid for 'Global Community')")), '$max_author_posts_community_page' => ['max_author_posts_community_page', t("Posts per user on community page"), Config::get('system','max_author_posts_community_page'), t("The maximum number of posts per user on the community page. (Not valid for 'Global Community')")],
'$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !Config::get('system','ostatus_disabled'), t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")), '$ostatus_disabled' => ['ostatus_disabled', t("Enable OStatus support"), !Config::get('system','ostatus_disabled'), t("Provide built-in OStatus \x28StatusNet, GNU Social etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.")],
'$ostatus_full_threads' => array('ostatus_full_threads', t("Only import OStatus threads from our contacts"), Config::get('system','ostatus_full_threads'), t("Normally we import every content from our OStatus contacts. With this option we only store threads that are started by a contact that is known on our system.")), '$ostatus_full_threads' => ['ostatus_full_threads', t("Only import OStatus threads from our contacts"), Config::get('system','ostatus_full_threads'), t("Normally we import every content from our OStatus contacts. With this option we only store threads that are started by a contact that is known on our system.")],
'$ostatus_not_able' => t("OStatus support can only be enabled if threading is enabled."), '$ostatus_not_able' => t("OStatus support can only be enabled if threading is enabled."),
'$diaspora_able' => $diaspora_able, '$diaspora_able' => $diaspora_able,
'$diaspora_not_able' => t("Diaspora support can't be enabled because Friendica was installed into a sub directory."), '$diaspora_not_able' => t("Diaspora support can't be enabled because Friendica was installed into a sub directory."),
'$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), Config::get('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")), '$diaspora_enabled' => ['diaspora_enabled', t("Enable Diaspora support"), Config::get('system','diaspora_enabled'), t("Provide built-in Diaspora network compatibility.")],
'$dfrn_only' => array('dfrn_only', t('Only allow Friendica contacts'), Config::get('system','dfrn_only'), t("All contacts must use Friendica protocols. All other built-in communication protocols disabled.")), '$dfrn_only' => ['dfrn_only', t('Only allow Friendica contacts'), Config::get('system','dfrn_only'), t("All contacts must use Friendica protocols. All other built-in communication protocols disabled.")],
'$verifyssl' => array('verifyssl', t("Verify SSL"), Config::get('system','verifyssl'), t("If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.")), '$verifyssl' => ['verifyssl', t("Verify SSL"), Config::get('system','verifyssl'), t("If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.")],
'$proxyuser' => array('proxyuser', t("Proxy user"), Config::get('system','proxyuser'), ""), '$proxyuser' => ['proxyuser', t("Proxy user"), Config::get('system','proxyuser'), ""],
'$proxy' => array('proxy', t("Proxy URL"), Config::get('system','proxy'), ""), '$proxy' => ['proxy', t("Proxy URL"), Config::get('system','proxy'), ""],
'$timeout' => array('timeout', t("Network timeout"), (x(Config::get('system','curl_timeout'))?Config::get('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")), '$timeout' => ['timeout', t("Network timeout"), (x(Config::get('system','curl_timeout'))?Config::get('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")],
'$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(Config::get('system','maxloadavg')) > 0)?Config::get('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")), '$maxloadavg' => ['maxloadavg', t("Maximum Load Average"), ((intval(Config::get('system','maxloadavg')) > 0)?Config::get('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")],
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(Config::get('system','maxloadavg_frontend')) > 0)?Config::get('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")), '$maxloadavg_frontend' => ['maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(Config::get('system','maxloadavg_frontend')) > 0)?Config::get('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")],
'$min_memory' => array('min_memory', t("Minimal Memory"), ((intval(Config::get('system','min_memory')) > 0)?Config::get('system','min_memory'):0), t("Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated).")), '$min_memory' => ['min_memory', t("Minimal Memory"), ((intval(Config::get('system','min_memory')) > 0)?Config::get('system','min_memory'):0), t("Minimal free memory in MB for the worker. Needs access to /proc/meminfo - default 0 (deactivated).")],
'$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")), '$optimize_max_tablesize'=> ['optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")],
'$optimize_fragmentation'=> array('optimize_fragmentation', t("Minimum level of fragmentation"), ((intval(Config::get('system','optimize_fragmentation')) > 0)?Config::get('system','optimize_fragmentation'):30), t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")), '$optimize_fragmentation'=> ['optimize_fragmentation', t("Minimum level of fragmentation"), ((intval(Config::get('system','optimize_fragmentation')) > 0)?Config::get('system','optimize_fragmentation'):30), t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")],
'$poco_completion' => array('poco_completion', t("Periodical check of global contacts"), Config::get('system','poco_completion'), t("If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.")), '$poco_completion' => ['poco_completion', t("Periodical check of global contacts"), Config::get('system','poco_completion'), t("If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.")],
'$poco_requery_days' => array('poco_requery_days', t("Days between requery"), Config::get('system','poco_requery_days'), t("Number of days after which a server is requeried for his contacts.")), '$poco_requery_days' => ['poco_requery_days', t("Days between requery"), Config::get('system','poco_requery_days'), t("Number of days after which a server is requeried for his contacts.")],
'$poco_discovery' => array('poco_discovery', t("Discover contacts from other servers"), (string) intval(Config::get('system','poco_discovery')), t("Periodically query other servers for contacts. You can choose between 'users': the users on the remote system, 'Global Contacts': active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren't available. The fallback increases the server load, so the recommened setting is 'Users, Global Contacts'."), $poco_discovery_choices), '$poco_discovery' => ['poco_discovery', t("Discover contacts from other servers"), (string) intval(Config::get('system','poco_discovery')), t("Periodically query other servers for contacts. You can choose between 'users': the users on the remote system, 'Global Contacts': active contacts that are known on the system. The fallback is meant for Redmatrix servers and older friendica servers, where global contacts weren't available. The fallback increases the server load, so the recommened setting is 'Users, Global Contacts'."), $poco_discovery_choices],
'$poco_discovery_since' => array('poco_discovery_since', t("Timeframe for fetching global contacts"), (string) intval(Config::get('system','poco_discovery_since')), t("When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers."), $poco_discovery_since_choices), '$poco_discovery_since' => ['poco_discovery_since', t("Timeframe for fetching global contacts"), (string) intval(Config::get('system','poco_discovery_since')), t("When the discovery is activated, this value defines the timeframe for the activity of the global contacts that are fetched from other servers."), $poco_discovery_since_choices],
'$poco_local_search' => array('poco_local_search', t("Search the local directory"), Config::get('system','poco_local_search'), t("Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.")), '$poco_local_search' => ['poco_local_search', t("Search the local directory"), Config::get('system','poco_local_search'), t("Search the local directory instead of the global directory. When searching locally, every search will be executed on the global directory in the background. This improves the search results when the search is repeated.")],
'$nodeinfo' => array('nodeinfo', t("Publish server information"), Config::get('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")), '$nodeinfo' => ['nodeinfo', t("Publish server information"), Config::get('system','nodeinfo'), t("If enabled, general server and usage data will be published. The data contains the name and version of the server, number of users with public profiles, number of posts and the activated protocols and connectors. See <a href='http://the-federation.info/'>the-federation.info</a> for details.")],
'$check_new_version_url' => array('check_new_version_url', t("Check upstream version"), Config::get('system', 'check_new_version_url'), t("Enables checking for new Friendica versions at github. If there is a new version, you will be informed in the admin panel overview."), $check_git_version_choices), '$check_new_version_url' => ['check_new_version_url', t("Check upstream version"), Config::get('system', 'check_new_version_url'), t("Enables checking for new Friendica versions at github. If there is a new version, you will be informed in the admin panel overview."), $check_git_version_choices],
'$suppress_tags' => array('suppress_tags', t("Suppress Tags"), Config::get('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")), '$suppress_tags' => ['suppress_tags', t("Suppress Tags"), Config::get('system','suppress_tags'), t("Suppress showing a list of hashtags at the end of the posting.")],
'$itemcache' => array('itemcache', t("Path to item cache"), Config::get('system','itemcache'), t("The item caches buffers generated bbcode and external images.")), '$itemcache' => ['itemcache', t("Path to item cache"), Config::get('system','itemcache'), t("The item caches buffers generated bbcode and external images.")],
'$itemcache_duration' => array('itemcache_duration', t("Cache duration in seconds"), Config::get('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")), '$itemcache_duration' => ['itemcache_duration', t("Cache duration in seconds"), Config::get('system','itemcache_duration'), t("How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.")],
'$max_comments' => array('max_comments', t("Maximum numbers of comments per post"), Config::get('system','max_comments'), t("How much comments should be shown for each post? Default value is 100.")), '$max_comments' => ['max_comments', t("Maximum numbers of comments per post"), Config::get('system','max_comments'), t("How much comments should be shown for each post? Default value is 100.")],
'$temppath' => array('temppath', t("Temp path"), Config::get('system','temppath'), t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")), '$temppath' => ['temppath', t("Temp path"), Config::get('system','temppath'), t("If you have a restricted system where the webserver can't access the system temp path, enter another path here.")],
'$basepath' => array('basepath', t("Base path to installation"), Config::get('system','basepath'), t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot.")), '$basepath' => ['basepath', t("Base path to installation"), Config::get('system','basepath'), t("If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot.")],
'$proxy_disabled' => array('proxy_disabled', t("Disable picture proxy"), Config::get('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")), '$proxy_disabled' => ['proxy_disabled', t("Disable picture proxy"), Config::get('system','proxy_disabled'), t("The picture proxy increases performance and privacy. It shouldn't be used on systems with very low bandwith.")],
'$only_tag_search' => array('only_tag_search', t("Only search in tags"), Config::get('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")), '$only_tag_search' => ['only_tag_search', t("Only search in tags"), Config::get('system','only_tag_search'), t("On large systems the text search can slow down the system extremely.")],
'$relocate_url' => array('relocate_url', t("New base url"), System::baseUrl(), t("Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.")), '$relocate_url' => ['relocate_url', t("New base url"), System::baseUrl(), t("Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.")],
'$rino' => array('rino', t("RINO Encryption"), intval(Config::get('system','rino_encrypt')), t("Encryption layer between nodes."), array("Disabled", "RINO1 (deprecated)", "RINO2")), '$rino' => ['rino', t("RINO Encryption"), intval(Config::get('system','rino_encrypt')), t("Encryption layer between nodes."), ["Disabled", "RINO1 (deprecated)", "RINO2"]],
'$worker_queues' => array('worker_queues', t("Maximum number of parallel workers"), Config::get('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")), '$worker_queues' => ['worker_queues', t("Maximum number of parallel workers"), Config::get('system','worker_queues'), t("On shared hosters set this to 2. On larger systems, values of 10 are great. Default value is 4.")],
'$worker_dont_fork' => array('worker_dont_fork', t("Don't use 'proc_open' with the worker"), Config::get('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.")), '$worker_dont_fork' => ['worker_dont_fork', t("Don't use 'proc_open' with the worker"), Config::get('system','worker_dont_fork'), t("Enable this if your system doesn't allow the use of 'proc_open'. This can happen on shared hosters. If this is enabled you should increase the frequency of worker calls in your crontab.")],
'$worker_fastlane' => array('worker_fastlane', t("Enable fastlane"), Config::get('system','worker_fastlane'), t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")), '$worker_fastlane' => ['worker_fastlane', t("Enable fastlane"), Config::get('system','worker_fastlane'), t("When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.")],
'$worker_frontend' => array('worker_frontend', t('Enable frontend worker'), Config::get('system','frontend_worker'), t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', System::baseUrl())), '$worker_frontend' => ['worker_frontend', t('Enable frontend worker'), Config::get('system','frontend_worker'), t('When enabled the Worker process is triggered when backend access is performed (e.g. messages being delivered). On smaller sites you might want to call %s/worker on a regular basis via an external cron job. You should only enable this option if you cannot utilize cron/scheduled jobs on your server.', System::baseUrl())],
'$form_security_token' => get_form_security_token("admin_site") '$form_security_token' => get_form_security_token("admin_site")
)); ]);
} }
/** /**
@ -1405,7 +1405,7 @@ function admin_page_dbsync(App $a)
return $o; return $o;
} }
$failed = array(); $failed = [];
$r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' "); $r = q("SELECT `k`, `v` FROM `config` WHERE `cat` = 'database' ");
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
@ -1417,20 +1417,20 @@ function admin_page_dbsync(App $a)
} }
} }
if (!count($failed)) { if (!count($failed)) {
$o = replace_macros(get_markup_template('structure_check.tpl'), array( $o = replace_macros(get_markup_template('structure_check.tpl'), [
'$base' => System::baseUrl(true), '$base' => System::baseUrl(true),
'$banner' => t('No failed updates.'), '$banner' => t('No failed updates.'),
'$check' => t('Check database structure'), '$check' => t('Check database structure'),
)); ]);
} else { } else {
$o = replace_macros(get_markup_template('failed_updates.tpl'), array( $o = replace_macros(get_markup_template('failed_updates.tpl'), [
'$base' => System::baseUrl(true), '$base' => System::baseUrl(true),
'$banner' => t('Failed Updates'), '$banner' => t('Failed Updates'),
'$desc' => t('This does not include updates prior to 1139, which did not return a status.'), '$desc' => t('This does not include updates prior to 1139, which did not return a status.'),
'$mark' => t('Mark success (if update was manually applied)'), '$mark' => t('Mark success (if update was manually applied)'),
'$apply' => t('Attempt to execute this update step automatically'), '$apply' => t('Attempt to execute this update step automatically'),
'$failed' => $failed '$failed' => $failed
)); ]);
} }
return $o; return $o;
@ -1443,8 +1443,8 @@ function admin_page_dbsync(App $a)
*/ */
function admin_page_users_post(App $a) function admin_page_users_post(App $a)
{ {
$pending = defaults($_POST, 'pending' , array()); $pending = defaults($_POST, 'pending' , []);
$users = defaults($_POST, 'user' , array()); $users = defaults($_POST, 'user' , []);
$nu_name = defaults($_POST, 'new_user_name' , ''); $nu_name = defaults($_POST, 'new_user_name' , '');
$nu_nickname = defaults($_POST, 'new_user_nickname', ''); $nu_nickname = defaults($_POST, 'new_user_nickname', '');
$nu_email = defaults($_POST, 'new_user_email' , ''); $nu_email = defaults($_POST, 'new_user_email' , '');
@ -1499,12 +1499,12 @@ function admin_page_users_post(App $a)
$preamble = sprintf($preamble, $user['username'], $a->config['sitename']); $preamble = sprintf($preamble, $user['username'], $a->config['sitename']);
$body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], $a->config['sitename']); $body = sprintf($body, System::baseUrl(), $user['email'], $result['password'], $a->config['sitename']);
notification(array( notification([
'type' => SYSTEM_EMAIL, 'type' => SYSTEM_EMAIL,
'to_email' => $user['email'], 'to_email' => $user['email'],
'subject' => t('Registration details for %s', $a->config['sitename']), 'subject' => t('Registration details for %s', $a->config['sitename']),
'preamble' => $preamble, 'preamble' => $preamble,
'body' => $body)); 'body' => $body]);
} }
if (x($_POST, 'page_users_block')) { if (x($_POST, 'page_users_block')) {
@ -1595,14 +1595,14 @@ function admin_page_users(App $a)
} }
/* ordering */ /* ordering */
$valid_orders = array( $valid_orders = [
'contact.name', 'contact.name',
'user.email', 'user.email',
'user.register_date', 'user.register_date',
'user.login_date', 'user.login_date',
'lastitem_date', 'lastitem_date',
'user.page-flags' 'user.page-flags'
); ];
$order = "contact.name"; $order = "contact.name";
$order_direction = "+"; $order_direction = "+";
@ -1629,12 +1629,12 @@ function admin_page_users(App $a)
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email'])); $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
$_setup_users = function ($e) use ($adminlist) { $_setup_users = function ($e) use ($adminlist) {
$accounts = array( $accounts = [
t('Normal Account'), t('Normal Account'),
t('Automatic Follower Account'), t('Automatic Follower Account'),
t('Public Forum Account'), t('Public Forum Account'),
t('Automatic Friend Account') t('Automatic Friend Account')
); ];
$e['page-flags'] = $accounts[$e['page-flags']]; $e['page-flags'] = $accounts[$e['page-flags']];
$e['register_date'] = relative_date($e['register_date']); $e['register_date'] = relative_date($e['register_date']);
$e['login_date'] = relative_date($e['login_date']); $e['login_date'] = relative_date($e['login_date']);
@ -1651,11 +1651,11 @@ function admin_page_users(App $a)
// Get rid of dashes in key names, Smarty3 can't handle them // Get rid of dashes in key names, Smarty3 can't handle them
// and extracting deleted users // and extracting deleted users
$tmp_users = array(); $tmp_users = [];
$deleted = array(); $deleted = [];
while (count($users)) { while (count($users)) {
$new_user = array(); $new_user = [];
foreach (array_pop($users) as $k => $v) { foreach (array_pop($users) as $k => $v) {
$k = str_replace('-', '_', $k); $k = str_replace('-', '_', $k);
$new_user[$k] = $v; $new_user[$k] = $v;
@ -1672,11 +1672,11 @@ function admin_page_users(App $a)
array_push($users, array_pop($tmp_users)); array_push($users, array_pop($tmp_users));
} }
$th_users = array_map(null, array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account')), $valid_orders $th_users = array_map(null, [t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account')], $valid_orders
); );
$t = get_markup_template('admin/users.tpl'); $t = get_markup_template('admin/users.tpl');
$o = replace_macros($t, array( $o = replace_macros($t, [
// strings // // strings //
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Users'), '$page' => t('Users'),
@ -1684,7 +1684,7 @@ function admin_page_users(App $a)
'$select_all' => t('select all'), '$select_all' => t('select all'),
'$h_pending' => t('User registrations waiting for confirm'), '$h_pending' => t('User registrations waiting for confirm'),
'$h_deleted' => t('User waiting for permanent deletion'), '$h_deleted' => t('User waiting for permanent deletion'),
'$th_pending' => array(t('Request date'), t('Name'), t('Email')), '$th_pending' => [t('Request date'), t('Name'), t('Email')],
'$no_pending' => t('No registrations.'), '$no_pending' => t('No registrations.'),
'$pendingnotetext' => t('Note from the user'), '$pendingnotetext' => t('Note from the user'),
'$approve' => t('Approve'), '$approve' => t('Approve'),
@ -1697,7 +1697,7 @@ function admin_page_users(App $a)
'$h_users' => t('Users'), '$h_users' => t('Users'),
'$h_newuser' => t('New User'), '$h_newuser' => t('New User'),
'$th_deleted' => array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since')), '$th_deleted' => [t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Deleted since')],
'$th_users' => $th_users, '$th_users' => $th_users,
'$order_users' => $order, '$order_users' => $order,
'$order_direction_users' => $order_direction, '$order_direction_users' => $order_direction,
@ -1713,10 +1713,10 @@ function admin_page_users(App $a)
'$pending' => $pending, '$pending' => $pending,
'deleted' => $deleted, 'deleted' => $deleted,
'$users' => $users, '$users' => $users,
'$newusername' => array('new_user_name', t("Name"), '', t("Name of the new user.")), '$newusername' => ['new_user_name', t("Name"), '', t("Name of the new user.")],
'$newusernickname' => array('new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")), '$newusernickname' => ['new_user_nickname', t("Nickname"), '', t("Nickname of the new user.")],
'$newuseremail' => array('new_user_email', t("Email"), '', t("Email address of the new user."), '', '', 'email'), '$newuseremail' => ['new_user_email', t("Email"), '', t("Email address of the new user."), '', '', 'email'],
)); ]);
$o .= paginate($a); $o .= paginate($a);
return $o; return $o;
} }
@ -1793,7 +1793,7 @@ function admin_page_plugins(App $a)
$t = get_markup_template('admin/plugins_details.tpl'); $t = get_markup_template('admin/plugins_details.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Plugins'), '$page' => t('Plugins'),
'$toggle' => t('Toggle'), '$toggle' => t('Toggle'),
@ -1813,7 +1813,7 @@ function admin_page_plugins(App $a)
'$readme' => $readme, '$readme' => $readme,
'$form_security_token' => get_form_security_token("admin_themes"), '$form_security_token' => get_form_security_token("admin_themes"),
)); ]);
} }
/* /*
@ -1826,7 +1826,7 @@ function admin_page_plugins(App $a)
goaway(System::baseUrl() . '/admin/plugins'); goaway(System::baseUrl() . '/admin/plugins');
} }
$plugins = array(); $plugins = [];
$files = glob("addon/*/"); $files = glob("addon/*/");
if (is_array($files)) { if (is_array($files)) {
foreach ($files as $file) { foreach ($files as $file) {
@ -1846,14 +1846,14 @@ function admin_page_plugins(App $a)
} }
if ($show_plugin) { if ($show_plugin) {
$plugins[] = array($id, (in_array($id, $a->plugins) ? "on" : "off"), $info); $plugins[] = [$id, (in_array($id, $a->plugins) ? "on" : "off"), $info];
} }
} }
} }
} }
$t = get_markup_template('admin/plugins.tpl'); $t = get_markup_template('admin/plugins.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Plugins'), '$page' => t('Plugins'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
@ -1864,7 +1864,7 @@ function admin_page_plugins(App $a)
'$pcount' => count($plugins), '$pcount' => count($plugins),
'$noplugshint' => t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s', 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'), '$noplugshint' => t('There are currently no plugins available on your node. You can find the official plugin repository at %1$s and might find other interesting plugins in the open plugin registry at %2$s', 'https://github.com/friendica/friendica-addons', 'http://addons.friendi.ca'),
'$form_security_token' => get_form_security_token("admin_themes"), '$form_security_token' => get_form_security_token("admin_themes"),
)); ]);
} }
/** /**
@ -1948,7 +1948,7 @@ function admin_page_themes(App $a)
{ {
$allowed_themes_str = Config::get('system', 'allowed_themes'); $allowed_themes_str = Config::get('system', 'allowed_themes');
$allowed_themes_raw = explode(',', $allowed_themes_str); $allowed_themes_raw = explode(',', $allowed_themes_str);
$allowed_themes = array(); $allowed_themes = [];
if (count($allowed_themes_raw)) { if (count($allowed_themes_raw)) {
foreach ($allowed_themes_raw as $x) { foreach ($allowed_themes_raw as $x) {
if (strlen(trim($x))) { if (strlen(trim($x))) {
@ -1957,7 +1957,7 @@ function admin_page_themes(App $a)
} }
} }
$themes = array(); $themes = [];
$files = glob('view/theme/*'); $files = glob('view/theme/*');
if (is_array($files)) { if (is_array($files)) {
foreach ($files as $file) { foreach ($files as $file) {
@ -1976,7 +1976,7 @@ function admin_page_themes(App $a)
$is_allowed = intval(in_array($f, $allowed_themes)); $is_allowed = intval(in_array($f, $allowed_themes));
if ($is_allowed || $is_supported || Config::get("system", "show_unsupported_themes")) { if ($is_allowed || $is_supported || Config::get("system", "show_unsupported_themes")) {
$themes[] = array('name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed); $themes[] = ['name' => $f, 'experimental' => $is_experimental, 'supported' => $is_supported, 'allowed' => $is_allowed];
} }
} }
} }
@ -2056,13 +2056,13 @@ function admin_page_themes(App $a)
$a->page = $orig_page; $a->page = $orig_page;
} }
$screenshot = array(get_theme_screenshot($theme), t('Screenshot')); $screenshot = [get_theme_screenshot($theme), t('Screenshot')];
if (!stristr($screenshot[0], $theme)) { if (!stristr($screenshot[0], $theme)) {
$screenshot = null; $screenshot = null;
} }
$t = get_markup_template('admin/plugins_details.tpl'); $t = get_markup_template('admin/plugins_details.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Themes'), '$page' => t('Themes'),
'$toggle' => t('Toggle'), '$toggle' => t('Toggle'),
@ -2080,7 +2080,7 @@ function admin_page_themes(App $a)
'$readme' => $readme, '$readme' => $readme,
'$form_security_token' => get_form_security_token("admin_themes"), '$form_security_token' => get_form_security_token("admin_themes"),
)); ]);
} }
@ -2101,13 +2101,13 @@ function admin_page_themes(App $a)
* List themes * List themes
*/ */
$plugins = array(); $plugins = [];
foreach ($themes as $th) { foreach ($themes as $th) {
$plugins[] = array($th['name'], (($th['allowed']) ? "on" : "off"), get_theme_info($th['name'])); $plugins[] = [$th['name'], (($th['allowed']) ? "on" : "off"), get_theme_info($th['name'])];
} }
$t = get_markup_template('admin/plugins.tpl'); $t = get_markup_template('admin/plugins.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Themes'), '$page' => t('Themes'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
@ -2120,7 +2120,7 @@ function admin_page_themes(App $a)
'$experimental' => t('[Experimental]'), '$experimental' => t('[Experimental]'),
'$unsupported' => t('[Unsupported]'), '$unsupported' => t('[Unsupported]'),
'$form_security_token' => get_form_security_token("admin_themes"), '$form_security_token' => get_form_security_token("admin_themes"),
)); ]);
} }
/** /**
@ -2165,13 +2165,13 @@ function admin_page_logs_post(App $a)
*/ */
function admin_page_logs(App $a) function admin_page_logs(App $a)
{ {
$log_choices = array( $log_choices = [
LOGGER_NORMAL => 'Normal', LOGGER_NORMAL => 'Normal',
LOGGER_TRACE => 'Trace', LOGGER_TRACE => 'Trace',
LOGGER_DEBUG => 'Debug', LOGGER_DEBUG => 'Debug',
LOGGER_DATA => 'Data', LOGGER_DATA => 'Data',
LOGGER_ALL => 'All' LOGGER_ALL => 'All'
); ];
if (ini_get('log_errors')) { if (ini_get('log_errors')) {
$phplogenabled = t('PHP log currently enabled.'); $phplogenabled = t('PHP log currently enabled.');
@ -2181,7 +2181,7 @@ function admin_page_logs(App $a)
$t = get_markup_template('admin/logs.tpl'); $t = get_markup_template('admin/logs.tpl');
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Logs'), '$page' => t('Logs'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
@ -2189,15 +2189,15 @@ function admin_page_logs(App $a)
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$logname' => Config::get('system', 'logfile'), '$logname' => Config::get('system', 'logfile'),
// name, label, value, help string, extra data... // name, label, value, help string, extra data...
'$debugging' => array('debugging', t("Enable Debugging"), Config::get('system', 'debugging'), ""), '$debugging' => ['debugging', t("Enable Debugging"), Config::get('system', 'debugging'), ""],
'$logfile' => array('logfile', t("Log file"), Config::get('system', 'logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")), '$logfile' => ['logfile', t("Log file"), Config::get('system', 'logfile'), t("Must be writable by web server. Relative to your Friendica top-level directory.")],
'$loglevel' => array('loglevel', t("Log level"), Config::get('system', 'loglevel'), "", $log_choices), '$loglevel' => ['loglevel', t("Log level"), Config::get('system', 'loglevel'), "", $log_choices],
'$form_security_token' => get_form_security_token("admin_logs"), '$form_security_token' => get_form_security_token("admin_logs"),
'$phpheader' => t("PHP logging"), '$phpheader' => t("PHP logging"),
'$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."), '$phphint' => t("To enable logging of PHP errors and warnings you can add the following to the .htconfig.php file of your installation. The filename set in the 'error_log' line is relative to the friendica top-level directory and must be writeable by the web server. The option '1' for 'log_errors' and 'display_errors' is to enable these options, set to '0' to disable them."),
'$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');", '$phplogcode' => "error_reporting(E_ERROR | E_WARNING | E_PARSE);\nini_set('error_log','php.out');\nini_set('log_errors','1');\nini_set('display_errors', '1');",
'$phplogenabled' => $phplogenabled, '$phplogenabled' => $phplogenabled,
)); ]);
} }
/** /**
@ -2248,12 +2248,12 @@ function admin_page_viewlogs(App $a)
fclose($fp); fclose($fp);
} }
} }
return replace_macros($t, array( return replace_macros($t, [
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('View Logs'), '$page' => t('View Logs'),
'$data' => $data, '$data' => $data,
'$logname' => Config::get('system', 'logfile') '$logname' => Config::get('system', 'logfile')
)); ]);
} }
/** /**
@ -2311,28 +2311,28 @@ function admin_page_features_post(App $a)
function admin_page_features(App $a) function admin_page_features(App $a)
{ {
if ((argc() > 1) && (argv(1) === 'features')) { if ((argc() > 1) && (argv(1) === 'features')) {
$arr = array(); $arr = [];
$features = Feature::get(false); $features = Feature::get(false);
foreach ($features as $fname => $fdata) { foreach ($features as $fname => $fdata) {
$arr[$fname] = array(); $arr[$fname] = [];
$arr[$fname][0] = $fdata[0]; $arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata, 1) as $f) { foreach (array_slice($fdata, 1) as $f) {
$set = Config::get('feature', $f[0], $f[3]); $set = Config::get('feature', $f[0], $f[3]);
$arr[$fname][1][] = array( $arr[$fname][1][] = [
array('feature_' . $f[0], $f[1], $set, $f[2], array(t('Off'), t('On'))), ['feature_' . $f[0], $f[1], $set, $f[2], [t('Off'), t('On')]],
array('featurelock_' . $f[0], t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', array(t('Off'), t('On'))) ['featurelock_' . $f[0], t('Lock feature %s', $f[1]), (($f[4] !== false) ? "1" : ''), '', [t('Off'), t('On')]]
); ];
} }
} }
$tpl = get_markup_template('admin/settings_features.tpl'); $tpl = get_markup_template('admin/settings_features.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$form_security_token' => get_form_security_token("admin_manage_features"), '$form_security_token' => get_form_security_token("admin_manage_features"),
'$title' => t('Manage Additional Features'), '$title' => t('Manage Additional Features'),
'$features' => $arr, '$features' => $arr,
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
)); ]);
return $o; return $o;
} }

View file

@ -69,13 +69,13 @@ function allfriends_content(App $a)
$photo_menu = Contact::photoMenu($rr); $photo_menu = Contact::photoMenu($rr);
} else { } else {
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url']; $connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
$photo_menu = array( $photo_menu = [
'profile' => array(t("View Profile"), Profile::zrl($rr['url'])), 'profile' => [t("View Profile"), Profile::zrl($rr['url'])],
'follow' => array(t("Connect/Follow"), $connlnk) 'follow' => [t("Connect/Follow"), $connlnk]
); ];
} }
$entry = array( $entry = [
'url' => $rr['url'], 'url' => $rr['url'],
'itemurl' => defaults($contact_details, 'addr', $rr['url']), 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
'name' => htmlentities($contact_details['name']), 'name' => htmlentities($contact_details['name']),
@ -90,7 +90,7 @@ function allfriends_content(App $a)
'conntxt' => t('Connect'), 'conntxt' => t('Connect'),
'connlnk' => $connlnk, 'connlnk' => $connlnk,
'id' => ++$id, 'id' => ++$id,
); ];
$entries[] = $entry; $entries[] = $entry;
} }
@ -98,12 +98,12 @@ function allfriends_content(App $a)
$tpl = get_markup_template('viewcontact_template.tpl'); $tpl = get_markup_template('viewcontact_template.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
//'$title' => sprintf( t('Friends of %s'), htmlentities($c[0]['name'])), //'$title' => sprintf( t('Friends of %s'), htmlentities($c[0]['name'])),
'$tab_str' => $tab_str, '$tab_str' => $tab_str,
'$contacts' => $entries, '$contacts' => $entries,
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ]);
return $o; return $o;
} }

View file

@ -77,11 +77,11 @@ function api_content(App $a)
} }
$tpl = get_markup_template("oauth_authorize_done.tpl"); $tpl = get_markup_template("oauth_authorize_done.tpl");
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$title' => t('Authorize application connection'), '$title' => t('Authorize application connection'),
'$info' => t('Return to your app and insert this Securty Code:'), '$info' => t('Return to your app and insert this Securty Code:'),
'$code' => $verifier, '$code' => $verifier,
)); ]);
return $o; return $o;
} }
@ -99,13 +99,13 @@ function api_content(App $a)
} }
$tpl = get_markup_template('oauth_authorize.tpl'); $tpl = get_markup_template('oauth_authorize.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$title' => t('Authorize application connection'), '$title' => t('Authorize application connection'),
'$app' => $app, '$app' => $app,
'$authorize' => t('Do you want to authorize this application to access your posts and contacts, and/or create new posts for you?'), '$authorize' => t('Do you want to authorize this application to access your posts and contacts, and/or create new posts for you?'),
'$yes' => t('Yes'), '$yes' => t('Yes'),
'$no' => t('No'), '$no' => t('No'),
)); ]);
return $o; return $o;
} }

View file

@ -19,8 +19,8 @@ function apps_content(App $a) {
} }
$tpl = get_markup_template('apps.tpl'); $tpl = get_markup_template('apps.tpl');
return replace_macros($tpl, array( return replace_macros($tpl, [
'$title' => $title, '$title' => $title,
'$apps' => $a->apps, '$apps' => $a->apps,
)); ]);
} }

View file

@ -26,7 +26,7 @@ function bookmarklet_content(App $a)
if (!strstr($referer, $page)) { if (!strstr($referer, $page)) {
$content = add_page_info($_REQUEST["url"]); $content = add_page_info($_REQUEST["url"]);
$x = array( $x = [
'is_owner' => true, 'is_owner' => true,
'allow_location' => $a->user['allow_location'], 'allow_location' => $a->user['allow_location'],
'default_location' => $a->user['default-location'], 'default_location' => $a->user['default-location'],
@ -39,7 +39,7 @@ function bookmarklet_content(App $a)
'profile_uid' => local_user(), 'profile_uid' => local_user(),
'title' => trim($_REQUEST["title"], "*"), 'title' => trim($_REQUEST["title"], "*"),
'content' => $content 'content' => $content
); ];
$o = status_editor($a, $x, 0, false); $o = status_editor($a, $x, 0, false);
$o .= "<script>window.resizeTo(800,550);</script>"; $o .= "<script>window.resizeTo(800,550);</script>";
} else { } else {

View file

@ -51,13 +51,13 @@ function cal_init(App $a)
$tpl = get_markup_template("vcard-widget.tpl"); $tpl = get_markup_template("vcard-widget.tpl");
$vcard_widget = replace_macros($tpl, array( $vcard_widget = replace_macros($tpl, [
'$name' => $profile['name'], '$name' => $profile['name'],
'$photo' => $profile['photo'], '$photo' => $profile['photo'],
'$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""), '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""),
'$account_type' => $account_type, '$account_type' => $account_type,
'$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""), '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""),
)); ]);
$cal_widget = widget_events(); $cal_widget = widget_events();
@ -80,17 +80,17 @@ function cal_content(App $a)
$i18n = get_event_strings(); $i18n = get_event_strings();
$htpl = get_markup_template('event_head.tpl'); $htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl, array( $a->page['htmlhead'] .= replace_macros($htpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$module_url' => '/cal/' . $a->data['user']['nickname'], '$module_url' => '/cal/' . $a->data['user']['nickname'],
'$modparams' => 2, '$modparams' => 2,
'$i18n' => $i18n, '$i18n' => $i18n,
)); ]);
$etpl = get_markup_template('event_end.tpl'); $etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl, array( $a->page['end'] .= replace_macros($etpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
)); ]);
$mode = 'view'; $mode = 'view';
$y = 0; $y = 0;
@ -206,14 +206,14 @@ function cal_content(App $a)
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
// put the event parametes in an array so we can better transmit them // put the event parametes in an array so we can better transmit them
$event_params = array( $event_params = [
'event_id' => (x($_GET, 'id') ? $_GET["id"] : 0), 'event_id' => (x($_GET, 'id') ? $_GET["id"] : 0),
'start' => $start, 'start' => $start,
'finish' => $finish, 'finish' => $finish,
'adjust_start' => $adjust_start, 'adjust_start' => $adjust_start,
'adjust_finish' => $adjust_finish, 'adjust_finish' => $adjust_finish,
'ignored' => $ignored, 'ignored' => $ignored,
); ];
// get events by id or by date // get events by id or by date
if (x($_GET, 'id')) { if (x($_GET, 'id')) {
@ -222,7 +222,7 @@ function cal_content(App $a)
$r = events_by_date($owner_uid, $event_params, $sql_extra); $r = events_by_date($owner_uid, $event_params, $sql_extra);
} }
$links = array(); $links = [];
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
@ -255,7 +255,7 @@ function cal_content(App $a)
// Get rid of dashes in key names, Smarty3 can't handle them // Get rid of dashes in key names, Smarty3 can't handle them
foreach ($events as $key => $event) { foreach ($events as $key => $event) {
$event_item = array(); $event_item = [];
foreach ($event['item'] as $k => $v) { foreach ($event['item'] as $k => $v) {
$k = str_replace('-', '_', $k); $k = str_replace('-', '_', $k);
$event_item[$k] = $v; $event_item[$k] = $v;
@ -263,13 +263,13 @@ function cal_content(App $a)
$events[$key]['item'] = $event_item; $events[$key]['item'] = $event_item;
} }
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$tabs' => $tabs, '$tabs' => $tabs,
'$title' => t('Events'), '$title' => t('Events'),
'$view' => t('View'), '$view' => t('View'),
'$previous' => array(System::baseUrl() . "/events/$prevyear/$prevmonth", t('Previous'), '', ''), '$previous' => [System::baseUrl() . "/events/$prevyear/$prevmonth", t('Previous'), '', ''],
'$next' => array(System::baseUrl() . "/events/$nextyear/$nextmonth", t('Next'), '', ''), '$next' => [System::baseUrl() . "/events/$nextyear/$nextmonth", t('Next'), '', ''],
'$calendar' => cal($y, $m, $links, ' eventcal'), '$calendar' => cal($y, $m, $links, ' eventcal'),
'$events' => $events, '$events' => $events,
"today" => t("today"), "today" => t("today"),
@ -277,7 +277,7 @@ function cal_content(App $a)
"week" => t("week"), "week" => t("week"),
"day" => t("day"), "day" => t("day"),
"list" => t("list"), "list" => t("list"),
)); ]);
if (x($_GET, 'id')) { if (x($_GET, 'id')) {
echo $o; echo $o;

View file

@ -46,11 +46,11 @@ function common_content(App $a)
$contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]); $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]);
if (DBM::is_result($contact)) { if (DBM::is_result($contact)) {
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array( $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
'$name' => htmlentities($contact['name']), '$name' => htmlentities($contact['name']),
'$photo' => $contact['photo'], '$photo' => $contact['photo'],
'url' => 'contacts/' . $cid 'url' => 'contacts/' . $cid
)); ]);
if (!x($a->page, 'aside')) { if (!x($a->page, 'aside')) {
$a->page['aside'] = ''; $a->page['aside'] = '';
@ -115,7 +115,7 @@ function common_content(App $a)
$photo_menu = Contact::photoMenu($rr); $photo_menu = Contact::photoMenu($rr);
$entry = array( $entry = [
'url' => $rr['url'], 'url' => $rr['url'],
'itemurl' => defaults($contact_details, 'addr', $rr['url']), 'itemurl' => defaults($contact_details, 'addr', $rr['url']),
'name' => $contact_details['name'], 'name' => $contact_details['name'],
@ -128,7 +128,7 @@ function common_content(App $a)
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']), 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
'photo_menu' => $photo_menu, 'photo_menu' => $photo_menu,
'id' => ++$id, 'id' => ++$id,
); ];
$entries[] = $entry; $entries[] = $entry;
} }
@ -142,12 +142,12 @@ function common_content(App $a)
$tpl = get_markup_template('viewcontact_template.tpl'); $tpl = get_markup_template('viewcontact_template.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$title' => $title, '$title' => $title,
'$tab_str' => $tab_str, '$tab_str' => $tab_str,
'$contacts' => $entries, '$contacts' => $entries,
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ]);
return $o; return $o;
} }

View file

@ -67,35 +67,35 @@ function community_content(App $a, $update = 0)
$tabs = []; $tabs = [];
if ((local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(Config::get('system','singleuser'))) { if ((local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(Config::get('system','singleuser'))) {
$tabs[] = array( $tabs[] = [
'label' => t('Community'), 'label' => t('Community'),
'url' => 'community/local', 'url' => 'community/local',
'sel' => $content == 'local' ? 'active' : '', 'sel' => $content == 'local' ? 'active' : '',
'title' => t('Posts from local users on this server'), 'title' => t('Posts from local users on this server'),
'id' => 'community-local-tab', 'id' => 'community-local-tab',
'accesskey' => 'l' 'accesskey' => 'l'
); ];
} }
if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) { if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) {
$tabs[] = array( $tabs[] = [
'label' => t('Global Timeline'), 'label' => t('Global Timeline'),
'url' => 'community/global', 'url' => 'community/global',
'sel' => $content == 'global' ? 'active' : '', 'sel' => $content == 'global' ? 'active' : '',
'title' => t('Posts from users of the federated network'), 'title' => t('Posts from users of the federated network'),
'id' => 'community-global-tab', 'id' => 'community-global-tab',
'accesskey' => 'g' 'accesskey' => 'g'
); ];
} }
$tab_tpl = get_markup_template('common_tabs.tpl'); $tab_tpl = get_markup_template('common_tabs.tpl');
$o .= replace_macros($tab_tpl, array('$tabs' => $tabs)); $o .= replace_macros($tab_tpl, ['$tabs' => $tabs]);
nav_set_selected('community'); nav_set_selected('community');
// We need the editor here to be able to reshare an item. // We need the editor here to be able to reshare an item.
if (local_user()) { if (local_user()) {
$x = array( $x = [
'is_owner' => true, 'is_owner' => true,
'allow_location' => $a->user['allow_location'], 'allow_location' => $a->user['allow_location'],
'default_location' => $a->user['default-location'], 'default_location' => $a->user['default-location'],
@ -105,7 +105,7 @@ function community_content(App $a, $update = 0)
'bang' => '', 'bang' => '',
'visitor' => 'block', 'visitor' => 'block',
'profile_uid' => local_user(), 'profile_uid' => local_user(),
); ];
$o .= status_editor($a, $x, 0, true); $o .= status_editor($a, $x, 0, true);
} }
} }
@ -141,7 +141,7 @@ function community_content(App $a, $update = 0)
$count = 1; $count = 1;
$previousauthor = ""; $previousauthor = "";
$numposts = 0; $numposts = 0;
$s = array(); $s = [];
do { do {
foreach ($r as $item) { foreach ($r as $item) {
@ -171,12 +171,12 @@ function community_content(App $a, $update = 0)
} }
$t = get_markup_template("community.tpl"); $t = get_markup_template("community.tpl");
return replace_macros($t, array( return replace_macros($t, [
'$content' => $o, '$content' => $o,
'$header' => '', '$header' => '',
'$show_global_community_hint' => ($content == 'global') && Config::get('system', 'show_global_community_hint'), '$show_global_community_hint' => ($content == 'global') && Config::get('system', 'show_global_community_hint'),
'$global_community_hint' => t("This community stream shows all public posts received by this node. They may not reflect the opinions of this nodes users.") '$global_community_hint' => t("This community stream shows all public posts received by this node. They may not reflect the opinions of this nodes users.")
)); ]);
} }
function community_getitems($start, $itemspage, $content) function community_getitems($start, $itemspage, $content)
@ -204,5 +204,5 @@ function community_getitems($start, $itemspage, $content)
} }
// Should never happen // Should never happen
return array(); return [];
} }

View file

@ -33,7 +33,7 @@ function contactgroup_content(App $a)
$group = $r[0]; $group = $r[0];
$members = Contact::getByGroupId($group['id']); $members = Contact::getByGroupId($group['id']);
$preselected = array(); $preselected = [];
if (count($members)) { if (count($members)) {
foreach ($members as $member) { foreach ($members as $member) {
$preselected[] = $member['id']; $preselected[] = $member['id'];

View file

@ -48,7 +48,7 @@ function contacts_init(App $a)
} }
/// @TODO Add nice spaces /// @TODO Add nice spaces
$vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), array( $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
'$name' => htmlentities($a->data['contact']['name']), '$name' => htmlentities($a->data['contact']['name']),
'$photo' => $a->data['contact']['photo'], '$photo' => $a->data['contact']['photo'],
'$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/" . $a->data['contact']['id'] : $a->data['contact']['url'], '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/" . $a->data['contact']['id'] : $a->data['contact']['url'],
@ -56,7 +56,7 @@ function contacts_init(App $a)
'$network_name' => $networkname, '$network_name' => $networkname,
'$network' => t('Network:'), '$network' => t('Network:'),
'$account_type' => Contact::getAccountType($a->data['contact']) '$account_type' => Contact::getAccountType($a->data['contact'])
)); ]);
$findpeople_widget = ''; $findpeople_widget = '';
$follow_widget = ''; $follow_widget = '';
@ -75,26 +75,26 @@ function contacts_init(App $a)
$groups_widget = Group::sidebarWidget('contacts', 'group', 'full', 0, $contact_id); $groups_widget = Group::sidebarWidget('contacts', 'group', 'full', 0, $contact_id);
$a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), array( $a->page['aside'] .= replace_macros(get_markup_template("contacts-widget-sidebar.tpl"), [
'$vcard_widget' => $vcard_widget, '$vcard_widget' => $vcard_widget,
'$findpeople_widget' => $findpeople_widget, '$findpeople_widget' => $findpeople_widget,
'$follow_widget' => $follow_widget, '$follow_widget' => $follow_widget,
'$groups_widget' => $groups_widget, '$groups_widget' => $groups_widget,
'$networks_widget' => $networks_widget '$networks_widget' => $networks_widget
)); ]);
$base = System::baseUrl(); $base = System::baseUrl();
$tpl = get_markup_template("contacts-head.tpl"); $tpl = get_markup_template("contacts-head.tpl");
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$base' => $base '$base' => $base
)); ]);
$tpl = get_markup_template("contacts-end.tpl"); $tpl = get_markup_template("contacts-end.tpl");
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$base' => $base '$base' => $base
)); ]);
} }
function contacts_batch_actions(App $a) function contacts_batch_actions(App $a)
@ -259,13 +259,13 @@ function _contact_update_profile($contact_id)
$data = Probe::uri($contact["url"], "", 0, false); $data = Probe::uri($contact["url"], "", 0, false);
// "Feed" or "Unknown" is mostly a sign of communication problems // "Feed" or "Unknown" is mostly a sign of communication problems
if ((in_array($data["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) && ($data["network"] != $contact["network"])) { if ((in_array($data["network"], [NETWORK_FEED, NETWORK_PHANTOM])) && ($data["network"] != $contact["network"])) {
return; return;
} }
$updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", $updatefields = ["name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm",
"poco", "network", "alias"); "poco", "network", "alias"];
$update = array(); $update = [];
if ($data["network"] == NETWORK_OSTATUS) { if ($data["network"] == NETWORK_OSTATUS) {
$result = Contact::createFromProbe($uid, $data["url"], false); $result = Contact::createFromProbe($uid, $data["url"], false);
@ -442,17 +442,17 @@ function contacts_content(App $a)
// <form> can't take arguments in its "action" parameter // <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs // so add any arguments as hidden inputs
$query = explode_querystring($a->query_string); $query = explode_querystring($a->query_string);
$inputs = array(); $inputs = [];
foreach ($query['args'] as $arg) { foreach ($query['args'] as $arg) {
if (strpos($arg, 'confirm=') === false) { if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg); $arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
} }
} }
$a->page['aside'] = ''; $a->page['aside'] = '';
return replace_macros(get_markup_template('contact_drop_confirm.tpl'), array( return replace_macros(get_markup_template('contact_drop_confirm.tpl'), [
'$header' => t('Drop contact'), '$header' => t('Drop contact'),
'$contact' => _contact_detail_for_template($orig_record), '$contact' => _contact_detail_for_template($orig_record),
'$method' => 'get', '$method' => 'get',
@ -462,7 +462,7 @@ function contacts_content(App $a)
'$confirm_url' => $query['base'], '$confirm_url' => $query['base'],
'$confirm_name' => 'confirmed', '$confirm_name' => 'confirmed',
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
)); ]);
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if (x($_REQUEST, 'canceled')) { if (x($_REQUEST, 'canceled')) {
@ -493,12 +493,12 @@ function contacts_content(App $a)
$contact_id = $a->data['contact']['id']; $contact_id = $a->data['contact']['id'];
$contact = $a->data['contact']; $contact = $a->data['contact'];
$a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), array( $a->page['htmlhead'] .= replace_macros(get_markup_template('contact_head.tpl'), [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
)); ]);
$a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), array( $a->page['end'] .= replace_macros(get_markup_template('contact_end.tpl'), [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
)); ]);
$dir_icon = ''; $dir_icon = '';
$relation_text = ''; $relation_text = '';
@ -519,7 +519,7 @@ function contacts_content(App $a)
break; break;
} }
if (!in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) { if (!in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
$relation_text = ""; $relation_text = "";
} }
@ -542,7 +542,7 @@ function contacts_content(App $a)
} }
$lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : ''); $lblsuggest = (($contact['network'] === NETWORK_DFRN) ? t('Suggest friends') : '');
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL)); $poll_enabled = in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL]);
$nettype = t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"])); $nettype = t('Network type: %s', ContactSelector::networkToName($contact['network'], $contact["url"]));
@ -553,21 +553,21 @@ function contacts_content(App $a)
$fetch_further_information = null; $fetch_further_information = null;
if ($contact['network'] == NETWORK_FEED) { if ($contact['network'] == NETWORK_FEED) {
$fetch_further_information = array( $fetch_further_information = [
'fetch_further_information', 'fetch_further_information',
t('Fetch further information for feeds'), t('Fetch further information for feeds'),
$contact['fetch_further_information'], $contact['fetch_further_information'],
t("Fetch information like preview pictures, title and teaser from the feed item. You can activate this if the feed doesn't contain much text. Keywords are taken from the meta header in the feed item and are posted as hash tags."), t("Fetch information like preview pictures, title and teaser from the feed item. You can activate this if the feed doesn't contain much text. Keywords are taken from the meta header in the feed item and are posted as hash tags."),
array('0' => t('Disabled'), ['0' => t('Disabled'),
'1' => t('Fetch information'), '1' => t('Fetch information'),
'3' => t('Fetch keywords'), '3' => t('Fetch keywords'),
'2' => t('Fetch information and keywords') '2' => t('Fetch information and keywords')
) ]
); ];
} }
$poll_interval = null; $poll_interval = null;
if (in_array($contact['network'], array(NETWORK_FEED, NETWORK_MAIL))) { if (in_array($contact['network'], [NETWORK_FEED, NETWORK_MAIL])) {
$poll_interval = ContactSelector::pollInterval($contact['priority'], (!$poll_enabled)); $poll_interval = ContactSelector::pollInterval($contact['priority'], (!$poll_enabled));
} }
@ -578,7 +578,7 @@ function contacts_content(App $a)
$follow = ''; $follow = '';
$follow_text = ''; $follow_text = '';
if (in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) { if (in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS])) {
if ($contact['rel'] == CONTACT_IS_FOLLOWER) { if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
$follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]); $follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
$follow_text = t("Connect/Follow"); $follow_text = t("Connect/Follow");
@ -592,7 +592,7 @@ function contacts_content(App $a)
$contact_actions = contact_actions($contact); $contact_actions = contact_actions($contact);
$tpl = get_markup_template("contact_edit.tpl"); $tpl = get_markup_template("contact_edit.tpl");
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$header' => t("Contact"), '$header' => t("Contact"),
'$tab_str' => $tab_str, '$tab_str' => $tab_str,
'$submit' => t('Submit'), '$submit' => t('Submit'),
@ -626,16 +626,16 @@ function contacts_content(App $a)
'$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ), '$ignore_text' => (($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'$insecure' => (($contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA) ? $insecure : ''), '$insecure' => (($contact['network'] !== NETWORK_DFRN && $contact['network'] !== NETWORK_MAIL && $contact['network'] !== NETWORK_FACEBOOK && $contact['network'] !== NETWORK_DIASPORA) ? $insecure : ''),
'$info' => $contact['info'], '$info' => $contact['info'],
'$cinfo' => array('info', '', $contact['info'], ''), '$cinfo' => ['info', '', $contact['info'], ''],
'$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''), '$blocked' => (($contact['blocked']) ? t('Currently blocked') : ''),
'$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''), '$ignored' => (($contact['readonly']) ? t('Currently ignored') : ''),
'$archived' => (($contact['archive']) ? t('Currently archived') : ''), '$archived' => (($contact['archive']) ? t('Currently archived') : ''),
'$pending' => (($contact['pending']) ? t('Awaiting connection acknowledge') : ''), '$pending' => (($contact['pending']) ? t('Awaiting connection acknowledge') : ''),
'$hidden' => array('hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')), '$hidden' => ['hidden', t('Hide this contact from others'), ($contact['hidden'] == 1), t('Replies/likes to your public posts <strong>may</strong> still be visible')],
'$notify' => array('notify', t('Notification for new posts'), ($contact['notify_new_posts'] == 1), t('Send a notification of every new post of this contact')), '$notify' => ['notify', t('Notification for new posts'), ($contact['notify_new_posts'] == 1), t('Send a notification of every new post of this contact')],
'$fetch_further_information' => $fetch_further_information, '$fetch_further_information' => $fetch_further_information,
'$ffi_keyword_blacklist' => $contact['ffi_keyword_blacklist'], '$ffi_keyword_blacklist' => $contact['ffi_keyword_blacklist'],
'$ffi_keyword_blacklist' => array('ffi_keyword_blacklist', t('Blacklisted keywords'), $contact['ffi_keyword_blacklist'], t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')), '$ffi_keyword_blacklist' => ['ffi_keyword_blacklist', t('Blacklisted keywords'), $contact['ffi_keyword_blacklist'], t('Comma separated list of keywords that should not be converted to hashtags, when "Fetch information and keywords" is selected')],
'$photo' => $contact['photo'], '$photo' => $contact['photo'],
'$name' => htmlentities($contact['name']), '$name' => htmlentities($contact['name']),
'$dir_icon' => $dir_icon, '$dir_icon' => $dir_icon,
@ -657,9 +657,9 @@ function contacts_content(App $a)
'$contact_status' => t("Status"), '$contact_status' => t("Status"),
'$contact_settings_label' => t('Contact Settings'), '$contact_settings_label' => t('Contact Settings'),
'$contact_profile_label' => t("Profile"), '$contact_profile_label' => t("Profile"),
)); ]);
$arr = array('contact' => $contact, 'output' => $o); $arr = ['contact' => $contact, 'output' => $o];
call_hooks('contact_edit', $arr); call_hooks('contact_edit', $arr);
@ -694,67 +694,67 @@ function contacts_content(App $a)
$search = x($_GET, 'search') ? notags(trim($_GET['search'])) : ''; $search = x($_GET, 'search') ? notags(trim($_GET['search'])) : '';
$nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : ''; $nets = x($_GET, 'nets' ) ? notags(trim($_GET['nets'])) : '';
$tabs = array( $tabs = [
array( [
'label' => t('Suggestions'), 'label' => t('Suggestions'),
'url' => 'suggest', 'url' => 'suggest',
'sel' => '', 'sel' => '',
'title' => t('Suggest potential friends'), 'title' => t('Suggest potential friends'),
'id' => 'suggestions-tab', 'id' => 'suggestions-tab',
'accesskey' => 'g', 'accesskey' => 'g',
), ],
array( [
'label' => t('All Contacts'), 'label' => t('All Contacts'),
'url' => 'contacts/all', 'url' => 'contacts/all',
'sel' => ($all) ? 'active' : '', 'sel' => ($all) ? 'active' : '',
'title' => t('Show all contacts'), 'title' => t('Show all contacts'),
'id' => 'showall-tab', 'id' => 'showall-tab',
'accesskey' => 'l', 'accesskey' => 'l',
), ],
array( [
'label' => t('Unblocked'), 'label' => t('Unblocked'),
'url' => 'contacts', 'url' => 'contacts',
'sel' => ((!$all) && (!$blocked) && (!$hidden) && (!$search) && (!$nets) && (!$ignored) && (!$archived)) ? 'active' : '', 'sel' => ((!$all) && (!$blocked) && (!$hidden) && (!$search) && (!$nets) && (!$ignored) && (!$archived)) ? 'active' : '',
'title' => t('Only show unblocked contacts'), 'title' => t('Only show unblocked contacts'),
'id' => 'showunblocked-tab', 'id' => 'showunblocked-tab',
'accesskey' => 'o', 'accesskey' => 'o',
), ],
array( [
'label' => t('Blocked'), 'label' => t('Blocked'),
'url' => 'contacts/blocked', 'url' => 'contacts/blocked',
'sel' => ($blocked) ? 'active' : '', 'sel' => ($blocked) ? 'active' : '',
'title' => t('Only show blocked contacts'), 'title' => t('Only show blocked contacts'),
'id' => 'showblocked-tab', 'id' => 'showblocked-tab',
'accesskey' => 'b', 'accesskey' => 'b',
), ],
array( [
'label' => t('Ignored'), 'label' => t('Ignored'),
'url' => 'contacts/ignored', 'url' => 'contacts/ignored',
'sel' => ($ignored) ? 'active' : '', 'sel' => ($ignored) ? 'active' : '',
'title' => t('Only show ignored contacts'), 'title' => t('Only show ignored contacts'),
'id' => 'showignored-tab', 'id' => 'showignored-tab',
'accesskey' => 'i', 'accesskey' => 'i',
), ],
array( [
'label' => t('Archived'), 'label' => t('Archived'),
'url' => 'contacts/archived', 'url' => 'contacts/archived',
'sel' => ($archived) ? 'active' : '', 'sel' => ($archived) ? 'active' : '',
'title' => t('Only show archived contacts'), 'title' => t('Only show archived contacts'),
'id' => 'showarchived-tab', 'id' => 'showarchived-tab',
'accesskey' => 'y', 'accesskey' => 'y',
), ],
array( [
'label' => t('Hidden'), 'label' => t('Hidden'),
'url' => 'contacts/hidden', 'url' => 'contacts/hidden',
'sel' => ($hidden) ? 'active' : '', 'sel' => ($hidden) ? 'active' : '',
'title' => t('Only show hidden contacts'), 'title' => t('Only show hidden contacts'),
'id' => 'showhidden-tab', 'id' => 'showhidden-tab',
'accesskey' => 'h', 'accesskey' => 'h',
), ],
); ];
$tab_tpl = get_markup_template('common_tabs.tpl'); $tab_tpl = get_markup_template('common_tabs.tpl');
$t = replace_macros($tab_tpl, array('$tabs' => $tabs)); $t = replace_macros($tab_tpl, ['$tabs' => $tabs]);
$total = 0; $total = 0;
$searching = false; $searching = false;
@ -783,7 +783,7 @@ function contacts_content(App $a)
$sql_extra3 = Widget::unavailableNetworks(); $sql_extra3 = Widget::unavailableNetworks();
$contacts = array(); $contacts = [];
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT %d , %d ", $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `pending` = 0 $sql_extra $sql_extra2 $sql_extra3 ORDER BY `name` ASC LIMIT %d , %d ",
intval($_SESSION['uid']), intval($_SESSION['uid']),
@ -797,7 +797,7 @@ function contacts_content(App $a)
} }
$tpl = get_markup_template("contacts-template.tpl"); $tpl = get_markup_template("contacts-template.tpl");
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$header' => t('Contacts') . (($nets) ? ' - ' . ContactSelector::networkToName($nets) : ''), '$header' => t('Contacts') . (($nets) ? ' - ' . ContactSelector::networkToName($nets) : ''),
'$tabs' => $t, '$tabs' => $t,
@ -810,16 +810,16 @@ function contacts_content(App $a)
'$contacts' => $contacts, '$contacts' => $contacts,
'$contact_drop_confirm' => t('Do you really want to delete this contact?'), '$contact_drop_confirm' => t('Do you really want to delete this contact?'),
'multiselect' => 1, 'multiselect' => 1,
'$batch_actions' => array( '$batch_actions' => [
'contacts_batch_update' => t('Update'), 'contacts_batch_update' => t('Update'),
'contacts_batch_block' => t('Block') . "/" . t("Unblock"), 'contacts_batch_block' => t('Block') . "/" . t("Unblock"),
"contacts_batch_ignore" => t('Ignore') . "/" . t("Unignore"), "contacts_batch_ignore" => t('Ignore') . "/" . t("Unignore"),
"contacts_batch_archive" => t('Archive') . "/" . t("Unarchive"), "contacts_batch_archive" => t('Archive') . "/" . t("Unarchive"),
"contacts_batch_drop" => t('Delete'), "contacts_batch_drop" => t('Delete'),
), ],
'$h_batch_actions' => t('Batch Actions'), '$h_batch_actions' => t('Batch Actions'),
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ]);
return $o; return $o;
} }
@ -838,58 +838,58 @@ function contacts_content(App $a)
function contacts_tab($a, $contact_id, $active_tab) function contacts_tab($a, $contact_id, $active_tab)
{ {
// tabs // tabs
$tabs = array( $tabs = [
array( [
'label' => t('Status'), 'label' => t('Status'),
'url' => "contacts/" . $contact_id . "/posts", 'url' => "contacts/" . $contact_id . "/posts",
'sel' => (($active_tab == 1) ? 'active' : ''), 'sel' => (($active_tab == 1) ? 'active' : ''),
'title' => t('Status Messages and Posts'), 'title' => t('Status Messages and Posts'),
'id' => 'status-tab', 'id' => 'status-tab',
'accesskey' => 'm', 'accesskey' => 'm',
), ],
array( [
'label' => t('Profile'), 'label' => t('Profile'),
'url' => "contacts/" . $contact_id, 'url' => "contacts/" . $contact_id,
'sel' => (($active_tab == 2) ? 'active' : ''), 'sel' => (($active_tab == 2) ? 'active' : ''),
'title' => t('Profile Details'), 'title' => t('Profile Details'),
'id' => 'profile-tab', 'id' => 'profile-tab',
'accesskey' => 'o', 'accesskey' => 'o',
) ]
); ];
// Show this tab only if there is visible friend list // Show this tab only if there is visible friend list
$x = GContact::countAllFriends(local_user(), $contact_id); $x = GContact::countAllFriends(local_user(), $contact_id);
if ($x) { if ($x) {
$tabs[] = array('label' => t('Contacts'), $tabs[] = ['label' => t('Contacts'),
'url' => "allfriends/" . $contact_id, 'url' => "allfriends/" . $contact_id,
'sel' => (($active_tab == 3) ? 'active' : ''), 'sel' => (($active_tab == 3) ? 'active' : ''),
'title' => t('View all contacts'), 'title' => t('View all contacts'),
'id' => 'allfriends-tab', 'id' => 'allfriends-tab',
'accesskey' => 't'); 'accesskey' => 't'];
} }
// Show this tab only if there is visible common friend list // Show this tab only if there is visible common friend list
$common = GContact::countCommonFriends(local_user(), $contact_id); $common = GContact::countCommonFriends(local_user(), $contact_id);
if ($common) { if ($common) {
$tabs[] = array('label' => t('Common Friends'), $tabs[] = ['label' => t('Common Friends'),
'url' => "common/loc/" . local_user() . "/" . $contact_id, 'url' => "common/loc/" . local_user() . "/" . $contact_id,
'sel' => (($active_tab == 4) ? 'active' : ''), 'sel' => (($active_tab == 4) ? 'active' : ''),
'title' => t('View all common friends'), 'title' => t('View all common friends'),
'id' => 'common-loc-tab', 'id' => 'common-loc-tab',
'accesskey' => 'd' 'accesskey' => 'd'
); ];
} }
$tabs[] = array('label' => t('Advanced'), $tabs[] = ['label' => t('Advanced'),
'url' => 'crepair/' . $contact_id, 'url' => 'crepair/' . $contact_id,
'sel' => (($active_tab == 5) ? 'active' : ''), 'sel' => (($active_tab == 5) ? 'active' : ''),
'title' => t('Advanced Contact Settings'), 'title' => t('Advanced Contact Settings'),
'id' => 'advanced-tab', 'id' => 'advanced-tab',
'accesskey' => 'r' 'accesskey' => 'r'
); ];
$tab_tpl = get_markup_template('common_tabs.tpl'); $tab_tpl = get_markup_template('common_tabs.tpl');
$tab_str = replace_macros($tab_tpl, array('$tabs' => $tabs)); $tab_str = replace_macros($tab_tpl, ['$tabs' => $tabs]);
return $tab_str; return $tab_str;
} }
@ -936,7 +936,7 @@ function _contact_detail_for_template($rr)
$sparkle = ''; $sparkle = '';
} }
return array( return [
'img_hover' => t('Visit %s\'s profile [%s]', $rr['name'], $rr['url']), 'img_hover' => t('Visit %s\'s profile [%s]', $rr['name'], $rr['url']),
'edit_hover' => t('Edit contact'), 'edit_hover' => t('Edit contact'),
'photo_menu' => Contact::photoMenu($rr), 'photo_menu' => Contact::photoMenu($rr),
@ -951,7 +951,7 @@ function _contact_detail_for_template($rr)
'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']), 'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
'url' => $url, 'url' => $url,
'network' => ContactSelector::networkToName($rr['network'], $rr['url']), 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
); ];
} }
/** /**
@ -964,61 +964,61 @@ function _contact_detail_for_template($rr)
*/ */
function contact_actions($contact) function contact_actions($contact)
{ {
$poll_enabled = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL)); $poll_enabled = in_array($contact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_FEED, NETWORK_MAIL]);
$contact_actions = array(); $contact_actions = [];
// Provide friend suggestion only for Friendica contacts // Provide friend suggestion only for Friendica contacts
if ($contact['network'] === NETWORK_DFRN) { if ($contact['network'] === NETWORK_DFRN) {
$contact_actions['suggest'] = array( $contact_actions['suggest'] = [
'label' => t('Suggest friends'), 'label' => t('Suggest friends'),
'url' => 'fsuggest/' . $contact['id'], 'url' => 'fsuggest/' . $contact['id'],
'title' => '', 'title' => '',
'sel' => '', 'sel' => '',
'id' => 'suggest', 'id' => 'suggest',
); ];
} }
if ($poll_enabled) { if ($poll_enabled) {
$contact_actions['update'] = array( $contact_actions['update'] = [
'label' => t('Update now'), 'label' => t('Update now'),
'url' => 'contacts/' . $contact['id'] . '/update', 'url' => 'contacts/' . $contact['id'] . '/update',
'title' => '', 'title' => '',
'sel' => '', 'sel' => '',
'id' => 'update', 'id' => 'update',
); ];
} }
$contact_actions['block'] = array( $contact_actions['block'] = [
'label' => (intval($contact['blocked']) ? t('Unblock') : t('Block') ), 'label' => (intval($contact['blocked']) ? t('Unblock') : t('Block') ),
'url' => 'contacts/' . $contact['id'] . '/block', 'url' => 'contacts/' . $contact['id'] . '/block',
'title' => t('Toggle Blocked status'), 'title' => t('Toggle Blocked status'),
'sel' => (intval($contact['blocked']) ? 'active' : ''), 'sel' => (intval($contact['blocked']) ? 'active' : ''),
'id' => 'toggle-block', 'id' => 'toggle-block',
); ];
$contact_actions['ignore'] = array( $contact_actions['ignore'] = [
'label' => (intval($contact['readonly']) ? t('Unignore') : t('Ignore') ), 'label' => (intval($contact['readonly']) ? t('Unignore') : t('Ignore') ),
'url' => 'contacts/' . $contact['id'] . '/ignore', 'url' => 'contacts/' . $contact['id'] . '/ignore',
'title' => t('Toggle Ignored status'), 'title' => t('Toggle Ignored status'),
'sel' => (intval($contact['readonly']) ? 'active' : ''), 'sel' => (intval($contact['readonly']) ? 'active' : ''),
'id' => 'toggle-ignore', 'id' => 'toggle-ignore',
); ];
$contact_actions['archive'] = array( $contact_actions['archive'] = [
'label' => (intval($contact['archive']) ? t('Unarchive') : t('Archive') ), 'label' => (intval($contact['archive']) ? t('Unarchive') : t('Archive') ),
'url' => 'contacts/' . $contact['id'] . '/archive', 'url' => 'contacts/' . $contact['id'] . '/archive',
'title' => t('Toggle Archive status'), 'title' => t('Toggle Archive status'),
'sel' => (intval($contact['archive']) ? 'active' : ''), 'sel' => (intval($contact['archive']) ? 'active' : ''),
'id' => 'toggle-archive', 'id' => 'toggle-archive',
); ];
$contact_actions['delete'] = array( $contact_actions['delete'] = [
'label' => t('Delete'), 'label' => t('Delete'),
'url' => 'contacts/' . $contact['id'] . '/drop', 'url' => 'contacts/' . $contact['id'] . '/drop',
'title' => t('Delete contact'), 'title' => t('Delete contact'),
'sel' => '', 'sel' => '',
'id' => 'delete', 'id' => 'delete',
); ];
return $contact_actions; return $contact_actions;
} }

View file

@ -120,22 +120,22 @@ function crepair_content(App $a)
// Disable remote self for everything except feeds. // Disable remote self for everything except feeds.
// There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter // There is an issue when you repeat an item from maybe twitter and you got comments from friendica and twitter
// Problem is, you couldn't reply to both networks. // Problem is, you couldn't reply to both networks.
if (!in_array($contact['network'], array(NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA))) { if (!in_array($contact['network'], [NETWORK_FEED, NETWORK_DFRN, NETWORK_DIASPORA])) {
$allow_remote_self = false; $allow_remote_self = false;
} }
if ($contact['network'] == NETWORK_FEED) { if ($contact['network'] == NETWORK_FEED) {
$remote_self_options = array('0' => t('No mirroring'), '1' => t('Mirror as forwarded posting'), '2' => t('Mirror as my own posting')); $remote_self_options = ['0' => t('No mirroring'), '1' => t('Mirror as forwarded posting'), '2' => t('Mirror as my own posting')];
} else { } else {
$remote_self_options = array('0' => t('No mirroring'), '2' => t('Mirror as my own posting')); $remote_self_options = ['0' => t('No mirroring'), '2' => t('Mirror as my own posting')];
} }
$update_profile = in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)); $update_profile = in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]);
$tab_str = contacts_tab($a, $contact['id'], 5); $tab_str = contacts_tab($a, $contact['id'], 5);
$tpl = get_markup_template('crepair.tpl'); $tpl = get_markup_template('crepair.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$tab_str' => $tab_str, '$tab_str' => $tab_str,
'$warning' => $warning, '$warning' => $warning,
'$info' => $info, '$info' => $info,
@ -147,23 +147,23 @@ function crepair_content(App $a)
'$lbl_submit' => t('Submit'), '$lbl_submit' => t('Submit'),
'$label_remote_self' => t('Remote Self'), '$label_remote_self' => t('Remote Self'),
'$allow_remote_self' => $allow_remote_self, '$allow_remote_self' => $allow_remote_self,
'$remote_self' => array('remote_self', '$remote_self' => ['remote_self',
t('Mirror postings from this contact'), t('Mirror postings from this contact'),
$contact['remote_self'], $contact['remote_self'],
t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'), t('Mark this contact as remote_self, this will cause friendica to repost new entries from this contact.'),
$remote_self_options $remote_self_options
), ],
'$name' => array('name', t('Name') , htmlentities($contact['name'])), '$name' => ['name', t('Name') , htmlentities($contact['name'])],
'$nick' => array('nick', t('Account Nickname'), htmlentities($contact['nick'])), '$nick' => ['nick', t('Account Nickname'), htmlentities($contact['nick'])],
'$attag' => array('attag', t('@Tagname - overrides Name/Nickname'), $contact['attag']), '$attag' => ['attag', t('@Tagname - overrides Name/Nickname'), $contact['attag']],
'$url' => array('url', t('Account URL'), $contact['url']), '$url' => ['url', t('Account URL'), $contact['url']],
'$request' => array('request', t('Friend Request URL'), $contact['request']), '$request' => ['request', t('Friend Request URL'), $contact['request']],
'confirm' => array('confirm', t('Friend Confirm URL'), $contact['confirm']), 'confirm' => ['confirm', t('Friend Confirm URL'), $contact['confirm']],
'notify' => array('notify', t('Notification Endpoint URL'), $contact['notify']), 'notify' => ['notify', t('Notification Endpoint URL'), $contact['notify']],
'poll' => array('poll', t('Poll/Feed URL'), $contact['poll']), 'poll' => ['poll', t('Poll/Feed URL'), $contact['poll']],
'photo' => array('photo', t('New photo from this URL'), ''), 'photo' => ['photo', t('New photo from this URL'), ''],
)); ]);
return $o; return $o;
} }

View file

@ -107,10 +107,10 @@ function dfrn_poll_init(App $a)
if ((int) $xml->status === 1) { if ((int) $xml->status === 1) {
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
if (!x($_SESSION, 'remote')) { if (!x($_SESSION, 'remote')) {
$_SESSION['remote'] = array(); $_SESSION['remote'] = [];
} }
$_SESSION['remote'][] = array('cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']); $_SESSION['remote'][] = ['cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']];
$_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_id'] = $r[0]['id'];
$_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_home'] = $r[0]['url'];
@ -488,13 +488,13 @@ function dfrn_poll_content(App $a)
. '&sec=' . $sec . '&sec=' . $sec
); );
} else { } else {
$s = post_url($r[0]['poll'], array( $s = post_url($r[0]['poll'], [
'dfrn_id' => $encrypted_id, 'dfrn_id' => $encrypted_id,
'type' => 'profile-check', 'type' => 'profile-check',
'dfrn_version' => DFRN_PROTOCOL_VERSION, 'dfrn_version' => DFRN_PROTOCOL_VERSION,
'challenge' => $challenge, 'challenge' => $challenge,
'sec' => $sec 'sec' => $sec
)); ]);
} }
$profile = ((DBM::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); $profile = ((DBM::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname);
@ -529,10 +529,10 @@ function dfrn_poll_content(App $a)
if (((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) { if (((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
if (!x($_SESSION, 'remote')) { if (!x($_SESSION, 'remote')) {
$_SESSION['remote'] = array(); $_SESSION['remote'] = [];
} }
$_SESSION['remote'][] = array('cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']); $_SESSION['remote'][] = ['cid' => $r[0]['id'], 'uid' => $r[0]['uid'], 'url' => $r[0]['url']];
$_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_id'] = $r[0]['id'];
$_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_home'] = $r[0]['url'];
$_SESSION['visitor_visiting'] = $r[0]['uid']; $_SESSION['visitor_visiting'] = $r[0]['uid'];

View file

@ -316,7 +316,7 @@ function dfrn_request_post(App $a)
return; return;
} else { } else {
$contact_record = $ret[0]; $contact_record = $ret[0];
$parms = array('dfrn-request' => $ret[0]['request']); $parms = ['dfrn-request' => $ret[0]['request']];
} }
} }
@ -517,7 +517,7 @@ function dfrn_request_content(App $a)
} }
$tpl = get_markup_template("dfrn_req_confirm.tpl"); $tpl = get_markup_template("dfrn_req_confirm.tpl");
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$dfrn_url' => $dfrn_url, '$dfrn_url' => $dfrn_url,
'$aes_allow' => (($aes_allow) ? '<input type="hidden" name="aes_allow" value="1" />' : "" ), '$aes_allow' => (($aes_allow) ? '<input type="hidden" name="aes_allow" value="1" />' : "" ),
'$hidethem' => t('Hide this contact'), '$hidethem' => t('Hide this contact'),
@ -529,7 +529,7 @@ function dfrn_request_content(App $a)
'$uid' => $_SESSION['uid'], '$uid' => $_SESSION['uid'],
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
'dfrn_rawurl' => $_GET['dfrn_url'] 'dfrn_rawurl' => $_GET['dfrn_url']
)); ]);
return $o; return $o;
} elseif ((x($_GET, 'confirm_key')) && strlen($_GET['confirm_key'])) { } elseif ((x($_GET, 'confirm_key')) && strlen($_GET['confirm_key'])) {
// we are the requestee and it is now safe to send our user their introduction, // we are the requestee and it is now safe to send our user their introduction,
@ -553,7 +553,7 @@ function dfrn_request_content(App $a)
} }
if (!$auto_confirm) { if (!$auto_confirm) {
notification(array( notification([
'type' => NOTIFY_INTRO, 'type' => NOTIFY_INTRO,
'notify_flags' => $r[0]['notify-flags'], 'notify_flags' => $r[0]['notify-flags'],
'language' => $r[0]['language'], 'language' => $r[0]['language'],
@ -566,19 +566,19 @@ function dfrn_request_content(App $a)
'source_photo' => $r[0]['photo'], 'source_photo' => $r[0]['photo'],
'verb' => ACTIVITY_REQ_FRIEND, 'verb' => ACTIVITY_REQ_FRIEND,
'otype' => 'intro' 'otype' => 'intro'
)); ]);
} }
if ($auto_confirm) { if ($auto_confirm) {
require_once 'mod/dfrn_confirm.php'; require_once 'mod/dfrn_confirm.php';
$handsfree = array( $handsfree = [
'uid' => $r[0]['uid'], 'uid' => $r[0]['uid'],
'node' => $r[0]['nickname'], 'node' => $r[0]['nickname'],
'dfrn_id' => $r[0]['issued-id'], 'dfrn_id' => $r[0]['issued-id'],
'intro_id' => $intro[0]['id'], 'intro_id' => $intro[0]['id'],
'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0), 'duplex' => (($r[0]['page-flags'] == PAGE_FREELOVE) ? 1 : 0),
'activity' => intval(PConfig::get($r[0]['uid'], 'system', 'post_newfriend')) 'activity' => intval(PConfig::get($r[0]['uid'], 'system', 'post_newfriend'))
); ];
dfrn_confirm_post($a, $handsfree); dfrn_confirm_post($a, $handsfree);
} }
} }
@ -642,11 +642,11 @@ function dfrn_request_content(App $a)
get_server() get_server()
); );
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$header' => t('Friend/Connection Request'), '$header' => t('Friend/Connection Request'),
'$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@gnusocial.de'), '$desc' => t('Examples: jojo@demo.friendica.com, http://demo.friendica.com/profile/jojo, testuser@gnusocial.de'),
'$pls_answer' => t('Please answer the following:'), '$pls_answer' => t('Please answer the following:'),
'$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'), $a->profile['name']), false, '', array(t('No'), t('Yes'))), '$does_know_you' => ['knowyou', sprintf(t('Does %s know you?'), $a->profile['name']), false, '', [t('No'), t('Yes')]],
'$add_note' => t('Add a personal note:'), '$add_note' => t('Add a personal note:'),
'$page_desc' => $page_desc, '$page_desc' => $page_desc,
'$friendica' => t('Friendica'), '$friendica' => t('Friendica'),
@ -660,7 +660,7 @@ function dfrn_request_content(App $a)
'$nickname' => $a->argv[1], '$nickname' => $a->argv[1],
'$name' => $a->profile['name'], '$name' => $a->profile['name'],
'$myaddr' => $myaddr '$myaddr' => $myaddr
)); ]);
return $o; return $o;
} }

View file

@ -146,11 +146,11 @@ function directory_content(App $a) {
$location_e = $location; $location_e = $location;
$photo_menu = array( $photo_menu = [
'profile' => array(t("View Profile"), Profile::zrl($profile_link)) 'profile' => [t("View Profile"), Profile::zrl($profile_link)]
); ];
$entry = array( $entry = [
'id' => $rr['id'], 'id' => $rr['id'],
'url' => $profile_link, 'url' => $profile_link,
'itemurl' => $itemurl, 'itemurl' => $itemurl,
@ -169,9 +169,9 @@ function directory_content(App $a) {
'about' => $about, 'about' => $about,
'photo_menu' => $photo_menu, 'photo_menu' => $photo_menu,
); ];
$arr = array('contact' => $rr, 'entry' => $entry); $arr = ['contact' => $rr, 'entry' => $entry];
call_hooks('directory_item', $arr); call_hooks('directory_item', $arr);
@ -187,7 +187,7 @@ function directory_content(App $a) {
$tpl = get_markup_template('directory_header.tpl'); $tpl = get_markup_template('directory_header.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$search' => $search, '$search' => $search,
'$globaldir' => t('Global Directory'), '$globaldir' => t('Global Directory'),
'$gdirpath' => $gdirpath, '$gdirpath' => $gdirpath,
@ -198,7 +198,7 @@ function directory_content(App $a) {
'$title' => t('Site Directory'), '$title' => t('Site Directory'),
'$submit' => t('Find'), '$submit' => t('Find'),
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ]);
} }
else else

View file

@ -47,7 +47,7 @@ function dirfind_content(App $a, $prefix = "") {
if ((valid_email($search) && validate_email($search)) || if ((valid_email($search) && validate_email($search)) ||
(substr(normalise_link($search), 0, 7) == "http://")) { (substr(normalise_link($search), 0, 7) == "http://")) {
$user_data = Probe::uri($search); $user_data = Probe::uri($search);
$discover_user = (in_array($user_data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))); $discover_user = (in_array($user_data["network"], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA]));
} }
} }
@ -209,20 +209,20 @@ function dirfind_content(App $a, $prefix = "") {
$details = _contact_detail_for_template($contact[0]); $details = _contact_detail_for_template($contact[0]);
$alt_text = $details['alt_text']; $alt_text = $details['alt_text'];
} else { } else {
$photo_menu = array(); $photo_menu = [];
} }
} else { } else {
$connlnk = System::baseUrl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url); $connlnk = System::baseUrl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
$conntxt = t('Connect'); $conntxt = t('Connect');
$photo_menu = array( $photo_menu = [
'profile' => array(t("View Profile"), Profile::zrl($jj->url)), 'profile' => [t("View Profile"), Profile::zrl($jj->url)],
'follow' => array(t("Connect/Follow"), $connlnk) 'follow' => [t("Connect/Follow"), $connlnk]
); ];
} }
$jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo); $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
$entry = array( $entry = [
'alt_text' => $alt_text, 'alt_text' => $alt_text,
'url' => Profile::zrl($jj->url), 'url' => Profile::zrl($jj->url),
'itemurl' => $itemurl, 'itemurl' => $itemurl,
@ -238,17 +238,17 @@ function dirfind_content(App $a, $prefix = "") {
'account_type' => Contact::getAccountType($contact_details), 'account_type' => Contact::getAccountType($contact_details),
'network' => ContactSelector::networkToName($jj->network, $jj->url), 'network' => ContactSelector::networkToName($jj->network, $jj->url),
'id' => ++$id, 'id' => ++$id,
); ];
$entries[] = $entry; $entries[] = $entry;
} }
$tpl = get_markup_template('viewcontact_template.tpl'); $tpl = get_markup_template('viewcontact_template.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'title' => $header, 'title' => $header,
'$contacts' => $entries, '$contacts' => $entries,
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ]);
} else { } else {
info( t('No matches') . EOL); info( t('No matches') . EOL);

View file

@ -18,7 +18,7 @@ function display_init(App $a)
} }
$nick = (($a->argc > 1) ? $a->argv[1] : ''); $nick = (($a->argc > 1) ? $a->argv[1] : '');
$profiledata = array(); $profiledata = [];
if ($a->argc == 3) { if ($a->argc == 3) {
if (substr($a->argv[2], -5) == '.atom') { if (substr($a->argv[2], -5) == '.atom') {
@ -102,7 +102,7 @@ function display_init(App $a)
} }
$profiledata["network"] = NETWORK_DFRN; $profiledata["network"] = NETWORK_DFRN;
} else { } else {
$profiledata = array(); $profiledata = [];
} }
} }
} }
@ -111,7 +111,7 @@ function display_init(App $a)
} }
function display_fetchauthor($a, $item) { function display_fetchauthor($a, $item) {
$profiledata = array(); $profiledata = [];
$profiledata["uid"] = -1; $profiledata["uid"] = -1;
$profiledata["nickname"] = $item["author-name"]; $profiledata["nickname"] = $item["author-name"];
$profiledata["name"] = $item["author-name"]; $profiledata["name"] = $item["author-name"];
@ -181,7 +181,7 @@ function display_fetchauthor($a, $item) {
$profiledata["photo"] = System::removedBaseUrl($profiledata["photo"]); $profiledata["photo"] = System::removedBaseUrl($profiledata["photo"]);
if (local_user()) { if (local_user()) {
if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { if (in_array($profiledata["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
$profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]); $profiledata["remoteconnect"] = System::baseUrl()."/follow?url=".urlencode($profiledata["url"]);
} }
} elseif ($profiledata["network"] == NETWORK_DFRN) { } elseif ($profiledata["network"] == NETWORK_DFRN) {
@ -207,7 +207,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
if ($update) { if ($update) {
$item_id = $_REQUEST['item_id']; $item_id = $_REQUEST['item_id'];
$item = dba::selectFirst('item', ['uid', 'parent'], ['id' => $item_id]); $item = dba::selectFirst('item', ['uid', 'parent'], ['id' => $item_id]);
$a->profile = array('uid' => intval($item['uid']), 'profile_uid' => intval($item['uid'])); $a->profile = ['uid' => intval($item['uid']), 'profile_uid' => intval($item['uid'])];
$item_parent = $item['parent']; $item_parent = $item['parent'];
} else { } else {
$item_id = (($a->argc > 2) ? $a->argv[2] : 0); $item_id = (($a->argc > 2) ? $a->argv[2] : 0);
@ -245,7 +245,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
} }
// We are displaying an "alternate" link if that post was public. See issue 2864 // We are displaying an "alternate" link if that post was public. See issue 2864
$is_public = dba::exists('item', array('id' => $item_id, 'private' => false)); $is_public = dba::exists('item', ['id' => $item_id, 'private' => false]);
if ($is_public) { if ($is_public) {
// For the atom feed the nickname doesn't matter at all, we only need the item id. // For the atom feed the nickname doesn't matter at all, we only need the item id.
$alternate = System::baseUrl().'/display/feed-item/'.$item_id.'.atom'; $alternate = System::baseUrl().'/display/feed-item/'.$item_id.'.atom';
@ -256,10 +256,10 @@ function display_content(App $a, $update = false, $update_uid = 0) {
} }
$a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'), $a->page['htmlhead'] .= replace_macros(get_markup_template('display-head.tpl'),
array('$alternate' => $alternate, ['$alternate' => $alternate,
'$conversation' => $conversation)); '$conversation' => $conversation]);
$groups = array(); $groups = [];
$contact = null; $contact = null;
$remote_contact = false; $remote_contact = false;
@ -307,7 +307,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
// We need the editor here to be able to reshare an item. // We need the editor here to be able to reshare an item.
if ($is_owner) { if ($is_owner) {
$x = array( $x = [
'is_owner' => true, 'is_owner' => true,
'allow_location' => $a->user['allow_location'], 'allow_location' => $a->user['allow_location'],
'default_location' => $a->user['default-location'], 'default_location' => $a->user['default-location'],
@ -317,7 +317,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
'bang' => '', 'bang' => '',
'visitor' => 'block', 'visitor' => 'block',
'profile_uid' => local_user(), 'profile_uid' => local_user(),
); ];
$o .= status_editor($a, $x, 0, true); $o .= status_editor($a, $x, 0, true);
} }
@ -351,7 +351,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
if (local_user() && (local_user() == $a->profile['uid'])) { if (local_user() && (local_user() == $a->profile['uid'])) {
$unseen = dba::selectFirst('item', ['id'], ['parent' => $s[0]['parent'], 'unseen' => true]); $unseen = dba::selectFirst('item', ['id'], ['parent' => $s[0]['parent'], 'unseen' => true]);
if (DBM::is_result($unseen)) { if (DBM::is_result($unseen)) {
dba::update('item', array('unseen' => false), array('parent' => $s[0]['parent'], 'unseen' => true)); dba::update('item', ['unseen' => false], ['parent' => $s[0]['parent'], 'unseen' => true]);
} }
} }

View file

@ -36,25 +36,25 @@ function editpost_content(App $a) {
return; return;
} }
$o .= replace_macros(get_markup_template("section_title.tpl"),array( $o .= replace_macros(get_markup_template("section_title.tpl"),[
'$title' => t('Edit post') '$title' => t('Edit post')
)); ]);
$tpl = get_markup_template('jot-header.tpl'); $tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'), '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag, '$geotag' => $geotag,
'$nickname' => $a->user['nickname'] '$nickname' => $a->user['nickname']
)); ]);
$tpl = get_markup_template('jot-end.tpl'); $tpl = get_markup_template('jot-end.tpl');
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'), '$ispublic' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
'$geotag' => $geotag, '$geotag' => $geotag,
'$nickname' => $a->user['nickname'] '$nickname' => $a->user['nickname']
)); ]);
$tpl = get_markup_template("jot.tpl"); $tpl = get_markup_template("jot.tpl");
@ -100,7 +100,7 @@ function editpost_content(App $a) {
//$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$is_edit' => true, '$is_edit' => true,
'$return_path' => $_SESSION['return_url'], '$return_path' => $_SESSION['return_url'],
'$action' => 'item', '$action' => 'item',
@ -150,7 +150,7 @@ function editpost_content(App $a) {
'$message' => t('Message'), '$message' => t('Message'),
'$browser' => t('Browser'), '$browser' => t('Browser'),
'$shortpermset' => t('permissions'), '$shortpermset' => t('permissions'),
)); ]);
return $o; return $o;

View file

@ -150,7 +150,7 @@ function events_post(App $a) {
} }
$datarray = array(); $datarray = [];
$datarray['guid'] = get_guid(32); $datarray['guid'] = get_guid(32);
$datarray['start'] = $start; $datarray['start'] = $start;
$datarray['finish'] = $finish; $datarray['finish'] = $finish;
@ -221,17 +221,17 @@ function events_content(App $a) {
$i18n = get_event_strings(); $i18n = get_event_strings();
$htpl = get_markup_template('event_head.tpl'); $htpl = get_markup_template('event_head.tpl');
$a->page['htmlhead'] .= replace_macros($htpl, array( $a->page['htmlhead'] .= replace_macros($htpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$module_url' => '/events', '$module_url' => '/events',
'$modparams' => 1, '$modparams' => 1,
'$i18n' => $i18n, '$i18n' => $i18n,
)); ]);
$etpl = get_markup_template('event_end.tpl'); $etpl = get_markup_template('event_end.tpl');
$a->page['end'] .= replace_macros($etpl, array( $a->page['end'] .= replace_macros($etpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
)); ]);
$o = ''; $o = '';
$tabs = ''; $tabs = '';
@ -326,14 +326,14 @@ function events_content(App $a) {
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
// put the event parametes in an array so we can better transmit them // put the event parametes in an array so we can better transmit them
$event_params = array( $event_params = [
'event_id' => (x($_GET, 'id') ? $_GET['id'] : 0), 'event_id' => (x($_GET, 'id') ? $_GET['id'] : 0),
'start' => $start, 'start' => $start,
'finish' => $finish, 'finish' => $finish,
'adjust_start' => $adjust_start, 'adjust_start' => $adjust_start,
'adjust_finish' => $adjust_finish, 'adjust_finish' => $adjust_finish,
'ignored' => $ignored, 'ignored' => $ignored,
); ];
// get events by id or by date // get events by id or by date
if (x($_GET, 'id')) { if (x($_GET, 'id')) {
@ -342,7 +342,7 @@ function events_content(App $a) {
$r = events_by_date(local_user(), $event_params); $r = events_by_date(local_user(), $event_params);
} }
$links = array(); $links = [];
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$r = sort_by_date($r); $r = sort_by_date($r);
@ -354,7 +354,7 @@ function events_content(App $a) {
} }
} }
$events = array(); $events = [];
// transform the event in a usable array // transform the event in a usable array
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
@ -375,7 +375,7 @@ function events_content(App $a) {
// Get rid of dashes in key names, Smarty3 can't handle them // Get rid of dashes in key names, Smarty3 can't handle them
foreach ($events as $key => $event) { foreach ($events as $key => $event) {
$event_item = array(); $event_item = [];
foreach ($event['item'] as $k => $v) { foreach ($event['item'] as $k => $v) {
$k = str_replace('-' ,'_', $k); $k = str_replace('-' ,'_', $k);
$event_item[$k] = $v; $event_item[$k] = $v;
@ -383,14 +383,14 @@ function events_content(App $a) {
$events[$key]['item'] = $event_item; $events[$key]['item'] = $event_item;
} }
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$tabs' => $tabs, '$tabs' => $tabs,
'$title' => t('Events'), '$title' => t('Events'),
'$view' => t('View'), '$view' => t('View'),
'$new_event' => array(System::baseUrl() . '/events/new', t('Create New Event'), '', ''), '$new_event' => [System::baseUrl() . '/events/new', t('Create New Event'), '', ''],
'$previous' => array(System::baseUrl() . '/events/$prevyear/$prevmonth', t('Previous'), '', ''), '$previous' => [System::baseUrl() . '/events/$prevyear/$prevmonth', t('Previous'), '', ''],
'$next' => array(System::baseUrl() . '/events/$nextyear/$nextmonth', t('Next'), '', ''), '$next' => [System::baseUrl() . '/events/$nextyear/$nextmonth', t('Next'), '', ''],
'$calendar' => cal($y, $m, $links, ' eventcal'), '$calendar' => cal($y, $m, $links, ' eventcal'),
'$events' => $events, '$events' => $events,
@ -400,7 +400,7 @@ function events_content(App $a) {
'$week' => t('week'), '$week' => t('week'),
'$day' => t('day'), '$day' => t('day'),
'$list' => t('list'), '$list' => t('list'),
)); ]);
if (x($_GET, 'id')) { if (x($_GET, 'id')) {
echo $o; echo $o;
@ -421,8 +421,8 @@ function events_content(App $a) {
} }
// Passed parameters overrides anything found in the DB // Passed parameters overrides anything found in the DB
if (in_array($mode, array('edit', 'new', 'copy'))) { if (in_array($mode, ['edit', 'new', 'copy'])) {
if (!x($orig_event)) {$orig_event = array();} if (!x($orig_event)) {$orig_event = [];}
// In case of an error the browser is redirected back here, with these parameters filled in with the previous values // In case of an error the browser is redirected back here, with these parameters filled in with the previous values
if (x($_REQUEST, 'nofinish')) {$orig_event['nofinish'] = $_REQUEST['nofinish'];} if (x($_REQUEST, 'nofinish')) {$orig_event['nofinish'] = $_REQUEST['nofinish'];}
if (x($_REQUEST, 'adjust')) {$orig_event['adjust'] = $_REQUEST['adjust'];} if (x($_REQUEST, 'adjust')) {$orig_event['adjust'] = $_REQUEST['adjust'];}
@ -492,7 +492,7 @@ function events_content(App $a) {
$tpl = get_markup_template('event_form.tpl'); $tpl = get_markup_template('event_form.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$post' => System::baseUrl() . '/events', '$post' => System::baseUrl() . '/events',
'$eid' => $eid, '$eid' => $eid,
'$cid' => $cid, '$cid' => $cid,
@ -519,12 +519,12 @@ function events_content(App $a) {
'$l_orig' => $l_orig, '$l_orig' => $l_orig,
'$t_text' => t('Title:') . ' <span class="required" title="' . t('Required') . '">*</span>', '$t_text' => t('Title:') . ' <span class="required" title="' . t('Required') . '">*</span>',
'$t_orig' => $t_orig, '$t_orig' => $t_orig,
'$summary' => array('summary', t('Title:'), $t_orig, '', '*'), '$summary' => ['summary', t('Title:'), $t_orig, '', '*'],
'$sh_text' => t('Share this event'), '$sh_text' => t('Share this event'),
'$share' => array('share', t('Share this event'), $sh_checked, '', $sh_disabled), '$share' => ['share', t('Share this event'), $sh_checked, '', $sh_disabled],
'$sh_checked' => $sh_checked, '$sh_checked' => $sh_checked,
'$nofinish' => array('nofinish', t('Finish date/time is not known or not relevant'), $n_checked), '$nofinish' => ['nofinish', t('Finish date/time is not known or not relevant'), $n_checked],
'$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked), '$adjust' => ['adjust', t('Adjust for viewer timezone'), $a_checked],
'$preview' => t('Preview'), '$preview' => t('Preview'),
'$acl' => $acl, '$acl' => $acl,
'$submit' => t('Submit'), '$submit' => t('Submit'),
@ -532,7 +532,7 @@ function events_content(App $a) {
'$advanced' => t('Advanced'), '$advanced' => t('Advanced'),
'$permissions' => t('Permissions'), '$permissions' => t('Permissions'),
)); ]);
return $o; return $o;
} }
@ -541,7 +541,7 @@ function events_content(App $a) {
if ($mode === 'drop' && $event_id) { if ($mode === 'drop' && $event_id) {
$del = 0; $del = 0;
$params = array('event_id' => ($event_id)); $params = ['event_id' => ($event_id)];
$ev = event_by_id(local_user(), $params); $ev = event_by_id(local_user(), $params);
// Delete only real events (no birthdays) // Delete only real events (no birthdays)

View file

@ -30,7 +30,7 @@ function fbrowser_content(App $a) {
switch ($a->argv[1]) { switch ($a->argv[1]) {
case "image": case "image":
$path = array(array("", t("Photos"))); $path = [["", t("Photos")]];
$albums = false; $albums = false;
$sql_extra = ""; $sql_extra = "";
$sql_extra2 = " ORDER BY created DESC LIMIT 0, 10"; $sql_extra2 = " ORDER BY created DESC LIMIT 0, 10";
@ -42,7 +42,7 @@ function fbrowser_content(App $a) {
dbesc( t('Contact Photos')) dbesc( t('Contact Photos'))
); );
function _map_folder1($el){return array(bin2hex($el['album']),$el['album']);}; function _map_folder1($el){return [bin2hex($el['album']),$el['album']];};
$albums = array_map( "_map_folder1" , $albums); $albums = array_map( "_map_folder1" , $albums);
} }
@ -52,7 +52,7 @@ function fbrowser_content(App $a) {
$album = hex2bin($a->argv[2]); $album = hex2bin($a->argv[2]);
$sql_extra = sprintf("AND `album` = '%s' ",dbesc($album)); $sql_extra = sprintf("AND `album` = '%s' ",dbesc($album));
$sql_extra2 = ""; $sql_extra2 = "";
$path[]=array($a->argv[2], $album); $path[]=[$a->argv[2], $album];
} }
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`, $r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`type`) AS `type`,
@ -78,17 +78,17 @@ function fbrowser_content(App $a) {
else else
$scale = $rr['loq']; $scale = $rr['loq'];
return array( return [
System::baseUrl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'], System::baseUrl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
$filename_e, $filename_e,
System::baseUrl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext System::baseUrl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
); ];
} }
$files = array_map("_map_files1", $r); $files = array_map("_map_files1", $r);
$tpl = get_markup_template($template_file); $tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$type' => 'image', '$type' => 'image',
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$path' => $path, '$path' => $path,
@ -96,7 +96,7 @@ function fbrowser_content(App $a) {
'$files' => $files, '$files' => $files,
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
)); ]);
break; break;
@ -112,21 +112,21 @@ function fbrowser_content(App $a) {
$filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip"); $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
$filename_e = $rr['filename']; $filename_e = $rr['filename'];
return array(System::baseUrl() . '/attach/' . $rr['id'], $filename_e, System::baseUrl() . '/images/icons/16/' . $filetype . '.png'); return [System::baseUrl() . '/attach/' . $rr['id'], $filename_e, System::baseUrl() . '/images/icons/16/' . $filetype . '.png'];
} }
$files = array_map("_map_files2", $files); $files = array_map("_map_files2", $files);
$tpl = get_markup_template($template_file); $tpl = get_markup_template($template_file);
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$type' => 'file', '$type' => 'file',
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$path' => array( array( "", t("Files")) ), '$path' => [ [ "", t("Files")] ],
'$folders' => false, '$folders' => false,
'$files' =>$files, '$files' =>$files,
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
)); ]);
} }

View file

@ -11,7 +11,7 @@ use Friendica\Util\XML;
function fetch_init(App $a) function fetch_init(App $a)
{ {
if (($a->argc != 3) || (!in_array($a->argv[1], array("post", "status_message", "reshare")))) { if (($a->argc != 3) || (!in_array($a->argv[1], ["post", "status_message", "reshare"]))) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found')); header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
killme(); killme();
} }

View file

@ -28,10 +28,10 @@ function filer_content(App $a) {
$filetags = explode(",", $filetags); $filetags = explode(",", $filetags);
$tpl = get_markup_template("filer_dialog.tpl"); $tpl = get_markup_template("filer_dialog.tpl");
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$field' => array('term', t("Save to Folder:"), '', '', $filetags, t('- select -')), '$field' => ['term', t("Save to Folder:"), '', '', $filetags, t('- select -')],
'$submit' => t('Save'), '$submit' => t('Save'),
)); ]);
echo $o; echo $o;
} }

View file

@ -131,7 +131,7 @@ function follow_content(App $a) {
normalise_link($ret["url"])); normalise_link($ret["url"]));
if (!$r) { if (!$r) {
$r = array(array("location" => "", "about" => "", "keywords" => "")); $r = [["location" => "", "about" => "", "keywords" => ""]];
} else { } else {
$gcontact_id = $r[0]["id"]; $gcontact_id = $r[0]["id"];
} }
@ -143,12 +143,12 @@ function follow_content(App $a) {
$header = t("Connect/Follow"); $header = t("Connect/Follow");
$o = replace_macros($tpl,array( $o = replace_macros($tpl,[
'$header' => htmlentities($header), '$header' => htmlentities($header),
//'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL), //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
'$desc' => "", '$desc' => "",
'$pls_answer' => t('Please answer the following:'), '$pls_answer' => t('Please answer the following:'),
'$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'), t('Yes'))), '$does_know_you' => ['knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', [t('No'), t('Yes')]],
'$add_note' => t('Add a personal note:'), '$add_note' => t('Add a personal note:'),
'$page_desc' => "", '$page_desc' => "",
'$friendica' => "", '$friendica' => "",
@ -173,7 +173,7 @@ function follow_content(App $a) {
'$about_label' => t("About:"), */ '$about_label' => t("About:"), */
'$keywords' => $r[0]["keywords"], '$keywords' => $r[0]["keywords"],
'$keywords_label' => t("Tags:") '$keywords_label' => t("Tags:")
)); ]);
$a->page['aside'] = ""; $a->page['aside'] = "";
@ -181,8 +181,8 @@ function follow_content(App $a) {
if ($gcontact_id <> 0) { if ($gcontact_id <> 0) {
$o .= replace_macros(get_markup_template('section_title.tpl'), $o .= replace_macros(get_markup_template('section_title.tpl'),
array('$title' => t('Status Messages and Posts') ['$title' => t('Status Messages and Posts')
)); ]);
// Show last public posts // Show last public posts
$o .= Contact::getPostsFromUrl($ret["url"]); $o .= Contact::getPostsFromUrl($ret["url"]);

View file

@ -7,7 +7,7 @@ use Friendica\Database\DBM;
function friendica_init(App $a) { function friendica_init(App $a) {
if ($a->argv[1] == "json"){ if ($a->argv[1] == "json"){
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'); $register_policy = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
$sql_extra = ''; $sql_extra = '';
if (x($a->config,'admin_nickname')) { if (x($a->config,'admin_nickname')) {
@ -17,15 +17,15 @@ function friendica_init(App $a) {
$adminlist = explode(",", str_replace(" ", "", $a->config['admin_email'])); $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
$r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", dbesc($adminlist[0])); $r = q("SELECT `username`, `nickname` FROM `user` WHERE `email` = '%s' $sql_extra", dbesc($adminlist[0]));
$admin = array( $admin = [
'name' => $r[0]['username'], 'name' => $r[0]['username'],
'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'], 'profile'=> System::baseUrl() . '/profile/' . $r[0]['nickname'],
); ];
} else { } else {
$admin = false; $admin = false;
} }
$visible_plugins = array(); $visible_plugins = [];
if (is_array($a->plugins) && count($a->plugins)) { if (is_array($a->plugins) && count($a->plugins)) {
$r = q("SELECT * FROM `addon` WHERE `hidden` = 0"); $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
@ -36,7 +36,7 @@ function friendica_init(App $a) {
} }
Config::load('feature_lock'); Config::load('feature_lock');
$locked_features = array(); $locked_features = [];
if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) { if (is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
foreach ($a->config['feature_lock'] as $k => $v) { foreach ($a->config['feature_lock'] as $k => $v) {
if ($k === 'config_loaded') { if ($k === 'config_loaded') {
@ -47,7 +47,7 @@ function friendica_init(App $a) {
} }
} }
$data = Array( $data = [
'version' => FRIENDICA_VERSION, 'version' => FRIENDICA_VERSION,
'url' => System::baseUrl(), 'url' => System::baseUrl(),
'plugins' => $visible_plugins, 'plugins' => $visible_plugins,
@ -58,7 +58,7 @@ function friendica_init(App $a) {
'platform' => FRIENDICA_PLATFORM, 'platform' => FRIENDICA_PLATFORM,
'info' => ((x($a->config,'info')) ? $a->config['info'] : ''), 'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
'no_scrape_url' => System::baseUrl().'/noscrape' 'no_scrape_url' => System::baseUrl().'/noscrape'
); ];
echo json_encode($data); echo json_encode($data);
killme(); killme();
@ -83,7 +83,7 @@ function friendica_content(App $a) {
$o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com'); $o .= t('Suggestions, praise, donations, etc. - please email "Info" at Friendica - dot com');
$o .= '</p>' . PHP_EOL; $o .= '</p>' . PHP_EOL;
$visible_plugins = array(); $visible_plugins = [];
if (is_array($a->plugins) && count($a->plugins)) { if (is_array($a->plugins) && count($a->plugins)) {
$r = q("SELECT * FROM `addon` WHERE `hidden` = 0"); $r = q("SELECT * FROM `addon` WHERE `hidden` = 0");
if (DBM::is_result($r)) { if (DBM::is_result($r)) {

View file

@ -111,7 +111,7 @@ function fsuggest_content(App $a)
$o .= contact_selector( $o .= contact_selector(
'suggest', 'suggest',
'suggest-select', 'suggest-select',
array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true), ['size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true],
false false
); );

View file

@ -92,17 +92,17 @@ function group_content(App $a) {
$tpl = get_markup_template('group_edit.tpl'); $tpl = get_markup_template('group_edit.tpl');
$context = array( $context = [
'$submit' => t('Save Group'), '$submit' => t('Save Group'),
); ];
if (($a->argc == 2) && ($a->argv[1] === 'new')) { if (($a->argc == 2) && ($a->argv[1] === 'new')) {
return replace_macros($tpl, $context + array( return replace_macros($tpl, $context + [
'$title' => t('Create a group of contacts/friends.'), '$title' => t('Create a group of contacts/friends.'),
'$gname' => array('groupname', t('Group Name: '), '', ''), '$gname' => ['groupname', t('Group Name: '), '', ''],
'$gid' => 'new', '$gid' => 'new',
'$form_security_token' => get_form_security_token("group_edit"), '$form_security_token' => get_form_security_token("group_edit"),
)); ]);
} }
@ -160,8 +160,8 @@ function group_content(App $a) {
$group = $r[0]; $group = $r[0];
$members = Contact::getByGroupId($group['id']); $members = Contact::getByGroupId($group['id']);
$preselected = array(); $preselected = [];
$entry = array(); $entry = [];
$id = 0; $id = 0;
if (count($members)) { if (count($members)) {
@ -178,7 +178,7 @@ function group_content(App $a) {
} }
$members = Contact::getByGroupId($group['id']); $members = Contact::getByGroupId($group['id']);
$preselected = array(); $preselected = [];
if (count($members)) { if (count($members)) {
foreach ($members as $member) { foreach ($members as $member) {
$preselected[] = $member['id']; $preselected[] = $member['id'];
@ -187,21 +187,21 @@ function group_content(App $a) {
} }
$drop_tpl = get_markup_template('group_drop.tpl'); $drop_tpl = get_markup_template('group_drop.tpl');
$drop_txt = replace_macros($drop_tpl, array( $drop_txt = replace_macros($drop_tpl, [
'$id' => $group['id'], '$id' => $group['id'],
'$delete' => t('Delete Group'), '$delete' => t('Delete Group'),
'$form_security_token' => get_form_security_token("group_drop"), '$form_security_token' => get_form_security_token("group_drop"),
)); ]);
$context = $context + array( $context = $context + [
'$title' => t('Group Editor'), '$title' => t('Group Editor'),
'$gname' => array('groupname', t('Group Name: '), $group['name'], ''), '$gname' => ['groupname', t('Group Name: '), $group['name'], ''],
'$gid' => $group['id'], '$gid' => $group['id'],
'$drop' => $drop_txt, '$drop' => $drop_txt,
'$form_security_token' => get_form_security_token('group_edit'), '$form_security_token' => get_form_security_token('group_edit'),
'$edit_name' => t('Edit Group Name') '$edit_name' => t('Edit Group Name')
); ];
} }
@ -209,13 +209,13 @@ function group_content(App $a) {
return; return;
} }
$groupeditor = array( $groupeditor = [
'label_members' => t('Members'), 'label_members' => t('Members'),
'members' => array(), 'members' => [],
'label_contacts' => t('All Contacts'), 'label_contacts' => t('All Contacts'),
'group_is_empty' => t('Group is empty'), 'group_is_empty' => t('Group is empty'),
'contacts' => array(), 'contacts' => [],
); ];
$sec_token = addslashes(get_form_security_token('group_member_change')); $sec_token = addslashes(get_form_security_token('group_member_change'));
@ -225,12 +225,12 @@ function group_content(App $a) {
$entry = _contact_detail_for_template($member); $entry = _contact_detail_for_template($member);
$entry['label'] = 'members'; $entry['label'] = 'members';
$entry['photo_menu'] = ''; $entry['photo_menu'] = '';
$entry['change_member'] = array( $entry['change_member'] = [
'title' => t("Remove Contact"), 'title' => t("Remove Contact"),
'gid' => $group['id'], 'gid' => $group['id'],
'cid' => $member['id'], 'cid' => $member['id'],
'sec_token' => $sec_token 'sec_token' => $sec_token
); ];
$groupeditor['members'][] = $entry; $groupeditor['members'][] = $entry;
} else { } else {
@ -249,12 +249,12 @@ function group_content(App $a) {
$entry = _contact_detail_for_template($member); $entry = _contact_detail_for_template($member);
$entry['label'] = 'contacts'; $entry['label'] = 'contacts';
$entry['photo_menu'] = ''; $entry['photo_menu'] = '';
$entry['change_member'] = array( $entry['change_member'] = [
'title' => t("Add Contact"), 'title' => t("Add Contact"),
'gid' => $group['id'], 'gid' => $group['id'],
'cid' => $member['id'], 'cid' => $member['id'],
'sec_token' => $sec_token 'sec_token' => $sec_token
); ];
$groupeditor['contacts'][] = $entry; $groupeditor['contacts'][] = $entry;
} }

View file

@ -40,7 +40,7 @@ function hcard_init(App $a)
if (!$blocked) { if (!$blocked) {
$keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array(',',' ',',,'), array(' ',',',','), $keywords); $keywords = str_replace([',',' ',',,'], [' ',',',','], $keywords);
if (strlen($keywords)) { if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n" ;
} }
@ -52,7 +52,7 @@ function hcard_init(App $a)
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll'); $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
foreach ($dfrn_pages as $dfrn) { foreach ($dfrn_pages as $dfrn) {
$a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".System::baseUrl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"".System::baseUrl()."/dfrn_{$dfrn}/{$which}\" />\r\n";
} }

View file

@ -55,9 +55,9 @@ function help_content(App $a) {
if (!strlen($text)) { if (!strlen($text)) {
header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found')); header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
$tpl = get_markup_template("404.tpl"); $tpl = get_markup_template("404.tpl");
return replace_macros($tpl, array( return replace_macros($tpl, [
'$message' => t('Page not found.') '$message' => t('Page not found.')
)); ]);
} }
$html = Markdown::convert($text, false); $html = Markdown::convert($text, false);
@ -67,7 +67,7 @@ function help_content(App $a) {
$lines = explode("\n", $html); $lines = explode("\n", $html);
$toc="<style>aside ul {padding-left: 1em;}aside h1{font-size:2em}</style><h2>TOC</h2><ul id='toc'>"; $toc="<style>aside ul {padding-left: 1em;}aside h1{font-size:2em}</style><h2>TOC</h2><ul id='toc'>";
$lastlevel=1; $lastlevel=1;
$idnum = array(0,0,0,0,0,0,0); $idnum = [0,0,0,0,0,0,0];
foreach($lines as &$line){ foreach($lines as &$line){
if (substr($line,0,2)=="<h") { if (substr($line,0,2)=="<h") {
$level = substr($line,2,1); $level = substr($line,2,1);

View file

@ -8,7 +8,7 @@ use Friendica\Module\Login;
if(! function_exists('home_init')) { if(! function_exists('home_init')) {
function home_init(App $a) { function home_init(App $a) {
$ret = array(); $ret = [];
call_hooks('home_init',$ret); call_hooks('home_init',$ret);
if (local_user() && ($a->user['nickname'])) { if (local_user() && ($a->user['nickname'])) {

View file

@ -22,11 +22,11 @@ function hostxrd_init(App $a)
} }
$tpl = get_markup_template('xrd_host.tpl'); $tpl = get_markup_template('xrd_host.tpl');
echo replace_macros($tpl, array( echo replace_macros($tpl, [
'$zhost' => $a->get_hostname(), '$zhost' => $a->get_hostname(),
'$zroot' => System::baseUrl(), '$zroot' => System::baseUrl(),
'$domain' => System::baseUrl(), '$domain' => System::baseUrl(),
'$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))) '$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))]
); );
exit(); exit();

View file

@ -66,7 +66,7 @@ function hovercard_content()
} }
// Move the contact data to the profile array so we can deliver it to // Move the contact data to the profile array so we can deliver it to
$profile = array( $profile = [
'name' => $contact['name'], 'name' => $contact['name'],
'nick' => $contact['nick'], 'nick' => $contact['nick'],
'addr' => defaults($contact, 'addr', $contact['url']), 'addr' => defaults($contact, 'addr', $contact['url']),
@ -81,12 +81,12 @@ function hovercard_content()
'bd' => $contact['birthday'] <= '0001-01-01' ? '' : $contact['birthday'], 'bd' => $contact['birthday'] <= '0001-01-01' ? '' : $contact['birthday'],
'account_type' => Contact::getAccountType($contact), 'account_type' => Contact::getAccountType($contact),
'actions' => $actions, 'actions' => $actions,
); ];
if ($datatype == 'html') { if ($datatype == 'html') {
$tpl = get_markup_template('hovercard.tpl'); $tpl = get_markup_template('hovercard.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$profile' => $profile, '$profile' => $profile,
)); ]);
return $o; return $o;
} else { } else {

View file

@ -69,7 +69,7 @@ function install_post(App $a) {
dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true); dba::connect($dbhost, $dbuser, $dbpass, $dbdata, true);
$tpl = get_markup_template('htconfig.tpl'); $tpl = get_markup_template('htconfig.tpl');
$txt = replace_macros($tpl,array( $txt = replace_macros($tpl,[
'$dbhost' => $dbhost, '$dbhost' => $dbhost,
'$dbuser' => $dbuser, '$dbuser' => $dbuser,
'$dbpass' => $dbpass, '$dbpass' => $dbpass,
@ -80,7 +80,7 @@ function install_post(App $a) {
'$phpath' => $phpath, '$phpath' => $phpath,
'$adminmail' => $adminmail, '$adminmail' => $adminmail,
'$rino' => $rino '$rino' => $rino
)); ]);
$result = file_put_contents('.htconfig.php', $txt); $result = file_put_contents('.htconfig.php', $txt);
@ -138,12 +138,12 @@ function install_content(App $a) {
$r = q("SELECT COUNT(*) as `total` FROM `user`"); $r = q("SELECT COUNT(*) as `total` FROM `user`");
if (DBM::is_result($r) && $r[0]['total']) { if (DBM::is_result($r) && $r[0]['total']) {
$tpl = get_markup_template('install.tpl'); $tpl = get_markup_template('install.tpl');
return replace_macros($tpl, array( return replace_macros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => '', '$pass' => '',
'$status' => t('Database already in use.'), '$status' => t('Database already in use.'),
'$text' => '', '$text' => '',
)); ]);
} }
} }
@ -153,18 +153,18 @@ function install_content(App $a) {
if ($db_return_text != "") { if ($db_return_text != "") {
$tpl = get_markup_template('install.tpl'); $tpl = get_markup_template('install.tpl');
return replace_macros($tpl, array( return replace_macros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => "", '$pass' => "",
'$text' => $db_return_text . what_next(), '$text' => $db_return_text . what_next(),
)); ]);
} }
switch ($install_wizard_pass) { switch ($install_wizard_pass) {
case 1: { // System check case 1: { // System check
$checks = array(); $checks = [];
check_funcs($checks); check_funcs($checks);
@ -196,7 +196,7 @@ function install_content(App $a) {
$tpl = get_markup_template('install_checks.tpl'); $tpl = get_markup_template('install_checks.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => t('System check'), '$pass' => t('System check'),
'$checks' => $checks, '$checks' => $checks,
@ -206,7 +206,7 @@ function install_content(App $a) {
'$reload' => t('Check again'), '$reload' => t('Check again'),
'$phpath' => $phpath, '$phpath' => $phpath,
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
)); ]);
return $o; return $o;
}; break; }; break;
@ -220,7 +220,7 @@ function install_content(App $a) {
$tpl = get_markup_template('install_db.tpl'); $tpl = get_markup_template('install_db.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => t('Database connection'), '$pass' => t('Database connection'),
'$info_01' => t('In order to install Friendica we need to know how to connect to your database.'), '$info_01' => t('In order to install Friendica we need to know how to connect to your database.'),
@ -229,11 +229,11 @@ function install_content(App $a) {
'$status' => $wizard_status, '$status' => $wizard_status,
'$dbhost' => array('dbhost', t('Database Server Name'), $dbhost, '', 'required'), '$dbhost' => ['dbhost', t('Database Server Name'), $dbhost, '', 'required'],
'$dbuser' => array('dbuser', t('Database Login Name'), $dbuser, '', 'required', 'autofocus'), '$dbuser' => ['dbuser', t('Database Login Name'), $dbuser, '', 'required', 'autofocus'],
'$dbpass' => array('dbpass', t('Database Login Password'), $dbpass, t("For security reasons the password must not be empty"), 'required'), '$dbpass' => ['dbpass', t('Database Login Password'), $dbpass, t("For security reasons the password must not be empty"), 'required'],
'$dbdata' => array('dbdata', t('Database Name'), $dbdata, '', 'required'), '$dbdata' => ['dbdata', t('Database Name'), $dbdata, '', 'required'],
'$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'), '$adminmail' => ['adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'],
@ -245,7 +245,7 @@ function install_content(App $a) {
'$submit' => t('Submit'), '$submit' => t('Submit'),
)); ]);
return $o; return $o;
}; break; }; break;
case 3: { // Site settings case 3: { // Site settings
@ -262,7 +262,7 @@ function install_content(App $a) {
$lang_choices = get_available_languages(); $lang_choices = get_available_languages();
$tpl = get_markup_template('install_settings.tpl'); $tpl = get_markup_template('install_settings.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$title' => $install_title, '$title' => $install_title,
'$pass' => t('Site settings'), '$pass' => t('Site settings'),
@ -274,18 +274,18 @@ function install_content(App $a) {
'$dbdata' => $dbdata, '$dbdata' => $dbdata,
'$phpath' => $phpath, '$phpath' => $phpath,
'$adminmail' => array('adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'), '$adminmail' => ['adminmail', t('Site administrator email address'), $adminmail, t('Your account email address must match this in order to use the web admin panel.'), 'required', 'autofocus', 'email'],
'$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''), '$timezone' => field_timezone('timezone', t('Please select a default timezone for your website'), $timezone, ''),
'$language' => array('language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices), '$language' => ['language', t('System Language:'), 'en', t('Set the default language for your Friendica installation interface and to send emails.'), $lang_choices],
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$submit' => t('Submit'), '$submit' => t('Submit'),
)); ]);
return $o; return $o;
}; break; }; break;
@ -300,12 +300,12 @@ function install_content(App $a) {
* help : string optional * help : string optional
*/ */
function check_add(&$checks, $title, $status, $required, $help) { function check_add(&$checks, $title, $status, $required, $help) {
$checks[] = array( $checks[] = [
'title' => $title, 'title' => $title,
'status' => $status, 'status' => $status,
'required' => $required, 'required' => $required,
'help' => $help, 'help' => $help,
); ];
} }
function check_php(&$phpath, &$checks) { function check_php(&$phpath, &$checks) {
@ -322,9 +322,9 @@ function check_php(&$phpath, &$checks) {
$help .= t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . EOL; $help .= t("If you don't have a command line version of PHP installed on your server, you will not be able to run the background processing. See <a href='https://github.com/friendica/friendica/blob/master/doc/Install.md#set-up-the-worker'>'Setup the worker'</a>") . EOL;
$help .= EOL . EOL; $help .= EOL . EOL;
$tpl = get_markup_template('field_input.tpl'); $tpl = get_markup_template('field_input.tpl');
$help .= replace_macros($tpl, array( $help .= replace_macros($tpl, [
'$field' => array('phpath', t('PHP executable path'), $phpath, t('Enter full path to php executable. You can leave this blank to continue the installation.')), '$field' => ['phpath', t('PHP executable path'), $phpath, t('Enter full path to php executable. You can leave this blank to continue the installation.')],
)); ]);
$phpath = ""; $phpath = "";
} }
@ -367,11 +367,11 @@ function check_keys(&$checks) {
$res = false; $res = false;
if (function_exists('openssl_pkey_new')) { if (function_exists('openssl_pkey_new')) {
$res = openssl_pkey_new(array( $res = openssl_pkey_new([
'digest_alg' => 'sha1', 'digest_alg' => 'sha1',
'private_key_bits' => 4096, 'private_key_bits' => 4096,
'encrypt_key' => false 'encrypt_key' => false
)); ]);
} }
// Get private key // Get private key
@ -386,7 +386,7 @@ function check_keys(&$checks) {
function check_funcs(&$checks) { function check_funcs(&$checks) {
$ck_funcs = array(); $ck_funcs = [];
check_add($ck_funcs, t('libCurl PHP module'), true, true, ""); check_add($ck_funcs, t('libCurl PHP module'), true, true, "");
check_add($ck_funcs, t('GD graphics PHP module'), true, true, ""); check_add($ck_funcs, t('GD graphics PHP module'), true, true, "");
check_add($ck_funcs, t('OpenSSL PHP module'), true, true, ""); check_add($ck_funcs, t('OpenSSL PHP module'), true, true, "");

View file

@ -32,7 +32,7 @@ function invite_post(App $a) {
} }
$recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array()); $recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : []);
$message = ((x($_POST,'message')) ? notags(trim($_POST['message'])) : ''); $message = ((x($_POST,'message')) ? notags(trim($_POST['message'])) : '');
$total = 0; $total = 0;
@ -136,7 +136,7 @@ function invite_content(App $a) {
} }
} }
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$form_security_token' => get_form_security_token("send_invite"), '$form_security_token' => get_form_security_token("send_invite"),
'$invite' => t('Send invitations'), '$invite' => t('Send invitations'),
'$addr_text' => t('Enter email addresses, one per line:'), '$addr_text' => t('Enter email addresses, one per line:'),
@ -147,7 +147,7 @@ function invite_content(App $a) {
. "\r\n" . "\r\n" . System::baseUrl() . '/profile/' . $a->user['nickname'] . "\r\n" . "\r\n" . System::baseUrl() . '/profile/' . $a->user['nickname']
. "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n" , . "\r\n" . "\r\n" . t('For more information about the Friendica project and why we feel it is important, please visit http://friendi.ca') . "\r\n" . "\r\n" ,
'$submit' => t('Submit') '$submit' => t('Submit')
)); ]);
return $o; return $o;
} }

View file

@ -45,7 +45,7 @@ function item_post(App $a) {
if (x($_REQUEST, 'dropitems')) { if (x($_REQUEST, 'dropitems')) {
$arr_drop = explode(',', $_REQUEST['dropitems']); $arr_drop = explode(',', $_REQUEST['dropitems']);
drop_items($arr_drop); drop_items($arr_drop);
$json = array('success' => 1); $json = ['success' => 1];
echo json_encode($json); echo json_encode($json);
killme(); killme();
} }
@ -455,11 +455,11 @@ function item_post(App $a) {
} }
} }
$tagged = array(); $tagged = [];
$private_forum = false; $private_forum = false;
$only_to_forum = false; $only_to_forum = false;
$forum_contact = array(); $forum_contact = [];
if (count($tags)) { if (count($tags)) {
foreach ($tags as $tag) { foreach ($tags as $tag) {
@ -690,7 +690,7 @@ function item_post(App $a) {
$parent_uri = $uri; $parent_uri = $uri;
} }
$datarray = array(); $datarray = [];
$datarray['uid'] = $profile_uid; $datarray['uid'] = $profile_uid;
$datarray['type'] = $post_type; $datarray['type'] = $post_type;
$datarray['wall'] = $wall; $datarray['wall'] = $wall;
@ -735,8 +735,8 @@ function item_post(App $a) {
$datarray['postopts'] = $postopts; $datarray['postopts'] = $postopts;
$datarray['origin'] = $origin; $datarray['origin'] = $origin;
$datarray['moderated'] = $allow_moderated; $datarray['moderated'] = $allow_moderated;
$datarray['gcontact-id'] = GContact::getId(array("url" => $datarray['author-link'], "network" => $datarray['network'], $datarray['gcontact-id'] = GContact::getId(["url" => $datarray['author-link'], "network" => $datarray['network'],
"photo" => $datarray['author-avatar'], "name" => $datarray['author-name'])); "photo" => $datarray['author-avatar'], "name" => $datarray['author-name']]);
$datarray['object'] = $object; $datarray['object'] = $object;
$datarray['last-child'] = 1; $datarray['last-child'] = 1;
@ -777,9 +777,9 @@ function item_post(App $a) {
// We set the datarray ID to -1 because in preview mode the dataray // We set the datarray ID to -1 because in preview mode the dataray
// doesn't have an ID. // doesn't have an ID.
$datarray["id"] = -1; $datarray["id"] = -1;
$o = conversation($a,array(array_merge($contact_record,$datarray)),'search', false, true); $o = conversation($a,[array_merge($contact_record,$datarray)],'search', false, true);
logger('preview: ' . $o); logger('preview: ' . $o);
echo json_encode(array('preview' => $o)); echo json_encode(['preview' => $o]);
killme(); killme();
} }
@ -791,7 +791,7 @@ function item_post(App $a) {
goaway($return_path); goaway($return_path);
} }
$json = array('cancel' => 1); $json = ['cancel' => 1];
if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) { if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = System::baseUrl() . '/' . $_REQUEST['jsreload']; $json['reload'] = System::baseUrl() . '/' . $_REQUEST['jsreload'];
} }
@ -806,7 +806,7 @@ function item_post(App $a) {
// This could be done in Item::update as well - but we have to check for the existance of some fields. // This could be done in Item::update as well - but we have to check for the existance of some fields.
put_item_in_cache($datarray); put_item_in_cache($datarray);
$fields = array( $fields = [
'title' => $datarray['title'], 'title' => $datarray['title'],
'body' => $datarray['body'], 'body' => $datarray['body'],
'tag' => $datarray['tag'], 'tag' => $datarray['tag'],
@ -815,7 +815,7 @@ function item_post(App $a) {
'rendered-html' => $datarray['rendered-html'], 'rendered-html' => $datarray['rendered-html'],
'rendered-hash' => $datarray['rendered-hash'], 'rendered-hash' => $datarray['rendered-hash'],
'edited' => datetime_convert(), 'edited' => datetime_convert(),
'changed' => datetime_convert()); 'changed' => datetime_convert()];
Item::update($fields, ['id' => $post_id]); Item::update($fields, ['id' => $post_id]);
@ -845,7 +845,7 @@ function item_post(App $a) {
// These notifications are sent if someone else is commenting other your wall // These notifications are sent if someone else is commenting other your wall
if ($parent) { if ($parent) {
if ($contact_record != $author) { if ($contact_record != $author) {
notification(array( notification([
'type' => NOTIFY_COMMENT, 'type' => NOTIFY_COMMENT,
'notify_flags' => $user['notify-flags'], 'notify_flags' => $user['notify-flags'],
'language' => $user['language'], 'language' => $user['language'],
@ -861,14 +861,14 @@ function item_post(App $a) {
'otype' => 'item', 'otype' => 'item',
'parent' => $parent, 'parent' => $parent,
'parent_uri' => $parent_item['uri'] 'parent_uri' => $parent_item['uri']
)); ]);
} }
// Store the comment signature information in case we need to relay to Diaspora // Store the comment signature information in case we need to relay to Diaspora
Diaspora::storeCommentSignature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id); Diaspora::storeCommentSignature($datarray, $author, ($self ? $user['prvkey'] : false), $post_id);
} else { } else {
if (($contact_record != $author) && !count($forum_contact)) { if (($contact_record != $author) && !count($forum_contact)) {
notification(array( notification([
'type' => NOTIFY_WALL, 'type' => NOTIFY_WALL,
'notify_flags' => $user['notify-flags'], 'notify_flags' => $user['notify-flags'],
'language' => $user['language'], 'language' => $user['language'],
@ -882,7 +882,7 @@ function item_post(App $a) {
'source_photo' => $datarray['author-avatar'], 'source_photo' => $datarray['author-avatar'],
'verb' => ACTIVITY_POST, 'verb' => ACTIVITY_POST,
'otype' => 'item' 'otype' => 'item'
)); ]);
} }
} }
@ -909,7 +909,7 @@ function item_post(App $a) {
$html = prepare_body($datarray); $html = prepare_body($datarray);
$message = '<html><body>' . $link . $html . $disclaimer . '</body></html>'; $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';
include_once 'include/html2plain.php'; include_once 'include/html2plain.php';
$params = array ( $params = [
'fromName' => $a->user['username'], 'fromName' => $a->user['username'],
'fromEmail' => $a->user['email'], 'fromEmail' => $a->user['email'],
'toEmail' => $addr, 'toEmail' => $addr,
@ -917,7 +917,7 @@ function item_post(App $a) {
'messageSubject' => $subject, 'messageSubject' => $subject,
'htmlVersion' => $message, 'htmlVersion' => $message,
'textVersion' => html2plain($html.$disclaimer) 'textVersion' => html2plain($html.$disclaimer)
); ];
Emailer::send($params); Emailer::send($params);
} }
} }
@ -927,7 +927,7 @@ function item_post(App $a) {
// We now do it in the background to save some time. // We now do it in the background to save some time.
// This is important in interactive environments like the frontend or the API. // This is important in interactive environments like the frontend or the API.
// We don't fork a new process since this is done anyway with the following command // We don't fork a new process since this is done anyway with the following command
Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "CreateShadowEntry", $post_id); Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "CreateShadowEntry", $post_id);
// Call the background process that is delivering the item to the receivers // Call the background process that is delivering the item to the receivers
Worker::add(PRIORITY_HIGH, "Notifier", $notify_type, $post_id); Worker::add(PRIORITY_HIGH, "Notifier", $notify_type, $post_id);
@ -949,7 +949,7 @@ function item_post_return($baseurl, $api_source, $return_path) {
goaway($return_path); goaway($return_path);
} }
$json = array('success' => 1); $json = ['success' => 1];
if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) { if (x($_REQUEST, 'jsreload') && strlen($_REQUEST['jsreload'])) {
$json['reload'] = $baseurl . '/' . $_REQUEST['jsreload']; $json['reload'] = $baseurl . '/' . $_REQUEST['jsreload'];
} }
@ -975,7 +975,7 @@ function item_content(App $a) {
$o = drop_item($a->argv[2], !is_ajax()); $o = drop_item($a->argv[2], !is_ajax());
if (is_ajax()) { if (is_ajax()) {
// ajax return: [<item id>, 0 (no perm) | <owner id>] // ajax return: [<item id>, 0 (no perm) | <owner id>]
echo json_encode(array(intval($a->argv[2]), intval($o))); echo json_encode([intval($a->argv[2]), intval($o)]);
killme(); killme();
} }
} }
@ -1206,5 +1206,5 @@ function handle_tag(App $a, &$body, &$inform, &$str_tags, $profile_uid, $tag, $n
} }
} }
return array('replaced' => $replaced, 'contact' => $r[0]); return ['replaced' => $replaced, 'contact' => $r[0]];
} }

View file

@ -16,7 +16,7 @@ function lockview_content(App $a) {
if(! $item_id) if(! $item_id)
killme(); killme();
if (!in_array($type, array('item','photo','event'))) if (!in_array($type, ['item','photo','event']))
killme(); killme();
$r = q("SELECT * FROM `%s` WHERE `id` = %d LIMIT 1", $r = q("SELECT * FROM `%s` WHERE `id` = %d LIMIT 1",
@ -49,7 +49,7 @@ function lockview_content(App $a) {
$deny_groups = expand_acl($item['deny_gid']); $deny_groups = expand_acl($item['deny_gid']);
$o = t('Visible to:') . '<br />'; $o = t('Visible to:') . '<br />';
$l = array(); $l = [];
if(count($allowed_groups)) { if(count($allowed_groups)) {
$r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )", $r = q("SELECT `name` FROM `group` WHERE `id` IN ( %s )",

View file

@ -70,12 +70,12 @@ function lostpass_post(App $a) {
$preamble = sprintf($preamble, $username, $sitename); $preamble = sprintf($preamble, $username, $sitename);
$body = sprintf($body, $resetlink, System::baseUrl(), $email); $body = sprintf($body, $resetlink, System::baseUrl(), $email);
notification(array( notification([
'type' => SYSTEM_EMAIL, 'type' => SYSTEM_EMAIL,
'to_email' => $email, 'to_email' => $email,
'subject'=> sprintf( t('Password reset requested at %s'),$sitename), 'subject'=> sprintf( t('Password reset requested at %s'),$sitename),
'preamble'=> $preamble, 'preamble'=> $preamble,
'body' => $body)); 'body' => $body]);
goaway(System::baseUrl()); goaway(System::baseUrl());
@ -111,7 +111,7 @@ function lostpass_content(App $a) {
/// @TODO Is DBM::is_result() okay here? /// @TODO Is DBM::is_result() okay here?
if ($r) { if ($r) {
$tpl = get_markup_template('pwdreset.tpl'); $tpl = get_markup_template('pwdreset.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$lbl1' => t('Password Reset'), '$lbl1' => t('Password Reset'),
'$lbl2' => t('Your password has been reset as requested.'), '$lbl2' => t('Your password has been reset as requested.'),
'$lbl3' => t('Your new password is'), '$lbl3' => t('Your new password is'),
@ -121,7 +121,7 @@ function lostpass_content(App $a) {
'$newpass' => $new_password, '$newpass' => $new_password,
'$baseurl' => System::baseUrl() '$baseurl' => System::baseUrl()
)); ]);
info("Your password has been reset." . EOL); info("Your password has been reset." . EOL);
@ -146,12 +146,12 @@ function lostpass_content(App $a) {
$preamble = sprintf($preamble, $username); $preamble = sprintf($preamble, $username);
$body = sprintf($body, System::baseUrl(), $email, $new_password); $body = sprintf($body, System::baseUrl(), $email, $new_password);
notification(array( notification([
'type' => SYSTEM_EMAIL, 'type' => SYSTEM_EMAIL,
'to_email' => $email, 'to_email' => $email,
'subject'=> sprintf( t('Your password has been changed at %s'),$sitename), 'subject'=> sprintf( t('Your password has been changed at %s'),$sitename),
'preamble'=> $preamble, 'preamble'=> $preamble,
'body' => $body)); 'body' => $body]);
return $o; return $o;
} }
@ -160,12 +160,12 @@ function lostpass_content(App $a) {
else { else {
$tpl = get_markup_template('lostpass.tpl'); $tpl = get_markup_template('lostpass.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$title' => t('Forgot your Password?'), '$title' => t('Forgot your Password?'),
'$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'), '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'),
'$name' => t('Nickname or Email: '), '$name' => t('Nickname or Email: '),
'$submit' => t('Reset') '$submit' => t('Reset')
)); ]);
return $o; return $o;
} }

View file

@ -17,8 +17,8 @@ function maintenance_content(App $a) {
header('Status: 503 Service Temporarily Unavailable'); header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 600'); header('Retry-After: 600');
return replace_macros(get_markup_template('maintenance.tpl'), array( return replace_macros(get_markup_template('maintenance.tpl'), [
'$sysdown' => t('System down for maintenance'), '$sysdown' => t('System down for maintenance'),
'$reason' => $reason '$reason' => $reason
)); ]);
} }

View file

@ -90,7 +90,7 @@ function manage_post(App $a) {
$_SESSION['submanage'] = $original_id; $_SESSION['submanage'] = $original_id;
} }
$ret = array(); $ret = [];
call_hooks('home_init',$ret); call_hooks('home_init',$ret);
goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] ); goaway( System::baseUrl() . "/profile/" . $a->user['nickname'] );
@ -150,13 +150,13 @@ function manage_content(App $a) {
$identities[$key]['notifications'] = $notifications; $identities[$key]['notifications'] = $notifications;
} }
$o = replace_macros(get_markup_template('manage.tpl'), array( $o = replace_macros(get_markup_template('manage.tpl'), [
'$title' => t('Manage Identities and/or Pages'), '$title' => t('Manage Identities and/or Pages'),
'$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'), '$desc' => t('Toggle between different identities or community/group pages which share your account details or which you have been granted "manage" permissions'),
'$choose' => t('Select an identity to manage: '), '$choose' => t('Select an identity to manage: '),
'$identities' => $identities, '$identities' => $identities,
'$submit' => t('Submit'), '$submit' => t('Submit'),
)); ]);
return $o; return $o;

View file

@ -15,11 +15,11 @@ function manifest_content(App $a) {
$touch_icon = 'images/friendica-128.png'; $touch_icon = 'images/friendica-128.png';
} }
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$touch_icon' => $touch_icon, '$touch_icon' => $touch_icon,
'$title' => Config::get('config', 'sitename', 'Friendica'), '$title' => Config::get('config', 'sitename', 'Friendica'),
)); ]);
echo $o; echo $o;

View file

@ -47,7 +47,7 @@ function match_content(App $a)
return; return;
} }
$params = array(); $params = [];
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
if ($tags) { if ($tags) {
@ -83,14 +83,14 @@ function match_content(App $a)
if (!count($match)) { if (!count($match)) {
$jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo); $jj->photo = str_replace("http:///photo/", get_server()."/photo/", $jj->photo);
$connlnk = System::baseUrl() . '/follow/?url=' . $jj->url; $connlnk = System::baseUrl() . '/follow/?url=' . $jj->url;
$photo_menu = array( $photo_menu = [
'profile' => array(t("View Profile"), Profile::zrl($jj->url)), 'profile' => [t("View Profile"), Profile::zrl($jj->url)],
'follow' => array(t("Connect/Follow"), $connlnk) 'follow' => [t("Connect/Follow"), $connlnk]
); ];
$contact_details = Contact::getDetailsByURL($jj->url, local_user()); $contact_details = Contact::getDetailsByURL($jj->url, local_user());
$entry = array( $entry = [
'url' => Profile::zrl($jj->url), 'url' => Profile::zrl($jj->url),
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url), 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $jj->url),
'name' => $jj->name, 'name' => $jj->name,
@ -105,7 +105,7 @@ function match_content(App $a)
'img_hover' => $jj->tags, 'img_hover' => $jj->tags,
'photo_menu' => $photo_menu, 'photo_menu' => $photo_menu,
'id' => ++$id, 'id' => ++$id,
); ];
$entries[] = $entry; $entries[] = $entry;
} }
} }
@ -114,10 +114,10 @@ function match_content(App $a)
$o .= replace_macros( $o .= replace_macros(
$tpl, $tpl,
array( [
'$title' => t('Profile Match'), '$title' => t('Profile Match'),
'$contacts' => $entries, '$contacts' => $entries,
'$paginate' => paginate($a)) '$paginate' => paginate($a)]
); );
} else { } else {
info(t('No matches') . EOL); info(t('No matches') . EOL);

View file

@ -20,31 +20,31 @@ function message_init(App $a)
$tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl'); $tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl');
} }
$new = array( $new = [
'label' => t('New Message'), 'label' => t('New Message'),
'url' => 'message/new', 'url' => 'message/new',
'sel' => $a->argc > 1 && $a->argv[1] == 'new', 'sel' => $a->argc > 1 && $a->argv[1] == 'new',
'accesskey' => 'm', 'accesskey' => 'm',
); ];
$tpl = get_markup_template('message_side.tpl'); $tpl = get_markup_template('message_side.tpl');
$a->page['aside'] = replace_macros($tpl, array( $a->page['aside'] = replace_macros($tpl, [
'$tabs' => $tabs, '$tabs' => $tabs,
'$new' => $new, '$new' => $new,
)); ]);
$base = System::baseUrl(); $base = System::baseUrl();
$head_tpl = get_markup_template('message-head.tpl'); $head_tpl = get_markup_template('message-head.tpl');
$a->page['htmlhead'] .= replace_macros($head_tpl, array( $a->page['htmlhead'] .= replace_macros($head_tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$base' => $base '$base' => $base
)); ]);
$end_tpl = get_markup_template('message-end.tpl'); $end_tpl = get_markup_template('message-end.tpl');
$a->page['end'] .= replace_macros($end_tpl, array( $a->page['end'] .= replace_macros($end_tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$base' => $base '$base' => $base
)); ]);
} }
function message_post(App $a) function message_post(App $a)
@ -102,9 +102,9 @@ function message_content(App $a)
$myprofile = System::baseUrl() . '/profile/' . $a->user['nickname']; $myprofile = System::baseUrl() . '/profile/' . $a->user['nickname'];
$tpl = get_markup_template('mail_head.tpl'); $tpl = get_markup_template('mail_head.tpl');
$header = replace_macros($tpl, array( $header = replace_macros($tpl, [
'$messages' => t('Messages'), '$messages' => t('Messages'),
)); ]);
if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
if (!intval($a->argv[2])) { if (!intval($a->argv[2])) {
@ -116,16 +116,16 @@ function message_content(App $a)
// <form> can't take arguments in its "action" parameter // <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs // so add any arguments as hidden inputs
$query = explode_querystring($a->query_string); $query = explode_querystring($a->query_string);
$inputs = array(); $inputs = [];
foreach ($query['args'] as $arg) { foreach ($query['args'] as $arg) {
if (strpos($arg, 'confirm=') === false) { if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg); $arg_parts = explode('=', $arg);
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]); $inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
} }
} }
//$a->page['aside'] = ''; //$a->page['aside'] = '';
return replace_macros(get_markup_template('confirm.tpl'), array( return replace_macros(get_markup_template('confirm.tpl'), [
'$method' => 'get', '$method' => 'get',
'$message' => t('Do you really want to delete this message?'), '$message' => t('Do you really want to delete this message?'),
'$extra_inputs' => $inputs, '$extra_inputs' => $inputs,
@ -133,7 +133,7 @@ function message_content(App $a)
'$confirm_url' => $query['base'], '$confirm_url' => $query['base'],
'$confirm_name' => 'confirmed', '$confirm_name' => 'confirmed',
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
)); ]);
} }
// Now check how the user responded to the confirmation query // Now check how the user responded to the confirmation query
if ($_REQUEST['canceled']) { if ($_REQUEST['canceled']) {
@ -188,20 +188,20 @@ function message_content(App $a)
$o .= $header; $o .= $header;
$tpl = get_markup_template('msg-header.tpl'); $tpl = get_markup_template('msg-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:') '$linkurl' => t('Please enter a link URL:')
)); ]);
$tpl = get_markup_template('msg-end.tpl'); $tpl = get_markup_template('msg-end.tpl');
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:') '$linkurl' => t('Please enter a link URL:')
)); ]);
$preselect = isset($a->argv[2]) ? array($a->argv[2]) : false; $preselect = isset($a->argv[2]) ? [$a->argv[2]] : false;
$prename = $preurl = $preid = ''; $prename = $preurl = $preid = '';
@ -228,7 +228,7 @@ function message_content(App $a)
$prename = $r[0]['name']; $prename = $r[0]['name'];
$preurl = $r[0]['url']; $preurl = $r[0]['url'];
$preid = $r[0]['id']; $preid = $r[0]['id'];
$preselect = array($preid); $preselect = [$preid];
} else { } else {
$preselect = false; $preselect = false;
} }
@ -240,7 +240,7 @@ function message_content(App $a)
$select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10); $select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10);
$tpl = get_markup_template('prv_message.tpl'); $tpl = get_markup_template('prv_message.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$header' => t('Send Private Message'), '$header' => t('Send Private Message'),
'$to' => t('To:'), '$to' => t('To:'),
'$showinputs' => 'true', '$showinputs' => 'true',
@ -258,7 +258,7 @@ function message_content(App $a)
'$insert' => t('Insert web link'), '$insert' => t('Insert web link'),
'$wait' => t('Please wait'), '$wait' => t('Please wait'),
'$submit' => t('Submit') '$submit' => t('Submit')
)); ]);
return $o; return $o;
} }
@ -334,20 +334,20 @@ function message_content(App $a)
require_once("include/bbcode.php"); require_once("include/bbcode.php");
$tpl = get_markup_template('msg-header.tpl'); $tpl = get_markup_template('msg-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:') '$linkurl' => t('Please enter a link URL:')
)); ]);
$tpl = get_markup_template('msg-end.tpl'); $tpl = get_markup_template('msg-end.tpl');
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$nickname' => $a->user['nickname'], '$nickname' => $a->user['nickname'],
'$linkurl' => t('Please enter a link URL:') '$linkurl' => t('Please enter a link URL:')
)); ]);
$mails = array(); $mails = [];
$seen = 0; $seen = 0;
$unknown = false; $unknown = false;
@ -382,7 +382,7 @@ function message_content(App $a)
$from_photo = $message['from-photo']; $from_photo = $message['from-photo'];
} }
$mails[] = array( $mails[] = [
'id' => $message['id'], 'id' => $message['id'],
'from_name' => $from_name_e, 'from_name' => $from_name_e,
'from_url' => $from_url, 'from_url' => $from_url,
@ -395,7 +395,7 @@ function message_content(App $a)
'to_name' => $to_name_e, 'to_name' => $to_name_e,
'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A'), 'date' => datetime_convert('UTC', date_default_timezone_get(), $message['created'], 'D, d M Y - g:i A'),
'ago' => relative_date($message['created']), 'ago' => relative_date($message['created']),
); ];
$seen = $message['seen']; $seen = $message['seen'];
} }
@ -404,7 +404,7 @@ function message_content(App $a)
$parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />';
$tpl = get_markup_template('mail_display.tpl'); $tpl = get_markup_template('mail_display.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$thread_id' => $a->argv[1], '$thread_id' => $a->argv[1],
'$thread_subject' => $message['title'], '$thread_subject' => $message['title'],
'$thread_seen' => $seen, '$thread_seen' => $seen,
@ -428,7 +428,7 @@ function message_content(App $a)
'$insert' => t('Insert web link'), '$insert' => t('Insert web link'),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$wait' => t('Please wait') '$wait' => t('Please wait')
)); ]);
return $o; return $o;
} }
@ -483,7 +483,7 @@ function render_messages(array $msg, $t)
$from_photo = (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']); $from_photo = (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']);
} }
$rslt .= replace_macros($tpl, array( $rslt .= replace_macros($tpl, [
'$id' => $rr['id'], '$id' => $rr['id'],
'$from_name' => $participants, '$from_name' => $participants,
'$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']), '$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']),
@ -498,7 +498,7 @@ function render_messages(array $msg, $t)
'$ago' => relative_date($rr['mailcreated']), '$ago' => relative_date($rr['mailcreated']),
'$seen' => $rr['mailseen'], '$seen' => $rr['mailseen'],
'$count' => tt('%d message', '%d messages', $rr['count']), '$count' => tt('%d message', '%d messages', $rr['count']),
)); ]);
} }
return $rslt; return $rslt;

View file

@ -21,7 +21,7 @@ function msearch_post(App $a) {
if (DBM::is_result($r)) if (DBM::is_result($r))
$total = $r[0]['total']; $total = $r[0]['total'];
$results = array(); $results = [];
$r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ", $r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ",
dbesc($search), dbesc($search),
@ -31,15 +31,15 @@ function msearch_post(App $a) {
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach($r as $rr) foreach($r as $rr)
$results[] = array( $results[] = [
'name' => $rr['name'], 'name' => $rr['name'],
'url' => System::baseUrl() . '/profile/' . $rr['nickname'], 'url' => System::baseUrl() . '/profile/' . $rr['nickname'],
'photo' => System::baseUrl() . '/photo/avatar/' . $rr['uid'] . '.jpg', 'photo' => System::baseUrl() . '/photo/avatar/' . $rr['uid'] . '.jpg',
'tags' => str_replace(array(',',' '),array(' ',' '),$rr['pub_keywords']) 'tags' => str_replace([',',' '],[' ',' '],$rr['pub_keywords'])
); ];
} }
$output = array('total' => $total, 'items_page' => $perpage, 'page' => $page + 1, 'results' => $results); $output = ['total' => $total, 'items_page' => $perpage, 'page' => $page + 1, 'results' => $results];
echo json_encode($output); echo json_encode($output);

View file

@ -32,13 +32,13 @@ function network_init(App $a) {
} }
if (x($_GET, 'save')) { if (x($_GET, 'save')) {
$exists = dba::exists('search', array('uid' => local_user(), 'term' => $search)); $exists = dba::exists('search', ['uid' => local_user(), 'term' => $search]);
if (!$exists) { if (!$exists) {
dba::insert('search', array('uid' => local_user(), 'term' => $search)); dba::insert('search', ['uid' => local_user(), 'term' => $search]);
} }
} }
if (x($_GET, 'remove')) { if (x($_GET, 'remove')) {
dba::delete('search', array('uid' => local_user(), 'term' => $search)); dba::delete('search', ['uid' => local_user(), 'term' => $search]);
} }
$is_a_date_query = false; $is_a_date_query = false;
@ -64,7 +64,7 @@ function network_init(App $a) {
} }
// convert query string to array. remove friendica args // convert query string to array. remove friendica args
$query_array = array(); $query_array = [];
$query_string = str_replace($a->cmd."?", "", $a->query_string); $query_string = str_replace($a->cmd."?", "", $a->query_string);
parse_str($query_string, $query_array); parse_str($query_string, $query_array);
array_shift($query_array); array_shift($query_array);
@ -83,7 +83,7 @@ function network_init(App $a) {
$remember_group = ($sel_groups === false && $last_sel_groups && $last_sel_groups != 0); $remember_group = ($sel_groups === false && $last_sel_groups && $last_sel_groups != 0);
$net_baseurl = '/network'; $net_baseurl = '/network';
$net_args = array(); $net_args = [];
if ($remember_group) { if ($remember_group) {
$net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection $net_baseurl .= '/' . $last_sel_groups; // Note that the group number must come before the "/new" tab selection
@ -96,7 +96,7 @@ function network_init(App $a) {
// last selected tab is _not_ '/network?f=&order=comment'. // last selected tab is _not_ '/network?f=&order=comment'.
// and this isn't a date query // and this isn't a date query
$tab_baseurls = array( $tab_baseurls = [
'', //all '', //all
'', //postord '', //postord
'', //conv '', //conv
@ -104,8 +104,8 @@ function network_init(App $a) {
'', //starred '', //starred
'', //bookmarked '', //bookmarked
'', //spam '', //spam
); ];
$tab_args = array( $tab_args = [
'f=&order=comment', //all 'f=&order=comment', //all
'f=&order=post', //postord 'f=&order=post', //postord
'f=&conv=1', //conv 'f=&conv=1', //conv
@ -113,7 +113,7 @@ function network_init(App $a) {
'f=&star=1', //starred 'f=&star=1', //starred
'f=&bmark=1', //bookmarked 'f=&bmark=1', //bookmarked
'f=&spam=1', //spam 'f=&spam=1', //spam
); ];
$k = array_search('active', $last_sel_tabs); $k = array_search('active', $last_sel_tabs);
@ -121,7 +121,7 @@ function network_init(App $a) {
$net_baseurl .= $tab_baseurls[$k]; $net_baseurl .= $tab_baseurls[$k];
// parse out tab queries // parse out tab queries
$dest_qa = array(); $dest_qa = [];
$dest_qs = $tab_args[$k]; $dest_qs = $tab_args[$k];
parse_str($dest_qs, $dest_qa); parse_str($dest_qs, $dest_qa);
$net_args = array_merge($net_args, $dest_qa); $net_args = array_merge($net_args, $dest_qa);
@ -188,26 +188,26 @@ function saved_searches($search) {
$o = ''; $o = '';
$terms = dba::select('search', array('id', 'term'), array('uid' => local_user())); $terms = dba::select('search', ['id', 'term'], ['uid' => local_user()]);
$saved = array(); $saved = [];
while ($rr = dba::fetch($terms)) { while ($rr = dba::fetch($terms)) {
$saved[] = array( $saved[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'term' => $rr['term'], 'term' => $rr['term'],
'encodedterm' => urlencode($rr['term']), 'encodedterm' => urlencode($rr['term']),
'delete' => t('Remove term'), 'delete' => t('Remove term'),
'selected' => ($search==$rr['term']), 'selected' => ($search==$rr['term']),
); ];
} }
$tpl = get_markup_template("saved_searches_aside.tpl"); $tpl = get_markup_template("saved_searches_aside.tpl");
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$title' => t('Saved Searches'), '$title' => t('Saved Searches'),
'$add' => t('add'), '$add' => t('add'),
'$searchbox' => search($search,'netsearch-box',$srchurl,true), '$searchbox' => search($search,'netsearch-box',$srchurl,true),
'$saved' => $saved, '$saved' => $saved,
)); ]);
return $o; return $o;
} }
@ -275,7 +275,7 @@ function network_query_get_sel_tab(App $a) {
} }
} }
return array($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active); return [$no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active];
} }
/** /**
@ -350,7 +350,7 @@ function networkSetSeen($condition) {
$unseen = dba::exists('item', $condition); $unseen = dba::exists('item', $condition);
if ($unseen) { if ($unseen) {
$r = dba::update('item', array('unseen' => false), $condition); $r = dba::update('item', ['unseen' => false], $condition);
} }
} }
@ -386,7 +386,7 @@ function network_content(App $a, $update = 0) {
} }
/// @TODO Is this really necessary? $a is already available to hooks /// @TODO Is this really necessary? $a is already available to hooks
$arr = array('query' => $a->query_string); $arr = ['query' => $a->query_string];
call_hooks('network_content_init', $arr); call_hooks('network_content_init', $arr);
$nouveau = false; $nouveau = false;
@ -442,7 +442,7 @@ function networkFlatView(App $a, $update = 0) {
nav_set_selected('network'); nav_set_selected('network');
$x = array( $x = [
'is_owner' => true, 'is_owner' => true,
'allow_location' => $a->user['allow_location'], 'allow_location' => $a->user['allow_location'],
'default_location' => $a->user['default-location'], 'default_location' => $a->user['default-location'],
@ -456,7 +456,7 @@ function networkFlatView(App $a, $update = 0) {
'visitor' => 'block', 'visitor' => 'block',
'profile_uid' => local_user(), 'profile_uid' => local_user(),
'content' => '', 'content' => '',
); ];
$o .= status_editor($a, $x); $o .= status_editor($a, $x);
@ -483,7 +483,7 @@ function networkFlatView(App $a, $update = 0) {
intval($_SESSION['uid']) intval($_SESSION['uid'])
); );
$condition = array('unseen' => true, 'uid' => local_user()); $condition = ['unseen' => true, 'uid' => local_user()];
networkSetSeen($condition); networkSetSeen($condition);
$mode = 'network-new'; $mode = 'network-new';
@ -531,7 +531,7 @@ function networkThreadedView(App $a, $update = 0) {
} }
} elseif (intval($a->argv[$x])) { } elseif (intval($a->argv[$x])) {
$gid = intval($a->argv[$x]); $gid = intval($a->argv[$x]);
$def_acl = array('allow_gid' => '<' . $gid . '>'); $def_acl = ['allow_gid' => '<' . $gid . '>'];
} }
} }
} }
@ -546,18 +546,18 @@ function networkThreadedView(App $a, $update = 0) {
$nets = ((x($_GET,'nets')) ? $_GET['nets'] : ''); $nets = ((x($_GET,'nets')) ? $_GET['nets'] : '');
if ($cid) { if ($cid) {
$def_acl = array('allow_cid' => '<' . intval($cid) . '>'); $def_acl = ['allow_cid' => '<' . intval($cid) . '>'];
} }
if ($nets) { if ($nets) {
$r = dba::select('contact', array('id'), array('uid' => local_user(), 'network' => $nets), array('self' => false)); $r = dba::select('contact', ['id'], ['uid' => local_user(), 'network' => $nets], ['self' => false]);
$str = ''; $str = '';
while ($rr = dba::fetch($r)) { while ($rr = dba::fetch($r)) {
$str .= '<' . $rr['id'] . '>'; $str .= '<' . $rr['id'] . '>';
} }
if (strlen($str)) { if (strlen($str)) {
$def_acl = array('allow_cid' => $str); $def_acl = ['allow_cid' => $str];
} }
} }
PConfig::set(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all')); PConfig::set(local_user(), 'network.view', 'net.selected', ($nets ? $nets : 'all'));
@ -592,7 +592,7 @@ function networkThreadedView(App $a, $update = 0) {
} }
} }
$x = array( $x = [
'is_owner' => true, 'is_owner' => true,
'allow_location' => $a->user['allow_location'], 'allow_location' => $a->user['allow_location'],
'default_location' => $a->user['default-location'], 'default_location' => $a->user['default-location'],
@ -606,7 +606,7 @@ function networkThreadedView(App $a, $update = 0) {
'visitor' => 'block', 'visitor' => 'block',
'profile_uid' => local_user(), 'profile_uid' => local_user(),
'content' => $content, 'content' => $content,
); ];
$o .= status_editor($a, $x); $o .= status_editor($a, $x);
} }
@ -644,7 +644,7 @@ function networkThreadedView(App $a, $update = 0) {
// NOTREACHED // NOTREACHED
} }
$contacts = Group::expand(array($gid)); $contacts = Group::expand([$gid]);
if ((is_array($contacts)) && count($contacts)) { if ((is_array($contacts)) && count($contacts)) {
$contact_str_self = ""; $contact_str_self = "";
@ -663,9 +663,9 @@ function networkThreadedView(App $a, $update = 0) {
info(t('Group is empty')); info(t('Group is empty'));
} }
$o = replace_macros(get_markup_template("section_title.tpl"),array( $o = replace_macros(get_markup_template("section_title.tpl"),[
'$title' => t('Group: %s', $group['name']) '$title' => t('Group: %s', $group['name'])
)) . $o; ]) . $o;
} elseif ($cid) { } elseif ($cid) {
$fields = ['id', 'name', 'network', 'writable', 'nurl', $fields = ['id', 'name', 'network', 'writable', 'nurl',
@ -675,20 +675,20 @@ function networkThreadedView(App $a, $update = 0) {
if (DBM::is_result($contact)) { if (DBM::is_result($contact)) {
$sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid); $sql_extra = " AND ".$sql_table.".`contact-id` = ".intval($cid);
$entries[0] = array( $entries[0] = [
'id' => 'network', 'id' => 'network',
'name' => htmlentities($contact['name']), 'name' => htmlentities($contact['name']),
'itemurl' => defaults($contact, 'addr', $contact['nurl']), 'itemurl' => defaults($contact, 'addr', $contact['nurl']),
'thumb' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB), 'thumb' => proxy_url($contact['thumb'], false, PROXY_SIZE_THUMB),
'details' => $contact['location'], 'details' => $contact['location'],
); ];
$entries[0]["account_type"] = Contact::getAccountType($contact); $entries[0]["account_type"] = Contact::getAccountType($contact);
$o = replace_macros(get_markup_template("viewcontact_template.tpl"),array( $o = replace_macros(get_markup_template("viewcontact_template.tpl"),[
'contacts' => $entries, 'contacts' => $entries,
'id' => 'network', 'id' => 'network',
)) . $o; ]) . $o;
if ($contact['network'] === NETWORK_OSTATUS && $contact['writable'] && !PConfig::get(local_user(),'system','nowarn_insecure')) { if ($contact['network'] === NETWORK_OSTATUS && $contact['writable'] && !PConfig::get(local_user(),'system','nowarn_insecure')) {
notice(t('Private messages to this person are at risk of public disclosure.') . EOL); notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
@ -851,11 +851,11 @@ function networkThreadedView(App $a, $update = 0) {
// Then fetch all the children of the parents that are on this page // Then fetch all the children of the parents that are on this page
$parents_arr = array(); $parents_arr = [];
$parents_str = ''; $parents_str = '';
$date_offset = ""; $date_offset = "";
$items = array(); $items = [];
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach ($r as $rr) { foreach ($r as $rr) {
if (!in_array($rr['item_id'], $parents_arr)) { if (!in_array($rr['item_id'], $parents_arr)) {
@ -901,10 +901,10 @@ function networkThreadedView(App $a, $update = 0) {
// at the top level network page just mark everything seen. // at the top level network page just mark everything seen.
if (!$gid && !$cid && !$star) { if (!$gid && !$cid && !$star) {
$condition = array('unseen' => true, 'uid' => local_user()); $condition = ['unseen' => true, 'uid' => local_user()];
networkSetSeen($condition); networkSetSeen($condition);
} elseif ($parents_str) { } elseif ($parents_str) {
$condition = array("`uid` = ? AND `unseen` AND `parent` IN (" . dbesc($parents_str) . ")", local_user()); $condition = ["`uid` = ? AND `unseen` AND `parent` IN (" . dbesc($parents_str) . ")", local_user()];
networkSetSeen($condition); networkSetSeen($condition);
} }
@ -936,80 +936,80 @@ function network_tabs(App $a)
$cmd = $a->cmd; $cmd = $a->cmd;
// tabs // tabs
$tabs = array( $tabs = [
array( [
'label' => t('Commented Order'), 'label' => t('Commented Order'),
'url' => str_replace('/new', '', $cmd) . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 'url' => str_replace('/new', '', $cmd) . '?f=&order=comment' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
'sel' => $all_active, 'sel' => $all_active,
'title' => t('Sort by Comment Date'), 'title' => t('Sort by Comment Date'),
'id' => 'commented-order-tab', 'id' => 'commented-order-tab',
'accesskey' => "e", 'accesskey' => "e",
), ],
array( [
'label' => t('Posted Order'), 'label' => t('Posted Order'),
'url' => str_replace('/new', '', $cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''), 'url' => str_replace('/new', '', $cmd) . '?f=&order=post' . ((x($_GET,'cid')) ? '&cid=' . $_GET['cid'] : ''),
'sel' => $postord_active, 'sel' => $postord_active,
'title' => t('Sort by Post Date'), 'title' => t('Sort by Post Date'),
'id' => 'posted-order-tab', 'id' => 'posted-order-tab',
'accesskey' => "t", 'accesskey' => "t",
), ],
); ];
if (Feature::isEnabled(local_user(),'personal_tab')) { if (Feature::isEnabled(local_user(),'personal_tab')) {
$tabs[] = array( $tabs[] = [
'label' => t('Personal'), 'label' => t('Personal'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1',
'sel' => $conv_active, 'sel' => $conv_active,
'title' => t('Posts that mention or involve you'), 'title' => t('Posts that mention or involve you'),
'id' => 'personal-tab', 'id' => 'personal-tab',
'accesskey' => "r", 'accesskey' => "r",
); ];
} }
if (Feature::isEnabled(local_user(),'new_tab')) { if (Feature::isEnabled(local_user(),'new_tab')) {
$tabs[] = array( $tabs[] = [
'label' => t('New'), 'label' => t('New'),
'url' => 'network/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''), 'url' => 'network/new' . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : ''),
'sel' => $new_active, 'sel' => $new_active,
'title' => t('Activity Stream - by date'), 'title' => t('Activity Stream - by date'),
'id' => 'activitiy-by-date-tab', 'id' => 'activitiy-by-date-tab',
'accesskey' => "w", 'accesskey' => "w",
); ];
} }
if (Feature::isEnabled(local_user(),'link_tab')) { if (Feature::isEnabled(local_user(),'link_tab')) {
$tabs[] = array( $tabs[] = [
'label' => t('Shared Links'), 'label' => t('Shared Links'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1',
'sel' => $bookmarked_active, 'sel' => $bookmarked_active,
'title' => t('Interesting Links'), 'title' => t('Interesting Links'),
'id' => 'shared-links-tab', 'id' => 'shared-links-tab',
'accesskey' => "b", 'accesskey' => "b",
); ];
} }
if (Feature::isEnabled(local_user(),'star_posts')) { if (Feature::isEnabled(local_user(),'star_posts')) {
$tabs[] = array( $tabs[] = [
'label' => t('Starred'), 'label' => t('Starred'),
'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1', 'url' => str_replace('/new', '', $cmd) . ((x($_GET,'cid')) ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1',
'sel' => $starred_active, 'sel' => $starred_active,
'title' => t('Favourite Posts'), 'title' => t('Favourite Posts'),
'id' => 'starred-posts-tab', 'id' => 'starred-posts-tab',
'accesskey' => "m", 'accesskey' => "m",
); ];
} }
// save selected tab, but only if not in file mode // save selected tab, but only if not in file mode
if (!x($_GET,'file')) { if (!x($_GET,'file')) {
PConfig::set(local_user(), 'network.view','tab.selected',array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active)); PConfig::set(local_user(), 'network.view','tab.selected',[$all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active]);
} }
$arr = array('tabs' => $tabs); $arr = ['tabs' => $tabs];
call_hooks('network_tabs', $arr); call_hooks('network_tabs', $arr);
$tpl = get_markup_template('common_tabs.tpl'); $tpl = get_markup_template('common_tabs.tpl');
return replace_macros($tpl, array('$tabs' => $arr['tabs'])); return replace_macros($tpl, ['$tabs' => $arr['tabs']]);
// --- end item filter tabs // --- end item filter tabs
} }

View file

@ -12,8 +12,8 @@ use Friendica\Core\Config;
require_once 'include/plugin.php'; require_once 'include/plugin.php';
function nodeinfo_wellknown(App $a) { function nodeinfo_wellknown(App $a) {
$nodeinfo = array('links' => array(array('rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0', $nodeinfo = ['links' => [['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0',
'href' => System::baseUrl().'/nodeinfo/1.0'))); 'href' => System::baseUrl().'/nodeinfo/1.0']]];
header('Content-type: application/json; charset=utf-8'); header('Content-type: application/json; charset=utf-8');
echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES); echo json_encode($nodeinfo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
@ -33,13 +33,13 @@ function nodeinfo_init(App $a) {
$smtp = (function_exists('imap_open') && !Config::get('system', 'imap_disabled') && !Config::get('system', 'dfrn_only')); $smtp = (function_exists('imap_open') && !Config::get('system', 'imap_disabled') && !Config::get('system', 'dfrn_only'));
$nodeinfo = array(); $nodeinfo = [];
$nodeinfo['version'] = '1.0'; $nodeinfo['version'] = '1.0';
$nodeinfo['software'] = array('name' => 'friendica', 'version' => FRIENDICA_VERSION.'-'.DB_UPDATE_VERSION); $nodeinfo['software'] = ['name' => 'friendica', 'version' => FRIENDICA_VERSION.'-'.DB_UPDATE_VERSION];
$nodeinfo['protocols'] = array(); $nodeinfo['protocols'] = [];
$nodeinfo['protocols']['inbound'] = array(); $nodeinfo['protocols']['inbound'] = [];
$nodeinfo['protocols']['outbound'] = array(); $nodeinfo['protocols']['outbound'] = [];
if (Config::get('system', 'diaspora_enabled')) { if (Config::get('system', 'diaspora_enabled')) {
$nodeinfo['protocols']['inbound'][] = 'diaspora'; $nodeinfo['protocols']['inbound'][] = 'diaspora';
@ -54,21 +54,21 @@ function nodeinfo_init(App $a) {
$nodeinfo['protocols']['outbound'][] = 'gnusocial'; $nodeinfo['protocols']['outbound'][] = 'gnusocial';
} }
$nodeinfo['services'] = array(); $nodeinfo['services'] = [];
$nodeinfo['services']['inbound'] = array(); $nodeinfo['services']['inbound'] = [];
$nodeinfo['services']['outbound'] = array(); $nodeinfo['services']['outbound'] = [];
$nodeinfo['usage'] = array(); $nodeinfo['usage'] = [];
$nodeinfo['openRegistrations'] = ($a->config['register_policy'] != 0); $nodeinfo['openRegistrations'] = ($a->config['register_policy'] != 0);
$nodeinfo['metadata'] = array('nodeName' => $a->config['sitename']); $nodeinfo['metadata'] = ['nodeName' => $a->config['sitename']];
if (Config::get('system', 'nodeinfo')) { if (Config::get('system', 'nodeinfo')) {
$nodeinfo['usage']['users'] = array('total' => (int)Config::get('nodeinfo', 'total_users'), $nodeinfo['usage']['users'] = ['total' => (int)Config::get('nodeinfo', 'total_users'),
'activeHalfyear' => (int)Config::get('nodeinfo', 'active_users_halfyear'), 'activeHalfyear' => (int)Config::get('nodeinfo', 'active_users_halfyear'),
'activeMonth' => (int)Config::get('nodeinfo', 'active_users_monthly')); 'activeMonth' => (int)Config::get('nodeinfo', 'active_users_monthly')];
$nodeinfo['usage']['localPosts'] = (int)Config::get('nodeinfo', 'local_posts'); $nodeinfo['usage']['localPosts'] = (int)Config::get('nodeinfo', 'local_posts');
$nodeinfo['usage']['localComments'] = (int)Config::get('nodeinfo', 'local_comments'); $nodeinfo['usage']['localComments'] = (int)Config::get('nodeinfo', 'local_comments');
@ -159,7 +159,7 @@ function nodeinfo_cron() {
$plugin = 'statistics_json'; $plugin = 'statistics_json';
$plugins = Config::get('system', 'addon'); $plugins = Config::get('system', 'addon');
$plugins_arr = array(); $plugins_arr = [];
if ($plugins) { if ($plugins) {
$plugins_arr = explode(',',str_replace(' ', '',$plugins)); $plugins_arr = explode(',',str_replace(' ', '',$plugins));

View file

@ -39,7 +39,7 @@ function nogroup_content(App $a)
foreach ($r as $rr) { foreach ($r as $rr) {
$contact_details = Contact::getDetailsByURL($rr['url'], local_user(), $rr); $contact_details = Contact::getDetailsByURL($rr['url'], local_user(), $rr);
$contacts[] = array( $contacts[] = [
'img_hover' => t('Visit %s\'s profile [%s]', $contact_details['name'], $rr['url']), 'img_hover' => t('Visit %s\'s profile [%s]', $contact_details['name'], $rr['url']),
'edit_hover' => t('Edit contact'), 'edit_hover' => t('Edit contact'),
'photo_menu' => Contact::photoMenu($rr), 'photo_menu' => Contact::photoMenu($rr),
@ -53,17 +53,17 @@ function nogroup_content(App $a)
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']), 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
'url' => $rr['url'], 'url' => $rr['url'],
'network' => ContactSelector::networkToName($rr['network'], $rr['url']), 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
); ];
} }
} }
$tpl = get_markup_template("nogroup-template.tpl"); $tpl = get_markup_template("nogroup-template.tpl");
$o = replace_macros( $o = replace_macros(
$tpl, $tpl,
array( [
'$header' => t('Contacts who are not members of a group'), '$header' => t('Contacts who are not members of a group'),
'$contacts' => $contacts, '$contacts' => $contacts,
'$paginate' => paginate($a)) '$paginate' => paginate($a)]
); );
return $o; return $o;

View file

@ -25,18 +25,18 @@ function noscrape_init(App $a)
if (!$a->profile['net-publish'] || $a->profile['hidewall']) { if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
header('Content-type: application/json; charset=utf-8'); header('Content-type: application/json; charset=utf-8');
$json_info = array("hide" => true); $json_info = ["hide" => true];
echo json_encode($json_info); echo json_encode($json_info);
exit; exit;
} }
$keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : ''); $keywords = ((x($a->profile, 'pub_keywords')) ? $a->profile['pub_keywords'] : '');
$keywords = str_replace(array('#',',',' ',',,'), array('',' ',',',','), $keywords); $keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords);
$keywords = explode(',', $keywords); $keywords = explode(',', $keywords);
$contactPhoto = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]); $contactPhoto = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
$json_info = array( $json_info = [
'fn' => $a->profile['name'], 'fn' => $a->profile['name'],
'addr' => $a->profile['addr'], 'addr' => $a->profile['addr'],
'nick' => $which, 'nick' => $which,
@ -46,7 +46,7 @@ function noscrape_init(App $a)
'comm' => (x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY), 'comm' => (x($a->profile, 'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
'photo' => $contactPhoto["photo"], 'photo' => $contactPhoto["photo"],
'tags' => $keywords 'tags' => $keywords
); ];
if (is_array($a->profile) && !$a->profile['hide-friends']) { if (is_array($a->profile) && !$a->profile['hide-friends']) {
/// @todo What should this value tell us? /// @todo What should this value tell us?
@ -86,14 +86,14 @@ function noscrape_init(App $a)
$json_info["last-activity"] = date("o-W", $last_active); $json_info["last-activity"] = date("o-W", $last_active);
//These are optional fields. //These are optional fields.
$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about'); $profile_fields = ['pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about'];
foreach ($profile_fields as $field) { foreach ($profile_fields as $field) {
if (!empty($a->profile[$field])) { if (!empty($a->profile[$field])) {
$json_info["$field"] = $a->profile[$field]; $json_info["$field"] = $a->profile[$field];
} }
} }
$dfrn_pages = array('request', 'confirm', 'notify', 'poll'); $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
foreach ($dfrn_pages as $dfrn) { foreach ($dfrn_pages as $dfrn) {
$json_info["dfrn-{$dfrn}"] = System::baseUrl()."/dfrn_{$dfrn}/{$which}"; $json_info["dfrn-{$dfrn}"] = System::baseUrl()."/dfrn_{$dfrn}/{$which}";
} }

View file

@ -34,7 +34,7 @@ function notes_content(App $a, $update = false) {
require_once('include/security.php'); require_once('include/security.php');
require_once('include/conversation.php'); require_once('include/conversation.php');
require_once('include/acl_selectors.php'); require_once('include/acl_selectors.php');
$groups = array(); $groups = [];
$o = ''; $o = '';
@ -55,7 +55,7 @@ function notes_content(App $a, $update = false) {
$commpage = false; $commpage = false;
$commvisitor = false; $commvisitor = false;
$x = array( $x = [
'is_owner' => $is_owner, 'is_owner' => $is_owner,
'allow_location' => (($a->user['allow_location']) ? true : false), 'allow_location' => (($a->user['allow_location']) ? true : false),
'default_location' => $a->user['default-location'], 'default_location' => $a->user['default-location'],
@ -67,7 +67,7 @@ function notes_content(App $a, $update = false) {
'profile_uid' => local_user(), 'profile_uid' => local_user(),
'button' => t('Save'), 'button' => t('Save'),
'acl_data' => '', 'acl_data' => '',
); ];
$o .= status_editor($a,$x,$a->contact['id']); $o .= status_editor($a,$x,$a->contact['id']);
@ -106,7 +106,7 @@ function notes_content(App $a, $update = false) {
); );
$parents_arr = array(); $parents_arr = [];
$parents_str = ''; $parents_str = '';
if (DBM::is_result($r)) { if (DBM::is_result($r)) {

View file

@ -86,7 +86,7 @@ function notifications_content(App $a) {
$o = ''; $o = '';
// Get the nav tabs for the notification pages // Get the nav tabs for the notification pages
$tabs = $nm->getTabs(); $tabs = $nm->getTabs();
$notif_content = array(); $notif_content = [];
// Notification results per page // Notification results per page
$perpage = 20; $perpage = 20;
@ -149,10 +149,10 @@ function notifications_content(App $a) {
$tpl = get_markup_template("intros.tpl"); $tpl = get_markup_template("intros.tpl");
// The link to switch between ignored and normal connection requests // The link to switch between ignored and normal connection requests
$notif_show_lnk = array( $notif_show_lnk = [
'href' => (!$all ? 'notifications/intros/all' : 'notifications/intros' ), 'href' => (!$all ? 'notifications/intros/all' : 'notifications/intros' ),
'text' => (!$all ? t('Show Ignored Requests') : t('Hide Ignored Requests')) 'text' => (!$all ? t('Show Ignored Requests') : t('Hide Ignored Requests'))
); ];
// Loop through all introduction notifications.This creates an array with the output html for each // Loop through all introduction notifications.This creates an array with the output html for each
// introduction // introduction
@ -162,7 +162,7 @@ function notifications_content(App $a) {
// We have to distinguish between these two because they use different data. // We have to distinguish between these two because they use different data.
switch ($it['label']) { switch ($it['label']) {
case 'friend_suggestion': case 'friend_suggestion':
$notif_content[] = replace_macros($sugg, array( $notif_content[] = replace_macros($sugg, [
'$str_notifytype' => t('Notification type: '), '$str_notifytype' => t('Notification type: '),
'$notify_type' => $it['notify_type'], '$notify_type' => $it['notify_type'],
'$intro_id' => $it['intro_id'], '$intro_id' => $it['intro_id'],
@ -171,8 +171,8 @@ function notifications_content(App $a) {
'$photo' => $it['photo'], '$photo' => $it['photo'],
'$fullname' => $it['name'], '$fullname' => $it['name'],
'$url' => $it['url'], '$url' => $it['url'],
'$hidden' => array('hidden', t('Hide this contact from others'), ($it['hidden'] == 1), ''), '$hidden' => ['hidden', t('Hide this contact from others'), ($it['hidden'] == 1), ''],
'$activity' => array('activity', t('Post a new friend activity'), $it['post_newfriend'], t('if applicable')), '$activity' => ['activity', t('Post a new friend activity'), $it['post_newfriend'], t('if applicable')],
'$knowyou' => $it['knowyou'], '$knowyou' => $it['knowyou'],
'$approve' => t('Approve'), '$approve' => t('Approve'),
@ -180,7 +180,7 @@ function notifications_content(App $a) {
'$request' => $it['request'], '$request' => $it['request'],
'$ignore' => t('Ignore'), '$ignore' => t('Ignore'),
'$discard' => t('Discard'), '$discard' => t('Discard'),
)); ]);
break; break;
// Normal connection requests // Normal connection requests
@ -207,7 +207,7 @@ function notifications_content(App $a) {
} }
} }
$dfrn_text = replace_macros($dfrn_tpl,array( $dfrn_text = replace_macros($dfrn_tpl,[
'$intro_id' => $it['intro_id'], '$intro_id' => $it['intro_id'],
'$friend_selected' => $friend_selected, '$friend_selected' => $friend_selected,
'$fan_selected' => $fan_selected, '$fan_selected' => $fan_selected,
@ -216,7 +216,7 @@ function notifications_content(App $a) {
'$approve_as3' => $helptext3, '$approve_as3' => $helptext3,
'$as_friend' => t('Friend'), '$as_friend' => t('Friend'),
'$as_fan' => (($it['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Subscriber')) '$as_fan' => (($it['network'] == NETWORK_DIASPORA) ? t('Sharer') : t('Subscriber'))
)); ]);
$header = $it["name"]; $header = $it["name"];
@ -231,7 +231,7 @@ function notifications_content(App $a) {
$discard = ''; $discard = '';
} }
$notif_content[] = replace_macros($tpl, array( $notif_content[] = replace_macros($tpl, [
'$header' => htmlentities($header), '$header' => htmlentities($header),
'$str_notifytype' => t('Notification type: '), '$str_notifytype' => t('Notification type: '),
'$notify_type' => $it['notify_type'], '$notify_type' => $it['notify_type'],
@ -250,8 +250,8 @@ function notifications_content(App $a) {
'$lbl_keywords' => t('Tags:'), '$lbl_keywords' => t('Tags:'),
'$gender' => $it['gender'], '$gender' => $it['gender'],
'$lbl_gender' => t('Gender:'), '$lbl_gender' => t('Gender:'),
'$hidden' => array('hidden', t('Hide this contact from others'), ($it['hidden'] == 1), ''), '$hidden' => ['hidden', t('Hide this contact from others'), ($it['hidden'] == 1), ''],
'$activity' => array('activity', t('Post a new friend activity'), $it['post_newfriend'], t('if applicable')), '$activity' => ['activity', t('Post a new friend activity'), $it['post_newfriend'], t('if applicable')],
'$url' => $it['url'], '$url' => $it['url'],
'$zrl' => $it['zrl'], '$zrl' => $it['zrl'],
'$lbl_url' => t('Profile URL'), '$lbl_url' => t('Profile URL'),
@ -265,7 +265,7 @@ function notifications_content(App $a) {
'$ignore' => t('Ignore'), '$ignore' => t('Ignore'),
'$discard' => $discard, '$discard' => $discard,
)); ]);
break; break;
} }
} }
@ -295,7 +295,7 @@ function notifications_content(App $a) {
$tpl_var_name = 'tpl_item_'.$it['label']; $tpl_var_name = 'tpl_item_'.$it['label'];
$tpl_notif = get_markup_template($$tpl_var_name); $tpl_notif = get_markup_template($$tpl_var_name);
$notif_content[] = replace_macros($tpl_notif,array( $notif_content[] = replace_macros($tpl_notif,[
'$item_label' => $it['label'], '$item_label' => $it['label'],
'$item_link' => $it['link'], '$item_link' => $it['link'],
'$item_image' => $it['image'], '$item_image' => $it['image'],
@ -304,16 +304,16 @@ function notifications_content(App $a) {
'$item_when' => $it['when'], '$item_when' => $it['when'],
'$item_ago' => $it['ago'], '$item_ago' => $it['ago'],
'$item_seen' => $it['seen'], '$item_seen' => $it['seen'],
)); ]);
} }
// It doesn't make sense to show the Show unread / Show all link visible if the user is on the // It doesn't make sense to show the Show unread / Show all link visible if the user is on the
// "Show all" page and there are no notifications. So we will hide it. // "Show all" page and there are no notifications. So we will hide it.
if($show == 0 || intval($show) && $notifs['total'] > 0) { if($show == 0 || intval($show) && $notifs['total'] > 0) {
$notif_show_lnk = array( $notif_show_lnk = [
'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ), 'href' => ($show ? 'notifications/'.$notifs['ident'] : 'notifications/'.$notifs['ident'].'?show=all' ),
'text' => ($show ? t('Show unread') : t('Show all')), 'text' => ($show ? t('Show unread') : t('Show all')),
); ];
} }
// Output if there aren't any notifications available // Output if there aren't any notifications available
@ -321,14 +321,14 @@ function notifications_content(App $a) {
$notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']); $notif_nocontent = sprintf( t('No more %s notifications.'), $notifs['ident']);
} }
$o .= replace_macros($notif_tpl, array( $o .= replace_macros($notif_tpl, [
'$notif_header' => $notif_header, '$notif_header' => $notif_header,
'$tabs' => $tabs, '$tabs' => $tabs,
'$notif_content' => $notif_content, '$notif_content' => $notif_content,
'$notif_nocontent' => $notif_nocontent, '$notif_nocontent' => $notif_nocontent,
'$notif_show_lnk' => $notif_show_lnk, '$notif_show_lnk' => $notif_show_lnk,
'$notif_paginate' => paginate($a) '$notif_paginate' => paginate($a)
)); ]);
return $o; return $o;
} }

View file

@ -37,7 +37,7 @@ function notify_init(App $a) {
if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) { if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
$r = $nm->setAllSeen(); $r = $nm->setAllSeen();
$j = json_encode(array('result' => ($r) ? 'success' : 'fail')); $j = json_encode(['result' => ($r) ? 'success' : 'fail']);
echo $j; echo $j;
killme(); killme();
} }
@ -56,25 +56,25 @@ function notify_content(App $a) {
$not_tpl = get_markup_template('notify.tpl'); $not_tpl = get_markup_template('notify.tpl');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$r = $nm->getAll(array('seen'=>0)); $r = $nm->getAll(['seen'=>0]);
if (DBM::is_result($r) > 0) { if (DBM::is_result($r) > 0) {
foreach ($r as $it) { foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array( $notif_content .= replace_macros($not_tpl,[
'$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'], '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
'$item_image' => $it['photo'], '$item_image' => $it['photo'],
'$item_text' => strip_tags(bbcode($it['msg'])), '$item_text' => strip_tags(bbcode($it['msg'])),
'$item_when' => relative_date($it['date']) '$item_when' => relative_date($it['date'])
)); ]);
} }
} else { } else {
$notif_content .= t('No more system notifications.'); $notif_content .= t('No more system notifications.');
} }
$o .= replace_macros($notif_tpl, array( $o .= replace_macros($notif_tpl, [
'$notif_header' => t('System Notifications'), '$notif_header' => t('System Notifications'),
'$tabs' => false, // $tabs, '$tabs' => false, // $tabs,
'$notif_content' => $notif_content, '$notif_content' => $notif_content,
)); ]);
return $o; return $o;

View file

@ -9,7 +9,7 @@ function oexchange_init(App $a) {
if (($a->argc > 1) && ($a->argv[1] === 'xrd')) { if (($a->argc > 1) && ($a->argv[1] === 'xrd')) {
$tpl = get_markup_template('oexchange_xrd.tpl'); $tpl = get_markup_template('oexchange_xrd.tpl');
$o = replace_macros($tpl, array('$base' => System::baseUrl())); $o = replace_macros($tpl, ['$base' => System::baseUrl()]);
echo $o; echo $o;
killme(); killme();
} }
@ -44,7 +44,7 @@ function oexchange_content(App $a) {
require_once('include/html2bbcode.php'); require_once('include/html2bbcode.php');
$post = array(); $post = [];
$post['profile_uid'] = local_user(); $post['profile_uid'] = local_user();
$post['return'] = '/oexchange/done' ; $post['return'] = '/oexchange/done' ;

View file

@ -9,10 +9,10 @@ function opensearch_content(App $a) {
header("Content-type: application/opensearchdescription+xml"); header("Content-type: application/opensearchdescription+xml");
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$nodename' => $a->get_hostname(), '$nodename' => $a->get_hostname(),
)); ]);
echo $o; echo $o;

View file

@ -59,10 +59,10 @@ function parse_url_content(App $a) {
// the URL with the corresponding BBCode media tag // the URL with the corresponding BBCode media tag
$redirects = 0; $redirects = 0;
// Fetch the header of the URL // Fetch the header of the URL
$result = z_fetch_url($url, false, $redirects, array("novalidate" => true, "nobody" => true)); $result = z_fetch_url($url, false, $redirects, ["novalidate" => true, "nobody" => true]);
if($result["success"]) { if($result["success"]) {
// Convert the header fields into an array // Convert the header fields into an array
$hdrs = array(); $hdrs = [];
$h = explode("\n", $result["header"]); $h = explode("\n", $result["header"]);
foreach ($h as $l) { foreach ($h as $l) {
list($k,$v) = array_map("trim", explode(":", trim($l), 2)); list($k,$v) = array_map("trim", explode(":", trim($l), 2));
@ -89,7 +89,7 @@ function parse_url_content(App $a) {
$template = "[bookmark=%s]%s[/bookmark]%s"; $template = "[bookmark=%s]%s[/bookmark]%s";
$arr = array("url" => $url, "text" => ""); $arr = ["url" => $url, "text" => ""];
call_hooks("parse_link", $arr); call_hooks("parse_link", $arr);
@ -102,7 +102,7 @@ function parse_url_content(App $a) {
// need to parse the url for content. // need to parse the url for content.
if ($url && $title && $text) { if ($url && $title && $text) {
$title = str_replace(array("\r","\n"),array("",""),$title); $title = str_replace(["\r","\n"],["",""],$title);
$text = "[quote]" . trim($text) . "[/quote]" . $br; $text = "[quote]" . trim($text) . "[/quote]" . $br;

View file

@ -71,7 +71,7 @@ function photo_init(App $a)
break; break;
} }
$uid = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $person); $uid = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $person);
foreach (Image::supportedTypes() AS $m => $e) { foreach (Image::supportedTypes() AS $m => $e) {
$uid = str_replace('.' . $e, '', $uid); $uid = str_replace('.' . $e, '', $uid);
@ -92,7 +92,7 @@ function photo_init(App $a)
} else { } else {
// Other photos // Other photos
$resolution = 0; $resolution = 0;
$photo = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $photo); $photo = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $photo);
foreach (Image::supportedTypes() AS $m => $e) { foreach (Image::supportedTypes() AS $m => $e) {
$photo = str_replace('.' . $e, '', $photo); $photo = str_replace('.' . $e, '', $photo);

View file

@ -55,20 +55,20 @@ function photos_init(App $a) {
$tpl = get_markup_template("vcard-widget.tpl"); $tpl = get_markup_template("vcard-widget.tpl");
$vcard_widget = replace_macros($tpl, array( $vcard_widget = replace_macros($tpl, [
'$name' => $profile['name'], '$name' => $profile['name'],
'$photo' => $profile['photo'], '$photo' => $profile['photo'],
'$addr' => defaults($profile, 'addr', ''), '$addr' => defaults($profile, 'addr', ''),
'$account_type' => $account_type, '$account_type' => $account_type,
'$pdesc' => defaults($profile, 'pdesc', ''), '$pdesc' => defaults($profile, 'pdesc', ''),
)); ]);
$albums = Photo::getAlbums($a->data['user']['uid']); $albums = Photo::getAlbums($a->data['user']['uid']);
$albums_visible = ((intval($a->data['user']['hidewall']) && !local_user() && !remote_user()) ? false : true); $albums_visible = ((intval($a->data['user']['hidewall']) && !local_user() && !remote_user()) ? false : true);
// add various encodings to the array so we can just loop through and pick them out in a template // add various encodings to the array so we can just loop through and pick them out in a template
$ret = array('success' => false); $ret = ['success' => false];
if ($albums) { if ($albums) {
$a->data['albums'] = $albums; $a->data['albums'] = $albums;
@ -76,18 +76,18 @@ function photos_init(App $a) {
$ret['success'] = true; $ret['success'] = true;
} }
$ret['albums'] = array(); $ret['albums'] = [];
foreach ($albums as $k => $album) { foreach ($albums as $k => $album) {
//hide profile photos to others //hide profile photos to others
if (!$is_owner && !remote_user() && ($album['album'] == t('Profile Photos'))) if (!$is_owner && !remote_user() && ($album['album'] == t('Profile Photos')))
continue; continue;
$entry = array( $entry = [
'text' => $album['album'], 'text' => $album['album'],
'total' => $album['total'], 'total' => $album['total'],
'url' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']), 'url' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album['album']),
'urlencode' => urlencode($album['album']), 'urlencode' => urlencode($album['album']),
'bin2hex' => bin2hex($album['album']) 'bin2hex' => bin2hex($album['album'])
); ];
$ret['albums'][] = $entry; $ret['albums'][] = $entry;
} }
} }
@ -97,15 +97,15 @@ function photos_init(App $a) {
} }
if ($ret['success']) { if ($ret['success']) {
$photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'), array( $photo_albums_widget = replace_macros(get_markup_template('photo_albums.tpl'), [
'$nick' => $a->data['user']['nickname'], '$nick' => $a->data['user']['nickname'],
'$title' => t('Photo Albums'), '$title' => t('Photo Albums'),
'$recent' => t('Recent Photos'), '$recent' => t('Recent Photos'),
'$albums' => $ret['albums'], '$albums' => $ret['albums'],
'$baseurl' => System::baseUrl(), '$baseurl' => System::baseUrl(),
'$upload' => array(t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload'), '$upload' => [t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload'],
'$can_post' => $can_post '$can_post' => $can_post
)); ]);
} }
@ -116,9 +116,9 @@ function photos_init(App $a) {
$a->page['aside'] .= $photo_albums_widget; $a->page['aside'] .= $photo_albums_widget;
$tpl = get_markup_template("photos_head.tpl"); $tpl = get_markup_template("photos_head.tpl");
$a->page['htmlhead'] .= replace_macros($tpl,array( $a->page['htmlhead'] .= replace_macros($tpl,[
'$ispublic' => t('everybody') '$ispublic' => t('everybody')
)); ]);
} }
return; return;
@ -229,10 +229,10 @@ function photos_post(App $a)
// Check if we should do HTML-based delete confirmation // Check if we should do HTML-based delete confirmation
if (x($_REQUEST, 'confirm')) { if (x($_REQUEST, 'confirm')) {
$drop_url = $a->query_string; $drop_url = $a->query_string;
$extra_inputs = array( $extra_inputs = [
array('name' => 'albumname', 'value' => $_POST['albumname']), ['name' => 'albumname', 'value' => $_POST['albumname']],
); ];
$a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array( $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), [
'$method' => 'post', '$method' => 'post',
'$message' => t('Do you really want to delete this photo album and all its photos?'), '$message' => t('Do you really want to delete this photo album and all its photos?'),
'$extra_inputs' => $extra_inputs, '$extra_inputs' => $extra_inputs,
@ -240,12 +240,12 @@ function photos_post(App $a)
'$confirm_url' => $drop_url, '$confirm_url' => $drop_url,
'$confirm_name' => 'dropalbum', // Needed so that confirmation will bring us back into this if statement '$confirm_name' => 'dropalbum', // Needed so that confirmation will bring us back into this if statement
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
)); ]);
$a->error = 1; // Set $a->error so the other module functions don't execute $a->error = 1; // Set $a->error so the other module functions don't execute
return; return;
} }
$res = array(); $res = [];
// get the list of photos we are about to delete // get the list of photos we are about to delete
@ -321,15 +321,15 @@ function photos_post(App $a)
// Check if we should do HTML-based delete confirmation // Check if we should do HTML-based delete confirmation
if (x($_REQUEST, 'confirm')) { if (x($_REQUEST, 'confirm')) {
$drop_url = $a->query_string; $drop_url = $a->query_string;
$a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), array( $a->page['content'] = replace_macros(get_markup_template('confirm.tpl'), [
'$method' => 'post', '$method' => 'post',
'$message' => t('Do you really want to delete this photo?'), '$message' => t('Do you really want to delete this photo?'),
'$extra_inputs' => array(), '$extra_inputs' => [],
'$confirm' => t('Delete Photo'), '$confirm' => t('Delete Photo'),
'$confirm_url' => $drop_url, '$confirm_url' => $drop_url,
'$confirm_name' => 'delete', // Needed so that confirmation will bring us back into this if statement '$confirm_name' => 'delete', // Needed so that confirmation will bring us back into this if statement
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
)); ]);
$a->error = 1; // Set $a->error so the other module functions don't execute $a->error = 1; // Set $a->error so the other module functions don't execute
return; return;
} }
@ -489,7 +489,7 @@ function photos_post(App $a)
$title = ''; $title = '';
$uri = item_new_uri($a->get_hostname(),$page_owner_uid); $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
$arr = array(); $arr = [];
$arr['guid'] = get_guid(32); $arr['guid'] = get_guid(32);
$arr['uid'] = $page_owner_uid; $arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri; $arr['uri'] = $uri;
@ -541,7 +541,7 @@ function photos_post(App $a)
$rawtags = '#' . $rawtags; $rawtags = '#' . $rawtags;
} }
$taginfo = array(); $taginfo = [];
$tags = get_tags($rawtags); $tags = get_tags($rawtags);
if (count($tags)) { if (count($tags)) {
@ -566,7 +566,7 @@ function photos_post(App $a)
} }
} }
} }
$taginfo[] = array($newname, $profile, $salmon); $taginfo[] = [$newname, $profile, $salmon];
} else { } else {
$newname = $name; $newname = $name;
$alias = ''; $alias = '';
@ -611,9 +611,9 @@ function photos_post(App $a)
} }
if ($profile) { if ($profile) {
if (substr($notify, 0, 4) === 'cid:') { if (substr($notify, 0, 4) === 'cid:') {
$taginfo[] = array($newname, $profile, $notify, $r[0], '@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]'); $taginfo[] = [$newname, $profile, $notify, $r[0], '@[url=' . str_replace(',','%2c',$profile) . ']' . $newname . '[/url]'];
} else { } else {
$taginfo[] = array($newname, $profile, $notify, null, $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'); $taginfo[] = [$newname, $profile, $notify, null, $str_tags .= '@[url=' . $profile . ']' . $newname . '[/url]'];
} }
if (strlen($str_tags)) { if (strlen($str_tags)) {
$str_tags .= ','; $str_tags .= ',';
@ -667,7 +667,7 @@ function photos_post(App $a)
foreach ($taginfo as $tagged) { foreach ($taginfo as $tagged) {
$uri = item_new_uri($a->get_hostname(), $page_owner_uid); $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
$arr = array(); $arr = [];
$arr['guid'] = get_guid(32); $arr['guid'] = get_guid(32);
$arr['uid'] = $page_owner_uid; $arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri; $arr['uri'] = $uri;
@ -769,7 +769,7 @@ function photos_post(App $a)
$str_group_deny = perms2str(is_array($group_deny) ? $group_deny : explode(',', $group_deny)); $str_group_deny = perms2str(is_array($group_deny) ? $group_deny : explode(',', $group_deny));
$str_contact_deny = perms2str(is_array($contact_deny) ? $contact_deny : explode(',', $contact_deny)); $str_contact_deny = perms2str(is_array($contact_deny) ? $contact_deny : explode(',', $contact_deny));
$ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); $ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''];
call_hooks('photo_post_file', $ret); call_hooks('photo_post_file', $ret);
@ -899,7 +899,7 @@ function photos_post(App $a)
$lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']); $lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']);
} }
$arr = array(); $arr = [];
if ($lat && $lon) { if ($lat && $lon) {
$arr['coord'] = $lat . ' ' . $lon; $arr['coord'] = $lat . ' ' . $lon;
} }
@ -1101,16 +1101,16 @@ function photos_content(App $a)
$uploader = ''; $uploader = '';
$ret = array('post_url' => 'photos/' . $a->data['user']['nickname'], $ret = ['post_url' => 'photos/' . $a->data['user']['nickname'],
'addon_text' => $uploader, 'addon_text' => $uploader,
'default_upload' => true); 'default_upload' => true];
call_hooks('photo_upload_form',$ret); call_hooks('photo_upload_form',$ret);
$default_upload_box = replace_macros(get_markup_template('photos_default_uploader_box.tpl'), array()); $default_upload_box = replace_macros(get_markup_template('photos_default_uploader_box.tpl'), []);
$default_upload_submit = replace_macros(get_markup_template('photos_default_uploader_submit.tpl'), array( $default_upload_submit = replace_macros(get_markup_template('photos_default_uploader_submit.tpl'), [
'$submit' => t('Submit'), '$submit' => t('Submit'),
)); ]);
$usage_message = ''; $usage_message = '';
@ -1118,7 +1118,7 @@ function photos_content(App $a)
$aclselect_e = ($visitor ? '' : populate_acl($a->user)); $aclselect_e = ($visitor ? '' : populate_acl($a->user));
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$pagename' => t('Upload Photos'), '$pagename' => t('Upload Photos'),
'$sessid' => session_id(), '$sessid' => session_id(),
'$usage' => $usage_message, '$usage' => $usage_message,
@ -1138,7 +1138,7 @@ function photos_content(App $a)
'$group_perms' => t('Show to Groups'), '$group_perms' => t('Show to Groups'),
'$contact_perms' => t('Show to Contacts'), '$contact_perms' => t('Show to Contacts'),
'$return_path' => $a->query_string, '$return_path' => $a->query_string,
)); ]);
return $o; return $o;
} }
@ -1184,29 +1184,29 @@ function photos_content(App $a)
$album_e = $album; $album_e = $album;
$o .= replace_macros($edit_tpl,array( $o .= replace_macros($edit_tpl,[
'$nametext' => t('New album name: '), '$nametext' => t('New album name: '),
'$nickname' => $a->data['user']['nickname'], '$nickname' => $a->data['user']['nickname'],
'$album' => $album_e, '$album' => $album_e,
'$hexalbum' => bin2hex($album), '$hexalbum' => bin2hex($album),
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$dropsubmit' => t('Delete Album') '$dropsubmit' => t('Delete Album')
)); ]);
} }
} }
} else { } else {
if (($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos')) && $can_post) { if (($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos')) && $can_post) {
$edit = array(t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'); $edit = [t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'];
} }
} }
if ($order_field === 'posted') { if ($order_field === 'posted') {
$order = array(t('Show Newest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album)); $order = [t('Show Newest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album)];
} else { } else {
$order = array(t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted'); $order = [t('Show Oldest First'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '?f=&order=posted'];
} }
$photos = array(); $photos = [];
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
// "Twist" is only used for the duepunto theme with style "slackr" // "Twist" is only used for the duepunto theme with style "slackr"
@ -1219,7 +1219,7 @@ function photos_content(App $a)
$imgalt_e = $rr['filename']; $imgalt_e = $rr['filename'];
$desc_e = $rr['desc']; $desc_e = $rr['desc'];
$photos[] = array( $photos[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4), 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'] 'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id']
@ -1230,20 +1230,20 @@ function photos_content(App $a)
'desc'=> $desc_e, 'desc'=> $desc_e,
'ext' => $ext, 'ext' => $ext,
'hash'=> $rr['resource-id'], 'hash'=> $rr['resource-id'],
); ];
} }
} }
$tpl = get_markup_template('photo_album.tpl'); $tpl = get_markup_template('photo_album.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$photos' => $photos, '$photos' => $photos,
'$album' => $album, '$album' => $album,
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => array(t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)), '$upload' => [t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)],
'$order' => $order, '$order' => $order,
'$edit' => $edit, '$edit' => $edit,
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ]);
return $o; return $o;
@ -1329,10 +1329,10 @@ function photos_content(App $a)
$lock = null; $lock = null;
if ($can_post && ($ph[0]['uid'] == $owner_uid)) { if ($can_post && ($ph[0]['uid'] == $owner_uid)) {
$tools = array( $tools = [
'edit' => array('photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))), 'edit' => ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))],
'profile'=>array('profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')), 'profile'=>['profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')],
); ];
// lock // lock
$lock = ( ( ($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid']) $lock = ( ( ($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
@ -1345,16 +1345,16 @@ function photos_content(App $a)
if ( $cmd === 'edit') { if ( $cmd === 'edit') {
$tpl = get_markup_template('photo_edit_head.tpl'); $tpl = get_markup_template('photo_edit_head.tpl');
$a->page['htmlhead'] .= replace_macros($tpl,array( $a->page['htmlhead'] .= replace_macros($tpl,[
'$prevlink' => $prevlink, '$prevlink' => $prevlink,
'$nextlink' => $nextlink '$nextlink' => $nextlink
)); ]);
} }
if ($prevlink) if ($prevlink)
$prevlink = array($prevlink, '<div class="icon prev"></div>') ; $prevlink = [$prevlink, '<div class="icon prev"></div>'] ;
$photo = array( $photo = [
'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']], 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
'title'=> t('View Full Size'), 'title'=> t('View Full Size'),
'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis'), 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?f=&_u=' . datetime_convert('','','','ymdhis'),
@ -1362,10 +1362,10 @@ function photos_content(App $a)
'width' => $hires['width'], 'width' => $hires['width'],
'album' => $hires['album'], 'album' => $hires['album'],
'filename' => $hires['filename'], 'filename' => $hires['filename'],
); ];
if ($nextlink) { if ($nextlink) {
$nextlink = array($nextlink, '<div class="icon next"></div>'); $nextlink = [$nextlink, '<div class="icon next"></div>'];
} }
@ -1447,7 +1447,7 @@ function photos_content(App $a)
} }
$tag_str .= bbcode($t); $tag_str .= bbcode($t);
} }
$tags = array(t('Tags: '), $tag_str); $tags = [t('Tags: '), $tag_str];
if ($cmd === 'edit') { if ($cmd === 'edit') {
$tags[] = 'tagrm/' . $link_item['id']; $tags[] = 'tagrm/' . $link_item['id'];
$tags[] = t('[Remove any tag]'); $tags[] = t('[Remove any tag]');
@ -1463,14 +1463,14 @@ function photos_content(App $a)
$caption_e = $ph[0]['desc']; $caption_e = $ph[0]['desc'];
$aclselect_e = populate_acl($ph[0]); $aclselect_e = populate_acl($ph[0]);
$edit = replace_macros($edit_tpl, array( $edit = replace_macros($edit_tpl, [
'$id' => $ph[0]['id'], '$id' => $ph[0]['id'],
'$album' => array('albname', t('New album name'), $album_e,''), '$album' => ['albname', t('New album name'), $album_e,''],
'$caption' => array('desc', t('Caption'), $caption_e, ''), '$caption' => ['desc', t('Caption'), $caption_e, ''],
'$tags' => array('newtag', t('Add a Tag'), "", t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')), '$tags' => ['newtag', t('Add a Tag'), "", t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
'$rotate_none' => array('rotate', t('Do not rotate'),0,'', true), '$rotate_none' => ['rotate', t('Do not rotate'),0,'', true],
'$rotate_cw' => array('rotate', t('Rotate CW (right)'),1,''), '$rotate_cw' => ['rotate', t('Rotate CW (right)'),1,''],
'$rotate_ccw' => array('rotate', t('Rotate CCW (left)'),2,''), '$rotate_ccw' => ['rotate', t('Rotate CCW (left)'),2,''],
'$nickname' => $a->data['user']['nickname'], '$nickname' => $a->data['user']['nickname'],
'$resource_id' => $ph[0]['resource-id'], '$resource_id' => $ph[0]['resource-id'],
@ -1485,7 +1485,7 @@ function photos_content(App $a)
'$group_perms' => t('Show to Groups'), '$group_perms' => t('Show to Groups'),
'$contact_perms' => t('Show to Contacts'), '$contact_perms' => t('Show to Contacts'),
'$return_path' => $a->query_string, '$return_path' => $a->query_string,
)); ]);
} }
$like = ''; $like = '';
@ -1502,18 +1502,18 @@ function photos_content(App $a)
if ($can_post || can_write_wall($owner_uid)) { if ($can_post || can_write_wall($owner_uid)) {
$like_tpl = get_markup_template('like_noshare.tpl'); $like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = replace_macros($like_tpl, array( $likebuttons = replace_macros($like_tpl, [
'$id' => $link_item['id'], '$id' => $link_item['id'],
'$likethis' => t("I like this \x28toggle\x29"), '$likethis' => t("I like this \x28toggle\x29"),
'$nolike' => (Feature::isEnabled(local_user(), 'dislike') ? t("I don't like this \x28toggle\x29") : ''), '$nolike' => (Feature::isEnabled(local_user(), 'dislike') ? t("I don't like this \x28toggle\x29") : ''),
'$wait' => t('Please wait'), '$wait' => t('Please wait'),
'$return_path' => $a->query_string, '$return_path' => $a->query_string,
)); ]);
} }
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
if (($can_post || can_write_wall($owner_uid)) && $link_item['last-child']) { if (($can_post || can_write_wall($owner_uid)) && $link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array( $comments .= replace_macros($cmnt_tpl, [
'$return_path' => '', '$return_path' => '',
'$jsreload' => $return_url, '$jsreload' => $return_url,
'$type' => 'wall-comment', '$type' => 'wall-comment',
@ -1529,14 +1529,14 @@ function photos_content(App $a)
'$sourceapp' => t($a->sourcename), '$sourceapp' => t($a->sourcename),
'$ww' => '', '$ww' => '',
'$rand_num' => random_digits(12) '$rand_num' => random_digits(12)
)); ]);
} }
} }
$conv_responses = array( $conv_responses = [
'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')), 'like' => ['title' => t('Likes','title')],'dislike' => ['title' => t('Dislikes','title')],
'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) 'attendyes' => ['title' => t('Attending','title')], 'attendno' => ['title' => t('Not attending','title')], 'attendmaybe' => ['title' => t('Might attend','title')]
); ];
// display comments // display comments
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
@ -1552,7 +1552,7 @@ function photos_content(App $a)
} }
if (($can_post || can_write_wall($owner_uid)) && $link_item['last-child']) { if (($can_post || can_write_wall($owner_uid)) && $link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl,array( $comments .= replace_macros($cmnt_tpl,[
'$return_path' => '', '$return_path' => '',
'$jsreload' => $return_url, '$jsreload' => $return_url,
'$type' => 'wall-comment', '$type' => 'wall-comment',
@ -1568,7 +1568,7 @@ function photos_content(App $a)
'$sourceapp' => t($a->sourcename), '$sourceapp' => t($a->sourcename),
'$ww' => '', '$ww' => '',
'$rand_num' => random_digits(12) '$rand_num' => random_digits(12)
)); ]);
} }
foreach ($r as $item) { foreach ($r as $item) {
@ -1599,18 +1599,18 @@ function photos_content(App $a)
$profile_link = $profile_url; $profile_link = $profile_url;
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user())); $dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == local_user()));
$drop = array( $drop = [
'dropping' => $dropping, 'dropping' => $dropping,
'pagedrop' => false, 'pagedrop' => false,
'select' => t('Select'), 'select' => t('Select'),
'delete' => t('Delete'), 'delete' => t('Delete'),
); ];
$name_e = $profile_name; $name_e = $profile_name;
$title_e = $item['title']; $title_e = $item['title'];
$body_e = bbcode($item['body']); $body_e = bbcode($item['body']);
$comments .= replace_macros($template,array( $comments .= replace_macros($template,[
'$id' => $item['item_id'], '$id' => $item['item_id'],
'$profile_url' => $profile_link, '$profile_url' => $profile_link,
'$name' => $name_e, '$name' => $name_e,
@ -1622,10 +1622,10 @@ function photos_content(App $a)
'$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''), '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
'$drop' => $drop, '$drop' => $drop,
'$comment' => $comment '$comment' => $comment
)); ]);
if (($can_post || can_write_wall($owner_uid)) && $item['last-child']) { if (($can_post || can_write_wall($owner_uid)) && $item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array( $comments .= replace_macros($cmnt_tpl, [
'$return_path' => '', '$return_path' => '',
'$jsreload' => $return_url, '$jsreload' => $return_url,
'$type' => 'wall-comment', '$type' => 'wall-comment',
@ -1641,11 +1641,11 @@ function photos_content(App $a)
'$sourceapp' => t($a->sourcename), '$sourceapp' => t($a->sourcename),
'$ww' => '', '$ww' => '',
'$rand_num' => random_digits(12) '$rand_num' => random_digits(12)
)); ]);
} }
} }
} }
$response_verbs = array('like'); $response_verbs = ['like'];
if (Feature::isEnabled($owner_uid, 'dislike')) { if (Feature::isEnabled($owner_uid, 'dislike')) {
$response_verbs[] = 'dislike'; $response_verbs[] = 'dislike';
} }
@ -1655,7 +1655,7 @@ function photos_content(App $a)
} }
$photo_tpl = get_markup_template('photo_view.tpl'); $photo_tpl = get_markup_template('photo_view.tpl');
$o .= replace_macros($photo_tpl, array( $o .= replace_macros($photo_tpl, [
'$id' => $ph[0]['id'], '$id' => $ph[0]['id'],
'$album' => [$album_link, $ph[0]['album']], '$album' => [$album_link, $ph[0]['album']],
'$tools' => $tools, '$tools' => $tools,
@ -1674,7 +1674,7 @@ function photos_content(App $a)
'responses' => $responses, 'responses' => $responses,
'$comments' => $comments, '$comments' => $comments,
'$paginate' => $paginate, '$paginate' => $paginate,
)); ]);
$a->page['htmlhead'] .= "\n" . '<meta name="twitter:card" content="photo" />' . "\n"; $a->page['htmlhead'] .= "\n" . '<meta name="twitter:card" content="photo" />' . "\n";
$a->page['htmlhead'] .= '<meta name="twitter:title" content="' . $photo["album"] . '" />' . "\n"; $a->page['htmlhead'] .= '<meta name="twitter:title" content="' . $photo["album"] . '" />' . "\n";
@ -1711,7 +1711,7 @@ function photos_content(App $a)
intval($a->pager['itemspage']) intval($a->pager['itemspage'])
); );
$photos = array(); $photos = [];
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
// "Twist" is only used for the duepunto theme with style "slackr" // "Twist" is only used for the duepunto theme with style "slackr"
$twist = false; $twist = false;
@ -1727,31 +1727,31 @@ function photos_content(App $a)
$alt_e = $rr['filename']; $alt_e = $rr['filename'];
$name_e = $rr['album']; $name_e = $rr['album'];
$photos[] = array( $photos[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4), 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'], 'link' => 'photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
'title' => t('View Photo'), 'title' => t('View Photo'),
'src' => 'photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, 'src' => 'photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
'alt' => $alt_e, 'alt' => $alt_e,
'album' => array( 'album' => [
'link' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), 'link' => 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e, 'name' => $name_e,
'alt' => t('View Album'), 'alt' => t('View Album'),
), ],
); ];
} }
} }
$tpl = get_markup_template('photos_recent.tpl'); $tpl = get_markup_template('photos_recent.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$title' => t('Recent Photos'), '$title' => t('Recent Photos'),
'$can_post' => $can_post, '$can_post' => $can_post,
'$upload' => array(t('Upload New Photos'), 'photos/'.$a->data['user']['nickname'].'/upload'), '$upload' => [t('Upload New Photos'), 'photos/'.$a->data['user']['nickname'].'/upload'],
'$photos' => $photos, '$photos' => $photos,
'$paginate' => paginate($a), '$paginate' => paginate($a),
)); ]);
return $o; return $o;
} }

View file

@ -60,15 +60,15 @@ function ping_init(App $a)
$format = 'json'; $format = 'json';
} }
$tags = array(); $tags = [];
$comments = array(); $comments = [];
$likes = array(); $likes = [];
$dislikes = array(); $dislikes = [];
$friends = array(); $friends = [];
$posts = array(); $posts = [];
$regs = array(); $regs = [];
$mails = array(); $mails = [];
$notifications = array(); $notifications = [];
$intro_count = 0; $intro_count = 0;
$mail_count = 0; $mail_count = 0;
@ -76,8 +76,8 @@ function ping_init(App $a)
$network_count = 0; $network_count = 0;
$register_count = 0; $register_count = 0;
$sysnotify_count = 0; $sysnotify_count = 0;
$groups_unseen = array(); $groups_unseen = [];
$forums_unseen = array(); $forums_unseen = [];
$all_events = 0; $all_events = 0;
$all_events_today = 0; $all_events_today = 0;
@ -86,7 +86,7 @@ function ping_init(App $a)
$birthdays = 0; $birthdays = 0;
$birthdays_today = 0; $birthdays_today = 0;
$data = array(); $data = [];
$data['intro'] = $intro_count; $data['intro'] = $intro_count;
$data['mail'] = $mail_count; $data['mail'] = $mail_count;
$data['net'] = $network_count; $data['net'] = $network_count;
@ -103,7 +103,7 @@ function ping_init(App $a)
if (local_user()) { if (local_user()) {
// Different login session than the page that is calling us. // Different login session than the page that is calling us.
if (intval($_GET['uid']) && intval($_GET['uid']) != local_user()) { if (intval($_GET['uid']) && intval($_GET['uid']) != local_user()) {
$data = array('result' => array('invalid' => 1)); $data = ['result' => ['invalid' => 1]];
if ($format == 'json') { if ($format == 'json') {
if (isset($_GET['callback'])) { if (isset($_GET['callback'])) {
@ -137,7 +137,7 @@ function ping_init(App $a)
); );
if (DBM::is_result($items_unseen)) { if (DBM::is_result($items_unseen)) {
$arr = array('items' => $items_unseen); $arr = ['items' => $items_unseen];
call_hooks('network_ping', $arr); call_hooks('network_ping', $arr);
foreach ($items_unseen as $item) { foreach ($items_unseen as $item) {
@ -278,7 +278,7 @@ function ping_init(App $a)
// merge all notification types in one array // merge all notification types in one array
if (DBM::is_result($intros)) { if (DBM::is_result($intros)) {
foreach ($intros as $intro) { foreach ($intros as $intro) {
$notif = array( $notif = [
'href' => System::baseUrl() . '/notifications/intros/' . $intro['id'], 'href' => System::baseUrl() . '/notifications/intros/' . $intro['id'],
'name' => $intro['name'], 'name' => $intro['name'],
'url' => $intro['url'], 'url' => $intro['url'],
@ -286,14 +286,14 @@ function ping_init(App $a)
'date' => $intro['datetime'], 'date' => $intro['datetime'],
'seen' => false, 'seen' => false,
'message' => t('{0} wants to be your friend'), 'message' => t('{0} wants to be your friend'),
); ];
$notifs[] = $notif; $notifs[] = $notif;
} }
} }
if (DBM::is_result($mails)) { if (DBM::is_result($mails)) {
foreach ($mails as $mail) { foreach ($mails as $mail) {
$notif = array( $notif = [
'href' => System::baseUrl() . '/message/' . $mail['id'], 'href' => System::baseUrl() . '/message/' . $mail['id'],
'name' => $mail['from-name'], 'name' => $mail['from-name'],
'url' => $mail['from-url'], 'url' => $mail['from-url'],
@ -301,14 +301,14 @@ function ping_init(App $a)
'date' => $mail['created'], 'date' => $mail['created'],
'seen' => false, 'seen' => false,
'message' => t('{0} sent you a message'), 'message' => t('{0} sent you a message'),
); ];
$notifs[] = $notif; $notifs[] = $notif;
} }
} }
if (DBM::is_result($regs)) { if (DBM::is_result($regs)) {
foreach ($regs as $reg) { foreach ($regs as $reg) {
$notif = array( $notif = [
'href' => System::baseUrl() . '/admin/users/', 'href' => System::baseUrl() . '/admin/users/',
'name' => $reg['name'], 'name' => $reg['name'],
'url' => $reg['url'], 'url' => $reg['url'],
@ -316,7 +316,7 @@ function ping_init(App $a)
'date' => $reg['created'], 'date' => $reg['created'],
'seen' => false, 'seen' => false,
'message' => t('{0} requested registration'), 'message' => t('{0} requested registration'),
); ];
$notifs[] = $notif; $notifs[] = $notif;
} }
} }
@ -360,7 +360,7 @@ function ping_init(App $a)
$local_time = datetime_convert('UTC', date_default_timezone_get(), $notif['date']); $local_time = datetime_convert('UTC', date_default_timezone_get(), $notif['date']);
$notifications[] = array( $notifications[] = [
'id' => $notif['id'], 'id' => $notif['id'],
'href' => $notif['href'], 'href' => $notif['href'],
'name' => $notif['name'], 'name' => $notif['name'],
@ -370,13 +370,13 @@ function ping_init(App $a)
'message' => $notif['message'], 'message' => $notif['message'],
'seen' => $notif['seen'], 'seen' => $notif['seen'],
'timestamp' => strtotime($local_time) 'timestamp' => strtotime($local_time)
); ];
} }
} }
} }
$sysmsgs = array(); $sysmsgs = [];
$sysmsgs_info = array(); $sysmsgs_info = [];
if (x($_SESSION, 'sysmsg')) { if (x($_SESSION, 'sysmsg')) {
$sysmsgs = $_SESSION['sysmsg']; $sysmsgs = $_SESSION['sysmsg'];
@ -393,12 +393,12 @@ function ping_init(App $a)
$data['forums'] = $forums_unseen; $data['forums'] = $forums_unseen;
$data['notify'] = $sysnotify_count + $intro_count + $mail_count + $register_count; $data['notify'] = $sysnotify_count + $intro_count + $mail_count + $register_count;
$data['notifications'] = $notifications; $data['notifications'] = $notifications;
$data['sysmsgs'] = array( $data['sysmsgs'] = [
'notice' => $sysmsgs, 'notice' => $sysmsgs,
'info' => $sysmsgs_info 'info' => $sysmsgs_info
); ];
$json_payload = json_encode(array("result" => $data)); $json_payload = json_encode(["result" => $data]);
if (isset($_GET['callback'])) { if (isset($_GET['callback'])) {
// JSONP support // JSONP support
@ -413,7 +413,7 @@ function ping_init(App $a)
$data = ping_format_xml_data($data, $sysnotify_count, $notifications, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen); $data = ping_format_xml_data($data, $sysnotify_count, $notifications, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen);
header("Content-type: text/xml"); header("Content-type: text/xml");
echo XML::fromArray(array("result" => $data), $xml); echo XML::fromArray(["result" => $data], $xml);
} }
killme(); killme();
@ -427,7 +427,7 @@ function ping_init(App $a)
*/ */
function ping_get_notifications($uid) function ping_get_notifications($uid)
{ {
$result = array(); $result = [];
$offset = 0; $offset = 0;
$seen = false; $seen = false;
$seensql = "NOT"; $seensql = "NOT";
@ -523,11 +523,11 @@ function ping_get_notifications($uid)
*/ */
function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen) function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_info, $groups_unseen, $forums_unseen)
{ {
$notifications = array(); $notifications = [];
foreach ($notifs as $key => $notif) { foreach ($notifs as $key => $notif) {
$notifications[$key . ':note'] = $notif['message']; $notifications[$key . ':note'] = $notif['message'];
$notifications[$key . ':@attributes'] = array( $notifications[$key . ':@attributes'] = [
'id' => $notif['id'], 'id' => $notif['id'],
'href' => $notif['href'], 'href' => $notif['href'],
'name' => $notif['name'], 'name' => $notif['name'],
@ -536,10 +536,10 @@ function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_inf
'date' => $notif['date'], 'date' => $notif['date'],
'seen' => $notif['seen'], 'seen' => $notif['seen'],
'timestamp' => $notif['timestamp'] 'timestamp' => $notif['timestamp']
); ];
} }
$sysmsg = array(); $sysmsg = [];
foreach ($sysmsgs as $key => $m) { foreach ($sysmsgs as $key => $m) {
$sysmsg[$key . ':notice'] = $m; $sysmsg[$key . ':notice'] = $m;
} }
@ -548,27 +548,27 @@ function ping_format_xml_data($data, $sysnotify, $notifs, $sysmsgs, $sysmsgs_inf
} }
$data['notif'] = $notifications; $data['notif'] = $notifications;
$data['@attributes'] = array('count' => $sysnotify_count + $data['intro'] + $data['mail'] + $data['register']); $data['@attributes'] = ['count' => $sysnotify_count + $data['intro'] + $data['mail'] + $data['register']];
$data['sysmsgs'] = $sysmsg; $data['sysmsgs'] = $sysmsg;
if ($data['register'] == 0) { if ($data['register'] == 0) {
unset($data['register']); unset($data['register']);
} }
$groups = array(); $groups = [];
if (count($groups_unseen)) { if (count($groups_unseen)) {
foreach ($groups_unseen as $key => $item) { foreach ($groups_unseen as $key => $item) {
$groups[$key . ':group'] = $item['count']; $groups[$key . ':group'] = $item['count'];
$groups[$key . ':@attributes'] = array('id' => $item['id']); $groups[$key . ':@attributes'] = ['id' => $item['id']];
} }
$data['groups'] = $groups; $data['groups'] = $groups;
} }
$forums = array(); $forums = [];
if (count($forums_unseen)) { if (count($forums_unseen)) {
foreach ($forums_unseen as $key => $item) { foreach ($forums_unseen as $key => $item) {
$forums[$count . ':forum'] = $item['count']; $forums[$count . ':forum'] = $item['count'];
$forums[$count . ':@attributes'] = array('id' => $item['id']); $forums[$count . ':@attributes'] = ['id' => $item['id']];
} }
$data['forums'] = $forums; $data['forums'] = $forums;
} }

View file

@ -152,7 +152,7 @@ function poco_init(App $a) {
} }
logger("Query done", LOGGER_DEBUG); logger("Query done", LOGGER_DEBUG);
$ret = array(); $ret = [];
if (x($_GET, 'sorted')) { if (x($_GET, 'sorted')) {
$ret['sorted'] = false; $ret['sorted'] = false;
} }
@ -165,10 +165,10 @@ function poco_init(App $a) {
$ret['startIndex'] = (int) $startIndex; $ret['startIndex'] = (int) $startIndex;
$ret['itemsPerPage'] = (int) $itemsPerPage; $ret['itemsPerPage'] = (int) $itemsPerPage;
$ret['totalResults'] = (int) $totalResults; $ret['totalResults'] = (int) $totalResults;
$ret['entry'] = array(); $ret['entry'] = [];
$fields_ret = array( $fields_ret = [
'id' => false, 'id' => false,
'displayName' => false, 'displayName' => false,
'urls' => false, 'urls' => false,
@ -183,7 +183,7 @@ function poco_init(App $a) {
'address' => false, 'address' => false,
'contactType' => false, 'contactType' => false,
'generation' => false 'generation' => false
); ];
if ((! x($_GET, 'fields')) || ($_GET['fields'] === '@all')) { if ((! x($_GET, 'fields')) || ($_GET['fields'] === '@all')) {
foreach ($fields_ret as $k => $v) { foreach ($fields_ret as $k => $v) {
@ -254,7 +254,7 @@ function poco_init(App $a) {
$contact['gender'] = ""; $contact['gender'] = "";
} }
$entry = array(); $entry = [];
if ($fields_ret['id']) { if ($fields_ret['id']) {
$entry['id'] = (int)$contact['id']; $entry['id'] = (int)$contact['id'];
} }
@ -274,9 +274,9 @@ function poco_init(App $a) {
$entry['generation'] = (int)$contact['generation']; $entry['generation'] = (int)$contact['generation'];
} }
if ($fields_ret['urls']) { if ($fields_ret['urls']) {
$entry['urls'] = array(array('value' => $contact['url'], 'type' => 'profile')); $entry['urls'] = [['value' => $contact['url'], 'type' => 'profile']];
if ($contact['addr'] && ($contact['network'] !== NETWORK_MAIL)) { if ($contact['addr'] && ($contact['network'] !== NETWORK_MAIL)) {
$entry['urls'][] = array('value' => 'acct:' . $contact['addr'], 'type' => 'webfinger'); $entry['urls'][] = ['value' => 'acct:' . $contact['addr'], 'type' => 'webfinger'];
} }
} }
if ($fields_ret['preferredUsername']) { if ($fields_ret['preferredUsername']) {
@ -301,7 +301,7 @@ function poco_init(App $a) {
$entry['updated'] = date("c", strtotime($entry['updated'])); $entry['updated'] = date("c", strtotime($entry['updated']));
} }
if ($fields_ret['photos']) { if ($fields_ret['photos']) {
$entry['photos'] = array(array('value' => $contact['photo'], 'type' => 'profile')); $entry['photos'] = [['value' => $contact['photo'], 'type' => 'profile']];
} }
if ($fields_ret['network']) { if ($fields_ret['network']) {
$entry['network'] = $contact['network']; $entry['network'] = $contact['network'];
@ -316,7 +316,7 @@ function poco_init(App $a) {
$tags = str_replace(",", " ", $contact['keywords']); $tags = str_replace(",", " ", $contact['keywords']);
$tags = explode(" ", $tags); $tags = explode(" ", $tags);
$cleaned = array(); $cleaned = [];
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tag = trim(strtolower($tag)); $tag = trim(strtolower($tag));
if ($tag != "") { if ($tag != "") {
@ -324,10 +324,10 @@ function poco_init(App $a) {
} }
} }
$entry['tags'] = array($cleaned); $entry['tags'] = [$cleaned];
} }
if ($fields_ret['address']) { if ($fields_ret['address']) {
$entry['address'] = array(); $entry['address'] = [];
// Deactivated. It just reveals too much data. (Although its from the default profile) // Deactivated. It just reveals too much data. (Although its from the default profile)
//if (isset($rr['paddress'])) //if (isset($rr['paddress']))
@ -354,7 +354,7 @@ function poco_init(App $a) {
$ret['entry'][] = $entry; $ret['entry'][] = $entry;
} }
} else { } else {
$ret['entry'][] = array(); $ret['entry'][] = [];
} }
} else { } else {
http_status_exit(500); http_status_exit(500);
@ -363,7 +363,7 @@ function poco_init(App $a) {
if ($format === 'xml') { if ($format === 'xml') {
header('Content-type: text/xml'); header('Content-type: text/xml');
echo replace_macros(get_markup_template('poco_xml.tpl'), array_xmlify(array('$response' => $ret))); echo replace_macros(get_markup_template('poco_xml.tpl'), array_xmlify(['$response' => $ret]));
killme(); killme();
} }
if ($format === 'json') { if ($format === 'json') {

View file

@ -97,7 +97,7 @@ function poke_init(App $a) {
$uri = item_new_uri($a->get_hostname(),$uid); $uri = item_new_uri($a->get_hostname(),$uid);
$arr = array(); $arr = [];
$arr['guid'] = get_guid(32); $arr['guid'] = get_guid(32);
$arr['uid'] = $uid; $arr['uid'] = $uid;
@ -177,10 +177,10 @@ function poke_content(App $a) {
$base = System::baseUrl(); $base = System::baseUrl();
$head_tpl = get_markup_template('poke_head.tpl'); $head_tpl = get_markup_template('poke_head.tpl');
$a->page['htmlhead'] .= replace_macros($head_tpl,array( $a->page['htmlhead'] .= replace_macros($head_tpl,[
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$base' => $base '$base' => $base
)); ]);
$parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0'); $parent = ((x($_GET,'parent')) ? intval($_GET['parent']) : '0');
@ -188,15 +188,15 @@ function poke_content(App $a) {
$verbs = get_poke_verbs(); $verbs = get_poke_verbs();
$shortlist = array(); $shortlist = [];
foreach($verbs as $k => $v) foreach($verbs as $k => $v)
if($v[1] !== 'NOTRANSLATION') if($v[1] !== 'NOTRANSLATION')
$shortlist[] = array($k,$v[1]); $shortlist[] = [$k,$v[1]];
$tpl = get_markup_template('poke_content.tpl'); $tpl = get_markup_template('poke_content.tpl');
$o = replace_macros($tpl,array( $o = replace_macros($tpl,[
'$title' => t('Poke/Prod'), '$title' => t('Poke/Prod'),
'$desc' => t('poke, prod or do other things to somebody'), '$desc' => t('poke, prod or do other things to somebody'),
'$clabel' => t('Recipient'), '$clabel' => t('Recipient'),
@ -207,7 +207,7 @@ function poke_content(App $a) {
'$submit' => t('Submit'), '$submit' => t('Submit'),
'$name' => $name, '$name' => $name,
'$id' => $id '$id' => $id
)); ]);
return $o; return $o;

View file

@ -17,7 +17,7 @@ function pretheme_init(App $a) {
$version = ''; $version = '';
$credits = ''; $credits = '';
} }
echo json_encode(array('img' => get_theme_screenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits)); echo json_encode(['img' => get_theme_screenshot($theme), 'desc' => $desc, 'version' => $version, 'credits' => $credits]);
} }
killme(); killme();

View file

@ -6,8 +6,8 @@ use Friendica\Network\Probe;
function probe_content(App $a) { function probe_content(App $a) {
if (!local_user()) { if (!local_user()) {
http_status_exit(403, array("title" => t("Public access denied."), http_status_exit(403, ["title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a probing."))); "description" => t("Only logged in users are permitted to perform a probing.")]);
killme(); killme();
} }

View file

@ -61,7 +61,7 @@ function profile_init(App $a)
// site block // site block
if (!$blocked && !$userblock) { if (!$blocked && !$userblock) {
$keywords = str_replace(array('#', ',', ' ', ',,'), array('', ' ', ',', ','), defaults($a->profile, 'pub_keywords', '')); $keywords = str_replace(['#', ',', ' ', ',,'], ['', ' ', ',', ','], defaults($a->profile, 'pub_keywords', ''));
if (strlen($keywords)) { if (strlen($keywords)) {
$a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n"; $a->page['htmlhead'] .= '<meta name="keywords" content="' . $keywords . '" />' . "\r\n";
} }
@ -75,7 +75,7 @@ function profile_init(App $a)
$a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n"; $a->page['htmlhead'] .= '<link rel="lrdd" type="application/xrd+xml" href="' . System::baseUrl() . '/xrd/?uri=' . $uri . '" />' . "\r\n";
header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); header('Link: <' . System::baseUrl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
$dfrn_pages = array('request', 'confirm', 'notify', 'poll'); $dfrn_pages = ['request', 'confirm', 'notify', 'poll'];
foreach ($dfrn_pages as $dfrn) { foreach ($dfrn_pages as $dfrn) {
$a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . System::baseUrl() . "/dfrn_{$dfrn}/{$which}\" />\r\n"; $a->page['htmlhead'] .= "<link rel=\"dfrn-{$dfrn}\" href=\"" . System::baseUrl() . "/dfrn_{$dfrn}/{$which}\" />\r\n";
} }
@ -116,7 +116,7 @@ function profile_content(App $a, $update = 0)
require_once 'include/acl_selectors.php'; require_once 'include/acl_selectors.php';
require_once 'include/items.php'; require_once 'include/items.php';
$groups = array(); $groups = [];
$tab = 'posts'; $tab = 'posts';
$o = ''; $o = '';
@ -197,7 +197,7 @@ function profile_content(App $a, $update = 0)
$a->page['aside'] .= tagcloud_wall_widget(); $a->page['aside'] .= tagcloud_wall_widget();
if (can_write_wall($a->profile['profile_uid'])) { if (can_write_wall($a->profile['profile_uid'])) {
$x = array( $x = [
'is_owner' => $is_owner, 'is_owner' => $is_owner,
'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'], 'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'],
'default_location' => $is_owner ? $a->user['default-location'] : '', 'default_location' => $is_owner ? $a->user['default-location'] : '',
@ -212,7 +212,7 @@ function profile_content(App $a, $update = 0)
'bang' => '', 'bang' => '',
'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none',
'profile_uid' => $a->profile['profile_uid'], 'profile_uid' => $a->profile['profile_uid'],
); ];
$o .= status_editor($a, $x); $o .= status_editor($a, $x);
} }
@ -319,7 +319,7 @@ function profile_content(App $a, $update = 0)
); );
} }
$parents_arr = array(); $parents_arr = [];
$parents_str = ''; $parents_str = '';
// Set a time stamp for this page. We will make use of it when we // Set a time stamp for this page. We will make use of it when we
@ -342,7 +342,7 @@ function profile_content(App $a, $update = 0)
$items = conv_sort($items, 'created'); $items = conv_sort($items, 'created');
} else { } else {
$items = array(); $items = [];
} }
if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) { if ($is_owner && !$update && !Config::get('theme', 'hide_eventlist')) {
@ -352,10 +352,10 @@ function profile_content(App $a, $update = 0)
if ($is_owner) { if ($is_owner) {
$unseen = dba::exists('item', array('wall' => true, 'unseen' => true, 'uid' => local_user())); $unseen = dba::exists('item', ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
if ($unseen) { if ($unseen) {
$r = dba::update('item', array('unseen' => false), $r = dba::update('item', ['unseen' => false],
array('wall' => true, 'unseen' => true, 'uid' => local_user())); ['wall' => true, 'unseen' => true, 'uid' => local_user()]);
} }
} }

View file

@ -254,7 +254,7 @@ function profile_photo_content(App $a) {
$tpl = get_markup_template('profile_photo.tpl'); $tpl = get_markup_template('profile_photo.tpl');
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$user' => $a->user['nickname'], '$user' => $a->user['nickname'],
'$lbl_upfile' => t('Upload File:'), '$lbl_upfile' => t('Upload File:'),
'$lbl_profiles' => t('Select a profile:'), '$lbl_profiles' => t('Select a profile:'),
@ -263,7 +263,7 @@ function profile_photo_content(App $a) {
'$profiles' => $profiles, '$profiles' => $profiles,
'$form_security_token' => get_form_security_token("profile_photo"), '$form_security_token' => get_form_security_token("profile_photo"),
'$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . System::baseUrl() . '">' . t('skip this step') . '</a>' : '<a href="'. System::baseUrl() . '/photos/' . $a->user['nickname'] . '">' . t('select a photo from your photo albums') . '</a>') '$select' => sprintf('%s %s', t('or'), ($newuser) ? '<a href="' . System::baseUrl() . '">' . t('skip this step') . '</a>' : '<a href="'. System::baseUrl() . '/photos/' . $a->user['nickname'] . '">' . t('select a photo from your photo albums') . '</a>')
)); ]);
return $o; return $o;
} }
@ -271,7 +271,7 @@ function profile_photo_content(App $a) {
$filename = $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'] . '.'.$a->config['imagecrop_ext']; $filename = $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'] . '.'.$a->config['imagecrop_ext'];
$resolution = $a->config['imagecrop_resolution']; $resolution = $a->config['imagecrop_resolution'];
$tpl = get_markup_template("cropbody.tpl"); $tpl = get_markup_template("cropbody.tpl");
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,[
'$filename' => $filename, '$filename' => $filename,
'$profile' => intval($_REQUEST['profile']), '$profile' => intval($_REQUEST['profile']),
'$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'], '$resource' => $a->config['imagecrop'] . '-' . $a->config['imagecrop_resolution'],
@ -280,7 +280,7 @@ function profile_photo_content(App $a) {
'$desc' => t('Please adjust the image cropping for optimum viewing.'), '$desc' => t('Please adjust the image cropping for optimum viewing.'),
'$form_security_token' => get_form_security_token("profile_photo"), '$form_security_token' => get_form_security_token("profile_photo"),
'$done' => t('Done Editing') '$done' => t('Done Editing')
)); ]);
return $o; return $o;
} }
@ -333,7 +333,7 @@ function profile_photo_crop_ui_head(App $a, Image $Image) {
$a->config['imagecrop'] = $hash; $a->config['imagecrop'] = $hash;
$a->config['imagecrop_resolution'] = $smallest; $a->config['imagecrop_resolution'] = $smallest;
$a->config['imagecrop_ext'] = $Image->getExt(); $a->config['imagecrop_ext'] = $Image->getExt();
$a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), array()); $a->page['htmlhead'] .= replace_macros(get_markup_template("crophead.tpl"), []);
$a->page['end'] .= replace_macros(get_markup_template("cropend.tpl"), array()); $a->page['end'] .= replace_macros(get_markup_template("cropend.tpl"), []);
return; return;
} }

View file

@ -154,7 +154,7 @@ function profile_clean_keywords($keywords) {
$keywords = str_replace(",", " ", $keywords); $keywords = str_replace(",", " ", $keywords);
$keywords = explode(" ", $keywords); $keywords = explode(" ", $keywords);
$cleaned = array(); $cleaned = [];
foreach ($keywords as $keyword) { foreach ($keywords as $keyword) {
$keyword = trim(strtolower($keyword)); $keyword = trim(strtolower($keyword));
$keyword = trim($keyword, "#"); $keyword = trim($keyword, "#");
@ -207,7 +207,7 @@ function profiles_post(App $a) {
} else { } else {
$ignore_year = false; $ignore_year = false;
} }
if (!in_array($dob, array('0000-00-00', '0001-01-01'))) { if (!in_array($dob, ['0000-00-00', '0001-01-01'])) {
if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) { if (strpos($dob, '0000-') === 0 || strpos($dob, '0001-') === 0) {
$ignore_year = true; $ignore_year = true;
$dob = substr($dob, 5); $dob = substr($dob, 5);
@ -331,7 +331,7 @@ function profiles_post(App $a) {
PConfig::set(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0)); PConfig::set(local_user(), 'system', 'detailled_profile', (($_POST['detailled_profile'] == 1) ? 1: 0));
$changes = array(); $changes = [];
$value = ''; $value = '';
if ($is_default) { if ($is_default) {
if ($marital != $orig[0]['marital']) { if ($marital != $orig[0]['marital']) {
@ -491,7 +491,7 @@ function profiles_post(App $a) {
} }
if ($is_default) { if ($is_default) {
$location = Profile::formatLocation(array("locality" => $locality, "region" => $region, "country-name" => $country_name)); $location = Profile::formatLocation(["locality" => $locality, "region" => $region, "country-name" => $country_name]);
q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d", q("UPDATE `contact` SET `about` = '%s', `location` = '%s', `keywords` = '%s', `gender` = '%s' WHERE `self` AND `uid` = %d",
dbesc($about), dbesc($about),
@ -541,7 +541,7 @@ function profile_activity($changed, $value) {
return; return;
} }
$arr = array(); $arr = [];
$arr['guid'] = get_guid(32); $arr['guid'] = get_guid(32);
$arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user()); $arr['uri'] = $arr['parent-uri'] = item_new_uri($a->get_hostname(), local_user());
@ -625,47 +625,47 @@ function profiles_content(App $a) {
return; return;
} }
$a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), array( $a->page['htmlhead'] .= replace_macros(get_markup_template('profed_head.tpl'), [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
)); ]);
$a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), array( $a->page['end'] .= replace_macros(get_markup_template('profed_end.tpl'), [
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
)); ]);
$opt_tpl = get_markup_template("profile-hide-friends.tpl"); $opt_tpl = get_markup_template("profile-hide-friends.tpl");
$hide_friends = replace_macros($opt_tpl,array( $hide_friends = replace_macros($opt_tpl,[
'$yesno' => array( '$yesno' => [
'hide-friends', //Name 'hide-friends', //Name
t('Hide contacts and friends:'), //Label t('Hide contacts and friends:'), //Label
!!$r[0]['hide-friends'], //Value !!$r[0]['hide-friends'], //Value
'', //Help string '', //Help string
array(t('No'), t('Yes')) //Off - On strings [t('No'), t('Yes')] //Off - On strings
), ],
'$desc' => t('Hide your contact/friend list from viewers of this profile?'), '$desc' => t('Hide your contact/friend list from viewers of this profile?'),
'$yes_str' => t('Yes'), '$yes_str' => t('Yes'),
'$no_str' => t('No'), '$no_str' => t('No'),
'$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""), '$yes_selected' => (($r[0]['hide-friends']) ? " checked=\"checked\" " : ""),
'$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "") '$no_selected' => (($r[0]['hide-friends'] == 0) ? " checked=\"checked\" " : "")
)); ]);
$personal_account = !(in_array($a->user["page-flags"], $personal_account = !(in_array($a->user["page-flags"],
array(PAGE_COMMUNITY, PAGE_PRVGROUP))); [PAGE_COMMUNITY, PAGE_PRVGROUP]));
$detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account); $detailled_profile = (PConfig::get(local_user(), 'system', 'detailled_profile') AND $personal_account);
$is_default = (($r[0]['is-default']) ? 1 : 0); $is_default = (($r[0]['is-default']) ? 1 : 0);
$tpl = get_markup_template("profile_edit.tpl"); $tpl = get_markup_template("profile_edit.tpl");
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$personal_account' => $personal_account, '$personal_account' => $personal_account,
'$detailled_profile' => $detailled_profile, '$detailled_profile' => $detailled_profile,
'$details' => array( '$details' => [
'detailled_profile', //Name 'detailled_profile', //Name
t('Show more profile fields:'), //Label t('Show more profile fields:'), //Label
$detailled_profile, //Value $detailled_profile, //Value
'', //Help string '', //Help string
array(t('No'), t('Yes')) //Off - On strings [t('No'), t('Yes')] //Off - On strings
), ],
'$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'), '$multi_profiles' => Feature::isEnabled(local_user(), 'multi_profiles'),
'$form_security_token' => get_form_security_token("profile_edit"), '$form_security_token' => get_form_security_token("profile_edit"),
@ -703,46 +703,46 @@ function profiles_content(App $a) {
'$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''), '$disabled' => (($is_default) ? 'onclick="return false;" style="color: #BBBBFF;"' : ''),
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$profile_id' => $r[0]['id'], '$profile_id' => $r[0]['id'],
'$profile_name' => array('profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'), '$profile_name' => ['profile_name', t('Profile Name:'), $r[0]['profile-name'], t('Required'), '*'],
'$is_default' => $is_default, '$is_default' => $is_default,
'$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""), '$default' => (($is_default) ? '<p id="profile-edit-default-desc">' . t('This is your <strong>public</strong> profile.<br />It <strong>may</strong> be visible to anybody using the internet.') . '</p>' : ""),
'$name' => array('name', t('Your Full Name:'), $r[0]['name']), '$name' => ['name', t('Your Full Name:'), $r[0]['name']],
'$pdesc' => array('pdesc', t('Title/Description:'), $r[0]['pdesc']), '$pdesc' => ['pdesc', t('Title/Description:'), $r[0]['pdesc']],
'$dob' => dob($r[0]['dob']), '$dob' => dob($r[0]['dob']),
'$hide_friends' => $hide_friends, '$hide_friends' => $hide_friends,
'$address' => array('address', t('Street Address:'), $r[0]['address']), '$address' => ['address', t('Street Address:'), $r[0]['address']],
'$locality' => array('locality', t('Locality/City:'), $r[0]['locality']), '$locality' => ['locality', t('Locality/City:'), $r[0]['locality']],
'$region' => array('region', t('Region/State:'), $r[0]['region']), '$region' => ['region', t('Region/State:'), $r[0]['region']],
'$postal_code' => array('postal_code', t('Postal/Zip Code:'), $r[0]['postal-code']), '$postal_code' => ['postal_code', t('Postal/Zip Code:'), $r[0]['postal-code']],
'$country_name' => array('country_name', t('Country:'), $r[0]['country-name']), '$country_name' => ['country_name', t('Country:'), $r[0]['country-name']],
'$age' => ((intval($r[0]['dob'])) ? '(' . t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''), '$age' => ((intval($r[0]['dob'])) ? '(' . t('Age: ') . age($r[0]['dob'],$a->user['timezone'],$a->user['timezone']) . ')' : ''),
'$gender' => ContactSelector::gender($r[0]['gender']), '$gender' => ContactSelector::gender($r[0]['gender']),
'$marital' => ContactSelector::maritalStatus($r[0]['marital']), '$marital' => ContactSelector::maritalStatus($r[0]['marital']),
'$with' => array('with', t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), t('Examples: cathy123, Cathy Williams, cathy@example.com')), '$with' => ['with', t("Who: \x28if applicable\x29"), strip_tags($r[0]['with']), t('Examples: cathy123, Cathy Williams, cathy@example.com')],
'$howlong' => array('howlong', t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))), '$howlong' => ['howlong', t('Since [date]:'), ($r[0]['howlong'] <= NULL_DATE ? '' : datetime_convert('UTC',date_default_timezone_get(),$r[0]['howlong']))],
'$sexual' => ContactSelector::sexualPreference($r[0]['sexual']), '$sexual' => ContactSelector::sexualPreference($r[0]['sexual']),
'$about' => array('about', t('Tell us about yourself...'), $r[0]['about']), '$about' => ['about', t('Tell us about yourself...'), $r[0]['about']],
'$xmpp' => array('xmpp', t('XMPP (Jabber) address:'), $r[0]['xmpp'], t("The XMPP address will be propagated to your contacts so that they can follow you.")), '$xmpp' => ['xmpp', t('XMPP (Jabber) address:'), $r[0]['xmpp'], t("The XMPP address will be propagated to your contacts so that they can follow you.")],
'$homepage' => array('homepage', t('Homepage URL:'), $r[0]['homepage']), '$homepage' => ['homepage', t('Homepage URL:'), $r[0]['homepage']],
'$hometown' => array('hometown', t('Hometown:'), $r[0]['hometown']), '$hometown' => ['hometown', t('Hometown:'), $r[0]['hometown']],
'$politic' => array('politic', t('Political Views:'), $r[0]['politic']), '$politic' => ['politic', t('Political Views:'), $r[0]['politic']],
'$religion' => array('religion', t('Religious Views:'), $r[0]['religion']), '$religion' => ['religion', t('Religious Views:'), $r[0]['religion']],
'$pub_keywords' => array('pub_keywords', t('Public Keywords:'), $r[0]['pub_keywords'], t("\x28Used for suggesting potential friends, can be seen by others\x29")), '$pub_keywords' => ['pub_keywords', t('Public Keywords:'), $r[0]['pub_keywords'], t("\x28Used for suggesting potential friends, can be seen by others\x29")],
'$prv_keywords' => array('prv_keywords', t('Private Keywords:'), $r[0]['prv_keywords'], t("\x28Used for searching profiles, never shown to others\x29")), '$prv_keywords' => ['prv_keywords', t('Private Keywords:'), $r[0]['prv_keywords'], t("\x28Used for searching profiles, never shown to others\x29")],
'$likes' => array('likes', t('Likes:'), $r[0]['likes']), '$likes' => ['likes', t('Likes:'), $r[0]['likes']],
'$dislikes' => array('dislikes', t('Dislikes:'), $r[0]['dislikes']), '$dislikes' => ['dislikes', t('Dislikes:'), $r[0]['dislikes']],
'$music' => array('music', t('Musical interests'), $r[0]['music']), '$music' => ['music', t('Musical interests'), $r[0]['music']],
'$book' => array('book', t('Books, literature'), $r[0]['book']), '$book' => ['book', t('Books, literature'), $r[0]['book']],
'$tv' => array('tv', t('Television'), $r[0]['tv']), '$tv' => ['tv', t('Television'), $r[0]['tv']],
'$film' => array('film', t('Film/dance/culture/entertainment'), $r[0]['film']), '$film' => ['film', t('Film/dance/culture/entertainment'), $r[0]['film']],
'$interest' => array('interest', t('Hobbies/Interests'), $r[0]['interest']), '$interest' => ['interest', t('Hobbies/Interests'), $r[0]['interest']],
'$romance' => array('romance', t('Love/romance'), $r[0]['romance']), '$romance' => ['romance', t('Love/romance'), $r[0]['romance']],
'$work' => array('work', t('Work/employment'), $r[0]['work']), '$work' => ['work', t('Work/employment'), $r[0]['work']],
'$education' => array('education', t('School/education'), $r[0]['education']), '$education' => ['education', t('School/education'), $r[0]['education']],
'$contact' => array('contact', t('Contact information and Social Networks'), $r[0]['contact']), '$contact' => ['contact', t('Contact information and Social Networks'), $r[0]['contact']],
)); ]);
$arr = array('profile' => $r[0], 'entry' => $o); $arr = ['profile' => $r[0], 'entry' => $o];
call_hooks('profile_edit', $arr); call_hooks('profile_edit', $arr);
return $o; return $o;
@ -767,24 +767,24 @@ function profiles_content(App $a) {
$profiles = ''; $profiles = '';
foreach ($r as $rr) { foreach ($r as $rr) {
$profiles .= replace_macros($tpl, array( $profiles .= replace_macros($tpl, [
'$photo' => $a->remove_baseurl($rr['thumb']), '$photo' => $a->remove_baseurl($rr['thumb']),
'$id' => $rr['id'], '$id' => $rr['id'],
'$alt' => t('Profile Image'), '$alt' => t('Profile Image'),
'$profile_name' => $rr['profile-name'], '$profile_name' => $rr['profile-name'],
'$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>' '$visible' => (($rr['is-default']) ? '<strong>' . t('visible to everybody') . '</strong>'
: '<a href="'.'profperm/'.$rr['id'].'" />' . t('Edit visibility') . '</a>') : '<a href="'.'profperm/'.$rr['id'].'" />' . t('Edit visibility') . '</a>')
)); ]);
} }
$tpl_header = get_markup_template('profile_listing_header.tpl'); $tpl_header = get_markup_template('profile_listing_header.tpl');
$o .= replace_macros($tpl_header,array( $o .= replace_macros($tpl_header,[
'$header' => t('Edit/Manage Profiles'), '$header' => t('Edit/Manage Profiles'),
'$chg_photo' => t('Change profile photo'), '$chg_photo' => t('Change profile photo'),
'$cr_new' => t('Create New Profile'), '$cr_new' => t('Create New Profile'),
'$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"), '$cr_new_link' => 'profiles/new?t=' . get_form_security_token("profile_new"),
'$profiles' => $profiles '$profiles' => $profiles
)); ]);
} }
return $o; return $o;
} }

View file

@ -69,7 +69,7 @@ function profperm_content(App $a) {
intval($a->argv[1]) intval($a->argv[1])
); );
$ingroup = array(); $ingroup = [];
if (DBM::is_result($r)) if (DBM::is_result($r))
foreach($r as $member) foreach($r as $member)
$ingroup[] = $member['id']; $ingroup[] = $member['id'];
@ -99,7 +99,7 @@ function profperm_content(App $a) {
$members = $r; $members = $r;
$ingroup = array(); $ingroup = [];
if (DBM::is_result($r)) if (DBM::is_result($r))
foreach($r as $member) foreach($r as $member)
$ingroup[] = $member['id']; $ingroup[] = $member['id'];

View file

@ -104,7 +104,7 @@ function proxy_init(App $a) {
$url = substr($url, 0, $pos + 1); $url = substr($url, 0, $pos + 1);
} }
$url = str_replace(array('.jpg', '.jpeg', '.gif', '.png'), array('','','',''), $url); $url = str_replace(['.jpg', '.jpeg', '.gif', '.png'], ['','','',''], $url);
$url = base64_decode(strtr($url, '-_', '+/'), true); $url = base64_decode(strtr($url, '-_', '+/'), true);
@ -186,10 +186,10 @@ function proxy_init(App $a) {
die(); die();
} }
$fields = array('uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => datetime_convert(), 'edited' => datetime_convert(), $fields = ['uid' => 0, 'contact-id' => 0, 'guid' => get_guid(), 'resource-id' => $urlhash, 'created' => datetime_convert(), 'edited' => datetime_convert(),
'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image), 'filename' => basename($_REQUEST['url']), 'type' => '', 'album' => '', 'height' => imagesy($image), 'width' => imagesx($image),
'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0, 'datasize' => 0, 'data' => $img_str, 'scale' => 100, 'profile' => 0,
'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime); 'allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '', 'desc' => $mime];
dba::insert('photo', $fields); dba::insert('photo', $fields);
} else { } else {
$Image = new Image($img_str, $mime); $Image = new Image($img_str, $mime);
@ -286,7 +286,7 @@ function proxy_url($url, $writemode = false, $size = '') {
// Extract the URL extension // Extract the URL extension
$extension = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION); $extension = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION);
$extensions = array('jpg', 'jpeg', 'gif', 'png'); $extensions = ['jpg', 'jpeg', 'gif', 'png'];
if (in_array($extension, $extensions)) { if (in_array($extension, $extensions)) {
$shortpath .= '.' . $extension; $shortpath .= '.' . $extension;
$longpath .= '.' . $extension; $longpath .= '.' . $extension;
@ -340,7 +340,7 @@ function proxy_parse_query($url) {
$query = parse_url($url, PHP_URL_QUERY); $query = parse_url($url, PHP_URL_QUERY);
$query = html_entity_decode($query); $query = html_entity_decode($query);
$query_list = explode('&', $query); $query_list = explode('&', $query);
$arr = array(); $arr = [];
foreach ($query_list as $key_value) { foreach ($query_list as $key_value) {
$key_value_list = explode('=', $key_value); $key_value_list = explode('=', $key_value);

View file

@ -19,7 +19,7 @@ function register_post(App $a)
$verified = 0; $verified = 0;
$blocked = 1; $blocked = 1;
$arr = array('post' => $_POST); $arr = ['post' => $_POST];
call_hooks('register_post', $arr); call_hooks('register_post', $arr);
$max_dailies = intval(Config::get('system', 'max_daily_registrations')); $max_dailies = intval(Config::get('system', 'max_daily_registrations'));
@ -133,7 +133,7 @@ function register_post(App $a)
// send notification to admins // send notification to admins
foreach ($adminlist as $admin) { foreach ($adminlist as $admin) {
notification(array( notification([
'type' => NOTIFY_SYSTEM, 'type' => NOTIFY_SYSTEM,
'event' => 'SYSTEM_REGISTER_REQUEST', 'event' => 'SYSTEM_REGISTER_REQUEST',
'source_name' => $user['username'], 'source_name' => $user['username'],
@ -146,7 +146,7 @@ function register_post(App $a)
'uid' => $admin['uid'], 'uid' => $admin['uid'],
'language' => $admin['language'] ? $admin['language'] : 'en', 'language' => $admin['language'] ? $admin['language'] : 'en',
'show_in_notification_page' => false 'show_in_notification_page' => false
)); ]);
} }
// send notification to the user, that the registration is pending // send notification to the user, that the registration is pending
User::sendRegisterPendingEmail( User::sendRegisterPendingEmail(
@ -222,14 +222,14 @@ function register_content(App $a)
$profile_publish = '<input type="hidden" name="profile_publish_reg" value="1" />'; $profile_publish = '<input type="hidden" name="profile_publish_reg" value="1" />';
} else { } else {
$publish_tpl = get_markup_template("profile_publish.tpl"); $publish_tpl = get_markup_template("profile_publish.tpl");
$profile_publish = replace_macros($publish_tpl, array( $profile_publish = replace_macros($publish_tpl, [
'$instance' => 'reg', '$instance' => 'reg',
'$pubdesc' => t('Include your profile in member directory?'), '$pubdesc' => t('Include your profile in member directory?'),
'$yes_selected' => ' checked="checked" ', '$yes_selected' => ' checked="checked" ',
'$no_selected' => '', '$no_selected' => '',
'$str_yes' => t('Yes'), '$str_yes' => t('Yes'),
'$str_no' => t('No'), '$str_no' => t('No'),
)); ]);
} }
$r = q("SELECT COUNT(*) AS `contacts` FROM `contact`"); $r = q("SELECT COUNT(*) AS `contacts` FROM `contact`");
@ -239,7 +239,7 @@ function register_content(App $a)
$tpl = get_markup_template("register.tpl"); $tpl = get_markup_template("register.tpl");
$arr = array('template' => $tpl); $arr = ['template' => $tpl];
call_hooks('register_form', $arr); call_hooks('register_form', $arr);
@ -249,7 +249,7 @@ function register_content(App $a)
'$oidhtml' => $oidhtml, '$oidhtml' => $oidhtml,
'$invitations' => Config::get('system', 'invitation_only'), '$invitations' => Config::get('system', 'invitation_only'),
'$permonly' => $a->config['register_policy'] == REGISTER_APPROVE, '$permonly' => $a->config['register_policy'] == REGISTER_APPROVE,
'$permonlybox' => array('permonlybox', t('Note for the admin'), '', t('Leave a message for the admin, why you want to join this node')), '$permonlybox' => ['permonlybox', t('Note for the admin'), '', t('Leave a message for the admin, why you want to join this node')],
'$invite_desc' => t('Membership on this site is by invitation only.'), '$invite_desc' => t('Membership on this site is by invitation only.'),
'$invite_label' => t('Your invitation ID: '), '$invite_label' => t('Your invitation ID: '),
'$invite_id' => $invite_id, '$invite_id' => $invite_id,
@ -263,8 +263,8 @@ function register_content(App $a)
'$namelabel' => t('Your Full Name ' . "\x28" . 'e.g. Joe Smith, real or real-looking' . "\x29" . ': '), '$namelabel' => t('Your Full Name ' . "\x28" . 'e.g. Joe Smith, real or real-looking' . "\x29" . ': '),
'$addrlabel' => t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'), '$addrlabel' => t('Your Email Address: (Initial information will be send there, so this has to be an existing address.)'),
'$passwords' => $passwords, '$passwords' => $passwords,
'$password1' => array('password1', t('New Password:'), '', t('Leave empty for an auto generated password.')), '$password1' => ['password1', t('New Password:'), '', t('Leave empty for an auto generated password.')],
'$password2' => array('confirm', t('Confirm:'), '', ''), '$password2' => ['confirm', t('Confirm:'), '', ''],
'$nickdesc' => t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@%s</strong>\'.', $a->get_hostname()), '$nickdesc' => t('Choose a profile nickname. This must begin with a text character. Your profile address on this site will then be \'<strong>nickname@%s</strong>\'.', $a->get_hostname()),
'$nicklabel' => t('Choose a nickname: '), '$nicklabel' => t('Choose a nickname: '),
'$photo' => $photo, '$photo' => $photo,

View file

@ -84,8 +84,8 @@ function user_deny($hash)
intval($register[0]['uid']) intval($register[0]['uid'])
); );
dba::delete('user', array('uid' => $register[0]['uid'])); dba::delete('user', ['uid' => $register[0]['uid']]);
dba::delete('register', array('hash' => $register[0]['hash'])); dba::delete('register', ['hash' => $register[0]['hash']]);
notice(sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL); notice(sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
return true; return true;

View file

@ -46,14 +46,14 @@ function removeme_content(App $a)
$_SESSION['remove_account_verify'] = $hash; $_SESSION['remove_account_verify'] = $hash;
$tpl = get_markup_template('removeme.tpl'); $tpl = get_markup_template('removeme.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$basedir' => System::baseUrl(), '$basedir' => System::baseUrl(),
'$hash' => $hash, '$hash' => $hash,
'$title' => t('Remove My Account'), '$title' => t('Remove My Account'),
'$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'), '$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'),
'$passwd' => t('Please enter your password for verification:'), '$passwd' => t('Please enter your password for verification:'),
'$submit' => t('Remove My Account') '$submit' => t('Remove My Account')
)); ]);
return $o; return $o;
} }

View file

@ -15,11 +15,11 @@ use Friendica\App;
*/ */
function robots_txt_init(App $a) function robots_txt_init(App $a)
{ {
$allDisalloweds = array( $allDisalloweds = [
'/settings/', '/settings/',
'/admin/', '/admin/',
'/message/', '/message/',
); ];
header('Content-Type: text/plain'); header('Content-Type: text/plain');
echo 'User-agent: *' . PHP_EOL; echo 'User-agent: *' . PHP_EOL;

View file

@ -69,7 +69,7 @@ function salmon_post(App $a) {
// unpack the data // unpack the data
// strip whitespace so our data element will return to one big base64 blob // strip whitespace so our data element will return to one big base64 blob
$data = str_replace(array(" ","\t","\r","\n"),array("","","",""),$base->data); $data = str_replace([" ","\t","\r","\n"],["","","",""],$base->data);
// stash away some other stuff for later // stash away some other stuff for later

View file

@ -25,26 +25,26 @@ function search_saved_searches() {
); );
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
$saved = array(); $saved = [];
foreach ($r as $rr) { foreach ($r as $rr) {
$saved[] = array( $saved[] = [
'id' => $rr['id'], 'id' => $rr['id'],
'term' => $rr['term'], 'term' => $rr['term'],
'encodedterm' => urlencode($rr['term']), 'encodedterm' => urlencode($rr['term']),
'delete' => t('Remove term'), 'delete' => t('Remove term'),
'selected' => ($search==$rr['term']), 'selected' => ($search==$rr['term']),
); ];
} }
$tpl = get_markup_template("saved_searches_aside.tpl"); $tpl = get_markup_template("saved_searches_aside.tpl");
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$title' => t('Saved Searches'), '$title' => t('Saved Searches'),
'$add' => '', '$add' => '',
'$searchbox' => '', '$searchbox' => '',
'$saved' => $saved, '$saved' => $saved,
)); ]);
} }
return $o; return $o;
@ -63,11 +63,11 @@ function search_init(App $a) {
dbesc($search) dbesc($search)
); );
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
dba::insert('search', array('uid' => local_user(), 'term' => $search)); dba::insert('search', ['uid' => local_user(), 'term' => $search]);
} }
} }
if (x($_GET,'remove') && $search) { if (x($_GET,'remove') && $search) {
dba::delete('search', array('uid' => local_user(), 'term' => $search)); dba::delete('search', ['uid' => local_user(), 'term' => $search]);
} }
$a->page['aside'] .= search_saved_searches(); $a->page['aside'] .= search_saved_searches();
@ -98,8 +98,8 @@ function search_content(App $a) {
if (Config::get('system','local_search') && !local_user() && !remote_user()) { if (Config::get('system','local_search') && !local_user() && !remote_user()) {
http_status_exit(403, http_status_exit(403,
array("title" => t("Public access denied."), ["title" => t("Public access denied."),
"description" => t("Only logged in users are permitted to perform a search."))); "description" => t("Only logged in users are permitted to perform a search.")]);
killme(); killme();
//notice(t('Public access denied.').EOL); //notice(t('Public access denied.').EOL);
//return; //return;
@ -123,13 +123,13 @@ function search_content(App $a) {
$resultdata = json_decode($result); $resultdata = json_decode($result);
if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) { if (($resultdata->time > (time() - $crawl_permit_period)) && ($resultdata->accesses > $free_crawls)) {
http_status_exit(429, http_status_exit(429,
array("title" => t("Too Many Requests"), ["title" => t("Too Many Requests"),
"description" => t("Only one search per minute is permitted for not logged in users."))); "description" => t("Only one search per minute is permitted for not logged in users.")]);
killme(); killme();
} }
Cache::set("remote_search:".$remote, json_encode(array("time" => time(), "accesses" => $resultdata->accesses + 1)), CACHE_HOUR); Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => $resultdata->accesses + 1]), CACHE_HOUR);
} else } else
Cache::set("remote_search:".$remote, json_encode(array("time" => time(), "accesses" => 1)), CACHE_HOUR); Cache::set("remote_search:".$remote, json_encode(["time" => time(), "accesses" => 1]), CACHE_HOUR);
} }
nav_set_selected('search'); nav_set_selected('search');
@ -146,12 +146,12 @@ function search_content(App $a) {
} }
// contruct a wrapper for the search header // contruct a wrapper for the search header
$o .= replace_macros(get_markup_template("content_wrapper.tpl"),array( $o .= replace_macros(get_markup_template("content_wrapper.tpl"),[
'name' => "search-header", 'name' => "search-header",
'$title' => t("Search"), '$title' => t("Search"),
'$title_size' => 3, '$title_size' => 3,
'$content' => search($search,'search-box','search',((local_user()) ? true : false), false) '$content' => search($search,'search-box','search',((local_user()) ? true : false), false)
)); ]);
if (strpos($search,'#') === 0) { if (strpos($search,'#') === 0) {
$tag = true; $tag = true;
@ -228,9 +228,9 @@ function search_content(App $a) {
else else
$title = sprintf( t('Results for: %s'), $search); $title = sprintf( t('Results for: %s'), $search);
$o .= replace_macros(get_markup_template("section_title.tpl"),array( $o .= replace_macros(get_markup_template("section_title.tpl"),[
'$title' => $title '$title' => $title
)); ]);
logger("Start Conversation for '".$search."'", LOGGER_DEBUG); logger("Start Conversation for '".$search."'", LOGGER_DEBUG);
$o .= conversation($a,$r,'search',false); $o .= conversation($a,$r,'search',false);

View file

@ -38,84 +38,84 @@ function settings_init(App $a)
// These lines provide the javascript needed by the acl selector // These lines provide the javascript needed by the acl selector
$tpl = get_markup_template('settings/head.tpl'); $tpl = get_markup_template('settings/head.tpl');
$a->page['htmlhead'] .= replace_macros($tpl,array( $a->page['htmlhead'] .= replace_macros($tpl,[
'$ispublic' => t('everybody') '$ispublic' => t('everybody')
)); ]);
$tabs = array( $tabs = [
array( [
'label' => t('Account'), 'label' => t('Account'),
'url' => 'settings', 'url' => 'settings',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'settings')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'settings')?'active':''),
'accesskey' => 'o', 'accesskey' => 'o',
), ],
); ];
if (Feature::get()) { if (Feature::get()) {
$tabs[] = array( $tabs[] = [
'label' => t('Additional features'), 'label' => t('Additional features'),
'url' => 'settings/features', 'url' => 'settings/features',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''),
'accesskey' => 't', 'accesskey' => 't',
); ];
} }
$tabs[] = array( $tabs[] = [
'label' => t('Display'), 'label' => t('Display'),
'url' => 'settings/display', 'url' => 'settings/display',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'display')?'active':''),
'accesskey' => 'i', 'accesskey' => 'i',
); ];
$tabs[] = array( $tabs[] = [
'label' => t('Social Networks'), 'label' => t('Social Networks'),
'url' => 'settings/connectors', 'url' => 'settings/connectors',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors')?'active':''),
'accesskey' => 'w', 'accesskey' => 'w',
); ];
$tabs[] = array( $tabs[] = [
'label' => t('Plugins'), 'label' => t('Plugins'),
'url' => 'settings/addon', 'url' => 'settings/addon',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon')?'active':''),
'accesskey' => 'l', 'accesskey' => 'l',
); ];
$tabs[] = array( $tabs[] = [
'label' => t('Delegations'), 'label' => t('Delegations'),
'url' => 'delegate', 'url' => 'delegate',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'delegate')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'delegate')?'active':''),
'accesskey' => 'd', 'accesskey' => 'd',
); ];
$tabs[] = array( $tabs[] = [
'label' => t('Connected apps'), 'label' => t('Connected apps'),
'url' => 'settings/oauth', 'url' => 'settings/oauth',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''), 'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth')?'active':''),
'accesskey' => 'b', 'accesskey' => 'b',
); ];
$tabs[] = array( $tabs[] = [
'label' => t('Export personal data'), 'label' => t('Export personal data'),
'url' => 'uexport', 'url' => 'uexport',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'uexport')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'uexport')?'active':''),
'accesskey' => 'e', 'accesskey' => 'e',
); ];
$tabs[] = array( $tabs[] = [
'label' => t('Remove account'), 'label' => t('Remove account'),
'url' => 'removeme', 'url' => 'removeme',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'removeme')?'active':''), 'selected' => (($a->argc == 1) && ($a->argv[0] === 'removeme')?'active':''),
'accesskey' => 'r', 'accesskey' => 'r',
); ];
$tabtpl = get_markup_template("generic_links_widget.tpl"); $tabtpl = get_markup_template("generic_links_widget.tpl");
$a->page['aside'] = replace_macros($tabtpl, array( $a->page['aside'] = replace_macros($tabtpl, [
'$title' => t('Settings'), '$title' => t('Settings'),
'$class' => 'settings-widget', '$class' => 'settings-widget',
'$items' => $tabs, '$items' => $tabs,
)); ]);
} }
@ -231,12 +231,12 @@ function settings_post(App $a)
intval(local_user()) intval(local_user())
); );
if (!DBM::is_result($r)) { if (!DBM::is_result($r)) {
dba::insert('mailacct', array('uid' => local_user())); dba::insert('mailacct', ['uid' => local_user()]);
} }
if (strlen($mail_pass)) { if (strlen($mail_pass)) {
$pass = ''; $pass = '';
openssl_public_encrypt($mail_pass, $pass, $a->user['pubkey']); openssl_public_encrypt($mail_pass, $pass, $a->user['pubkey']);
dba::update('mailacct', array('pass' => bin2hex($pass)), array('uid' => local_user())); dba::update('mailacct', ['pass' => bin2hex($pass)], ['uid' => local_user()]);
} }
$r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s', $r = q("UPDATE `mailacct` SET `server` = '%s', `port` = %d, `ssltype` = '%s', `user` = '%s',
`action` = %d, `movetofolder` = '%s', `action` = %d, `movetofolder` = '%s',
@ -466,13 +466,13 @@ function settings_post(App $a)
} }
// Adjust the page flag if the account type doesn't fit to the page flag. // Adjust the page flag if the account type doesn't fit to the page flag.
if (($account_type == ACCOUNT_TYPE_PERSON) && !in_array($page_flags, array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) { if (($account_type == ACCOUNT_TYPE_PERSON) && !in_array($page_flags, [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE])) {
$page_flags = PAGE_NORMAL; $page_flags = PAGE_NORMAL;
} elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, array(PAGE_SOAPBOX))) { } elseif (($account_type == ACCOUNT_TYPE_ORGANISATION) && !in_array($page_flags, [PAGE_SOAPBOX])) {
$page_flags = PAGE_SOAPBOX; $page_flags = PAGE_SOAPBOX;
} elseif (($account_type == ACCOUNT_TYPE_NEWS) && !in_array($page_flags, array(PAGE_SOAPBOX))) { } elseif (($account_type == ACCOUNT_TYPE_NEWS) && !in_array($page_flags, [PAGE_SOAPBOX])) {
$page_flags = PAGE_SOAPBOX; $page_flags = PAGE_SOAPBOX;
} elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, array(PAGE_COMMUNITY, PAGE_PRVGROUP))) { } elseif (($account_type == ACCOUNT_TYPE_COMMUNITY) && !in_array($page_flags, [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
$page_flags = PAGE_COMMUNITY; $page_flags = PAGE_COMMUNITY;
} }
@ -669,17 +669,17 @@ function settings_content(App $a)
if (($a->argc > 1) && ($a->argv[1] === 'oauth')) { if (($a->argc > 1) && ($a->argv[1] === 'oauth')) {
if (($a->argc > 2) && ($a->argv[2] === 'add')) { if (($a->argc > 2) && ($a->argv[2] === 'add')) {
$tpl = get_markup_template('settings/oauth_edit.tpl'); $tpl = get_markup_template('settings/oauth_edit.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$form_security_token' => get_form_security_token("settings_oauth"), '$form_security_token' => get_form_security_token("settings_oauth"),
'$title' => t('Add application'), '$title' => t('Add application'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
'$name' => array('name', t('Name'), '', ''), '$name' => ['name', t('Name'), '', ''],
'$key' => array('key', t('Consumer Key'), '', ''), '$key' => ['key', t('Consumer Key'), '', ''],
'$secret' => array('secret', t('Consumer Secret'), '', ''), '$secret' => ['secret', t('Consumer Secret'), '', ''],
'$redirect' => array('redirect', t('Redirect'), '', ''), '$redirect' => ['redirect', t('Redirect'), '', ''],
'$icon' => array('icon', t('Icon url'), '', ''), '$icon' => ['icon', t('Icon url'), '', ''],
)); ]);
return $o; return $o;
} }
@ -695,17 +695,17 @@ function settings_content(App $a)
$app = $r[0]; $app = $r[0];
$tpl = get_markup_template('settings/oauth_edit.tpl'); $tpl = get_markup_template('settings/oauth_edit.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$form_security_token' => get_form_security_token("settings_oauth"), '$form_security_token' => get_form_security_token("settings_oauth"),
'$title' => t('Add application'), '$title' => t('Add application'),
'$submit' => t('Update'), '$submit' => t('Update'),
'$cancel' => t('Cancel'), '$cancel' => t('Cancel'),
'$name' => array('name', t('Name'), $app['name'] , ''), '$name' => ['name', t('Name'), $app['name'] , ''],
'$key' => array('key', t('Consumer Key'), $app['client_id'], ''), '$key' => ['key', t('Consumer Key'), $app['client_id'], ''],
'$secret' => array('secret', t('Consumer Secret'), $app['pw'], ''), '$secret' => ['secret', t('Consumer Secret'), $app['pw'], ''],
'$redirect' => array('redirect', t('Redirect'), $app['redirect_uri'], ''), '$redirect' => ['redirect', t('Redirect'), $app['redirect_uri'], ''],
'$icon' => array('icon', t('Icon url'), $app['icon'], ''), '$icon' => ['icon', t('Icon url'), $app['icon'], ''],
)); ]);
return $o; return $o;
} }
@ -729,7 +729,7 @@ function settings_content(App $a)
$tpl = get_markup_template('settings/oauth.tpl'); $tpl = get_markup_template('settings/oauth.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$form_security_token' => get_form_security_token("settings_oauth"), '$form_security_token' => get_form_security_token("settings_oauth"),
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$title' => t('Connected Apps'), '$title' => t('Connected Apps'),
@ -740,7 +740,7 @@ function settings_content(App $a)
'$noname' => t('No name'), '$noname' => t('No name'),
'$remove' => t('Remove authorization'), '$remove' => t('Remove authorization'),
'$apps' => $r, '$apps' => $r,
)); ]);
return $o; return $o;
} }
@ -756,33 +756,33 @@ function settings_content(App $a)
$tpl = get_markup_template('settings/addons.tpl'); $tpl = get_markup_template('settings/addons.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$form_security_token' => get_form_security_token("settings_addon"), '$form_security_token' => get_form_security_token("settings_addon"),
'$title' => t('Plugin Settings'), '$title' => t('Plugin Settings'),
'$settings_addons' => $settings_addons '$settings_addons' => $settings_addons
)); ]);
return $o; return $o;
} }
if (($a->argc > 1) && ($a->argv[1] === 'features')) { if (($a->argc > 1) && ($a->argv[1] === 'features')) {
$arr = array(); $arr = [];
$features = Feature::get(); $features = Feature::get();
foreach ($features as $fname => $fdata) { foreach ($features as $fname => $fdata) {
$arr[$fname] = array(); $arr[$fname] = [];
$arr[$fname][0] = $fdata[0]; $arr[$fname][0] = $fdata[0];
foreach (array_slice($fdata,1) as $f) { foreach (array_slice($fdata,1) as $f) {
$arr[$fname][1][] = array('feature_' .$f[0], $f[1],((intval(Feature::isEnabled(local_user(), $f[0]))) ? "1" : ''), $f[2],array(t('Off'), t('On'))); $arr[$fname][1][] = ['feature_' .$f[0], $f[1],((intval(Feature::isEnabled(local_user(), $f[0]))) ? "1" : ''), $f[2],[t('Off'), t('On')]];
} }
} }
$tpl = get_markup_template('settings/features.tpl'); $tpl = get_markup_template('settings/features.tpl');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$form_security_token' => get_form_security_token("settings_features"), '$form_security_token' => get_form_security_token("settings_features"),
'$title' => t('Additional Features'), '$title' => t('Additional Features'),
'$features' => $arr, '$features' => $arr,
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
)); ]);
return $o; return $o;
} }
@ -835,7 +835,7 @@ function settings_content(App $a)
$mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : ''); $mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : '');
$o .= replace_macros($tpl, array( $o .= replace_macros($tpl, [
'$form_security_token' => get_form_security_token("settings_connectors"), '$form_security_token' => get_form_security_token("settings_connectors"),
'$title' => t('Social Networks'), '$title' => t('Social Networks'),
@ -844,10 +844,10 @@ function settings_content(App $a)
'$ostat_enabled' => $ostat_enabled, '$ostat_enabled' => $ostat_enabled,
'$general_settings' => t('General Social Media Settings'), '$general_settings' => t('General Social Media Settings'),
'$no_intelligent_shortening' => array('no_intelligent_shortening', t('Disable intelligent shortening'), $no_intelligent_shortening, t('Normally the system tries to find the best link to add to shortened posts. If this option is enabled then every shortened post will always point to the original friendica post.')), '$no_intelligent_shortening' => ['no_intelligent_shortening', t('Disable intelligent shortening'), $no_intelligent_shortening, t('Normally the system tries to find the best link to add to shortened posts. If this option is enabled then every shortened post will always point to the original friendica post.')],
'$ostatus_autofriend' => array('snautofollow', t('Automatically follow any GNU Social (OStatus) followers/mentioners'), $ostatus_autofriend, t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.')), '$ostatus_autofriend' => ['snautofollow', t('Automatically follow any GNU Social (OStatus) followers/mentioners'), $ostatus_autofriend, t('If you receive a message from an unknown OStatus user, this option decides what to do. If it is checked, a new contact will be created for every unknown user.')],
'$default_group' => Group::displayGroupSelection(local_user(), $default_group, t("Default group for OStatus contacts")), '$default_group' => Group::displayGroupSelection(local_user(), $default_group, t("Default group for OStatus contacts")),
'$legacy_contact' => array('legacy_contact', t('Your legacy GNU Social account'), $legacy_contact, t('If you enter your old GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.')), '$legacy_contact' => ['legacy_contact', t('Your legacy GNU Social account'), $legacy_contact, t('If you enter your old GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.')],
'$repair_ostatus_url' => System::baseUrl() . '/repair_ostatus', '$repair_ostatus_url' => System::baseUrl() . '/repair_ostatus',
'$repair_ostatus_text' => t('Repair OStatus subscriptions'), '$repair_ostatus_text' => t('Repair OStatus subscriptions'),
@ -856,19 +856,19 @@ function settings_content(App $a)
'$h_imap' => t('Email/Mailbox Setup'), '$h_imap' => t('Email/Mailbox Setup'),
'$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."), '$imap_desc' => t("If you wish to communicate with email contacts using this service \x28optional\x29, please specify how to connect to your mailbox."),
'$imap_lastcheck' => array('imap_lastcheck', t('Last successful email check:'), $mail_chk, ''), '$imap_lastcheck' => ['imap_lastcheck', t('Last successful email check:'), $mail_chk, ''],
'$mail_disabled' => $mail_disabled_message, '$mail_disabled' => $mail_disabled_message,
'$mail_server' => array('mail_server', t('IMAP server name:'), $mail_server, ''), '$mail_server' => ['mail_server', t('IMAP server name:'), $mail_server, ''],
'$mail_port' => array('mail_port', t('IMAP port:'), $mail_port, ''), '$mail_port' => ['mail_port', t('IMAP port:'), $mail_port, ''],
'$mail_ssl' => array('mail_ssl', t('Security:'), strtoupper($mail_ssl), '', array('notls'=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL')), '$mail_ssl' => ['mail_ssl', t('Security:'), strtoupper($mail_ssl), '', ['notls'=>t('None'), 'TLS'=>'TLS', 'SSL'=>'SSL']],
'$mail_user' => array('mail_user', t('Email login name:'), $mail_user, ''), '$mail_user' => ['mail_user', t('Email login name:'), $mail_user, ''],
'$mail_pass' => array('mail_pass', t('Email password:'), '', ''), '$mail_pass' => ['mail_pass', t('Email password:'), '', ''],
'$mail_replyto' => array('mail_replyto', t('Reply-to address:'), $mail_replyto, 'Optional'), '$mail_replyto' => ['mail_replyto', t('Reply-to address:'), $mail_replyto, 'Optional'],
'$mail_pubmail' => array('mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''), '$mail_pubmail' => ['mail_pubmail', t('Send public posts to all email contacts:'), $mail_pubmail, ''],
'$mail_action' => array('mail_action', t('Action after import:'), $mail_action, '', array(0=>t('None'), /*1=>t('Delete'),*/ 2=>t('Mark as seen'), 3=>t('Move to folder'))), '$mail_action' => ['mail_action', t('Action after import:'), $mail_action, '', [0=>t('None'), /*1=>t('Delete'),*/ 2=>t('Mark as seen'), 3=>t('Move to folder')]],
'$mail_movetofolder' => array('mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''), '$mail_movetofolder' => ['mail_movetofolder', t('Move to folder:'), $mail_movetofolder, ''],
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
)); ]);
call_hooks('display_settings', $o); call_hooks('display_settings', $o);
return $o; return $o;
@ -889,7 +889,7 @@ function settings_content(App $a)
$allowed_themes_str = Config::get('system', 'allowed_themes'); $allowed_themes_str = Config::get('system', 'allowed_themes');
$allowed_themes_raw = explode(',', $allowed_themes_str); $allowed_themes_raw = explode(',', $allowed_themes_str);
$allowed_themes = array(); $allowed_themes = [];
if (count($allowed_themes_raw)) { if (count($allowed_themes_raw)) {
foreach ($allowed_themes_raw as $x) { foreach ($allowed_themes_raw as $x) {
if (strlen(trim($x)) && is_dir("view/theme/$x")) { if (strlen(trim($x)) && is_dir("view/theme/$x")) {
@ -899,8 +899,8 @@ function settings_content(App $a)
} }
$themes = array(); $themes = [];
$mobile_themes = array("---" => t('No special theme for mobile devices')); $mobile_themes = ["---" => t('No special theme for mobile devices')];
if ($allowed_themes) { if ($allowed_themes) {
foreach ($allowed_themes as $theme) { foreach ($allowed_themes as $theme) {
$is_experimental = file_exists('view/theme/' . $theme . '/experimental'); $is_experimental = file_exists('view/theme/' . $theme . '/experimental');
@ -938,7 +938,7 @@ function settings_content(App $a)
$nosmile = PConfig::get(local_user(), 'system', 'no_smilies', 0); $nosmile = PConfig::get(local_user(), 'system', 'no_smilies', 0);
$first_day_of_week = PConfig::get(local_user(), 'system', 'first_day_of_week', 0); $first_day_of_week = PConfig::get(local_user(), 'system', 'first_day_of_week', 0);
$weekdays = array(0 => t("Sunday"), 1 => t("Monday")); $weekdays = [0 => t("Sunday"), 1 => t("Monday")];
$noinfo = PConfig::get(local_user(), 'system', 'ignore_info', 0); $noinfo = PConfig::get(local_user(), 'system', 'ignore_info', 0);
$infinite_scroll = PConfig::get(local_user(), 'system', 'infinite_scroll', 0); $infinite_scroll = PConfig::get(local_user(), 'system', 'infinite_scroll', 0);
@ -953,39 +953,39 @@ function settings_content(App $a)
} }
$tpl = get_markup_template('settings/display.tpl'); $tpl = get_markup_template('settings/display.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, [
'$ptitle' => t('Display Settings'), '$ptitle' => t('Display Settings'),
'$form_security_token' => get_form_security_token("settings_display"), '$form_security_token' => get_form_security_token("settings_display"),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$uid' => local_user(), '$uid' => local_user(),
'$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes, true), '$theme' => ['theme', t('Display Theme:'), $theme_selected, '', $themes, true],
'$mobile_theme' => array('mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false), '$mobile_theme' => ['mobile_theme', t('Mobile Theme:'), $mobile_theme_selected, '', $mobile_themes, false],
'$nowarn_insecure' => array('nowarn_insecure', t('Suppress warning of insecure networks'), $nowarn_insecure, t("Should the system suppress the warning that the current group contains members of networks that can't receive non public postings.")), '$nowarn_insecure' => ['nowarn_insecure', t('Suppress warning of insecure networks'), $nowarn_insecure, t("Should the system suppress the warning that the current group contains members of networks that can't receive non public postings.")],
'$ajaxint' => array('browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds. Enter -1 to disable it.')), '$ajaxint' => ['browser_update', t("Update browser every xx seconds"), $browser_update, t('Minimum of 10 seconds. Enter -1 to disable it.')],
'$itemspage_network' => array('itemspage_network', t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')), '$itemspage_network' => ['itemspage_network', t("Number of items to display per page:"), $itemspage_network, t('Maximum of 100 items')],
'$itemspage_mobile_network' => array('itemspage_mobile_network', t("Number of items to display per page when viewed from mobile device:"), $itemspage_mobile_network, t('Maximum of 100 items')), '$itemspage_mobile_network' => ['itemspage_mobile_network', t("Number of items to display per page when viewed from mobile device:"), $itemspage_mobile_network, t('Maximum of 100 items')],
'$nosmile' => array('nosmile', t("Don't show emoticons"), $nosmile, ''), '$nosmile' => ['nosmile', t("Don't show emoticons"), $nosmile, ''],
'$calendar_title' => t('Calendar'), '$calendar_title' => t('Calendar'),
'$first_day_of_week' => array('first_day_of_week', t('Beginning of week:'), $first_day_of_week, '', $weekdays, false), '$first_day_of_week' => ['first_day_of_week', t('Beginning of week:'), $first_day_of_week, '', $weekdays, false],
'$noinfo' => array('noinfo', t("Don't show notices"), $noinfo, ''), '$noinfo' => ['noinfo', t("Don't show notices"), $noinfo, ''],
'$infinite_scroll' => array('infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''), '$infinite_scroll' => ['infinite_scroll', t("Infinite scroll"), $infinite_scroll, ''],
'$no_auto_update' => array('no_auto_update', t("Automatic updates only at the top of the network page"), $no_auto_update, t('When disabled, the network page is updated all the time, which could be confusing while reading.')), '$no_auto_update' => ['no_auto_update', t("Automatic updates only at the top of the network page"), $no_auto_update, t('When disabled, the network page is updated all the time, which could be confusing while reading.')],
'$bandwidth_saver' => array('bandwidth_saver', t('Bandwith Saver Mode'), $bandwidth_saver, t('When enabled, embedded content is not displayed on automatic updates, they only show on page reload.')), '$bandwidth_saver' => ['bandwidth_saver', t('Bandwith Saver Mode'), $bandwidth_saver, t('When enabled, embedded content is not displayed on automatic updates, they only show on page reload.')],
'$smart_threading' => array('smart_threading', t('Smart Threading'), $smart_threading, t('When enabled, suppress extraneous thread indentation while keeping it where it matters. Only works if threading is available and enabled.')), '$smart_threading' => ['smart_threading', t('Smart Threading'), $smart_threading, t('When enabled, suppress extraneous thread indentation while keeping it where it matters. Only works if threading is available and enabled.')],
'$d_tset' => t('General Theme Settings'), '$d_tset' => t('General Theme Settings'),
'$d_ctset' => t('Custom Theme Settings'), '$d_ctset' => t('Custom Theme Settings'),
'$d_cset' => t('Content Settings'), '$d_cset' => t('Content Settings'),
'stitle' => t('Theme settings'), 'stitle' => t('Theme settings'),
'$theme_config' => $theme_config, '$theme_config' => $theme_config,
)); ]);
$tpl = get_markup_template('settings/display_end.tpl'); $tpl = get_markup_template('settings/display_end.tpl');
$a->page['end'] .= replace_macros($tpl, array( $a->page['end'] .= replace_macros($tpl, [
'$theme' => array('theme', t('Display Theme:'), $theme_selected, '', $themes) '$theme' => ['theme', t('Display Theme:'), $theme_selected, '', $themes]
)); ]);
return $o; return $o;
} }
@ -1034,13 +1034,13 @@ function settings_content(App $a)
// Set the account type to "Community" when the page is a community page but the account type doesn't fit // Set the account type to "Community" when the page is a community page but the account type doesn't fit
// This is only happening on the first visit after the update // This is only happening on the first visit after the update
if (in_array($a->user['page-flags'], array(PAGE_COMMUNITY, PAGE_PRVGROUP)) && if (in_array($a->user['page-flags'], [PAGE_COMMUNITY, PAGE_PRVGROUP]) &&
($a->user['account-type'] != ACCOUNT_TYPE_COMMUNITY)) ($a->user['account-type'] != ACCOUNT_TYPE_COMMUNITY))
$a->user['account-type'] = ACCOUNT_TYPE_COMMUNITY; $a->user['account-type'] = ACCOUNT_TYPE_COMMUNITY;
$pageset_tpl = get_markup_template('settings/pagetypes.tpl'); $pageset_tpl = get_markup_template('settings/pagetypes.tpl');
$pagetype = replace_macros($pageset_tpl, array( $pagetype = replace_macros($pageset_tpl, [
'$account_types' => t("Account Types"), '$account_types' => t("Account Types"),
'$user' => t("Personal Page Subtypes"), '$user' => t("Personal Page Subtypes"),
'$community' => t("Community Forum Subtypes"), '$community' => t("Community Forum Subtypes"),
@ -1050,93 +1050,93 @@ function settings_content(App $a)
'$type_news' => ACCOUNT_TYPE_NEWS, '$type_news' => ACCOUNT_TYPE_NEWS,
'$type_community' => ACCOUNT_TYPE_COMMUNITY, '$type_community' => ACCOUNT_TYPE_COMMUNITY,
'$account_person' => array('account-type', t('Personal Page'), ACCOUNT_TYPE_PERSON, '$account_person' => ['account-type', t('Personal Page'), ACCOUNT_TYPE_PERSON,
t('Account for a personal profile.'), t('Account for a personal profile.'),
($a->user['account-type'] == ACCOUNT_TYPE_PERSON)), ($a->user['account-type'] == ACCOUNT_TYPE_PERSON)],
'$account_organisation' => array('account-type', t('Organisation Page'), ACCOUNT_TYPE_ORGANISATION, '$account_organisation' => ['account-type', t('Organisation Page'), ACCOUNT_TYPE_ORGANISATION,
t('Account for an organisation that automatically approves contact requests as "Followers".'), t('Account for an organisation that automatically approves contact requests as "Followers".'),
($a->user['account-type'] == ACCOUNT_TYPE_ORGANISATION)), ($a->user['account-type'] == ACCOUNT_TYPE_ORGANISATION)],
'$account_news' => array('account-type', t('News Page'), ACCOUNT_TYPE_NEWS, '$account_news' => ['account-type', t('News Page'), ACCOUNT_TYPE_NEWS,
t('Account for a news reflector that automatically approves contact requests as "Followers".'), t('Account for a news reflector that automatically approves contact requests as "Followers".'),
($a->user['account-type'] == ACCOUNT_TYPE_NEWS)), ($a->user['account-type'] == ACCOUNT_TYPE_NEWS)],
'$account_community' => array('account-type', t('Community Forum'), ACCOUNT_TYPE_COMMUNITY, '$account_community' => ['account-type', t('Community Forum'), ACCOUNT_TYPE_COMMUNITY,
t('Account for community discussions.'), t('Account for community discussions.'),
($a->user['account-type'] == ACCOUNT_TYPE_COMMUNITY)), ($a->user['account-type'] == ACCOUNT_TYPE_COMMUNITY)],
'$page_normal' => array('page-flags', t('Normal Account Page'), PAGE_NORMAL, '$page_normal' => ['page-flags', t('Normal Account Page'), PAGE_NORMAL,
t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'), t('Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'),
($a->user['page-flags'] == PAGE_NORMAL)), ($a->user['page-flags'] == PAGE_NORMAL)],
'$page_soapbox' => array('page-flags', t('Soapbox Page'), PAGE_SOAPBOX, '$page_soapbox' => ['page-flags', t('Soapbox Page'), PAGE_SOAPBOX,
t('Account for a public profile that automatically approves contact requests as "Followers".'), t('Account for a public profile that automatically approves contact requests as "Followers".'),
($a->user['page-flags'] == PAGE_SOAPBOX)), ($a->user['page-flags'] == PAGE_SOAPBOX)],
'$page_community' => array('page-flags', t('Public Forum'), PAGE_COMMUNITY, '$page_community' => ['page-flags', t('Public Forum'), PAGE_COMMUNITY,
t('Automatically approves all contact requests.'), t('Automatically approves all contact requests.'),
($a->user['page-flags'] == PAGE_COMMUNITY)), ($a->user['page-flags'] == PAGE_COMMUNITY)],
'$page_freelove' => array('page-flags', t('Automatic Friend Page'), PAGE_FREELOVE, '$page_freelove' => ['page-flags', t('Automatic Friend Page'), PAGE_FREELOVE,
t('Account for a popular profile that automatically approves contact requests as "Friends".'), t('Account for a popular profile that automatically approves contact requests as "Friends".'),
($a->user['page-flags'] == PAGE_FREELOVE)), ($a->user['page-flags'] == PAGE_FREELOVE)],
'$page_prvgroup' => array('page-flags', t('Private Forum [Experimental]'), PAGE_PRVGROUP, '$page_prvgroup' => ['page-flags', t('Private Forum [Experimental]'), PAGE_PRVGROUP,
t('Requires manual approval of contact requests.'), t('Requires manual approval of contact requests.'),
($a->user['page-flags'] == PAGE_PRVGROUP)), ($a->user['page-flags'] == PAGE_PRVGROUP)],
)); ]);
$noid = Config::get('system', 'no_openid'); $noid = Config::get('system', 'no_openid');
if ($noid) { if ($noid) {
$openid_field = false; $openid_field = false;
} else { } else {
$openid_field = array('openid_url', t('OpenID:'), $openid, t("\x28Optional\x29 Allow this OpenID to login to this account."), "", "", "url"); $openid_field = ['openid_url', t('OpenID:'), $openid, t("\x28Optional\x29 Allow this OpenID to login to this account."), "", "", "url"];
} }
$opt_tpl = get_markup_template("field_yesno.tpl"); $opt_tpl = get_markup_template("field_yesno.tpl");
if (Config::get('system', 'publish_all')) { if (Config::get('system', 'publish_all')) {
$profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />'; $profile_in_dir = '<input type="hidden" name="profile_in_directory" value="1" />';
} else { } else {
$profile_in_dir = replace_macros($opt_tpl, array( $profile_in_dir = replace_macros($opt_tpl, [
'$field' => array('profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], t("Your profile may be visible in public."), array(t('No'), t('Yes'))) '$field' => ['profile_in_directory', t('Publish your default profile in your local site directory?'), $profile['publish'], t("Your profile may be visible in public."), [t('No'), t('Yes')]]
)); ]);
} }
if (strlen(Config::get('system', 'directory'))) { if (strlen(Config::get('system', 'directory'))) {
$profile_in_net_dir = replace_macros($opt_tpl, array( $profile_in_net_dir = replace_macros($opt_tpl, [
'$field' => array('profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', array(t('No'), t('Yes'))) '$field' => ['profile_in_netdirectory', t('Publish your default profile in the global social directory?'), $profile['net-publish'], '', [t('No'), t('Yes')]]
)); ]);
} else { } else {
$profile_in_net_dir = ''; $profile_in_net_dir = '';
} }
$hide_friends = replace_macros($opt_tpl, array( $hide_friends = replace_macros($opt_tpl, [
'$field' => array('hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', array(t('No'), t('Yes'))), '$field' => ['hide-friends', t('Hide your contact/friend list from viewers of your default profile?'), $profile['hide-friends'], '', [t('No'), t('Yes')]],
)); ]);
$hide_wall = replace_macros($opt_tpl, array( $hide_wall = replace_macros($opt_tpl, [
'$field' => array('hidewall', t('Hide your profile details from unknown viewers?'), $a->user['hidewall'], t("If enabled, posting public messages to Diaspora and other networks isn't possible."), array(t('No'), t('Yes'))), '$field' => ['hidewall', t('Hide your profile details from unknown viewers?'), $a->user['hidewall'], t("If enabled, posting public messages to Diaspora and other networks isn't possible."), [t('No'), t('Yes')]],
)); ]);
$blockwall = replace_macros($opt_tpl, array( $blockwall = replace_macros($opt_tpl, [
'$field' => array('blockwall', t('Allow friends to post to your profile page?'), (intval($a->user['blockwall']) ? '0' : '1'), '', array(t('No'), t('Yes'))), '$field' => ['blockwall', t('Allow friends to post to your profile page?'), (intval($a->user['blockwall']) ? '0' : '1'), '', [t('No'), t('Yes')]],
)); ]);
$blocktags = replace_macros($opt_tpl, array( $blocktags = replace_macros($opt_tpl, [
'$field' => array('blocktags', t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), '', array(t('No'), t('Yes'))), '$field' => ['blocktags', t('Allow friends to tag your posts?'), (intval($a->user['blocktags']) ? '0' : '1'), '', [t('No'), t('Yes')]],
)); ]);
$suggestme = replace_macros($opt_tpl, array( $suggestme = replace_macros($opt_tpl, [
'$field' => array('suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', array(t('No'), t('Yes'))), '$field' => ['suggestme', t('Allow us to suggest you as a potential friend to new members?'), $suggestme, '', [t('No'), t('Yes')]],
)); ]);
$unkmail = replace_macros($opt_tpl, array( $unkmail = replace_macros($opt_tpl, [
'$field' => array('unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', array(t('No'), t('Yes'))), '$field' => ['unkmail', t('Permit unknown people to send you private mail?'), $unkmail, '', [t('No'), t('Yes')]],
)); ]);
if (!$profile['publish'] && !$profile['net-publish']) { if (!$profile['publish'] && !$profile['net-publish']) {
info(t('Profile is <strong>not published</strong>.') . EOL); info(t('Profile is <strong>not published</strong>.') . EOL);
@ -1144,23 +1144,23 @@ function settings_content(App $a)
$tpl_addr = get_markup_template('settings/nick_set.tpl'); $tpl_addr = get_markup_template('settings/nick_set.tpl');
$prof_addr = replace_macros($tpl_addr,array( $prof_addr = replace_macros($tpl_addr,[
'$desc' => t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->get_hostname() . $a->get_path(), System::baseUrl() . '/profile/' . $nickname), '$desc' => t("Your Identity Address is <strong>'%s'</strong> or '%s'.", $nickname . '@' . $a->get_hostname() . $a->get_path(), System::baseUrl() . '/profile/' . $nickname),
'$basepath' => $a->get_hostname() '$basepath' => $a->get_hostname()
)); ]);
$stpl = get_markup_template('settings/settings.tpl'); $stpl = get_markup_template('settings/settings.tpl');
$expire_arr = array( $expire_arr = [
'days' => array('expire', t("Automatically expire posts after this many days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')), 'days' => ['expire', t("Automatically expire posts after this many days:"), $expire, t('If empty, posts will not expire. Expired posts will be deleted')],
'advanced' => t('Advanced expiration settings'), 'advanced' => t('Advanced expiration settings'),
'label' => t('Advanced Expiration'), 'label' => t('Advanced Expiration'),
'items' => array('expire_items', t("Expire posts:"), $expire_items, '', array(t('No'), t('Yes'))), 'items' => ['expire_items', t("Expire posts:"), $expire_items, '', [t('No'), t('Yes')]],
'notes' => array('expire_notes', t("Expire personal notes:"), $expire_notes, '', array(t('No'), t('Yes'))), 'notes' => ['expire_notes', t("Expire personal notes:"), $expire_notes, '', [t('No'), t('Yes')]],
'starred' => array('expire_starred', t("Expire starred posts:"), $expire_starred, '', array(t('No'), t('Yes'))), 'starred' => ['expire_starred', t("Expire starred posts:"), $expire_starred, '', [t('No'), t('Yes')]],
'photos' => array('expire_photos', t("Expire photos:"), $expire_photos, '', array(t('No'), t('Yes'))), 'photos' => ['expire_photos', t("Expire photos:"), $expire_photos, '', [t('No'), t('Yes')]],
'network_only' => array('expire_network_only', t("Only expire posts by others:"), $expire_network_only, '', array(t('No'), t('Yes'))), 'network_only' => ['expire_network_only', t("Only expire posts by others:"), $expire_network_only, '', [t('No'), t('Yes')]],
); ];
$group_select = Group::displayGroupSelection(local_user(), $a->user['def_gid']); $group_select = Group::displayGroupSelection(local_user(), $a->user['def_gid']);
@ -1172,7 +1172,7 @@ function settings_content(App $a)
$query_str = $a->query_string; $query_str = $a->query_string;
if (strpos($query_str, 'public=1') !== false) { 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);
} }
// I think $a->query_string may never have ? in it, but I could be wrong // I think $a->query_string may never have ? in it, but I could be wrong
@ -1188,7 +1188,7 @@ function settings_content(App $a)
$lang_choices = get_available_languages(); $lang_choices = get_available_languages();
/// @TODO Fix indending (or so) /// @TODO Fix indending (or so)
$o .= replace_macros($stpl, array( $o .= replace_macros($stpl, [
'$ptitle' => t('Account Settings'), '$ptitle' => t('Account Settings'),
'$submit' => t('Save Settings'), '$submit' => t('Save Settings'),
@ -1198,25 +1198,25 @@ function settings_content(App $a)
'$nickname_block' => $prof_addr, '$nickname_block' => $prof_addr,
'$h_pass' => t('Password Settings'), '$h_pass' => t('Password Settings'),
'$password1'=> array('password', t('New Password:'), '', ''), '$password1'=> ['password', t('New Password:'), '', ''],
'$password2'=> array('confirm', t('Confirm:'), '', t('Leave password fields blank unless changing')), '$password2'=> ['confirm', t('Confirm:'), '', t('Leave password fields blank unless changing')],
'$password3'=> array('opassword', t('Current Password:'), '', t('Your current password to confirm the changes')), '$password3'=> ['opassword', t('Current Password:'), '', t('Your current password to confirm the changes')],
'$password4'=> array('mpassword', t('Password:'), '', t('Your current password to confirm the changes')), '$password4'=> ['mpassword', t('Password:'), '', t('Your current password to confirm the changes')],
'$oid_enable' => (!Config::get('system', 'no_openid')), '$oid_enable' => (!Config::get('system', 'no_openid')),
'$openid' => $openid_field, '$openid' => $openid_field,
'$h_basic' => t('Basic Settings'), '$h_basic' => t('Basic Settings'),
'$username' => array('username', t('Full Name:'), $username, ''), '$username' => ['username', t('Full Name:'), $username, ''],
'$email' => array('email', t('Email Address:'), $email, '', '', '', 'email'), '$email' => ['email', t('Email Address:'), $email, '', '', '', 'email'],
'$timezone' => array('timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''), '$timezone' => ['timezone_select' , t('Your Timezone:'), select_timezone($timezone), ''],
'$language' => array('language', t('Your Language:'), $language, t('Set the language we use to show you friendica interface and to send you emails'), $lang_choices), '$language' => ['language', t('Your Language:'), $language, t('Set the language we use to show you friendica interface and to send you emails'), $lang_choices],
'$defloc' => array('defloc', t('Default Post Location:'), $defloc, ''), '$defloc' => ['defloc', t('Default Post Location:'), $defloc, ''],
'$allowloc' => array('allow_location', t('Use Browser Location:'), ($a->user['allow_location'] == 1), ''), '$allowloc' => ['allow_location', t('Use Browser Location:'), ($a->user['allow_location'] == 1), ''],
'$h_prv' => t('Security and Privacy Settings'), '$h_prv' => t('Security and Privacy Settings'),
'$maxreq' => array('maxreq', t('Maximum Friend Requests/Day:'), $maxreq , t("\x28to prevent spam abuse\x29")), '$maxreq' => ['maxreq', t('Maximum Friend Requests/Day:'), $maxreq , t("\x28to prevent spam abuse\x29")],
'$permissions' => t('Default Post Permissions'), '$permissions' => t('Default Post Permissions'),
'$permdesc' => t("\x28click to open/close\x29"), '$permdesc' => t("\x28click to open/close\x29"),
'$visibility' => $profile['net-publish'], '$visibility' => $profile['net-publish'],
@ -1245,33 +1245,33 @@ function settings_content(App $a)
'$hide_friends' => $hide_friends, '$hide_friends' => $hide_friends,
'$hide_wall' => $hide_wall, '$hide_wall' => $hide_wall,
'$unkmail' => $unkmail, '$unkmail' => $unkmail,
'$cntunkmail' => array('cntunkmail', t('Maximum private messages per day from unknown people:'), $cntunkmail , t("\x28to prevent spam abuse\x29")), '$cntunkmail' => ['cntunkmail', t('Maximum private messages per day from unknown people:'), $cntunkmail , t("\x28to prevent spam abuse\x29")],
'$h_not' => t('Notification Settings'), '$h_not' => t('Notification Settings'),
'$activity_options' => t('By default post a status message when:'), '$activity_options' => t('By default post a status message when:'),
'$post_newfriend' => array('post_newfriend', t('accepting a friend request'), $post_newfriend, ''), '$post_newfriend' => ['post_newfriend', t('accepting a friend request'), $post_newfriend, ''],
'$post_joingroup' => array('post_joingroup', t('joining a forum/community'), $post_joingroup, ''), '$post_joingroup' => ['post_joingroup', t('joining a forum/community'), $post_joingroup, ''],
'$post_profilechange' => array('post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, ''), '$post_profilechange' => ['post_profilechange', t('making an <em>interesting</em> profile change'), $post_profilechange, ''],
'$lbl_not' => t('Send a notification email when:'), '$lbl_not' => t('Send a notification email when:'),
'$notify1' => array('notify1', t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''), '$notify1' => ['notify1', t('You receive an introduction'), ($notify & NOTIFY_INTRO), NOTIFY_INTRO, ''],
'$notify2' => array('notify2', t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''), '$notify2' => ['notify2', t('Your introductions are confirmed'), ($notify & NOTIFY_CONFIRM), NOTIFY_CONFIRM, ''],
'$notify3' => array('notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''), '$notify3' => ['notify3', t('Someone writes on your profile wall'), ($notify & NOTIFY_WALL), NOTIFY_WALL, ''],
'$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''), '$notify4' => ['notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''],
'$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''), '$notify5' => ['notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''],
'$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''), '$notify6' => ['notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''],
'$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''), '$notify7' => ['notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''],
'$notify8' => array('notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''), '$notify8' => ['notify8', t('You are poked/prodded/etc. in a post'), ($notify & NOTIFY_POKE), NOTIFY_POKE, ''],
'$desktop_notifications' => array('desktop_notifications', t('Activate desktop notifications') , false, t('Show desktop popup on new notifications')), '$desktop_notifications' => ['desktop_notifications', t('Activate desktop notifications') , false, t('Show desktop popup on new notifications')],
'$email_textonly' => array('email_textonly', t('Text-only notification emails'), '$email_textonly' => ['email_textonly', t('Text-only notification emails'),
PConfig::get(local_user(), 'system', 'email_textonly'), PConfig::get(local_user(), 'system', 'email_textonly'),
t('Send text only notification emails, without the html part')), t('Send text only notification emails, without the html part')],
'$detailed_notif' => array('detailed_notif', t('Show detailled notifications'), '$detailed_notif' => ['detailed_notif', t('Show detailled notifications'),
PConfig::get(local_user(), 'system', 'detailed_notif'), PConfig::get(local_user(), 'system', 'detailed_notif'),
t('Per default the notificiation are condensed to a single notification per item. When enabled, every notification is displayed.')), t('Per default the notificiation are condensed to a single notification per item. When enabled, every notification is displayed.')],
'$h_advn' => t('Advanced Account/Page Type Settings'), '$h_advn' => t('Advanced Account/Page Type Settings'),
'$h_descadvn' => t('Change the behaviour of this account for special situations'), '$h_descadvn' => t('Change the behaviour of this account for special situations'),
@ -1281,7 +1281,7 @@ function settings_content(App $a)
'$relocate_text' => t("If you have moved this profile from another server, and some of your contacts don't receive your updates, try pushing this button."), '$relocate_text' => t("If you have moved this profile from another server, and some of your contacts don't receive your updates, try pushing this button."),
'$relocate_button' => t("Resend relocate message to contacts"), '$relocate_button' => t("Resend relocate message to contacts"),
)); ]);
call_hooks('settings_form', $o); call_hooks('settings_form', $o);

Some files were not shown because too many files have changed in this diff Show more