Use short form array syntax everywhere

- Add short form array syntax to po2php.php generation
This commit is contained in:
Hypolite Petovan 2018-01-15 08:05:12 -05:00
parent 77dfbaa0bf
commit e36f2bb1fb
212 changed files with 5160 additions and 5160 deletions

View file

@ -150,11 +150,11 @@ class Contact extends BaseObject
$archive = PConfig::get($contact['uid'], 'system', 'archive_removed_contacts');
if ($archive) {
dba::update('contact', array('archive' => true, 'network' => 'none', 'writable' => false), array('id' => $id));
dba::update('contact', ['archive' => true, 'network' => 'none', 'writable' => false], ['id' => $id]);
return;
}
dba::delete('contact', array('id' => $id));
dba::delete('contact', ['id' => $id]);
// Delete the rest in the background
Worker::add(PRIORITY_LOW, 'RemoveContact', $id);
@ -171,7 +171,7 @@ class Contact extends BaseObject
{
if ($contact['network'] === NETWORK_OSTATUS) {
// create an unfollow slap
$item = array();
$item = [];
$item['verb'] = NAMESPACE_OSTATUS . "/unfollow";
$item['follow'] = $contact["url"];
$slap = OStatus::salmon($item, $user);
@ -206,10 +206,10 @@ class Contact extends BaseObject
}
if ($contact['term-date'] <= NULL_DATE) {
dba::update('contact', array('term-date' => datetime_convert()), array('id' => $contact['id']));
dba::update('contact', ['term-date' => datetime_convert()], ['id' => $contact['id']]);
if ($contact['url'] != '') {
dba::update('contact', array('term-date' => datetime_convert()), array('`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE));
dba::update('contact', ['term-date' => datetime_convert()], ['`nurl` = ? AND `term-date` <= ? AND NOT `self`', normalise_link($contact['url']), NULL_DATE]);
}
} else {
/* @todo
@ -225,10 +225,10 @@ class Contact extends BaseObject
* delete, though if the owner tries to unarchive them we'll start
* the whole process over again.
*/
dba::update('contact', array('archive' => 1), array('id' => $contact['id']));
dba::update('contact', ['archive' => 1], ['id' => $contact['id']]);
if ($contact['url'] != '') {
dba::update('contact', array('archive' => 1), array('nurl' => normalise_link($contact['url']), 'self' => false));
dba::update('contact', ['archive' => 1], ['nurl' => normalise_link($contact['url']), 'self' => false]);
}
}
}
@ -244,7 +244,7 @@ class Contact extends BaseObject
*/
public static function unmarkForArchival(array $contact)
{
$condition = array('`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], NULL_DATE);
$condition = ['`id` = ? AND (`term-date` > ? OR `archive`)', $contact['id'], NULL_DATE];
$exists = dba::exists('contact', $condition);
// We don't need to update, we never marked this contact for archival
@ -253,11 +253,11 @@ class Contact extends BaseObject
}
// It's a miracle. Our dead contact has inexplicably come back to life.
$fields = array('term-date' => NULL_DATE, 'archive' => false);
dba::update('contact', $fields, array('id' => $contact['id']));
$fields = ['term-date' => NULL_DATE, 'archive' => false];
dba::update('contact', $fields, ['id' => $contact['id']]);
if ($contact['url'] != '') {
dba::update('contact', $fields, array('nurl' => normalise_link($contact['url'])));
dba::update('contact', $fields, ['nurl' => normalise_link($contact['url'])]);
}
}
@ -275,7 +275,7 @@ class Contact extends BaseObject
*/
public static function getDetailsByURL($url, $uid = -1, array $default = [])
{
static $cache = array();
static $cache = [];
if ($url == '') {
return $default;
@ -387,7 +387,7 @@ class Contact extends BaseObject
}
if ((($profile["addr"] == "") || ($profile["name"] == "")) && ($profile["gid"] != 0)
&& in_array($profile["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))
&& in_array($profile["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])
) {
Worker::add(PRIORITY_LOW, "UpdateGContact", $profile["gid"]);
}
@ -417,10 +417,10 @@ class Contact extends BaseObject
*/
public static function getDetailsByAddr($addr, $uid = -1)
{
static $cache = array();
static $cache = [];
if ($addr == '') {
return array();
return [];
}
if ($uid == -1) {
@ -490,7 +490,7 @@ class Contact extends BaseObject
if ($contact['uid'] != $uid) {
if ($uid == 0) {
$profile_link = Profile::zrl($contact['url']);
$menu = array('profile' => array(t('View Profile'), $profile_link, true));
$menu = ['profile' => [t('View Profile'), $profile_link, true]];
return $menu;
}
@ -502,10 +502,10 @@ class Contact extends BaseObject
} else {
$profile_link = Profile::zrl($contact['url']);
$connlnk = 'follow/?url=' . $contact['url'];
$menu = array(
'profile' => array(t('View Profile'), $profile_link, true),
'follow' => array(t('Connect/Follow'), $connlnk, true)
);
$menu = [
'profile' => [t('View Profile'), $profile_link, true],
'follow' => [t('Connect/Follow'), $connlnk, true]
];
return $menu;
}
@ -529,7 +529,7 @@ class Contact extends BaseObject
$profile_link = $profile_link . '?url=profile';
}
if (in_array($contact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
if (in_array($contact['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
$pm_url = System::baseUrl() . '/message/new/' . $contact['id'];
}
@ -561,7 +561,7 @@ class Contact extends BaseObject
call_hooks('contact_photo_menu', $args);
$menucondensed = array();
$menucondensed = [];
foreach ($menu as $menuname => $menuitem) {
if ($menuitem[1] != '') {
@ -625,7 +625,7 @@ class Contact extends BaseObject
intval($start),
intval($count)
);
return $r;
}
@ -702,7 +702,7 @@ class Contact extends BaseObject
$data = Probe::uri($url, "", $uid);
// Last try in gcontact for unsupported networks
if (!in_array($data["network"], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO, NETWORK_MAIL))) {
if (!in_array($data["network"], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_PUMPIO, NETWORK_MAIL])) {
if ($uid != 0) {
return 0;
}
@ -775,7 +775,7 @@ class Contact extends BaseObject
if ($data['about'] != '') {
unset($gcontact['about']);
}
dba::update('contact', $gcontact, array('id' => $contact_id));
dba::update('contact', $gcontact, ['id' => $contact_id]);
}
if (count($contacts) > 1 && $uid == 0 && $contact_id != 0 && $data["url"] != "") {
@ -794,12 +794,12 @@ class Contact extends BaseObject
return $contact_id;
}
$updated = array('addr' => $data['addr'],
$updated = ['addr' => $data['addr'],
'alias' => $data['alias'],
'url' => $data['url'],
'nurl' => normalise_link($data['url']),
'name' => $data['name'],
'nick' => $data['nick']);
'nick' => $data['nick']];
// Only fill the pubkey if it was empty before. We have to prevent identity theft.
if (!empty($contact['pubkey'])) {
@ -827,7 +827,7 @@ class Contact extends BaseObject
$updated['avatar-date'] = datetime_convert();
dba::update('contact', $updated, array('id' => $contact_id), $contact);
dba::update('contact', $updated, ['id' => $contact_id], $contact);
return $contact_id;
}
@ -896,7 +896,7 @@ class Contact extends BaseObject
return '';
}
if (in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""))) {
if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
$sql = "(`item`.`uid` = 0 OR (`item`.`uid` = %d AND NOT `item`.`global`))";
} else {
$sql = "`item`.`uid` = %d";
@ -1013,7 +1013,7 @@ class Contact extends BaseObject
if (!DBM::is_result($contact)) {
return false;
} else {
$data = array($contact["photo"], $contact["thumb"], $contact["micro"]);
$data = [$contact["photo"], $contact["thumb"], $contact["micro"]];
}
if (($contact["avatar"] != $avatar) || $force) {
@ -1022,8 +1022,8 @@ class Contact extends BaseObject
if ($photos) {
dba::update(
'contact',
array('avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => datetime_convert()),
array('id' => $cid)
['avatar' => $avatar, 'photo' => $photos[0], 'thumb' => $photos[1], 'micro' => $photos[2], 'avatar-date' => datetime_convert()],
['id' => $cid]
);
// Update the public contact (contact id = 0)
@ -1122,7 +1122,7 @@ class Contact extends BaseObject
*/
public static function createFromProbe($uid, $url, $interactive = false, $network = '')
{
$result = array('cid' => -1, 'success' => false, 'message' => '');
$result = ['cid' => -1, 'success' => false, 'message' => ''];
$a = get_app();
@ -1144,7 +1144,7 @@ class Contact extends BaseObject
return $result;
}
$arr = array('url' => $url, 'contact' => array());
$arr = ['url' => $url, 'contact' => []];
call_hooks('follow', $arr);
@ -1217,7 +1217,7 @@ class Contact extends BaseObject
$hidden = (($ret['network'] === NETWORK_MAIL) ? 1 : 0);
if (in_array($ret['network'], array(NETWORK_MAIL, NETWORK_DIASPORA))) {
if (in_array($ret['network'], [NETWORK_MAIL, NETWORK_DIASPORA])) {
$writeable = 1;
}
@ -1244,10 +1244,10 @@ class Contact extends BaseObject
// update contact
$new_relation = (($r[0]['rel'] == CONTACT_IS_FOLLOWER) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
$fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false);
dba::update('contact', $fields, array('id' => $r[0]['id']));
$fields = ['rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false];
dba::update('contact', $fields, ['id' => $r[0]['id']]);
} else {
$new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
$new_relation = ((in_array($ret['network'], [NETWORK_MAIL])) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
// create contact record
dba::insert('contact', [
@ -1302,7 +1302,7 @@ class Contact extends BaseObject
if (DBM::is_result($r)) {
if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
// create a follow slap
$item = array();
$item = [];
$item['verb'] = ACTIVITY_FOLLOW;
$item['follow'] = $contact["url"];
$slap = OStatus::salmon($item, $r[0]);

View file

@ -157,7 +157,7 @@ class GContact
throw new Exception("This (".$gcontact['url'].") doesn't seem to be an url.");
}
if (in_array($urlparts["host"], array("www.facebook.com", "facebook.com", "twitter.com", "identi.ca", "alpha.app.net"))) {
if (in_array($urlparts["host"], ["www.facebook.com", "facebook.com", "twitter.com", "identi.ca", "alpha.app.net"])) {
throw new Exception('Contact from a non federated network ignored. ('.$gcontact['url'].')');
}
@ -168,7 +168,7 @@ class GContact
}
// Assure that there are no parameter fragments in the profile url
if (in_array($gcontact['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""))) {
if (in_array($gcontact['network'], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
$gcontact['url'] = self::cleanContactUrl($gcontact['url']);
}
@ -254,7 +254,7 @@ class GContact
throw new Exception('No name and photo for URL '.$gcontact['url']);
}
if (!in_array($gcontact['network'], array(NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA))) {
if (!in_array($gcontact['network'], [NETWORK_DFRN, NETWORK_OSTATUS, NETWORK_DIASPORA])) {
throw new Exception('No federated network ('.$gcontact['network'].') detected for URL '.$gcontact['url']);
}
@ -456,7 +456,7 @@ class GContact
public static function suggestionQuery($uid, $start = 0, $limit = 80)
{
if (!$uid) {
return array();
return [];
}
/*
@ -468,7 +468,7 @@ class GContact
// return $list;
//}
$network = array(NETWORK_DFRN);
$network = [NETWORK_DFRN];
if (Config::get('system', 'diaspora_enabled')) {
$network[] = NETWORK_DIASPORA;
@ -532,7 +532,7 @@ class GContact
intval($limit)
);
$list = array();
$list = [];
foreach ($r2 as $suggestion) {
$list[$suggestion["nurl"]] = $suggestion;
}
@ -560,7 +560,7 @@ class GContact
{
$a = get_app();
$done = array();
$done = [];
/// @TODO Check if it is really neccessary to poll the own server
PortableContact::loadWorker(0, 0, 0, System::baseUrl() . '/poco');
@ -665,7 +665,7 @@ class GContact
$gcontact_id = 0;
$doprobing = false;
if (in_array($contact["network"], array(NETWORK_PHANTOM))) {
if (in_array($contact["network"], [NETWORK_PHANTOM])) {
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
return false;
}
@ -683,7 +683,7 @@ class GContact
self::fixAlternateContactAddress($contact);
// Remove unwanted parts from the contact url (e.g. "?zrl=...")
if (in_array($contact["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
if (in_array($contact["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS])) {
$contact["url"] = self::cleanContactUrl($contact["url"]);
}
@ -697,7 +697,7 @@ class GContact
$gcontact_id = $r[0]["id"];
// Update every 90 days
if (in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""))) {
if (in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
$last_failure_str = $r[0]["last_failure"];
$last_failure = strtotime($r[0]["last_failure"]);
$last_contact_str = $r[0]["last_contact"];
@ -731,7 +731,7 @@ class GContact
if (DBM::is_result($r)) {
$gcontact_id = $r[0]["id"];
$doprobing = in_array($r[0]["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""));
$doprobing = in_array($r[0]["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""]);
}
}
dba::unlock();
@ -774,7 +774,7 @@ class GContact
);
// Get all field names
$fields = array();
$fields = [];
foreach ($public_contact[0] as $field => $data) {
$fields[$field] = $data;
}
@ -855,11 +855,11 @@ class GContact
if ($update) {
logger("Update gcontact for ".$contact["url"], LOGGER_DEBUG);
$condition = array('`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)',
normalise_link($contact["url"]), $contact["generation"]);
$condition = ['`nurl` = ? AND (`generation` = 0 OR `generation` >= ?)',
normalise_link($contact["url"]), $contact["generation"]];
$contact["updated"] = DBM::date($contact["updated"]);
$updated = array('photo' => $contact['photo'], 'name' => $contact['name'],
$updated = ['photo' => $contact['photo'], 'name' => $contact['name'],
'nick' => $contact['nick'], 'addr' => $contact['addr'],
'network' => $contact['network'], 'birthday' => $contact['birthday'],
'gender' => $contact['gender'], 'keywords' => $contact['keywords'],
@ -868,34 +868,34 @@ class GContact
'notify' => $contact['notify'], 'url' => $contact['url'],
'location' => $contact['location'], 'about' => $contact['about'],
'generation' => $contact['generation'], 'updated' => $contact['updated'],
'server_url' => $contact['server_url'], 'connect' => $contact['connect']);
'server_url' => $contact['server_url'], 'connect' => $contact['connect']];
dba::update('gcontact', $updated, $condition, $fields);
// Now update the contact entry with the user id "0" as well.
// This is used for the shadow copies of public items.
$public_contact = dba::selectFirst('contact', ['id'], ['nurl' => normalise_link($contact["url"]), 'uid' => 0]);
if (DBM::is_result($public_contact)) {
logger("Update public contact ".$public_contact["id"], LOGGER_DEBUG);
Contact::updateAvatar($contact["photo"], 0, $public_contact["id"]);
$fields = array('name', 'nick', 'addr',
$fields = ['name', 'nick', 'addr',
'network', 'bd', 'gender',
'keywords', 'alias', 'contact-type',
'url', 'location', 'about');
'url', 'location', 'about'];
$old_contact = dba::selectFirst('contact', $fields, ['id' => $public_contact["id"]]);
// Update it with the current values
$fields = array('name' => $contact['name'], 'nick' => $contact['nick'],
$fields = ['name' => $contact['name'], 'nick' => $contact['nick'],
'addr' => $contact['addr'], 'network' => $contact['network'],
'bd' => $contact['birthday'], 'gender' => $contact['gender'],
'keywords' => $contact['keywords'], 'alias' => $contact['alias'],
'contact-type' => $contact['contact-type'], 'url' => $contact['url'],
'location' => $contact['location'], 'about' => $contact['about']);
'location' => $contact['location'], 'about' => $contact['about']];
dba::update('contact', $fields, array('id' => $public_contact["id"]), $old_contact);
dba::update('contact', $fields, ['id' => $public_contact["id"]], $old_contact);
}
}
@ -912,7 +912,7 @@ class GContact
{
$data = Probe::uri($url);
if (in_array($data["network"], array(NETWORK_PHANTOM))) {
if (in_array($data["network"], [NETWORK_PHANTOM])) {
logger("Invalid network for contact url ".$data["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
return;
}
@ -944,24 +944,24 @@ class GContact
);
$location = Profile::formatLocation(
array("locality" => $r[0]["locality"], "region" => $r[0]["region"], "country-name" => $r[0]["country-name"])
["locality" => $r[0]["locality"], "region" => $r[0]["region"], "country-name" => $r[0]["country-name"]]
);
// The "addr" field was added in 3.4.3 so it can be empty for older users
if ($r[0]["addr"] != "") {
$addr = $r[0]["nickname"].'@'.str_replace(array("http://", "https://"), "", System::baseUrl());
$addr = $r[0]["nickname"].'@'.str_replace(["http://", "https://"], "", System::baseUrl());
} else {
$addr = $r[0]["addr"];
}
$gcontact = array("name" => $r[0]["name"], "location" => $location, "about" => $r[0]["about"],
$gcontact = ["name" => $r[0]["name"], "location" => $location, "about" => $r[0]["about"],
"gender" => $r[0]["gender"], "keywords" => $r[0]["pub_keywords"],
"birthday" => $r[0]["dob"], "photo" => $r[0]["photo"],
"notify" => $r[0]["notify"], "url" => $r[0]["url"],
"hide" => ($r[0]["hidewall"] || !$r[0]["net-publish"]),
"nick" => $r[0]["nickname"], "addr" => $addr,
"connect" => $addr, "server_url" => System::baseUrl(),
"generation" => 1, "network" => NETWORK_DFRN);
"generation" => 1, "network" => NETWORK_DFRN];
self::update($gcontact);
}
@ -1014,13 +1014,13 @@ class GContact
foreach ($statistics->users as $nick => $user) {
$profile_url = $server."/".$user->nickname;
$contact = array("url" => $profile_url,
$contact = ["url" => $profile_url,
"name" => $user->fullname,
"addr" => $user->nickname."@".$hostname,
"nick" => $user->nickname,
"about" => $user->bio,
"network" => NETWORK_OSTATUS,
"photo" => System::baseUrl()."/images/person-175.jpg");
"photo" => System::baseUrl()."/images/person-175.jpg"];
self::getId($contact);
}
}

View file

@ -330,10 +330,10 @@ class Group extends BaseObject
$label = t('Default privacy group for new contacts');
}
$o = replace_macros(get_markup_template('group_selection.tpl'), array(
$o = replace_macros(get_markup_template('group_selection.tpl'), [
'$label' => $label,
'$groups' => $display_groups
));
]);
return $o;
}
@ -369,7 +369,7 @@ class Group extends BaseObject
$stmt = dba::select('group', [], ['deleted' => 0, 'uid' => local_user()], ['order' => ['name']]);
$member_of = array();
$member_of = [];
if ($cid) {
$member_of = self::getIdsByContactId($cid);
}

View file

@ -171,7 +171,7 @@ class Photo
$micro = System::baseUrl() . '/images/person-48.jpg';
}
return array($image_url, $thumb, $micro);
return [$image_url, $thumb, $micro];
}
/**
@ -184,9 +184,9 @@ class Photo
$degrees = count($exifCoord) > 0 ? self::gps2Num($exifCoord[0]) : 0;
$minutes = count($exifCoord) > 1 ? self::gps2Num($exifCoord[1]) : 0;
$seconds = count($exifCoord) > 2 ? self::gps2Num($exifCoord[2]) : 0;
$flip = ($hemi == 'W' || $hemi == 'S') ? -1 : 1;
return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600)));
}
@ -197,15 +197,15 @@ class Photo
private static function gps2Num($coordPart)
{
$parts = explode('/', $coordPart);
if (count($parts) <= 0) {
return 0;
}
if (count($parts) == 1) {
return $parts[0];
}
return floatval($parts[0]) / floatval($parts[1]);
}

View file

@ -84,7 +84,7 @@ class Profile
* @param array $profiledata array
* @param boolean $show_connect Show connect link
*/
public static function load(App $a, $nickname, $profile = 0, $profiledata = array(), $show_connect = true)
public static function load(App $a, $nickname, $profile = 0, $profiledata = [], $show_connect = true)
{
$user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname]);
@ -160,10 +160,10 @@ class Profile
if (local_user() && local_user() == $a->profile['uid'] && $profiledata) {
$a->page['aside'] .= replace_macros(
get_markup_template('profile_edlink.tpl'),
array(
[
'$editprofile' => t('Edit profile'),
'$profid' => $a->profile['id']
)
]
);
}
@ -314,7 +314,7 @@ class Profile
$profile_url = normalise_link(System::baseUrl() . '/profile/' . $profile['nickname']);
}
if (dba::exists('contact', array('pending' => false, 'uid' => local_user(), 'nurl' => $profile_url))) {
if (dba::exists('contact', ['pending' => false, 'uid' => local_user(), 'nurl' => $profile_url])) {
$connect = false;
}
}
@ -365,21 +365,21 @@ class Profile
// show edit profile to yourself
if (!$is_contact && $profile['uid'] == local_user() && Feature::isEnabled(local_user(), 'multi_profiles')) {
$profile['edit'] = array(System::baseUrl() . '/profiles', t('Profiles'), '', t('Manage/edit profiles'));
$profile['edit'] = [System::baseUrl() . '/profiles', t('Profiles'), '', t('Manage/edit profiles')];
$r = q(
"SELECT * FROM `profile` WHERE `uid` = %d",
local_user()
);
$profile['menu'] = array(
$profile['menu'] = [
'chg_photo' => t('Change profile photo'),
'cr_new' => t('Create New Profile'),
'entries' => array(),
);
'entries' => [],
];
if (DBM::is_result($r)) {
foreach ($r as $rr) {
$profile['menu']['entries'][] = array(
$profile['menu']['entries'][] = [
'photo' => $rr['thumb'],
'id' => $rr['id'],
'alt' => t('Profile Image'),
@ -387,17 +387,17 @@ class Profile
'isdefault' => $rr['is-default'],
'visibile_to_everybody' => t('visible to everybody'),
'edit_visibility' => t('Edit visibility'),
);
];
}
}
}
if (!$is_contact && $profile['uid'] == local_user() && !Feature::isEnabled(local_user(), 'multi_profiles')) {
$profile['edit'] = array(System::baseUrl() . '/profiles/' . $profile['id'], t('Edit profile'), '', t('Edit profile'));
$profile['menu'] = array(
$profile['edit'] = [System::baseUrl() . '/profiles/' . $profile['id'], t('Edit profile'), '', t('Edit profile')];
$profile['menu'] = [
'chg_photo' => t('Change profile photo'),
'cr_new' => null,
'entries' => array(),
);
'entries' => [],
];
}
// Fetch the account type
@ -428,7 +428,7 @@ class Profile
$lastname = $split_name['last'];
if (x($profile, 'guid')) {
$diaspora = array(
$diaspora = [
'guid' => $profile['guid'],
'podloc' => System::baseUrl(),
'searchable' => (($profile['publish'] && $profile['net-publish']) ? 'true' : 'false' ),
@ -439,7 +439,7 @@ class Profile
'photo300' => $profile['contact_photo'],
'photo100' => $profile['contact_thumb'],
'photo50' => $profile['contact_micro'],
);
];
} else {
$diaspora = false;
}
@ -476,7 +476,7 @@ class Profile
}
}
$p = array();
$p = [];
foreach ($profile as $k => $v) {
$k = str_replace('-', '_', $k);
$p[$k] = $v;
@ -497,7 +497,7 @@ class Profile
}
$tpl = get_markup_template('profile_vcard.tpl');
$o .= replace_macros($tpl, array(
$o .= replace_macros($tpl, [
'$profile' => $p,
'$xmpp' => $xmpp,
'$connect' => $connect,
@ -516,9 +516,9 @@ class Profile
'$updated' => $updated,
'$diaspora' => $diaspora,
'$contact_block' => $contact_block,
));
]);
$arr = array('profile' => &$profile, 'entry' => &$o);
$arr = ['profile' => &$profile, 'entry' => &$o];
call_hooks('profile_sidebar', $arr);
@ -564,7 +564,7 @@ class Profile
if (DBM::is_result($r)) {
$total = 0;
$now = strtotime('now');
$cids = array();
$cids = [];
$istoday = false;
foreach ($r as $rr) {
@ -604,7 +604,7 @@ class Profile
}
}
$tpl = get_markup_template('birthdays_reminder.tpl');
return replace_macros($tpl, array(
return replace_macros($tpl, [
'$baseurl' => System::baseUrl(),
'$classtoday' => $classtoday,
'$count' => $total,
@ -613,7 +613,7 @@ class Profile
'$events' => $r,
'$lbr' => '{', // raw brackets mess up if/endif macro processing
'$rbr' => '}'
));
]);
}
public static function getEvents()
@ -645,7 +645,7 @@ class Profile
datetime_convert('UTC', 'UTC', 'now - 1 days')
);
$r = array();
$r = [];
if (DBM::is_result($s)) {
$istoday = false;
@ -691,14 +691,14 @@ class Profile
$classtoday = (($istoday) ? 'event-today' : '');
}
$tpl = get_markup_template('events_reminder.tpl');
return replace_macros($tpl, array(
return replace_macros($tpl, [
'$baseurl' => System::baseUrl(),
'$classtoday' => $classtoday,
'$count' => count($r),
'$event_reminders' => t('Event Reminders'),
'$event_title' => t('Events this week:'),
'$events' => $r,
));
]);
}
public static function getAdvanced(App $a)
@ -708,18 +708,18 @@ class Profile
$o .= replace_macros(
get_markup_template('section_title.tpl'),
array('$title' => t('Profile'))
['$title' => t('Profile')]
);
if ($a->profile['name']) {
$tpl = get_markup_template('profile_advanced.tpl');
$profile = array();
$profile = [];
$profile['fullname'] = array(t('Full Name:'), $a->profile['name']);
$profile['fullname'] = [t('Full Name:'), $a->profile['name']];
if ($a->profile['gender']) {
$profile['gender'] = array(t('Gender:'), $a->profile['gender']);
$profile['gender'] = [t('Gender:'), $a->profile['gender']];
}
if (($a->profile['dob']) && ($a->profile['dob'] > '0001-01-01')) {
@ -730,18 +730,18 @@ class Profile
day_translate(datetime_convert('UTC', 'UTC', $a->profile['dob'] . ' 00:00 +00:00', $year_bd_format))
: day_translate(datetime_convert('UTC', 'UTC', '2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format));
$profile['birthday'] = array(t('Birthday:'), $val);
$profile['birthday'] = [t('Birthday:'), $val];
}
if (!empty($a->profile['dob'])
&& $a->profile['dob'] > '0001-01-01'
&& $age = age($a->profile['dob'], $a->profile['timezone'], '')
) {
$profile['age'] = array(t('Age:'), $age);
$profile['age'] = [t('Age:'), $age];
}
if ($a->profile['marital']) {
$profile['marital'] = array(t('Status:'), $a->profile['marital']);
$profile['marital'] = [t('Status:'), $a->profile['marital']];
}
/// @TODO Maybe use x() here, plus below?
@ -754,92 +754,92 @@ class Profile
}
if ($a->profile['sexual']) {
$profile['sexual'] = array(t('Sexual Preference:'), $a->profile['sexual']);
$profile['sexual'] = [t('Sexual Preference:'), $a->profile['sexual']];
}
if ($a->profile['homepage']) {
$profile['homepage'] = array(t('Homepage:'), linkify($a->profile['homepage']));
$profile['homepage'] = [t('Homepage:'), linkify($a->profile['homepage'])];
}
if ($a->profile['hometown']) {
$profile['hometown'] = array(t('Hometown:'), linkify($a->profile['hometown']));
$profile['hometown'] = [t('Hometown:'), linkify($a->profile['hometown'])];
}
if ($a->profile['pub_keywords']) {
$profile['pub_keywords'] = array(t('Tags:'), $a->profile['pub_keywords']);
$profile['pub_keywords'] = [t('Tags:'), $a->profile['pub_keywords']];
}
if ($a->profile['politic']) {
$profile['politic'] = array(t('Political Views:'), $a->profile['politic']);
$profile['politic'] = [t('Political Views:'), $a->profile['politic']];
}
if ($a->profile['religion']) {
$profile['religion'] = array(t('Religion:'), $a->profile['religion']);
$profile['religion'] = [t('Religion:'), $a->profile['religion']];
}
if ($txt = prepare_text($a->profile['about'])) {
$profile['about'] = array(t('About:'), $txt);
$profile['about'] = [t('About:'), $txt];
}
if ($txt = prepare_text($a->profile['interest'])) {
$profile['interest'] = array(t('Hobbies/Interests:'), $txt);
$profile['interest'] = [t('Hobbies/Interests:'), $txt];
}
if ($txt = prepare_text($a->profile['likes'])) {
$profile['likes'] = array(t('Likes:'), $txt);
$profile['likes'] = [t('Likes:'), $txt];
}
if ($txt = prepare_text($a->profile['dislikes'])) {
$profile['dislikes'] = array(t('Dislikes:'), $txt);
$profile['dislikes'] = [t('Dislikes:'), $txt];
}
if ($txt = prepare_text($a->profile['contact'])) {
$profile['contact'] = array(t('Contact information and Social Networks:'), $txt);
$profile['contact'] = [t('Contact information and Social Networks:'), $txt];
}
if ($txt = prepare_text($a->profile['music'])) {
$profile['music'] = array(t('Musical interests:'), $txt);
$profile['music'] = [t('Musical interests:'), $txt];
}
if ($txt = prepare_text($a->profile['book'])) {
$profile['book'] = array(t('Books, literature:'), $txt);
$profile['book'] = [t('Books, literature:'), $txt];
}
if ($txt = prepare_text($a->profile['tv'])) {
$profile['tv'] = array(t('Television:'), $txt);
$profile['tv'] = [t('Television:'), $txt];
}
if ($txt = prepare_text($a->profile['film'])) {
$profile['film'] = array(t('Film/dance/culture/entertainment:'), $txt);
$profile['film'] = [t('Film/dance/culture/entertainment:'), $txt];
}
if ($txt = prepare_text($a->profile['romance'])) {
$profile['romance'] = array(t('Love/Romance:'), $txt);
$profile['romance'] = [t('Love/Romance:'), $txt];
}
if ($txt = prepare_text($a->profile['work'])) {
$profile['work'] = array(t('Work/employment:'), $txt);
$profile['work'] = [t('Work/employment:'), $txt];
}
if ($txt = prepare_text($a->profile['education'])) {
$profile['education'] = array(t('School/education:'), $txt);
$profile['education'] = [t('School/education:'), $txt];
}
//show subcribed forum if it is enabled in the usersettings
if (Feature::isEnabled($uid, 'forumlist_profile')) {
$profile['forumlist'] = array(t('Forums:'), ForumManager::profileAdvanced($uid));
$profile['forumlist'] = [t('Forums:'), ForumManager::profileAdvanced($uid)];
}
if ($a->profile['uid'] == local_user()) {
$profile['edit'] = array(System::baseUrl() . '/profiles/' . $a->profile['id'], t('Edit profile'), '', t('Edit profile'));
$profile['edit'] = [System::baseUrl() . '/profiles/' . $a->profile['id'], t('Edit profile'), '', t('Edit profile')];
}
return replace_macros($tpl, array(
return replace_macros($tpl, [
'$title' => t('Profile'),
'$basic' => t('Basic'),
'$advanced' => t('Advanced'),
'$profile' => $profile
));
]);
}
return '';
@ -858,92 +858,92 @@ class Profile
$url = System::baseUrl() . '/profile/' . $nickname;
$tabs = array(
array(
$tabs = [
[
'label' => t('Status'),
'url' => $url,
'sel' => !$tab && $a->argv[0] == 'profile' ? 'active' : '',
'title' => t('Status Messages and Posts'),
'id' => 'status-tab',
'accesskey' => 'm',
),
array(
],
[
'label' => t('Profile'),
'url' => $url . '/?tab=profile',
'sel' => $tab == 'profile' ? 'active' : '',
'title' => t('Profile Details'),
'id' => 'profile-tab',
'accesskey' => 'r',
),
array(
],
[
'label' => t('Photos'),
'url' => System::baseUrl() . '/photos/' . $nickname,
'sel' => !$tab && $a->argv[0] == 'photos' ? 'active' : '',
'title' => t('Photo Albums'),
'id' => 'photo-tab',
'accesskey' => 'h',
),
array(
],
[
'label' => t('Videos'),
'url' => System::baseUrl() . '/videos/' . $nickname,
'sel' => !$tab && $a->argv[0] == 'videos' ? 'active' : '',
'title' => t('Videos'),
'id' => 'video-tab',
'accesskey' => 'v',
),
);
],
];
// the calendar link for the full featured events calendar
if ($is_owner && $a->theme_events_in_profile) {
$tabs[] = array(
$tabs[] = [
'label' => t('Events'),
'url' => System::baseUrl() . '/events',
'sel' => !$tab && $a->argv[0] == 'events' ? 'active' : '',
'title' => t('Events and Calendar'),
'id' => 'events-tab',
'accesskey' => 'e',
);
];
// if the user is not the owner of the calendar we only show a calendar
// with the public events of the calendar owner
} elseif (!$is_owner) {
$tabs[] = array(
$tabs[] = [
'label' => t('Events'),
'url' => System::baseUrl() . '/cal/' . $nickname,
'sel' => !$tab && $a->argv[0] == 'cal' ? 'active' : '',
'title' => t('Events and Calendar'),
'id' => 'events-tab',
'accesskey' => 'e',
);
];
}
if ($is_owner) {
$tabs[] = array(
$tabs[] = [
'label' => t('Personal Notes'),
'url' => System::baseUrl() . '/notes',
'sel' => !$tab && $a->argv[0] == 'notes' ? 'active' : '',
'title' => t('Only You Can See This'),
'id' => 'notes-tab',
'accesskey' => 't',
);
];
}
if ((!$is_owner) && ((count($a->profile)) || (!$a->profile['hide-friends']))) {
$tabs[] = array(
$tabs[] = [
'label' => t('Contacts'),
'url' => System::baseUrl() . '/viewcontacts/' . $nickname,
'sel' => !$tab && $a->argv[0] == 'viewcontacts' ? 'active' : '',
'title' => t('Contacts'),
'id' => 'viewcontacts-tab',
'accesskey' => 'k',
);
];
}
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs);
$arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs];
call_hooks('profile_tabs', $arr);
$tpl = get_markup_template('common_tabs.tpl');
return replace_macros($tpl, array('$tabs' => $arr['tabs']));
return replace_macros($tpl, ['$tabs' => $arr['tabs']]);
}
/**
@ -969,13 +969,13 @@ class Profile
$urlparts = parse_url($my_url);
$result = Cache::get('gprobe:' . $urlparts['host']);
if ((!is_null($result)) && (in_array($result['network'], array(NETWORK_FEED, NETWORK_PHANTOM)))) {
if ((!is_null($result)) && (in_array($result['network'], [NETWORK_FEED, NETWORK_PHANTOM]))) {
logger('DDoS attempt detected for ' . $urlparts['host'] . ' by ' . $_SERVER['REMOTE_ADDR'] . '. server data: ' . print_r($_SERVER, true), LOGGER_DEBUG);
return;
}
Worker::add(PRIORITY_LOW, 'GProbe', $my_url);
$arr = array('zrl' => $my_url, 'url' => $a->cmd);
$arr = ['zrl' => $my_url, 'url' => $a->cmd];
call_hooks('zrl_init', $arr);
}
}

View file

@ -217,8 +217,8 @@ class User
$openid = new \LightOpenID;
$openid->identity = $openid_url;
$openid->returnUrl = System::baseUrl() . '/openid';
$openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
$openid->optional = array('namePerson/first', 'media/image/aspect11', 'media/image/default');
$openid->required = ['namePerson/friendly', 'contact/email', 'namePerson'];
$openid->optional = ['namePerson/first', 'media/image/aspect11', 'media/image/default'];
try {
$authurl = $openid->authUrl();
} catch (Exception $e) {
@ -456,11 +456,11 @@ class User
$body = sprintf($body, $username, $sitename);
return notification(array(
return notification([
'type' => SYSTEM_EMAIL,
'to_email' => $email,
'subject'=> sprintf( t('Registration at %s'), $sitename),
'body' => $body));
'body' => $body]);
}
/**
@ -510,12 +510,12 @@ class User
$preamble = sprintf($preamble, $username, $sitename);
$body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
return notification(array(
return notification([
'type' => SYSTEM_EMAIL,
'to_email' => $email,
'subject'=> sprintf( t('Registration details for %s'), $sitename),
'preamble'=> $preamble,
'body' => $body));
'body' => $body]);
}
/**