From e36f2bb1fb3439e9993c7568e57140c4f954b772 Mon Sep 17 00:00:00 2001
From: Hypolite Petovan
", "", "
",
+ $search = ["
", "", "
",
"", "
", "", "
",
"", "
", "", "
",
- "", "
", "", "
");
- $replace = array("
", "", "
",
+ "", "
", "", "
"];
+ $replace = ["
", "", "
",
"", "
", "", "
",
"", "
", "", "
",
- "", "
", "", "
");
+ "", "
", "", "
"];
$statushtml = str_replace($search, $replace, $statushtml);
if ($item['title'] != "") {
@@ -2682,12 +2682,12 @@ function api_convert_item($item)
$entities = api_get_entitities($statustext, $body);
- return array(
+ return [
"text" => $statustext,
"html" => $statushtml,
"attachments" => $attachments,
"entities" => $entities
- );
+ ];
}
/**
@@ -2708,13 +2708,13 @@ function api_get_attachments(&$body)
return false;
}
- $attachments = array();
+ $attachments = [];
foreach ($images[1] as $image) {
$imagedata = Image::getInfoFromURL($image);
if ($imagedata) {
- $attachments[] = array("url" => $image, "mimetype" => $imagedata["mime"], "size" => $imagedata["size"]);
+ $attachments[] = ["url" => $image, "mimetype" => $imagedata["mime"], "size" => $imagedata["size"]];
}
}
@@ -2746,7 +2746,7 @@ function api_get_entitities(&$text, $bbcode)
$replace = proxy_url($image);
$text = str_replace($image, $replace, $text);
}
- return array();
+ return [];
}
$bbcode = bb_CleanPictureLinks($bbcode);
@@ -2754,11 +2754,11 @@ function api_get_entitities(&$text, $bbcode)
// Change pure links in text to bbcode uris
$bbcode = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2]$2[/url]', $bbcode);
- $entities = array();
- $entities["hashtags"] = array();
- $entities["symbols"] = array();
- $entities["urls"] = array();
- $entities["user_mentions"] = array();
+ $entities = [];
+ $entities["hashtags"] = [];
+ $entities["symbols"] = [];
+ $entities["urls"] = [];
+ $entities["user_mentions"] = [];
$URLSearchString = "^\[\]";
@@ -2787,12 +2787,12 @@ function api_get_entitities(&$text, $bbcode)
//preg_match_all("/\[url\]([$URLSearchString]*)\[\/url\]/ism", $bbcode, $urls1);
preg_match_all("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $bbcode, $urls);
- $ordered_urls = array();
+ $ordered_urls = [];
foreach ($urls[1] as $id => $url) {
//$start = strpos($text, $url, $offset);
$start = iconv_strpos($text, $url, 0, "UTF-8");
if (!($start === false)) {
- $ordered_urls[$start] = array("url" => $url, "title" => $urls[2][$id]);
+ $ordered_urls[$start] = ["url" => $url, "title" => $urls[2][$id]];
}
}
@@ -2806,8 +2806,8 @@ function api_get_entitities(&$text, $bbcode)
) {
$display_url = $url["title"];
} else {
- $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url["url"]);
- $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
+ $display_url = str_replace(["http://www.", "https://www."], ["", ""], $url["url"]);
+ $display_url = str_replace(["http://", "https://"], ["", ""], $display_url);
if (strlen($display_url) > 26) {
$display_url = substr($display_url, 0, 25)."…";
@@ -2817,16 +2817,16 @@ function api_get_entitities(&$text, $bbcode)
//$start = strpos($text, $url, $offset);
$start = iconv_strpos($text, $url["url"], $offset, "UTF-8");
if (!($start === false)) {
- $entities["urls"][] = array("url" => $url["url"],
+ $entities["urls"][] = ["url" => $url["url"],
"expanded_url" => $url["url"],
"display_url" => $display_url,
- "indices" => array($start, $start+strlen($url["url"])));
+ "indices" => [$start, $start+strlen($url["url"])]];
$offset = $start + 1;
}
}
preg_match_all("/\[img](.*?)\[\/img\]/ism", $bbcode, $images);
- $ordered_images = array();
+ $ordered_images = [];
foreach ($images[1] as $image) {
//$start = strpos($text, $url, $offset);
$start = iconv_strpos($text, $image, 0, "UTF-8");
@@ -2838,8 +2838,8 @@ function api_get_entitities(&$text, $bbcode)
$offset = 0;
foreach ($ordered_images as $url) {
- $display_url = str_replace(array("http://www.", "https://www."), array("", ""), $url);
- $display_url = str_replace(array("http://", "https://"), array("", ""), $display_url);
+ $display_url = str_replace(["http://www.", "https://www."], ["", ""], $url);
+ $display_url = str_replace(["http://", "https://"], ["", ""], $display_url);
if (strlen($display_url) > 26) {
$display_url = substr($display_url, 0, 25)."…";
@@ -2854,38 +2854,38 @@ function api_get_entitities(&$text, $bbcode)
if (!Config::get("system", "proxy_disabled")) {
$media_url = proxy_url($url);
- $sizes = array();
+ $sizes = [];
$scale = Image::getScalingDimensions($image[0], $image[1], 150);
- $sizes["thumb"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ $sizes["thumb"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
if (($image[0] > 150) || ($image[1] > 150)) {
$scale = Image::getScalingDimensions($image[0], $image[1], 340);
- $sizes["small"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ $sizes["small"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
}
$scale = Image::getScalingDimensions($image[0], $image[1], 600);
- $sizes["medium"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ $sizes["medium"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
if (($image[0] > 600) || ($image[1] > 600)) {
$scale = Image::getScalingDimensions($image[0], $image[1], 1024);
- $sizes["large"] = array("w" => $scale["width"], "h" => $scale["height"], "resize" => "fit");
+ $sizes["large"] = ["w" => $scale["width"], "h" => $scale["height"], "resize" => "fit"];
}
} else {
$media_url = $url;
- $sizes["medium"] = array("w" => $image[0], "h" => $image[1], "resize" => "fit");
+ $sizes["medium"] = ["w" => $image[0], "h" => $image[1], "resize" => "fit"];
}
- $entities["media"][] = array(
+ $entities["media"][] = [
"id" => $start+1,
"id_str" => (string)$start+1,
- "indices" => array($start, $start+strlen($url)),
+ "indices" => [$start, $start+strlen($url)],
"media_url" => normalise_link($media_url),
"media_url_https" => $media_url,
"url" => $url,
"display_url" => $display_url,
"expanded_url" => $url,
"type" => "photo",
- "sizes" => $sizes);
+ "sizes" => $sizes];
}
$offset = $start + 1;
}
@@ -2923,18 +2923,18 @@ function api_format_items_embeded_images($item, $text)
*/
function api_contactlink_to_array($txt)
{
- $match = array();
+ $match = [];
$r = preg_match_all('|([^<]*)|', $txt, $match);
if ($r && count($match)==3) {
- $res = array(
+ $res = [
'name' => $match[2],
'url' => $match[1]
- );
+ ];
} else {
- $res = array(
+ $res = [
'name' => $text,
'url' => ""
- );
+ ];
}
return $res;
}
@@ -2954,13 +2954,13 @@ function api_format_items_activities(&$item, $type = "json")
{
$a = get_app();
- $activities = array(
- 'like' => array(),
- 'dislike' => array(),
- 'attendyes' => array(),
- 'attendno' => array(),
- 'attendmaybe' => array(),
- );
+ $activities = [
+ 'like' => [],
+ 'dislike' => [],
+ 'attendyes' => [],
+ 'attendno' => [],
+ 'attendmaybe' => [],
+ ];
$items = q(
'SELECT * FROM item
@@ -2997,7 +2997,7 @@ function api_format_items_activities(&$item, $type = "json")
}
if ($type == "xml") {
- $xml_activities = array();
+ $xml_activities = [];
foreach ($activities as $k => $v) {
// change xml element from "like" to "friendica:like"
$xml_activities["friendica:".$k] = $v;
@@ -3022,7 +3022,7 @@ function api_format_items_activities(&$item, $type = "json")
*/
function api_format_items_profiles($profile_row)
{
- $profile = array(
+ $profile = [
'profile_id' => $profile_row['id'],
'profile_name' => $profile_row['profile-name'],
'is_default' => $profile_row['is-default'] ? true : false,
@@ -3062,7 +3062,7 @@ function api_format_items_profiles($profile_row)
'social_networks' => bbcode(api_clean_plain_items($profile_row['contact']) , false, false, 2, false),
'homepage' => $profile_row['homepage'],
'users' => null
- );
+ ];
return $profile;
}
@@ -3078,7 +3078,7 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
{
$a = get_app();
- $ret = array();
+ $ret = [];
foreach ($r as $item) {
localize_item($item);
@@ -3099,7 +3099,7 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
$geo = "geo";
}
- $status = array(
+ $status = [
'text' => $converted["text"],
'truncated' => false,
'created_at'=> api_date($item['created']),
@@ -3120,7 +3120,7 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
'statusnet_conversation_id' => $item['parent'],
'external_url' => System::baseUrl() . "/display/" . $item['guid'],
'friendica_activities' => api_format_items_activities($item, $type),
- );
+ ];
if (count($converted["attachments"]) > 0) {
$status["attachments"] = $converted["attachments"];
@@ -3153,7 +3153,7 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
} catch (BadRequestException $e) {
// user not found. should be found?
/// @todo check if the user should be always found
- $retweeted_status["user"] = array();
+ $retweeted_status["user"] = [];
}
$rt_converted = api_convert_item($retweeted_item);
@@ -3174,9 +3174,9 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
$coords = explode(' ', $item["coord"]);
if (count($coords) == 2) {
if ($type == "json") {
- $status["geo"] = array('type' => 'Point',
- 'coordinates' => array((float) $coords[0],
- (float) $coords[1]));
+ $status["geo"] = ['type' => 'Point',
+ 'coordinates' => [(float) $coords[0],
+ (float) $coords[1]]];
} else {// Not sure if this is the official format - if someone founds a documentation we can check
$status["georss:point"] = $item["coord"];
}
@@ -3197,26 +3197,26 @@ function api_format_items($r, $user_info, $filter_user = false, $type = "json")
function api_account_rate_limit_status($type)
{
if ($type == "xml") {
- $hash = array(
+ $hash = [
'remaining-hits' => '150',
- '@attributes' => array("type" => "integer"),
+ '@attributes' => ["type" => "integer"],
'hourly-limit' => '150',
- '@attributes2' => array("type" => "integer"),
+ '@attributes2' => ["type" => "integer"],
'reset-time' => datetime_convert('UTC', 'UTC', 'now + 1 hour', ATOM_TIME),
- '@attributes3' => array("type" => "datetime"),
+ '@attributes3' => ["type" => "datetime"],
'reset_time_in_seconds' => strtotime('now + 1 hour'),
- '@attributes4' => array("type" => "integer"),
- );
+ '@attributes4' => ["type" => "integer"],
+ ];
} else {
- $hash = array(
+ $hash = [
'reset_time_in_seconds' => strtotime('now + 1 hour'),
'remaining_hits' => '150',
'hourly_limit' => '150',
'reset_time' => api_date(datetime_convert('UTC', 'UTC', 'now + 1 hour', ATOM_TIME)),
- );
+ ];
}
- return api_format_data('hash', $type, array('hash' => $hash));
+ return api_format_data('hash', $type, ['hash' => $hash]);
}
/// @TODO move to top of file or somewhere better
@@ -3237,7 +3237,7 @@ function api_help_test($type)
$ok = "ok";
}
- return api_format_data('ok', $type, array("ok" => $ok));
+ return api_format_data('ok', $type, ["ok" => $ok]);
}
/// @TODO move to top of file or somewhere better
@@ -3251,9 +3251,9 @@ api_register_func('api/help/test', 'api_help_test', false);
*/
function api_lists($type)
{
- $ret = array();
+ $ret = [];
/// @TODO $ret is not filled here?
- return api_format_data('lists', $type, array("lists_list" => $ret));
+ return api_format_data('lists', $type, ["lists_list" => $ret]);
}
/// @TODO move to top of file or somewhere better
@@ -3269,9 +3269,9 @@ api_register_func('api/lists', 'api_lists', true);
*/
function api_lists_list($type)
{
- $ret = array();
+ $ret = [];
/// @TODO $ret is not filled here?
- return api_format_data('lists', $type, array("lists_list" => $ret));
+ return api_format_data('lists', $type, ["lists_list" => $ret]);
}
/// @TODO move to top of file or somewhere better
@@ -3350,7 +3350,7 @@ function api_statuses_f($qtype)
intval($count)
);
- $ret = array();
+ $ret = [];
foreach ($r as $cid) {
$user = api_get_user($a, $cid['nurl']);
// "uid" and "self" are only needed for some internal stuff, so remove it from here
@@ -3362,7 +3362,7 @@ function api_statuses_f($qtype)
}
}
- return array('user' => $ret);
+ return ['user' => $ret];
}
@@ -3445,12 +3445,12 @@ function api_friendships_incoming($type)
return false;
}
- $ids = array();
+ $ids = [];
foreach ($data['user'] as $user) {
$ids[] = $user['id'];
}
- return api_format_data("ids", $type, array('id' => $ids));
+ return api_format_data("ids", $type, ['id' => $ids]);
}
/// @TODO move to top of file or somewhere better
@@ -3480,22 +3480,22 @@ function api_statusnet_config($type)
$ssl = ((Config::get('system', 'have_ssl')) ? 'true' : 'false');
$sslserver = (($ssl === 'true') ? str_replace('http:', 'https:', System::baseUrl()) : '');
- $config = array(
- 'site' => array('name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
+ $config = [
+ 'site' => ['name' => $name,'server' => $server, 'theme' => 'default', 'path' => '',
'logo' => $logo, 'fancy' => true, 'language' => 'en', 'email' => $email, 'broughtby' => '',
'broughtbyurl' => '', 'timezone' => 'UTC', 'closed' => $closed, 'inviteonly' => false,
'private' => $private, 'textlimit' => $textlimit, 'sslserver' => $sslserver, 'ssl' => $ssl,
'shorturllength' => '30',
- 'friendica' => array(
+ 'friendica' => [
'FRIENDICA_PLATFORM' => FRIENDICA_PLATFORM,
'FRIENDICA_VERSION' => FRIENDICA_VERSION,
'DFRN_PROTOCOL_VERSION' => DFRN_PROTOCOL_VERSION,
'DB_UPDATE_VERSION' => DB_UPDATE_VERSION
- )
- ),
- );
+ ]
+ ],
+ ];
- return api_format_data('config', $type, array('config' => $config));
+ return api_format_data('config', $type, ['config' => $config]);
}
/// @TODO move to top of file or somewhere better
@@ -3513,7 +3513,7 @@ function api_statusnet_version($type)
// liar
$fake_statusnet_version = "0.9.7";
- return api_format_data('version', $type, array('version' => $fake_statusnet_version));
+ return api_format_data('version', $type, ['version' => $fake_statusnet_version]);
}
/// @TODO move to top of file or somewhere better
@@ -3546,7 +3546,7 @@ function api_ff_ids($type)
return;
}
- $ids = array();
+ $ids = [];
foreach ($r as $rr) {
if ($stringify_ids) {
$ids[] = $rr['id'];
@@ -3555,7 +3555,7 @@ function api_ff_ids($type)
}
}
- return api_format_data("ids", $type, array('id' => $ids));
+ return api_format_data("ids", $type, ['id' => $ids]);
}
/**
@@ -3650,10 +3650,10 @@ function api_direct_messages_new($type)
$r = q("SELECT * FROM `mail` WHERE id=%d", intval($id));
$ret = api_format_messages($r[0], $recipient, $sender);
} else {
- $ret = array("error"=>$id);
+ $ret = ["error"=>$id];
}
- $data = array('direct_message'=>$ret);
+ $data = ['direct_message'=>$ret];
switch ($type) {
case "atom":
@@ -3696,8 +3696,8 @@ function api_direct_messages_destroy($type)
$uid = $user_info['uid'];
// error if no id or parenturi specified (for clients posting parent-uri as well)
if ($verbose == "true" && ($id == 0 || $parenturi == "")) {
- $answer = array('result' => 'error', 'message' => 'message id or parenturi not specified');
- return api_format_data("direct_messages_delete", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'message id or parenturi not specified'];
+ return api_format_data("direct_messages_delete", $type, ['$result' => $answer]);
}
// BadRequestException if no id specified (for clients using Twitter API)
@@ -3718,8 +3718,8 @@ function api_direct_messages_destroy($type)
// error message if specified id is not in database
if (!DBM::is_result($r)) {
if ($verbose == "true") {
- $answer = array('result' => 'error', 'message' => 'message id not in database');
- return api_format_data("direct_messages_delete", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'message id not in database'];
+ return api_format_data("direct_messages_delete", $type, ['$result' => $answer]);
}
/// @todo BadRequestException ok for Twitter API clients?
throw new BadRequestException('message id not in database');
@@ -3735,11 +3735,11 @@ function api_direct_messages_destroy($type)
if ($verbose == "true") {
if ($result) {
// return success
- $answer = array('result' => 'ok', 'message' => 'message deleted');
- return api_format_data("direct_message_delete", $type, array('$result' => $answer));
+ $answer = ['result' => 'ok', 'message' => 'message deleted'];
+ return api_format_data("direct_message_delete", $type, ['$result' => $answer]);
} else {
- $answer = array('result' => 'error', 'message' => 'unknown error');
- return api_format_data("direct_messages_delete", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'unknown error'];
+ return api_format_data("direct_messages_delete", $type, ['$result' => $answer]);
}
}
/// @todo return JSON data like Twitter API not yet implemented
@@ -3819,11 +3819,11 @@ function api_direct_messages_box($type, $box, $verbose)
intval($count)
);
if ($verbose == "true" && !DBM::is_result($r)) {
- $answer = array('result' => 'error', 'message' => 'no mails available');
- return api_format_data("direct_messages_all", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'no mails available'];
+ return api_format_data("direct_messages_all", $type, ['$result' => $answer]);
}
- $ret = array();
+ $ret = [];
foreach ($r as $item) {
if ($box == "inbox" || $item['from-url'] != $profile_url) {
$recipient = $user_info;
@@ -3837,7 +3837,7 @@ function api_direct_messages_box($type, $box, $verbose)
}
- $data = array('direct_message' => $ret);
+ $data = ['direct_message' => $ret];
switch ($type) {
case "atom":
case "rss":
@@ -3991,12 +3991,12 @@ function api_fr_photoalbum_delete($type)
}
// now let's delete all photos from the album
- $result = dba::delete('photo', array('uid' => api_user(), 'album' => $album));
+ $result = dba::delete('photo', ['uid' => api_user(), 'album' => $album]);
// return success of deletion or error message
if ($result) {
- $answer = array('result' => 'deleted', 'message' => 'album `' . $album . '` with all containing photos has been deleted.');
- return api_format_data("photoalbum_delete", $type, array('$result' => $answer));
+ $answer = ['result' => 'deleted', 'message' => 'album `' . $album . '` with all containing photos has been deleted.'];
+ return api_format_data("photoalbum_delete", $type, ['$result' => $answer]);
} else {
throw new InternalServerErrorException("unknown error - deleting from database failed");
}
@@ -4043,8 +4043,8 @@ function api_fr_photoalbum_update($type)
// return success of updating or error message
if ($result) {
- $answer = array('result' => 'updated', 'message' => 'album `' . $album . '` with all containing photos has been renamed to `' . $album_new . '`.');
- return api_format_data("photoalbum_update", $type, array('$result' => $answer));
+ $answer = ['result' => 'updated', 'message' => 'album `' . $album . '` with all containing photos has been renamed to `' . $album_new . '`.'];
+ return api_format_data("photoalbum_update", $type, ['$result' => $answer]);
} else {
throw new InternalServerErrorException("unknown error - updating in database failed");
}
@@ -4068,15 +4068,15 @@ function api_fr_photos_list($type)
WHERE `uid` = %d AND `album` != 'Contact Photos' GROUP BY `resource-id`",
intval(local_user())
);
- $typetoext = array(
+ $typetoext = [
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif'
- );
- $data = array('photo'=>array());
+ ];
+ $data = ['photo'=>[]];
if (DBM::is_result($r)) {
foreach ($r as $rr) {
- $photo = array();
+ $photo = [];
$photo['id'] = $rr['resource-id'];
$photo['album'] = $rr['album'];
$photo['filename'] = $rr['filename'];
@@ -4087,7 +4087,7 @@ function api_fr_photos_list($type)
$photo['desc'] = $rr['desc'];
if ($type == "xml") {
- $data['photo'][] = array("@attributes" => $photo, "1" => $thumb);
+ $data['photo'][] = ["@attributes" => $photo, "1" => $thumb];
} else {
$photo['thumb'] = $thumb;
$data['photo'][] = $photo;
@@ -4231,12 +4231,12 @@ function api_fr_photo_create_update($type)
// return success of updating or error message
if ($result) {
- $answer = array('result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.');
- return api_format_data("photo_update", $type, array('$result' => $answer));
+ $answer = ['result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.'];
+ return api_format_data("photo_update", $type, ['$result' => $answer]);
} else {
if ($nothingtodo) {
- $answer = array('result' => 'cancelled', 'message' => 'Nothing to update for image id `' . $photo_id . '`.');
- return api_format_data("photo_update", $type, array('$result' => $answer));
+ $answer = ['result' => 'cancelled', 'message' => 'Nothing to update for image id `' . $photo_id . '`.'];
+ return api_format_data("photo_update", $type, ['$result' => $answer]);
}
throw new InternalServerErrorException("unknown error - update photo entry in database failed");
}
@@ -4274,7 +4274,7 @@ function api_fr_photo_delete($type)
throw new BadRequestException("photo not available");
}
// now we can perform on the deletion of the photo
- $result = dba::delete('photo', array('uid' => api_user(), 'resource-id' => $photo_id));
+ $result = dba::delete('photo', ['uid' => api_user(), 'resource-id' => $photo_id]);
// return success of deletion or error message
if ($result) {
@@ -4292,8 +4292,8 @@ function api_fr_photo_delete($type)
// to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion)
drop_item($photo_item[0]['id'], false);
- $answer = array('result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.');
- return api_format_data("photo_delete", $type, array('$result' => $answer));
+ $answer = ['result' => 'deleted', 'message' => 'photo with id `' . $photo_id . '` has been deleted from server.'];
+ return api_format_data("photo_delete", $type, ['$result' => $answer]);
} else {
throw new InternalServerErrorException("unknown error on deleting photo from database table");
}
@@ -4692,7 +4692,7 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
$uri = item_new_uri(get_app()->get_hostname(), intval(api_user()));
$owner_record = q("SELECT * FROM `contact` WHERE `uid`= %d AND `self` LIMIT 1", intval(api_user()));
- $arr = array();
+ $arr = [];
$arr['guid'] = get_guid(32);
$arr['uid'] = intval(api_user());
$arr['uri'] = $uri;
@@ -4716,11 +4716,11 @@ function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $f
$arr['visible'] = $visibility;
$arr['origin'] = 1;
- $typetoext = array(
+ $typetoext = [
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif'
- );
+ ];
// adds link to the thumbnail scale photo
$arr['body'] = '[url=' . System::baseUrl() . '/photos/' . $owner_record[0]['nick'] . '/image/' . $hash . ']'
@@ -4757,15 +4757,15 @@ function prepare_photo_data($type, $scale, $photo_id)
$scale_sql
);
- $typetoext = array(
+ $typetoext = [
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif'
- );
+ ];
// prepare output data for photo
if (DBM::is_result($r)) {
- $data = array('photo' => $r[0]);
+ $data = ['photo' => $r[0]];
$data['photo']['id'] = $data['photo']['resource-id'];
if ($scale !== false) {
$data['photo']['data'] = base64_encode($data['photo']['data']);
@@ -4773,14 +4773,14 @@ function prepare_photo_data($type, $scale, $photo_id)
unset($data['photo']['datasize']); //needed only with scale param
}
if ($type == "xml") {
- $data['photo']['links'] = array();
+ $data['photo']['links'] = [];
for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
- $data['photo']['links'][$k . ":link"]["@attributes"] = array("type" => $data['photo']['type'],
+ $data['photo']['links'][$k . ":link"]["@attributes"] = ["type" => $data['photo']['type'],
"scale" => $k,
- "href" => System::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . $typetoext[$data['photo']['type']]);
+ "href" => System::baseUrl() . "/photo/" . $data['photo']['resource-id'] . "-" . $k . "." . $typetoext[$data['photo']['type']]];
}
} else {
- $data['photo']['link'] = array();
+ $data['photo']['link'] = [];
// when we have profile images we could have only scales from 4 to 6, but index of array always needs to start with 0
$i = 0;
for ($k = intval($data['photo']['minscale']); $k <= intval($data['photo']['maxscale']); $k++) {
@@ -4822,7 +4822,7 @@ function prepare_photo_data($type, $scale, $photo_id)
// prepare output of comments
$commentData = api_format_items($r, api_get_user(get_app()), false, $type);
- $comments = array();
+ $comments = [];
if ($type == "xml") {
$k = 0;
foreach ($commentData as $comment) {
@@ -5104,7 +5104,7 @@ function api_get_nick($profile)
*/
function api_in_reply_to($item)
{
- $in_reply_to = array();
+ $in_reply_to = [];
$in_reply_to['status_id'] = null;
$in_reply_to['user_id'] = null;
@@ -5223,7 +5223,7 @@ function api_clean_attachments($body)
*/
function api_best_nickname(&$contacts)
{
- $best_contact = array();
+ $best_contact = [];
if (count($contact) == 0) {
return;
@@ -5232,14 +5232,14 @@ function api_best_nickname(&$contacts)
foreach ($contacts as $contact) {
if ($contact["network"] == "") {
$contact["network"] = "dfrn";
- $best_contact = array($contact);
+ $best_contact = [$contact];
}
}
if (sizeof($best_contact) == 0) {
foreach ($contacts as $contact) {
if ($contact["network"] == "dfrn") {
- $best_contact = array($contact);
+ $best_contact = [$contact];
}
}
}
@@ -5247,7 +5247,7 @@ function api_best_nickname(&$contacts)
if (sizeof($best_contact) == 0) {
foreach ($contacts as $contact) {
if ($contact["network"] == "dspr") {
- $best_contact = array($contact);
+ $best_contact = [$contact];
}
}
}
@@ -5255,7 +5255,7 @@ function api_best_nickname(&$contacts)
if (sizeof($best_contact) == 0) {
foreach ($contacts as $contact) {
if ($contact["network"] == "stat") {
- $best_contact = array($contact);
+ $best_contact = [$contact];
}
}
}
@@ -5263,7 +5263,7 @@ function api_best_nickname(&$contacts)
if (sizeof($best_contact) == 0) {
foreach ($contacts as $contact) {
if ($contact["network"] == "pump") {
- $best_contact = array($contact);
+ $best_contact = [$contact];
}
}
}
@@ -5271,7 +5271,7 @@ function api_best_nickname(&$contacts)
if (sizeof($best_contact) == 0) {
foreach ($contacts as $contact) {
if ($contact["network"] == "twit") {
- $best_contact = array($contact);
+ $best_contact = [$contact];
}
}
}
@@ -5279,7 +5279,7 @@ function api_best_nickname(&$contacts)
if (sizeof($best_contact) == 1) {
$contacts = $best_contact;
} else {
- $contacts = array($contacts[0]);
+ $contacts = [$contacts[0]];
}
}
@@ -5324,7 +5324,7 @@ function api_friendica_group_show($type)
// loop through all groups and retrieve all members for adding data in the user array
foreach ($r as $rr) {
$members = Contact::getByGroupId($rr['id']);
- $users = array();
+ $users = [];
if ($type == "xml") {
$user_element = "users";
@@ -5340,9 +5340,9 @@ function api_friendica_group_show($type)
$users[] = $user;
}
}
- $grps[] = array('name' => $rr['name'], 'gid' => $rr['id'], $user_element => $users);
+ $grps[] = ['name' => $rr['name'], 'gid' => $rr['id'], $user_element => $users];
}
- return api_format_data("groups", $type, array('group' => $grps));
+ return api_format_data("groups", $type, ['group' => $grps]);
}
api_register_func('api/friendica/group_show', 'api_friendica_group_show', true);
@@ -5400,8 +5400,8 @@ function api_friendica_group_delete($type)
$ret = Group::removeByName($uid, $name);
if ($ret) {
// return success
- $success = array('success' => $ret, 'gid' => $gid, 'name' => $name, 'status' => 'deleted', 'wrong users' => array());
- return api_format_data("group_delete", $type, array('result' => $success));
+ $success = ['success' => $ret, 'gid' => $gid, 'name' => $name, 'status' => 'deleted', 'wrong users' => []];
+ return api_format_data("group_delete", $type, ['result' => $success]);
} else {
throw new BadRequestException('other API error');
}
@@ -5468,7 +5468,7 @@ function api_friendica_group_create($type)
// add members
$erroraddinguser = false;
- $errorusers = array();
+ $errorusers = [];
foreach ($users as $user) {
$cid = $user['cid'];
// check if user really exists as contact
@@ -5487,8 +5487,8 @@ function api_friendica_group_create($type)
// return success message incl. missing users in array
$status = ($erroraddinguser ? "missing user" : ($reactivate_group ? "reactivated" : "ok"));
- $success = array('success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers);
- return api_format_data("group_create", $type, array('result' => $success));
+ $success = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
+ return api_format_data("group_create", $type, ['result' => $success]);
}
api_register_func('api/friendica/group_create', 'api_friendica_group_create', true, API_METHOD_POST);
@@ -5540,7 +5540,7 @@ function api_friendica_group_update($type)
// add members
$erroraddinguser = false;
- $errorusers = array();
+ $errorusers = [];
foreach ($users as $user) {
$cid = $user['cid'];
// check if user really exists as contact
@@ -5560,8 +5560,8 @@ function api_friendica_group_update($type)
// return success message incl. missing users in array
$status = ($erroraddinguser ? "missing user" : "ok");
- $success = array('success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers);
- return api_format_data("group_update", $type, array('result' => $success));
+ $success = ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
+ return api_format_data("group_update", $type, ['result' => $success]);
}
api_register_func('api/friendica/group_update', 'api_friendica_group_update', true, API_METHOD_POST);
@@ -5592,7 +5592,7 @@ function api_friendica_activity($type)
} else {
$ok = "ok";
}
- return api_format_data('ok', $type, array('ok' => $ok));
+ return api_format_data('ok', $type, ['ok' => $ok]);
} else {
throw new BadRequestException('Error adding activity');
}
@@ -5628,18 +5628,18 @@ function api_friendica_notification($type)
}
$nm = new NotificationsManager();
- $notes = $nm->getAll(array(), "+seen -date", 50);
+ $notes = $nm->getAll([], "+seen -date", 50);
if ($type == "xml") {
- $xmlnotes = array();
+ $xmlnotes = [];
foreach ($notes as $note) {
- $xmlnotes[] = array("@attributes" => $note);
+ $xmlnotes[] = ["@attributes" => $note];
}
$notes = $xmlnotes;
}
- return api_format_data("notes", $type, array('note' => $notes));
+ return api_format_data("notes", $type, ['note' => $notes]);
}
/**
@@ -5681,12 +5681,12 @@ function api_friendica_notification_seen($type)
// we found the item, return it to the user
$user_info = api_get_user($a);
$ret = api_format_items($r, $user_info, false, $type);
- $data = array('status' => $ret);
+ $data = ['status' => $ret];
return api_format_data("status", $type, $data);
}
// the item can't be found, but we set the note as seen, so we count this as a success
}
- return api_format_data('result', $type, array('result' => "success"));
+ return api_format_data('result', $type, ['result' => "success"]);
}
/// @TODO move to top of file or somewhere better
@@ -5713,8 +5713,8 @@ function api_friendica_direct_messages_setseen($type)
// return error if id is zero
if ($id == "") {
- $answer = array('result' => 'error', 'message' => 'message id not specified');
- return api_format_data("direct_messages_setseen", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'message id not specified'];
+ return api_format_data("direct_messages_setseen", $type, ['$result' => $answer]);
}
// get data of the specified message id
@@ -5726,8 +5726,8 @@ function api_friendica_direct_messages_setseen($type)
// error message if specified id is not in database
if (!DBM::is_result($r)) {
- $answer = array('result' => 'error', 'message' => 'message id not in database');
- return api_format_data("direct_messages_setseen", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'message id not in database'];
+ return api_format_data("direct_messages_setseen", $type, ['$result' => $answer]);
}
// update seen indicator
@@ -5739,11 +5739,11 @@ function api_friendica_direct_messages_setseen($type)
if ($result) {
// return success
- $answer = array('result' => 'ok', 'message' => 'message set to seen');
- return api_format_data("direct_message_setseen", $type, array('$result' => $answer));
+ $answer = ['result' => 'ok', 'message' => 'message set to seen'];
+ return api_format_data("direct_message_setseen", $type, ['$result' => $answer]);
} else {
- $answer = array('result' => 'error', 'message' => 'unknown error');
- return api_format_data("direct_messages_setseen", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'unknown error'];
+ return api_format_data("direct_messages_setseen", $type, ['$result' => $answer]);
}
}
@@ -5773,8 +5773,8 @@ function api_friendica_direct_messages_search($type)
// error if no searchstring specified
if ($searchstring == "") {
- $answer = array('result' => 'error', 'message' => 'searchstring not specified');
- return api_format_data("direct_messages_search", $type, array('$result' => $answer));
+ $answer = ['result' => 'error', 'message' => 'searchstring not specified'];
+ return api_format_data("direct_messages_search", $type, ['$result' => $answer]);
}
// get data for the specified searchstring
@@ -5788,11 +5788,11 @@ function api_friendica_direct_messages_search($type)
// message if nothing was found
if (!DBM::is_result($r)) {
- $success = array('success' => false, 'search_results' => 'problem with query');
+ $success = ['success' => false, 'search_results' => 'problem with query'];
} elseif (count($r) == 0) {
- $success = array('success' => false, 'search_results' => 'nothing found');
+ $success = ['success' => false, 'search_results' => 'nothing found'];
} else {
- $ret = array();
+ $ret = [];
foreach ($r as $item) {
if ($box == "inbox" || $item['from-url'] != $profile_url) {
$recipient = $user_info;
@@ -5804,10 +5804,10 @@ function api_friendica_direct_messages_search($type)
$ret[] = api_format_messages($item, $recipient, $sender);
}
- $success = array('success' => true, 'search_results' => $ret);
+ $success = ['success' => true, 'search_results' => $ret];
}
- return api_format_data("direct_message_search", $type, array('$result' => $success));
+ return api_format_data("direct_message_search", $type, ['$result' => $success]);
}
/// @TODO move to top of file or somewhere better
@@ -5858,7 +5858,7 @@ function api_friendica_profile_show($type)
$profile = api_format_items_profiles($rr);
// select all users from contact table, loop and prepare standard return for user data
- $users = array();
+ $users = [];
$r = q(
"SELECT `id`, `nurl` FROM `contact` WHERE `uid`= %d AND `profile-id` = %d",
intval(api_user()),
@@ -5882,11 +5882,11 @@ function api_friendica_profile_show($type)
// return settings, authenticated user and profiles data
$self = q("SELECT `nurl` FROM `contact` WHERE `uid`= %d AND `self` LIMIT 1", intval(api_user()));
- $result = array('multi_profiles' => $multi_profiles ? true : false,
+ $result = ['multi_profiles' => $multi_profiles ? true : false,
'global_dir' => $directory,
'friendica_owner' => api_get_user($a, $self[0]['nurl']),
- 'profiles' => $profiles);
- return api_format_data("friendica_profiles", $type, array('$result' => $result));
+ 'profiles' => $profiles];
+ return api_format_data("friendica_profiles", $type, ['$result' => $result]);
}
api_register_func('api/friendica/profile/show', 'api_friendica_profile_show', true, API_METHOD_GET);
@@ -5901,21 +5901,21 @@ api_register_func('api/friendica/profile/show', 'api_friendica_profile_show', tr
*/
function api_saved_searches_list($type)
{
- $terms = dba::select('search', array('id', 'term'), array('uid' => local_user()));
+ $terms = dba::select('search', ['id', 'term'], ['uid' => local_user()]);
- $result = array();
+ $result = [];
while ($term = $terms->fetch()) {
- $result[] = array(
+ $result[] = [
'name' => $term['term'],
'query' => $term['term'],
'id_str' => $term['id'],
'id' => intval($term['id'])
- );
+ ];
}
dba::close($terms);
- return api_format_data("terms", $type, array('terms' => $result));
+ return api_format_data("terms", $type, ['terms' => $result]);
}
/// @TODO move to top of file or somewhere better
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 73210860d..fc25a584a 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -51,7 +51,7 @@ function diaspora2bb($s) {
$s = preg_replace('/^([^\*]+)\*([^\*]*)$/im', '$1\*$2', $s);
// The parser cannot handle paragraphs correctly
- $s = str_replace(array('
', '
'), 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) //