diff --git a/boot.php b/boot.php
index 2fe73bc81..4bfa5c098 100644
--- a/boot.php
+++ b/boot.php
@@ -288,7 +288,7 @@ define('NETWORK_PHANTOM', 'unkn'); // Place holder
* and existing allocations MUST NEVER BE CHANGED
* OR RE-ASSIGNED! You may only add to them.
*/
-$netgroup_ids = array(
+$netgroup_ids = [
NETWORK_DFRN => (-1),
NETWORK_ZOT => (-2),
NETWORK_OSTATUS => (-3),
@@ -310,7 +310,7 @@ $netgroup_ids = array(
NETWORK_PNUT => (-20),
NETWORK_PHANTOM => (-127),
-);
+];
/**
* 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);
if (get_magic_quotes_gpc()) {
- $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
+ $process = [&$_GET, &$_POST, &$_COOKIE, &$_REQUEST];
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
@@ -817,11 +817,11 @@ function check_plugins(App $a)
if (DBM::is_result($r)) {
$installed = $r;
} else {
- $installed = array();
+ $installed = [];
}
$plugins = Config::get('system', 'addon');
- $plugins_arr = array();
+ $plugins_arr = [];
if ($plugins) {
$plugins_arr = explode(',', str_replace(' ', '', $plugins));
@@ -829,7 +829,7 @@ function check_plugins(App $a)
$a->plugins = $plugins_arr;
- $installed_arr = array();
+ $installed_arr = [];
if (count($installed)) {
foreach ($installed as $i) {
@@ -966,7 +966,7 @@ function notice($s)
{
$a = get_app();
if (!x($_SESSION, 'sysmsg')) {
- $_SESSION['sysmsg'] = array();
+ $_SESSION['sysmsg'] = [];
}
if ($a->interactive) {
$_SESSION['sysmsg'][] = $s;
@@ -989,7 +989,7 @@ function info($s)
}
if (!x($_SESSION, 'sysmsg_info')) {
- $_SESSION['sysmsg_info'] = array();
+ $_SESSION['sysmsg_info'] = [];
}
if ($a->interactive) {
$_SESSION['sysmsg_info'][] = $s;
@@ -1010,7 +1010,7 @@ function get_max_import_size()
function current_theme()
{
- $app_base_themes = array('duepuntozero', 'dispy', 'quattro');
+ $app_base_themes = ['duepuntozero', 'dispy', 'quattro'];
$a = get_app();
@@ -1238,10 +1238,10 @@ function explode_querystring($query)
$args = array_values($args);
}
- return array(
+ return [
'base' => $base,
'args' => $args,
- );
+ ];
}
/**
@@ -1571,7 +1571,7 @@ function infinite_scroll_data($module)
$reload_uri .= "&offset=" . urlencode($a->page_offset);
}
- $arr = array("pageno" => $pageno, "reload_uri" => $reload_uri);
+ $arr = ["pageno" => $pageno, "reload_uri" => $reload_uri];
return $arr;
}
diff --git a/htconfig.php b/htconfig.php
index ada7a130b..67db66e86 100644
--- a/htconfig.php
+++ b/htconfig.php
@@ -86,7 +86,7 @@ $a->config['system']['no_regfullname'] = true;
$a->config['system']['directory'] = 'https://dir.friendica.social';
// 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
$a->config['system']['auth_cookie_lifetime'] = 7;
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index a93393d80..5be3fd1f3 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -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'
@@ -87,20 +87,20 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
if (x($options, 'networks')) {
switch ($options['networks']) {
case 'DFRN_ONLY':
- $networks = array(NETWORK_DFRN);
+ $networks = [NETWORK_DFRN];
break;
case 'PRIVATE':
if (is_array($a->user) && $a->user['prvnets']) {
- $networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
+ $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
} else {
- $networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA);
+ $networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA];
}
break;
case 'TWO_WAY':
if (is_array($a->user) && $a->user['prvnets']) {
- $networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
+ $networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
} 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;
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);
@@ -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'
@@ -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'
call_hooks($a->module . '_pre_' . $selname, $arr);
- $receiverlist = array();
+ $receiverlist = [];
if (DBM::is_result($r)) {
foreach ($r as $rr) {
@@ -270,7 +270,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
function fixacl(&$item) {
- $item = intval(str_replace(array('<', '>'), array('', ''), $item));
+ $item = intval(str_replace(['<', '>'], ['', ''], $item));
}
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 ");
if (DBM::is_result($r)) {
- $ret = array();
+ $ret = [];
foreach ($r as $rr) {
$ret[] = intval($rr['id']);
}
return $ret;
}
- return array();
+ return [];
}
@@ -300,13 +300,13 @@ function get_acl_permissions($user = null) {
if (is_array($user)) {
$allow_cid = ((strlen($user['allow_cid']))
- ? explode('><', $user['allow_cid']) : array() );
+ ? explode('><', $user['allow_cid']) : [] );
$allow_gid = ((strlen($user['allow_gid']))
- ? explode('><', $user['allow_gid']) : array() );
+ ? explode('><', $user['allow_gid']) : [] );
$deny_cid = ((strlen($user['deny_cid']))
- ? explode('><', $user['deny_cid']) : array() );
+ ? explode('><', $user['deny_cid']) : [] );
$deny_gid = ((strlen($user['deny_gid']))
- ? explode('><', $user['deny_gid']) : array() );
+ ? explode('><', $user['deny_gid']) : [] );
array_walk($allow_cid,'fixacl');
array_walk($allow_gid,'fixacl');
array_walk($deny_cid,'fixacl');
@@ -315,12 +315,12 @@ function get_acl_permissions($user = null) {
$allow_cid = prune_deadguys($allow_cid);
- return array(
+ return [
'allow_cid' => $allow_cid,
'allow_gid' => $allow_gid,
'deny_cid' => $deny_cid,
'deny_gid' => $deny_gid,
- );
+ ];
}
@@ -361,7 +361,7 @@ function populate_acl($user = null, $show_jotnets = false) {
}
$tpl = get_markup_template("acl_selector.tpl");
- $o = replace_macros($tpl, array(
+ $o = replace_macros($tpl, [
'$showall'=> t("Visible to everybody"),
'$show' => t("show"),
'$hide' => t("don't show"),
@@ -375,10 +375,10 @@ function populate_acl($user = null, $show_jotnets = false) {
'$jotnets' => $jotnets,
'$aclModalTitle' => t('Permissions'),
'$aclModalDismiss' => t('Close'),
- '$features' => array(
+ '$features' => [
'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "false")
- ),
- ));
+ ],
+ ]);
return $o;
@@ -475,8 +475,8 @@ function acl_lookup(App $a, $out_type = 'json')
$tot = $group_count + $contact_count;
- $groups = array();
- $contacts = array();
+ $groups = [];
+ $contacts = [];
if ($type == '' || $type == 'g') {
/// @todo We should cache this query.
@@ -495,7 +495,7 @@ function acl_lookup(App $a, $out_type = 'json')
);
foreach ($r as $g) {
- $groups[] = array(
+ $groups[] = [
"type" => "g",
"photo" => "images/twopeople.png",
"name" => htmlentities($g['name']),
@@ -503,10 +503,10 @@ function acl_lookup(App $a, $out_type = 'json')
"uids" => array_map("intval", explode(",",$g['uids'])),
"link" => '',
"forum" => '0'
- );
+ ];
}
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') {
// autocomplete for global contact search (e.g. navbar search)
$r = navbar_complete($a);
- $contacts = array();
+ $contacts = [];
if ($r) {
foreach ($r as $g) {
- $contacts[] = array(
+ $contacts[] = [
'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
'name' => $g['name'],
'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
'network' => $g['network'],
'link' => $g['url'],
'forum' => (x($g['community']) ? 1 : 0),
- );
+ ];
}
}
- $o = array(
+ $o = [
'start' => $start,
'count' => $count,
'items' => $contacts,
- );
+ ];
echo json_encode($o);
killme();
} else {
- $r = array();
+ $r = [];
}
if (DBM::is_result($r)) {
- $forums = array();
+ $forums = [];
foreach ($r as $g) {
- $entry = array(
+ $entry = [
'type' => 'c',
'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
'name' => htmlentities($g['name']),
@@ -595,7 +595,7 @@ function acl_lookup(App $a, $out_type = 'json')
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']),
'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0),
- );
+ ];
if ($entry['forum']) {
$forums[] = $entry;
} else {
@@ -604,7 +604,7 @@ function acl_lookup(App $a, $out_type = 'json')
}
if (count($forums) > 0) {
if ($search == "") {
- $forums[] = array("separator" => true);
+ $forums[] = ["separator" => true];
}
$contacts = array_merge($forums, $contacts);
}
@@ -623,7 +623,7 @@ function acl_lookup(App $a, $out_type = 'json')
}
, $contacts);
- $unknown_contacts = array();
+ $unknown_contacts = [];
$r = q("SELECT `author-link`
FROM `item` WHERE `parent` = %d
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']);
if (count($contact) > 0) {
- $unknown_contacts[] = array(
+ $unknown_contacts[] = [
'type' => 'c',
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
'name' => htmlentities($contact['name']),
@@ -651,7 +651,7 @@ function acl_lookup(App $a, $out_type = 'json')
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']),
'forum' => $contact['forum']
- );
+ ];
}
}
}
@@ -660,7 +660,7 @@ function acl_lookup(App $a, $out_type = 'json')
$tot += count($unknown_contacts);
}
- $results = array(
+ $results = [
'tot' => $tot,
'start' => $start,
'count' => $count,
@@ -669,27 +669,27 @@ function acl_lookup(App $a, $out_type = 'json')
'items' => $items,
'type' => $type,
'search' => $search,
- );
+ ];
call_hooks('acl_lookup_end', $results);
if ($out_type === 'html') {
- $o = array(
+ $o = [
'tot' => $results['tot'],
'start' => $results['start'],
'count' => $results['count'],
'groups' => $results['groups'],
'contacts' => $results['contacts'],
- );
+ ];
return $o;
}
- $o = array(
+ $o = [
'tot' => $results['tot'],
'start' => $results['start'],
'count' => $results['count'],
'items' => $results['items'],
- );
+ ];
echo json_encode($o);
@@ -717,7 +717,7 @@ function navbar_complete(App $a) {
// don't search if search term has less than 2 characters
if (! $search || mb_strlen($search) < 2) {
- return array();
+ return [];
}
if (substr($search,0,1) === '@') {
diff --git a/include/api.php b/include/api.php
index da7a83f51..21db40433 100644
--- a/include/api.php
+++ b/include/api.php
@@ -51,7 +51,7 @@ define('API_METHOD_GET', 'GET');
define('API_METHOD_POST', 'POST,PUT');
define('API_METHOD_DELETE', 'POST,DELETE');
-$API = array();
+$API = [];
$called_api = null;
/**
@@ -125,20 +125,20 @@ function api_register_func($path, $func, $auth = false, $method = API_METHOD_ANY
{
global $API;
- $API[$path] = array(
+ $API[$path] = [
'func' => $func,
'auth' => $auth,
'method' => $method,
- );
+ ];
// Workaround for hotot
$path = str_replace("api/", "api/1.1/", $path);
- $API[$path] = array(
+ $API[$path] = [
'func' => $func,
'auth' => $auth,
'method' => $method,
- );
+ ];
}
/**
@@ -203,12 +203,12 @@ function api_login(App $a)
// next code from mod/auth.php. needs better solution
$record = null;
- $addon_auth = array(
+ $addon_auth = [
'username' => trim($user),
'password' => trim($password),
'authenticated' => 0,
'user_record' => null,
- );
+ ];
/*
* A plugin indicates successful login by setting 'authenticated' to non-zero value and returning a user record
@@ -409,11 +409,11 @@ function api_error($type, $e)
$error = ($e->getMessage() !== "" ? $e->getMessage() : $e->httpdesc);
/// @TODO: https://dev.twitter.com/overview/api/response-codes
- $error = array("error" => $error,
+ $error = ["error" => $error,
"code" => $e->httpcode . " " . $e->httpdesc,
- "request" => $a->query_string);
+ "request" => $a->query_string];
- $return = api_format_data('status', $type, array('status' => $error));
+ $return = api_format_data('status', $type, ['status' => $error]);
switch ($type) {
case "xml":
@@ -450,7 +450,7 @@ function api_rss_extra(App $a, $arr, $user_info)
}
$arr['$user'] = $user_info;
- $arr['$rss'] = array(
+ $arr['$rss'] = [
'alternate' => $user_info['url'],
'self' => System::baseUrl() . "/" . $a->query_string,
'base' => System::baseUrl(),
@@ -458,7 +458,7 @@ function api_rss_extra(App $a, $arr, $user_info)
'atom_updated' => datetime_convert('UTC', 'UTC', 'now', ATOM_TIME),
'language' => $user_info['language'],
'logo' => System::baseUrl() . "/images/friendica-32.png",
- );
+ ];
return $arr;
}
@@ -473,7 +473,7 @@ function api_rss_extra(App $a, $arr, $user_info)
*/
function api_unique_id_to_nurl($id)
{
- $r = dba::selectFirst('contact', array('nurl'), array('uid' => 0, 'id' => $id));
+ $r = dba::selectFirst('contact', ['nurl'], ['uid' => 0, 'id' => $id]);
if (DBM::is_result($r)) {
return $r["nurl"];
@@ -603,7 +603,7 @@ function api_get_user(App $a, $contact_id = null)
// if the contact wasn't found, fetch it from the contacts with uid = 0
if (!DBM::is_result($uinfo)) {
- $r = array();
+ $r = [];
if ($url != "") {
$r = q("SELECT * FROM `contact` WHERE `uid` = 0 AND `nurl` = '%s' LIMIT 1", dbesc(normalise_link($url)));
@@ -617,7 +617,7 @@ function api_get_user(App $a, $contact_id = null)
$r[0]['nick'] = api_get_nick($r[0]["url"]);
}
- $ret = array(
+ $ret = [
'id' => $r[0]["id"],
'id_str' => (string) $r[0]["id"],
'name' => $r[0]["name"],
@@ -651,7 +651,7 @@ function api_get_user(App $a, $contact_id = null)
'cid' => Contact::getIdForURL($r[0]["url"], api_user(), true),
'self' => 0,
'network' => $r[0]["network"],
- );
+ ];
return $ret;
} else {
@@ -752,7 +752,7 @@ function api_get_user(App $a, $contact_id = null)
$location = $network_name;
}
- $ret = array(
+ $ret = [
'id' => intval($pcontact_id),
'id_str' => (string) intval($pcontact_id),
'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
@@ -788,7 +788,7 @@ function api_get_user(App $a, $contact_id = null)
'cid' => intval($uinfo[0]['cid']),
'self' => $uinfo[0]['self'],
'network' => $uinfo[0]['network'],
- );
+ ];
// If this is a local user and it uses Frio, we can get its color preferences.
if ($ret['self']) {
@@ -847,7 +847,7 @@ function api_item_get_user(App $a, $item)
$owner_user = $status_user;
}
- return (array($status_user, $owner_user));
+ return ([$status_user, $owner_user]);
}
/**
@@ -860,7 +860,7 @@ function api_item_get_user(App $a, $item)
*/
function api_walk_recursive(array &$array, callable $callback)
{
- $new_array = array();
+ $new_array = [];
foreach ($array as $k => $v) {
if (is_array($v)) {
@@ -918,14 +918,14 @@ function api_create_xml($data, $root_element)
$data2 = array_pop($data);
$key = key($data2);
- $namespaces = array("" => "http://api.twitter.com",
+ $namespaces = ["" => "http://api.twitter.com",
"statusnet" => "http://status.net/schema/api/1/",
"friendica" => "http://friendi.ca/schema/api/1/",
- "georss" => "http://www.georss.org/georss");
+ "georss" => "http://www.georss.org/georss"];
/// @todo Auto detection of needed namespaces
- if (in_array($root_element, array("ok", "hash", "config", "version", "ids", "notes", "photos"))) {
- $namespaces = array();
+ if (in_array($root_element, ["ok", "hash", "config", "version", "ids", "notes", "photos"])) {
+ $namespaces = [];
}
if (is_array($data2)) {
@@ -933,7 +933,7 @@ function api_create_xml($data, $root_element)
}
if ($key == "0") {
- $data4 = array();
+ $data4 = [];
$i = 1;
foreach ($data2 as $item) {
@@ -943,7 +943,7 @@ function api_create_xml($data, $root_element)
$data2 = $data4;
}
- $data3 = array($root_element => $data2);
+ $data3 = [$root_element => $data2];
$ret = XML::fromArray($data3, $xml, false, $namespaces);
return $ret;
@@ -1021,7 +1021,7 @@ function api_account_verify_credentials($type)
unset($user_info["uid"]);
unset($user_info["self"]);
- return api_format_data("user", $type, array('user' => $user_info));
+ return api_format_data("user", $type, ['user' => $user_info]);
}
/// @TODO move to top of file or somewhere better
@@ -1301,17 +1301,17 @@ function api_media_upload()
throw new InternalServerErrorException();
}
- $returndata = array();
+ $returndata = [];
$returndata["media_id"] = $media["id"];
$returndata["media_id_string"] = (string)$media["id"];
$returndata["size"] = $media["size"];
- $returndata["image"] = array("w" => $media["width"],
+ $returndata["image"] = ["w" => $media["width"],
"h" => $media["height"],
- "image_type" => $media["type"]);
+ "image_type" => $media["type"]];
logger("Media uploaded: " . print_r($returndata, true), LOGGER_DEBUG);
- return array("media" => $returndata);
+ return ["media" => $returndata];
}
/// @TODO move to top of file or somewhere better
@@ -1367,7 +1367,7 @@ function api_status_show($type)
$geo = "geo";
}
- $status_info = array(
+ $status_info = [
'created_at' => api_date($lastwall['created']),
'id' => intval($lastwall['id']),
'id_str' => (string) $lastwall['id'],
@@ -1394,7 +1394,7 @@ function api_status_show($type)
'statusnet_html' => $converted["html"],
'statusnet_conversation_id' => $lastwall['parent'],
'external_url' => System::baseUrl() . "/display/" . $lastwall['guid'],
- );
+ ];
if (count($converted["attachments"]) > 0) {
$status_info["attachments"] = $converted["attachments"];
@@ -1421,7 +1421,7 @@ function api_status_show($type)
return $status_info;
}
- return api_format_data("statuses", $type, array('status' => $status_info));
+ return api_format_data("statuses", $type, ['status' => $status_info]);
}
/**
@@ -1468,7 +1468,7 @@ function api_users_show($type)
$geo = "geo";
}
- $user_info['status'] = array(
+ $user_info['status'] = [
'text' => $converted["text"],
'truncated' => false,
'created_at' => api_date($lastwall['created']),
@@ -1485,7 +1485,7 @@ function api_users_show($type)
'statusnet_html' => $converted["html"],
'statusnet_conversation_id' => $lastwall['parent'],
'external_url' => System::baseUrl() . "/display/" . $lastwall['guid'],
- );
+ ];
if (count($converted["attachments"]) > 0) {
$user_info["status"]["attachments"] = $converted["attachments"];
@@ -1508,7 +1508,7 @@ function api_users_show($type)
unset($user_info["uid"]);
unset($user_info["self"]);
- return api_format_data("user", $type, array('user' => $user_info));
+ return api_format_data("user", $type, ['user' => $user_info]);
}
/// @TODO move to top of file or somewhere better
@@ -1527,7 +1527,7 @@ function api_users_search($type)
{
$a = get_app();
- $userlist = array();
+ $userlist = [];
if (x($_GET, 'q')) {
$r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
@@ -1547,7 +1547,7 @@ function api_users_search($type)
$userlist[] = $user_info;
}
}
- $userlist = array("users" => $userlist);
+ $userlist = ["users" => $userlist];
} else {
throw new BadRequestException("User not found.");
}
@@ -1573,7 +1573,7 @@ api_register_func('api/users/search', 'api_users_search');
*/
function api_users_lookup($type)
{
- $users = array();
+ $users = [];
if (x($_REQUEST['user_id'])) {
foreach (explode(',', $_REQUEST['user_id']) as $id) {
@@ -1587,7 +1587,7 @@ function api_users_lookup($type)
throw new NotFoundException;
}
- return api_format_data("users", $type, array('users' => $users));
+ return api_format_data("users", $type, ['users' => $users]);
}
/// @TODO move to top of file or somewhere better
@@ -1605,7 +1605,7 @@ api_register_func('api/users/lookup', 'api_users_lookup', true);
*/
function api_search($type)
{
- $data = array();
+ $data = [];
if (!x($_REQUEST, 'q')) {
throw new BadRequestException("q parameter is required.");
@@ -1726,7 +1726,7 @@ function api_statuses_home_timeline($type)
$ret = api_format_items($r, $user_info, false, $type);
// Set all posts from the query above to seen
- $idarray = array();
+ $idarray = [];
foreach ($r as $item) {
$idarray[] = intval($item["id"]);
}
@@ -1741,7 +1741,7 @@ function api_statuses_home_timeline($type)
}
}
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -1848,7 +1848,7 @@ function api_statuses_public_timeline($type)
$ret = api_format_items($r, $user_info, false, $type);
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -1920,7 +1920,7 @@ function api_statuses_networkpublic_timeline($type)
$ret = api_format_items($r, $user_info, false, $type);
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -1998,10 +1998,10 @@ function api_statuses_show($type)
$ret = api_format_items($r, $user_info, false, $type);
if ($conversation) {
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
return api_format_data("statuses", $type, $data);
} else {
- $data = array('status' => $ret[0]);
+ $data = ['status' => $ret[0]];
return api_format_data("status", $type, $data);
}
}
@@ -2091,7 +2091,7 @@ function api_conversation_show($type)
$ret = api_format_items($r, $user_info, false, $type);
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
return api_format_data("statuses", $type, $data);
}
@@ -2294,7 +2294,7 @@ function api_statuses_mentions($type)
$ret = api_format_items($r, $user_info, false, $type);
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -2390,7 +2390,7 @@ function api_statuses_user_timeline($type)
$ret = api_format_items($r, $user_info, true, $type);
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -2468,7 +2468,7 @@ function api_favorites_create_destroy($type)
$rets = api_format_items($item, $user_info, false, $type);
$ret = $rets[0];
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -2499,7 +2499,7 @@ function api_favorites($type)
throw new ForbiddenException();
}
- $called_api = array();
+ $called_api = [];
$user_info = api_get_user($a);
@@ -2508,7 +2508,7 @@ function api_favorites($type)
logger('api_favorites: self:' . $user_info['self']);
if ($user_info['self'] == 0) {
- $ret = array();
+ $ret = [];
} else {
$sql_extra = "";
@@ -2550,7 +2550,7 @@ function api_favorites($type)
$ret = api_format_items($r, $user_info, false, $type);
}
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -2574,7 +2574,7 @@ api_register_func('api/favorites', 'api_favorites', true);
function api_format_messages($item, $recipient, $sender)
{
// standard meta information
- $ret = array(
+ $ret = [
'id' => $item['id'],
'sender_id' => $sender['id'] ,
'text' => "",
@@ -2587,7 +2587,7 @@ function api_format_messages($item, $recipient, $sender)
'title' => "",
'friendica_seen' => $item['seen'],
'friendica_parent_uri' => $item['parent-uri'],
- );
+ ];
// "uid" and "self" are only needed for some internal stuff, so remove it from here
unset($ret["sender"]["uid"]);
@@ -2648,14 +2648,14 @@ function api_convert_item($item)
$statushtml = trim(bbcode($body, false, false));
// Workaround for clients with limited HTML parser functionality
- $search = array("
", "
", "", + $search = ["
", "", "
", "
", "
', '
'), array('
', '
', '
'), $s);
+ $s = str_replace(['
', '
'], ['
', '
', '
'], $s);
// Escaping the hash tags
$s = preg_replace('/\#([^\s\#])/', '#$1', $s);
@@ -178,11 +178,11 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) {
}
// mask some special HTML chars from conversation to markdown
- $Text = str_replace(array('<', '>', '&'), array('&_lt_;', '&_gt_;', '&_amp_;'), $Text);
+ $Text = str_replace(['<', '>', '&'], ['&_lt_;', '&_gt_;', '&_amp_;'], $Text);
// 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.
- $Text = str_replace(array("
"), array(""), $Text); + $Text = str_replace([""], [""], $Text); $stamp1 = microtime(true); @@ -191,12 +191,12 @@ function bb2diaspora($Text, $preserve_nl = false, $fordiaspora = true) { $Text = $converter->convert($Text); // unmask the special chars back to HTML - $Text = str_replace(array('&\_lt\_;', '&\_gt\_;', '&\_amp\_;'), array('<', '>', '&'), $Text); + $Text = str_replace(['&\_lt\_;', '&\_gt\_;', '&\_amp\_;'], ['<', '>', '&'], $Text); $a->save_timestamp($stamp1, "parser"); // 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 // the Diaspora signature verification and cause the item to disappear diff --git a/include/bbcode.php b/include/bbcode.php index 47c401821..a6ffc39c1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -60,7 +60,7 @@ function bb_attachment($return, $simplehtml = false, $tryoembed = true) if (isset($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"] != "")) { @@ -280,7 +280,7 @@ function bb_find_open_close($s, $open, $close, $occurence = 1) { return false; } - $res = array( 'start' => $start_pos, 'end' => $end_pos ); + $res = [ 'start' => $start_pos, 'end' => $end_pos ]; return $res; } @@ -316,16 +316,16 @@ function get_bb_tag_pos($s, $name, $occurence = 1) { return false; } - $res = array( - 'start' => array( + $res = [ + 'start' => [ 'open' => $start_open, 'close' => $start_close - ), - 'end' => array( + ], + 'end' => [ 'open' => $end_open, 'close' => $end_open + strlen('[/' . $name . ']') - ), - ); + ], + ]; if ($start_equal !== false) { $res['start']['equal'] = $start_equal + 1; @@ -360,7 +360,7 @@ function bb_tag_preg_replace($pattern, $replace, $name, $s) { function bb_extract_images($body) { - $saved_image = array(); + $saved_image = []; $orig_body = $body; $new_body = ''; @@ -398,7 +398,7 @@ function bb_extract_images($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) { @@ -595,14 +595,14 @@ function bb_ShareAttributes($share, $simplehtml) $avatar = proxy_url($avatar, false, PROXY_SIZE_THUMB); $tpl = get_markup_template('shared_content.tpl'); - $text .= replace_macros($tpl, array( + $text .= replace_macros($tpl, [ '$profile' => $profile, '$avatar' => $avatar, '$author' => $author, '$link' => $link, '$posted' => $posted, '$content' => trim($share[3]) - )); + ]); } break; } @@ -752,7 +752,7 @@ function bb_RemovePictureLinks($match) { $xpath = new DomXPath($doc); $list = $xpath->query("//meta[@name]"); foreach ($list as $node) { - $attr = array(); + $attr = []; if ($node->attributes->length) foreach ($node->attributes as $attribute) @@ -809,7 +809,7 @@ function bb_CleanPictureLinksSub($match) { $xpath = new DomXPath($doc); $list = $xpath->query("//meta[@name]"); foreach ($list as $node) { - $attr = array(); + $attr = []; if ($node->attributes->length) foreach ($node->attributes as $attribute) @@ -951,10 +951,10 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa // removing multiplicated newlines 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", - "\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]", - "[h1]", "[/h1]", "[h2]", "[/h2]", "[h3]", "[/h3]", "[h4]", "[/h4]", "[h5]", "[/h5]", "[h6]", "[/h6]"); + $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"]; + $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]"]; do { $oldtext = $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 $Text = bb_attachment($Text, $simplehtml, $tryoembed); - $Text = str_replace(array("\r","\n"), array('
', '
'), $Text); + $Text = str_replace(["\r","\n"], ['
', '
'], $Text); if ($preserve_nl) { - $Text = str_replace(array("\n", "\r"), array('', ''), $Text); + $Text = str_replace(["\n", "\r"], ['', ''], $Text); } // 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); } elseif ($simplehtml == 3) { $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", "[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("/[^#@!]\[url\=([^\]]*)\](.*?)\[\/url\]/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)=(.*?)\&\;(.*?)\>/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) - static $allowed_src_protocols = array('http', 'redir', 'cid'); + static $allowed_src_protocols = ['http', 'redir', 'cid']; $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); // sanitize href attributes (only whitelisted protocols URLs) // 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 $allowed_link_protocols[] = 'http'; @@ -1386,7 +1386,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa @$doc->loadHTML($encoding.$doctype."".$Text.""); $doc->encoding = 'UTF-8'; $Text = $doc->saveHTML(); - $Text = str_replace(array("", "", $doctype, $encoding), array("", "", "", ""), $Text); + $Text = str_replace(["", "", $doctype, $encoding], ["", "", "", ""], $Text); $Text = str_replace('
', '', $Text); @@ -1427,7 +1427,7 @@ function remove_abstract($text) { */ function fetch_abstract($text, $addon = "") { $abstract = ""; - $abstracts = array(); + $abstracts = []; $addon = strtolower($addon); if (preg_match_all("/\[abstract=(.*?)\](.*?)\[\/abstract\]/ism",$text, $results, PREG_SET_ORDER)) diff --git a/include/conversation.php b/include/conversation.php index 80ea6a900..d93b744d9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -19,7 +19,7 @@ require_once "include/acl_selectors.php"; function item_extract_images($body) { - $saved_image = array(); + $saved_image = []; $orig_body = $body; $new_body = ''; @@ -57,7 +57,7 @@ function item_extract_images($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) { @@ -145,7 +145,7 @@ function localize_item(&$item) { default: if ($obj['resource-id']) { $post_type = t('photo'); - $m = array(); + $m = []; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); $rr['plink'] = $m[1]; } else { @@ -283,7 +283,7 @@ function localize_item(&$item) { default: if ($obj['resource-id']) { $post_type = t('photo'); - $m=array(); preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); + $m=[]; preg_match("/\[url=([^]]*)\]/", $obj['body'], $m); $rr['plink'] = $m[1]; } else { $post_type = t('status'); @@ -382,7 +382,7 @@ function visible_activity($item) { * likes (etc.) can apply to other things besides posts. Check if they are post children, * in which case we handle them specially */ - $hidden_activities = array(ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); + $hidden_activities = [ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE]; foreach ($hidden_activities as $act) { if (activity_match($item['verb'], $act)) { return false; @@ -595,18 +595,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $_SESSION['return_url'] = $a->query_string; } - $cb = array('items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview); + $cb = ['items' => $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview]; call_hooks('conversation_start',$cb); $items = $cb['items']; - $conv_responses = array( - 'like' => array('title' => t('Likes','title')), 'dislike' => array('title' => t('Dislikes','title')), - 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) - ); + $conv_responses = [ + 'like' => ['title' => t('Likes','title')], 'dislike' => ['title' => t('Dislikes','title')], + 'attendyes' => ['title' => t('Attending','title')], 'attendno' => ['title' => t('Not attending','title')], 'attendmaybe' => ['title' => t('Might attend','title')] + ]; // array with html for each thread (parent+comments) - $threads = array(); + $threads = []; $threadsid = -1; $page_template = get_markup_template("conversation.tpl"); @@ -620,7 +620,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $community_readonly = false; $writable = true; } else { - $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN)); + $writable = ($items[0]['uid'] == 0) && in_array($items[0]['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN]); } } else { $writable = false; @@ -673,15 +673,15 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $profile_name = $item['author-link']; } - $tags = array(); - $hashtags = array(); - $mentions = array(); + $tags = []; + $hashtags = []; + $mentions = []; $searchpath = System::baseUrl()."/search?tag="; - $taglist = dba::select('term', array('type', 'term', 'url'), - array("`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION), - array('order' => array('tid'))); + $taglist = dba::select('term', ['type', 'term', 'url'], + ["`otype` = ? AND `oid` = ? AND `type` IN (?, ?)", TERM_OBJ_POST, $item['id'], TERM_HASHTAG, TERM_MENTION], + ['order' => ['tid']]); while ($tag = dba::fetch($taglist)) { if ($tag["url"] == "") { @@ -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); $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; } - $drop = array( + $drop = [ 'dropping' => $dropping, 'pagedrop' => $page_dropping, 'select' => t('Select'), 'delete' => t('Delete'), - ); + ]; $star = false; $isstarred = "unstarred"; @@ -773,7 +773,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $item['item_network'] = $item['network']; } - $tmp_item = array( + $tmp_item = [ 'template' => $tpl, 'id' => (($preview) ? 'P0' : $item['item_id']), 'guid' => (($preview) ? 'Q0' : $item['guid']), @@ -814,18 +814,18 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { 'like' => '', 'dislike' => '', 'comment' => '', - 'conv' => (($preview) ? '' : array('href'=> 'display/'.$item['guid'], 'title'=> t('View in context'))), + 'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> t('View in context')]), 'previewing' => $previewing, 'wait' => t('Please wait'), 'thread_level' => 1, - ); + ]; - $arr = array('item' => $item, 'output' => $tmp_item); + $arr = ['item' => $item, 'output' => $tmp_item]; call_hooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['network'] = $item['item_network']; - $threads[$threadsid]['items'] = array($arr['output']); + $threads[$threadsid]['items'] = [$arr['output']]; } } else { @@ -878,12 +878,12 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { $threads = $conv->getTemplateData($conv_responses); if (!$threads) { logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG); - $threads = array(); + $threads = []; } } } - $o = replace_macros($page_template, array( + $o = replace_macros($page_template, [ '$baseurl' => System::baseUrl($ssl_state), '$return_path' => $a->query_string, '$live_update' => $live_update_div, @@ -892,7 +892,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { '$user' => $a->user, '$threads' => $threads, '$dropping' => ($page_dropping && Feature::isEnabled(local_user(), 'multi_delete') ? t('Delete Selected Items') : False), - )); + ]); return $o; } @@ -910,7 +910,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { function community_add_items($parents) { $max_comments = Config::get("system", "max_comments", 100); - $items = array(); + $items = []; foreach ($parents AS $parent) { $thread_items = dba::p(item_query()." AND `item`.`uid` = ? @@ -932,7 +932,7 @@ function community_add_items($parents) { } } if (!$parent_found) { - $comments = array(); + $comments = []; } } @@ -1046,13 +1046,13 @@ function item_photo_menu($item) { $contact_url = 'contacts/' . $cid; $posts_link = 'contacts/' . $cid . '/posts'; - if (in_array($network, array(NETWORK_DFRN, NETWORK_DIASPORA))) { + if (in_array($network, [NETWORK_DFRN, NETWORK_DIASPORA])) { $pm_url = 'message/new/' . $cid; } } if (local_user()) { - $menu = array( + $menu = [ t('Follow Thread') => $sub_link, t('View Status') => $status_link, t('View Profile') => $profile_link, @@ -1060,21 +1060,21 @@ function item_photo_menu($item) { t('Network Posts') => $posts_link, t('View Contact') => $contact_url, t('Send PM') => $pm_url - ); + ]; if ($network == NETWORK_DFRN) { $menu[t("Poke")] = $poke_link; } if ((($cid == 0) || ($rel == CONTACT_IS_FOLLOWER)) && - in_array($item['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) { + in_array($item['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) { $menu[t('Connect/Follow')] = 'follow?url=' . urlencode($item['author-link']); } } else { - $menu = array(t('View Profile') => $item['author-link']); + $menu = [t('View Profile') => $item['author-link']]; } - $args = array('item' => $item, 'menu' => $menu); + $args = ['item' => $item, 'menu' => $menu]; call_hooks('item_photo_menu', $args); @@ -1142,7 +1142,7 @@ function builtin_activity_puller($item, &$conv_responses) { if (! ((isset($conv_responses[$mode][$item['thr-parent'] . '-l'])) && (is_array($conv_responses[$mode][$item['thr-parent'] . '-l'])))) { - $conv_responses[$mode][$item['thr-parent'] . '-l'] = array(); + $conv_responses[$mode][$item['thr-parent'] . '-l'] = []; } // only list each unique author once @@ -1250,11 +1250,11 @@ function format_like($cnt, array $arr, $type, $id) { } $phrase .= EOL ; - $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), array( + $o .= replace_macros(get_markup_template('voting_fakelink.tpl'), [ '$phrase' => $phrase, '$type' => $type, '$id' => $id - )); + ]); $o .= $expanded; return $o; @@ -1264,10 +1264,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) { $o = ''; - $geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : ''; + $geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), []) : ''; $tpl = get_markup_template('jot-header.tpl'); - $a->page['htmlhead'] .= replace_macros($tpl, array( + $a->page['htmlhead'] .= replace_macros($tpl, [ '$newpost' => 'true', '$baseurl' => System::baseUrl(true), '$geotag' => $geotag, @@ -1280,10 +1280,10 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) '$fileas' => t('Save to Folder:'), '$whereareu' => t('Where are you right now?'), '$delitems' => t('Delete item(s)?') - )); + ]); $tpl = get_markup_template('jot-end.tpl'); - $a->page['end'] .= replace_macros($tpl, array( + $a->page['end'] .= replace_macros($tpl, [ '$newpost' => 'true', '$baseurl' => System::baseUrl(true), '$geotag' => $geotag, @@ -1295,7 +1295,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) '$term' => t('Tag term:'), '$fileas' => t('Save to Folder:'), '$whereareu' => t('Where are you right now?') - )); + ]); $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; 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 = get_markup_template("jot.tpl"); - $o .= replace_macros($tpl,array( + $o .= replace_macros($tpl,[ '$return_path' => $query_str, '$action' => 'item', '$share' => defaults($x, 'button', t('Share')), @@ -1379,7 +1379,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) //jot nav tab (used in some themes) '$message' => t('Message'), '$browser' => t('Browser'), - )); + ]); if ($popup == true) { @@ -1636,9 +1636,9 @@ function render_location_dummy($item) { /// @TODO Add type-hint function get_responses($conv_responses, $response_verbs, $ob, $item) { - $ret = array(); + $ret = []; foreach ($response_verbs as $v) { - $ret[$v] = array(); + $ret[$v] = []; $ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], ''); $ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', ''); $ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0'); diff --git a/include/datetime.php b/include/datetime.php index 1c9510c33..0faea8c90 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -102,9 +102,9 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang $options = str_replace('','', $options); $tpl = get_markup_template('field_select_raw.tpl'); - return replace_macros($tpl, array( - '$field' => array($name, $label, $current, $help, $options), - )); + return replace_macros($tpl, [ + '$field' => [$name, $label, $current, $help, $options], + ]); } @@ -189,16 +189,16 @@ function dob($dob) $age = ((intval($value)) ? age($value, $a->user["timezone"], $a->user["timezone"]) : ""); - $o = replace_macros(get_markup_template("field_input.tpl"), array( - '$field' => array( + $o = replace_macros(get_markup_template("field_input.tpl"), [ + '$field' => [ 'dob', t('Birthday:'), $value, (((intval($age)) > 0 ) ? t('Age: ') . $age : ""), '', 'placeholder="' . t('YYYY-MM-DD or MM-DD') . '"' - ) - )); + ] + ]); /// @TODO Old-lost code? // 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); // 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'); } @@ -327,9 +327,9 @@ function datetimesel($min, $max, $default, $label, $id = 'datetimepicker', $pick $readable_format = str_replace('i','MM',$readable_format); $tpl = get_markup_template('field_input.tpl'); - $o .= replace_macros($tpl, array( - '$field' => array($id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'), - )); + $o .= replace_macros($tpl, [ + '$field' => [$id, $label, $input_text, '', (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'], + ]); $o .= ""; } else { diff --git a/mod/cal.php b/mod/cal.php index 31ab5976b..de00feadd 100644 --- a/mod/cal.php +++ b/mod/cal.php @@ -51,13 +51,13 @@ function cal_init(App $a) $tpl = get_markup_template("vcard-widget.tpl"); - $vcard_widget = replace_macros($tpl, array( + $vcard_widget = replace_macros($tpl, [ '$name' => $profile['name'], '$photo' => $profile['photo'], '$addr' => (($profile['addr'] != "") ? $profile['addr'] : ""), '$account_type' => $account_type, '$pdesc' => (($profile['pdesc'] != "") ? $profile['pdesc'] : ""), - )); + ]); $cal_widget = widget_events(); @@ -80,17 +80,17 @@ function cal_content(App $a) $i18n = get_event_strings(); $htpl = get_markup_template('event_head.tpl'); - $a->page['htmlhead'] .= replace_macros($htpl, array( + $a->page['htmlhead'] .= replace_macros($htpl, [ '$baseurl' => System::baseUrl(), '$module_url' => '/cal/' . $a->data['user']['nickname'], '$modparams' => 2, '$i18n' => $i18n, - )); + ]); $etpl = get_markup_template('event_end.tpl'); - $a->page['end'] .= replace_macros($etpl, array( + $a->page['end'] .= replace_macros($etpl, [ '$baseurl' => System::baseUrl(), - )); + ]); $mode = 'view'; $y = 0; @@ -206,14 +206,14 @@ function cal_content(App $a) $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); // 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), 'start' => $start, 'finish' => $finish, 'adjust_start' => $adjust_start, 'adjust_finish' => $adjust_finish, 'ignored' => $ignored, - ); + ]; // get events by id or by date if (x($_GET, 'id')) { @@ -222,7 +222,7 @@ function cal_content(App $a) $r = events_by_date($owner_uid, $event_params, $sql_extra); } - $links = array(); + $links = []; if (DBM::is_result($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 foreach ($events as $key => $event) { - $event_item = array(); + $event_item = []; foreach ($event['item'] as $k => $v) { $k = str_replace('-', '_', $k); $event_item[$k] = $v; @@ -263,13 +263,13 @@ function cal_content(App $a) $events[$key]['item'] = $event_item; } - $o = replace_macros($tpl, array( + $o = replace_macros($tpl, [ '$baseurl' => System::baseUrl(), '$tabs' => $tabs, '$title' => t('Events'), '$view' => t('View'), - '$previous' => array(System::baseUrl() . "/events/$prevyear/$prevmonth", t('Previous'), '', ''), - '$next' => array(System::baseUrl() . "/events/$nextyear/$nextmonth", t('Next'), '', ''), + '$previous' => [System::baseUrl() . "/events/$prevyear/$prevmonth", t('Previous'), '', ''], + '$next' => [System::baseUrl() . "/events/$nextyear/$nextmonth", t('Next'), '', ''], '$calendar' => cal($y, $m, $links, ' eventcal'), '$events' => $events, "today" => t("today"), @@ -277,7 +277,7 @@ function cal_content(App $a) "week" => t("week"), "day" => t("day"), "list" => t("list"), - )); + ]); if (x($_GET, 'id')) { echo $o; diff --git a/mod/common.php b/mod/common.php index cfeb531f7..c4f236fad 100644 --- a/mod/common.php +++ b/mod/common.php @@ -46,12 +46,12 @@ function common_content(App $a) $contact = dba::selectFirst('contact', ['name', 'url', 'photo'], ['self' => true, 'uid' => $uid]); 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']), '$photo' => $contact['photo'], 'url' => 'contacts/' . $cid - )); - + ]); + if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } @@ -115,7 +115,7 @@ function common_content(App $a) $photo_menu = Contact::photoMenu($rr); - $entry = array( + $entry = [ 'url' => $rr['url'], 'itemurl' => defaults($contact_details, 'addr', $rr['url']), 'name' => $contact_details['name'], @@ -128,7 +128,7 @@ function common_content(App $a) 'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']), 'photo_menu' => $photo_menu, 'id' => ++$id, - ); + ]; $entries[] = $entry; } @@ -142,12 +142,12 @@ function common_content(App $a) $tpl = get_markup_template('viewcontact_template.tpl'); - $o .= replace_macros($tpl, array( + $o .= replace_macros($tpl, [ '$title' => $title, '$tab_str' => $tab_str, '$contacts' => $entries, '$paginate' => paginate($a), - )); + ]); return $o; } diff --git a/mod/community.php b/mod/community.php index 4b755e18c..cfd2087d9 100644 --- a/mod/community.php +++ b/mod/community.php @@ -67,35 +67,35 @@ function community_content(App $a, $update = 0) $tabs = []; 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'), 'url' => 'community/local', 'sel' => $content == 'local' ? 'active' : '', 'title' => t('Posts from local users on this server'), 'id' => 'community-local-tab', 'accesskey' => 'l' - ); + ]; } if (local_user() || in_array($page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) { - $tabs[] = array( + $tabs[] = [ 'label' => t('Global Timeline'), 'url' => 'community/global', 'sel' => $content == 'global' ? 'active' : '', 'title' => t('Posts from users of the federated network'), 'id' => 'community-global-tab', 'accesskey' => 'g' - ); + ]; } $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'); // We need the editor here to be able to reshare an item. if (local_user()) { - $x = array( + $x = [ 'is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], @@ -105,7 +105,7 @@ function community_content(App $a, $update = 0) 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user(), - ); + ]; $o .= status_editor($a, $x, 0, true); } } @@ -141,7 +141,7 @@ function community_content(App $a, $update = 0) $count = 1; $previousauthor = ""; $numposts = 0; - $s = array(); + $s = []; do { foreach ($r as $item) { @@ -171,12 +171,12 @@ function community_content(App $a, $update = 0) } $t = get_markup_template("community.tpl"); - return replace_macros($t, array( + return replace_macros($t, [ '$content' => $o, '$header' => '', '$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 node’s users.") - )); + ]); } function community_getitems($start, $itemspage, $content) @@ -204,5 +204,5 @@ function community_getitems($start, $itemspage, $content) } // Should never happen - return array(); + return []; } diff --git a/mod/contactgroup.php b/mod/contactgroup.php index 13f8b492b..388725c00 100644 --- a/mod/contactgroup.php +++ b/mod/contactgroup.php @@ -33,7 +33,7 @@ function contactgroup_content(App $a) $group = $r[0]; $members = Contact::getByGroupId($group['id']); - $preselected = array(); + $preselected = []; if (count($members)) { foreach ($members as $member) { $preselected[] = $member['id']; diff --git a/mod/contacts.php b/mod/contacts.php index 7089cf05a..ae0edb3cc 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -48,7 +48,7 @@ function contacts_init(App $a) } /// @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']), '$photo' => $a->data['contact']['photo'], '$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' => t('Network:'), '$account_type' => Contact::getAccountType($a->data['contact']) - )); + ]); $findpeople_widget = ''; $follow_widget = ''; @@ -75,26 +75,26 @@ function contacts_init(App $a) $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, '$findpeople_widget' => $findpeople_widget, '$follow_widget' => $follow_widget, '$groups_widget' => $groups_widget, '$networks_widget' => $networks_widget - )); + ]); $base = System::baseUrl(); $tpl = get_markup_template("contacts-head.tpl"); - $a->page['htmlhead'] .= replace_macros($tpl, array( + $a->page['htmlhead'] .= replace_macros($tpl, [ '$baseurl' => System::baseUrl(true), '$base' => $base - )); + ]); $tpl = get_markup_template("contacts-end.tpl"); - $a->page['end'] .= replace_macros($tpl, array( + $a->page['end'] .= replace_macros($tpl, [ '$baseurl' => System::baseUrl(true), '$base' => $base - )); + ]); } function contacts_batch_actions(App $a) @@ -259,13 +259,13 @@ function _contact_update_profile($contact_id) $data = Probe::uri($contact["url"], "", 0, false); // "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; } - $updatefields = array("name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", - "poco", "network", "alias"); - $update = array(); + $updatefields = ["name", "nick", "url", "addr", "batch", "notify", "poll", "request", "confirm", + "poco", "network", "alias"]; + $update = []; if ($data["network"] == NETWORK_OSTATUS) { $result = Contact::createFromProbe($uid, $data["url"], false); @@ -442,17 +442,17 @@ function contacts_content(App $a) //