mirror of
https://github.com/friendica/friendica
synced 2025-11-16 03:24:56 +01:00
Use short form array syntax everywhere
- Add short form array syntax to po2php.php generation
This commit is contained in:
parent
77dfbaa0bf
commit
e36f2bb1fb
212 changed files with 5160 additions and 5160 deletions
24
boot.php
24
boot.php
|
|
@ -288,7 +288,7 @@ define('NETWORK_PHANTOM', 'unkn'); // Place holder
|
|||
* and existing allocations MUST NEVER BE CHANGED
|
||||
* OR RE-ASSIGNED! You may only add to them.
|
||||
*/
|
||||
$netgroup_ids = array(
|
||||
$netgroup_ids = [
|
||||
NETWORK_DFRN => (-1),
|
||||
NETWORK_ZOT => (-2),
|
||||
NETWORK_OSTATUS => (-3),
|
||||
|
|
@ -310,7 +310,7 @@ $netgroup_ids = array(
|
|||
NETWORK_PNUT => (-20),
|
||||
|
||||
NETWORK_PHANTOM => (-127),
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Maximum number of "people who like (or don't like) this" that we will list by name
|
||||
|
|
@ -504,7 +504,7 @@ function startup()
|
|||
ini_set('pcre.backtrack_limit', 500000);
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
|
||||
$process = [&$_GET, &$_POST, &$_COOKIE, &$_REQUEST];
|
||||
while (list($key, $val) = each($process)) {
|
||||
foreach ($val as $k => $v) {
|
||||
unset($process[$key][$k]);
|
||||
|
|
@ -817,11 +817,11 @@ function check_plugins(App $a)
|
|||
if (DBM::is_result($r)) {
|
||||
$installed = $r;
|
||||
} else {
|
||||
$installed = array();
|
||||
$installed = [];
|
||||
}
|
||||
|
||||
$plugins = Config::get('system', 'addon');
|
||||
$plugins_arr = array();
|
||||
$plugins_arr = [];
|
||||
|
||||
if ($plugins) {
|
||||
$plugins_arr = explode(',', str_replace(' ', '', $plugins));
|
||||
|
|
@ -829,7 +829,7 @@ function check_plugins(App $a)
|
|||
|
||||
$a->plugins = $plugins_arr;
|
||||
|
||||
$installed_arr = array();
|
||||
$installed_arr = [];
|
||||
|
||||
if (count($installed)) {
|
||||
foreach ($installed as $i) {
|
||||
|
|
@ -966,7 +966,7 @@ function notice($s)
|
|||
{
|
||||
$a = get_app();
|
||||
if (!x($_SESSION, 'sysmsg')) {
|
||||
$_SESSION['sysmsg'] = array();
|
||||
$_SESSION['sysmsg'] = [];
|
||||
}
|
||||
if ($a->interactive) {
|
||||
$_SESSION['sysmsg'][] = $s;
|
||||
|
|
@ -989,7 +989,7 @@ function info($s)
|
|||
}
|
||||
|
||||
if (!x($_SESSION, 'sysmsg_info')) {
|
||||
$_SESSION['sysmsg_info'] = array();
|
||||
$_SESSION['sysmsg_info'] = [];
|
||||
}
|
||||
if ($a->interactive) {
|
||||
$_SESSION['sysmsg_info'][] = $s;
|
||||
|
|
@ -1010,7 +1010,7 @@ function get_max_import_size()
|
|||
|
||||
function current_theme()
|
||||
{
|
||||
$app_base_themes = array('duepuntozero', 'dispy', 'quattro');
|
||||
$app_base_themes = ['duepuntozero', 'dispy', 'quattro'];
|
||||
|
||||
$a = get_app();
|
||||
|
||||
|
|
@ -1238,10 +1238,10 @@ function explode_querystring($query)
|
|||
$args = array_values($args);
|
||||
}
|
||||
|
||||
return array(
|
||||
return [
|
||||
'base' => $base,
|
||||
'args' => $args,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1571,7 +1571,7 @@ function infinite_scroll_data($module)
|
|||
$reload_uri .= "&offset=" . urlencode($a->page_offset);
|
||||
}
|
||||
|
||||
$arr = array("pageno" => $pageno, "reload_uri" => $reload_uri);
|
||||
$arr = ["pageno" => $pageno, "reload_uri" => $reload_uri];
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ $a->config['system']['no_regfullname'] = true;
|
|||
$a->config['system']['directory'] = 'https://dir.friendica.social';
|
||||
|
||||
// Allowed protocols in link URLs; HTTP protocols always are accepted
|
||||
$a->config['system']['allowed_link_protocols'] = array('ftp', 'ftps', 'mailto', 'cid', 'gopher');
|
||||
$a->config['system']['allowed_link_protocols'] = ['ftp', 'ftps', 'mailto', 'cid', 'gopher'];
|
||||
|
||||
// Authentication cookie lifetime, in days
|
||||
$a->config['system']['auth_cookie_lifetime'] = 7;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) {
|
|||
);
|
||||
|
||||
|
||||
$arr = array('group' => $r, 'entry' => $o);
|
||||
$arr = ['group' => $r, 'entry' => $o];
|
||||
|
||||
// e.g. 'network_pre_group_deny', 'profile_pre_group_allow'
|
||||
|
||||
|
|
@ -87,20 +87,20 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
|
|||
if (x($options, 'networks')) {
|
||||
switch ($options['networks']) {
|
||||
case 'DFRN_ONLY':
|
||||
$networks = array(NETWORK_DFRN);
|
||||
$networks = [NETWORK_DFRN];
|
||||
break;
|
||||
case 'PRIVATE':
|
||||
if (is_array($a->user) && $a->user['prvnets']) {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
|
||||
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||
} else {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA);
|
||||
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||
}
|
||||
break;
|
||||
case 'TWO_WAY':
|
||||
if (is_array($a->user) && $a->user['prvnets']) {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA);
|
||||
$networks = [NETWORK_DFRN, NETWORK_MAIL, NETWORK_DIASPORA];
|
||||
} else {
|
||||
$networks = array(NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS);
|
||||
$networks = [NETWORK_DFRN, NETWORK_FACEBOOK, NETWORK_MAIL, NETWORK_DIASPORA, NETWORK_OSTATUS];
|
||||
}
|
||||
break;
|
||||
default: /// @TODO Maybe log this call?
|
||||
|
|
@ -109,7 +109,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
|
|||
}
|
||||
}
|
||||
|
||||
$x = array('options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks);
|
||||
$x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks];
|
||||
|
||||
call_hooks('contact_select_options', $x);
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false)
|
|||
);
|
||||
|
||||
|
||||
$arr = array('contact' => $r, 'entry' => $o);
|
||||
$arr = ['contact' => $r, 'entry' => $o];
|
||||
|
||||
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
|
||||
|
||||
|
|
@ -228,13 +228,13 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
);
|
||||
|
||||
|
||||
$arr = array('contact' => $r, 'entry' => $o);
|
||||
$arr = ['contact' => $r, 'entry' => $o];
|
||||
|
||||
// e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow'
|
||||
|
||||
call_hooks($a->module . '_pre_' . $selname, $arr);
|
||||
|
||||
$receiverlist = array();
|
||||
$receiverlist = [];
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r as $rr) {
|
||||
|
|
@ -270,7 +270,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
|
|||
|
||||
|
||||
function fixacl(&$item) {
|
||||
$item = intval(str_replace(array('<', '>'), array('', ''), $item));
|
||||
$item = intval(str_replace(['<', '>'], ['', ''], $item));
|
||||
}
|
||||
|
||||
function prune_deadguys($arr) {
|
||||
|
|
@ -284,14 +284,14 @@ function prune_deadguys($arr) {
|
|||
$r = q("SELECT `id` FROM `contact` WHERE `id` IN ( " . $str . ") AND `blocked` = 0 AND `pending` = 0 AND `archive` = 0 ");
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
foreach ($r as $rr) {
|
||||
$ret[] = intval($rr['id']);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -300,13 +300,13 @@ function get_acl_permissions($user = null) {
|
|||
|
||||
if (is_array($user)) {
|
||||
$allow_cid = ((strlen($user['allow_cid']))
|
||||
? explode('><', $user['allow_cid']) : array() );
|
||||
? explode('><', $user['allow_cid']) : [] );
|
||||
$allow_gid = ((strlen($user['allow_gid']))
|
||||
? explode('><', $user['allow_gid']) : array() );
|
||||
? explode('><', $user['allow_gid']) : [] );
|
||||
$deny_cid = ((strlen($user['deny_cid']))
|
||||
? explode('><', $user['deny_cid']) : array() );
|
||||
? explode('><', $user['deny_cid']) : [] );
|
||||
$deny_gid = ((strlen($user['deny_gid']))
|
||||
? explode('><', $user['deny_gid']) : array() );
|
||||
? explode('><', $user['deny_gid']) : [] );
|
||||
array_walk($allow_cid,'fixacl');
|
||||
array_walk($allow_gid,'fixacl');
|
||||
array_walk($deny_cid,'fixacl');
|
||||
|
|
@ -315,12 +315,12 @@ function get_acl_permissions($user = null) {
|
|||
|
||||
$allow_cid = prune_deadguys($allow_cid);
|
||||
|
||||
return array(
|
||||
return [
|
||||
'allow_cid' => $allow_cid,
|
||||
'allow_gid' => $allow_gid,
|
||||
'deny_cid' => $deny_cid,
|
||||
'deny_gid' => $deny_gid,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ function populate_acl($user = null, $show_jotnets = false) {
|
|||
}
|
||||
|
||||
$tpl = get_markup_template("acl_selector.tpl");
|
||||
$o = replace_macros($tpl, array(
|
||||
$o = replace_macros($tpl, [
|
||||
'$showall'=> t("Visible to everybody"),
|
||||
'$show' => t("show"),
|
||||
'$hide' => t("don't show"),
|
||||
|
|
@ -375,10 +375,10 @@ function populate_acl($user = null, $show_jotnets = false) {
|
|||
'$jotnets' => $jotnets,
|
||||
'$aclModalTitle' => t('Permissions'),
|
||||
'$aclModalDismiss' => t('Close'),
|
||||
'$features' => array(
|
||||
'$features' => [
|
||||
'aclautomention' => (Feature::isEnabled($user['uid'], "aclautomention") ? "true" : "false")
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
return $o;
|
||||
|
|
@ -475,8 +475,8 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
|
||||
$tot = $group_count + $contact_count;
|
||||
|
||||
$groups = array();
|
||||
$contacts = array();
|
||||
$groups = [];
|
||||
$contacts = [];
|
||||
|
||||
if ($type == '' || $type == 'g') {
|
||||
/// @todo We should cache this query.
|
||||
|
|
@ -495,7 +495,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
);
|
||||
|
||||
foreach ($r as $g) {
|
||||
$groups[] = array(
|
||||
$groups[] = [
|
||||
"type" => "g",
|
||||
"photo" => "images/twopeople.png",
|
||||
"name" => htmlentities($g['name']),
|
||||
|
|
@ -503,10 +503,10 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
"uids" => array_map("intval", explode(",",$g['uids'])),
|
||||
"link" => '',
|
||||
"forum" => '0'
|
||||
);
|
||||
];
|
||||
}
|
||||
if ((count($groups) > 0) && ($search == "")) {
|
||||
$groups[] = array("separator" => true);
|
||||
$groups[] = ["separator" => true];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -558,34 +558,34 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
} elseif ($type == 'x') {
|
||||
// autocomplete for global contact search (e.g. navbar search)
|
||||
$r = navbar_complete($a);
|
||||
$contacts = array();
|
||||
$contacts = [];
|
||||
if ($r) {
|
||||
foreach ($r as $g) {
|
||||
$contacts[] = array(
|
||||
$contacts[] = [
|
||||
'photo' => proxy_url($g['photo'], false, PROXY_SIZE_MICRO),
|
||||
'name' => $g['name'],
|
||||
'nick' => (x($g['addr']) ? $g['addr'] : $g['url']),
|
||||
'network' => $g['network'],
|
||||
'link' => $g['url'],
|
||||
'forum' => (x($g['community']) ? 1 : 0),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
$o = array(
|
||||
$o = [
|
||||
'start' => $start,
|
||||
'count' => $count,
|
||||
'items' => $contacts,
|
||||
);
|
||||
];
|
||||
echo json_encode($o);
|
||||
killme();
|
||||
} else {
|
||||
$r = array();
|
||||
$r = [];
|
||||
}
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$forums = array();
|
||||
$forums = [];
|
||||
foreach ($r as $g) {
|
||||
$entry = array(
|
||||
$entry = [
|
||||
'type' => 'c',
|
||||
'photo' => proxy_url($g['micro'], false, PROXY_SIZE_MICRO),
|
||||
'name' => htmlentities($g['name']),
|
||||
|
|
@ -595,7 +595,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
'nick' => htmlentities(($g['attag']) ? $g['attag'] : $g['nick']),
|
||||
'addr' => htmlentities(($g['addr']) ? $g['addr'] : $g['url']),
|
||||
'forum' => ((x($g, 'forum') || x($g, 'prv')) ? 1 : 0),
|
||||
);
|
||||
];
|
||||
if ($entry['forum']) {
|
||||
$forums[] = $entry;
|
||||
} else {
|
||||
|
|
@ -604,7 +604,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
}
|
||||
if (count($forums) > 0) {
|
||||
if ($search == "") {
|
||||
$forums[] = array("separator" => true);
|
||||
$forums[] = ["separator" => true];
|
||||
}
|
||||
$contacts = array_merge($forums, $contacts);
|
||||
}
|
||||
|
|
@ -623,7 +623,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
}
|
||||
, $contacts);
|
||||
|
||||
$unknown_contacts = array();
|
||||
$unknown_contacts = [];
|
||||
$r = q("SELECT `author-link`
|
||||
FROM `item` WHERE `parent` = %d
|
||||
AND (`author-name` LIKE '%%%s%%' OR `author-link` LIKE '%%%s%%')
|
||||
|
|
@ -641,7 +641,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
$contact = Contact::getDetailsByURL($row['author-link']);
|
||||
|
||||
if (count($contact) > 0) {
|
||||
$unknown_contacts[] = array(
|
||||
$unknown_contacts[] = [
|
||||
'type' => 'c',
|
||||
'photo' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
|
||||
'name' => htmlentities($contact['name']),
|
||||
|
|
@ -651,7 +651,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
'nick' => htmlentities($contact['nick'] ? : $contact['addr']),
|
||||
'addr' => htmlentities(($contact['addr']) ? $contact['addr'] : $contact['url']),
|
||||
'forum' => $contact['forum']
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -660,7 +660,7 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
$tot += count($unknown_contacts);
|
||||
}
|
||||
|
||||
$results = array(
|
||||
$results = [
|
||||
'tot' => $tot,
|
||||
'start' => $start,
|
||||
'count' => $count,
|
||||
|
|
@ -669,27 +669,27 @@ function acl_lookup(App $a, $out_type = 'json')
|
|||
'items' => $items,
|
||||
'type' => $type,
|
||||
'search' => $search,
|
||||
);
|
||||
];
|
||||
|
||||
call_hooks('acl_lookup_end', $results);
|
||||
|
||||
if ($out_type === 'html') {
|
||||
$o = array(
|
||||
$o = [
|
||||
'tot' => $results['tot'],
|
||||
'start' => $results['start'],
|
||||
'count' => $results['count'],
|
||||
'groups' => $results['groups'],
|
||||
'contacts' => $results['contacts'],
|
||||
);
|
||||
];
|
||||
return $o;
|
||||
}
|
||||
|
||||
$o = array(
|
||||
$o = [
|
||||
'tot' => $results['tot'],
|
||||
'start' => $results['start'],
|
||||
'count' => $results['count'],
|
||||
'items' => $results['items'],
|
||||
);
|
||||
];
|
||||
|
||||
echo json_encode($o);
|
||||
|
||||
|
|
@ -717,7 +717,7 @@ function navbar_complete(App $a) {
|
|||
|
||||
// don't search if search term has less than 2 characters
|
||||
if (! $search || mb_strlen($search) < 2) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
if (substr($search,0,1) === '@') {
|
||||
|
|
|
|||
464
include/api.php
464
include/api.php
|
|
@ -51,7 +51,7 @@ define('API_METHOD_GET', 'GET');
|
|||
define('API_METHOD_POST', 'POST,PUT');
|
||||
define('API_METHOD_DELETE', 'POST,DELETE');
|
||||
|
||||
$API = array();
|
||||
$API = [];
|
||||
$called_api = null;
|
||||
|
||||
/**
|
||||
|
|
@ -125,20 +125,20 @@ function api_register_func($path, $func, $auth = false, $method = API_METHOD_ANY
|
|||
{
|
||||
global $API;
|
||||
|
||||
$API[$path] = array(
|
||||
$API[$path] = [
|
||||
'func' => $func,
|
||||
'auth' => $auth,
|
||||
'method' => $method,
|
||||
);
|
||||
];
|
||||
|
||||
// Workaround for hotot
|
||||
$path = str_replace("api/", "api/1.1/", $path);
|
||||
|
||||
$API[$path] = array(
|
||||
$API[$path] = [
|
||||
'func' => $func,
|
||||
'auth' => $auth,
|
||||
'method' => $method,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -203,12 +203,12 @@ function api_login(App $a)
|
|||
// next code from mod/auth.php. needs better solution
|
||||
$record = null;
|
||||
|
||||
$addon_auth = array(
|
||||
$addon_auth = [
|
||||
'username' => trim($user),
|
||||
'password' => trim($password),
|
||||
'authenticated' => 0,
|
||||
'user_record' => null,
|
||||
);
|
||||
];
|
||||
|
||||
/*
|
||||
* A plugin indicates successful login by setting 'authenticated' to non-zero value and returning a user record
|
||||
|
|
@ -409,11 +409,11 @@ function api_error($type, $e)
|
|||
$error = ($e->getMessage() !== "" ? $e->getMessage() : $e->httpdesc);
|
||||
/// @TODO: https://dev.twitter.com/overview/api/response-codes
|
||||
|
||||
$error = array("error" => $error,
|
||||
$error = ["error" => $error,
|
||||
"code" => $e->httpcode . " " . $e->httpdesc,
|
||||
"request" => $a->query_string);
|
||||
"request" => $a->query_string];
|
||||
|
||||
$return = api_format_data('status', $type, array('status' => $error));
|
||||
$return = api_format_data('status', $type, ['status' => $error]);
|
||||
|
||||
switch ($type) {
|
||||
case "xml":
|
||||
|
|
@ -450,7 +450,7 @@ function api_rss_extra(App $a, $arr, $user_info)
|
|||
}
|
||||
|
||||
$arr['$user'] = $user_info;
|
||||
$arr['$rss'] = array(
|
||||
$arr['$rss'] = [
|
||||
'alternate' => $user_info['url'],
|
||||
'self' => System::baseUrl() . "/" . $a->query_string,
|
||||
'base' => System::baseUrl(),
|
||||
|
|
@ -458,7 +458,7 @@ function api_rss_extra(App $a, $arr, $user_info)
|
|||
'atom_updated' => datetime_convert('UTC', 'UTC', 'now', ATOM_TIME),
|
||||
'language' => $user_info['language'],
|
||||
'logo' => System::baseUrl() . "/images/friendica-32.png",
|
||||
);
|
||||
];
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
|
@ -473,7 +473,7 @@ function api_rss_extra(App $a, $arr, $user_info)
|
|||
*/
|
||||
function api_unique_id_to_nurl($id)
|
||||
{
|
||||
$r = dba::selectFirst('contact', array('nurl'), array('uid' => 0, 'id' => $id));
|
||||
$r = dba::selectFirst('contact', ['nurl'], ['uid' => 0, 'id' => $id]);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
return $r["nurl"];
|
||||
|
|
@ -603,7 +603,7 @@ function api_get_user(App $a, $contact_id = null)
|
|||
|
||||
// if the contact wasn't found, fetch it from the contacts with uid = 0
|
||||
if (!DBM::is_result($uinfo)) {
|
||||
$r = array();
|
||||
$r = [];
|
||||
|
||||
if ($url != "") {
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = 0 AND `nurl` = '%s' LIMIT 1", dbesc(normalise_link($url)));
|
||||
|
|
@ -617,7 +617,7 @@ function api_get_user(App $a, $contact_id = null)
|
|||
$r[0]['nick'] = api_get_nick($r[0]["url"]);
|
||||
}
|
||||
|
||||
$ret = array(
|
||||
$ret = [
|
||||
'id' => $r[0]["id"],
|
||||
'id_str' => (string) $r[0]["id"],
|
||||
'name' => $r[0]["name"],
|
||||
|
|
@ -651,7 +651,7 @@ function api_get_user(App $a, $contact_id = null)
|
|||
'cid' => Contact::getIdForURL($r[0]["url"], api_user(), true),
|
||||
'self' => 0,
|
||||
'network' => $r[0]["network"],
|
||||
);
|
||||
];
|
||||
|
||||
return $ret;
|
||||
} else {
|
||||
|
|
@ -752,7 +752,7 @@ function api_get_user(App $a, $contact_id = null)
|
|||
$location = $network_name;
|
||||
}
|
||||
|
||||
$ret = array(
|
||||
$ret = [
|
||||
'id' => intval($pcontact_id),
|
||||
'id_str' => (string) intval($pcontact_id),
|
||||
'name' => (($uinfo[0]['name']) ? $uinfo[0]['name'] : $uinfo[0]['nick']),
|
||||
|
|
@ -788,7 +788,7 @@ function api_get_user(App $a, $contact_id = null)
|
|||
'cid' => intval($uinfo[0]['cid']),
|
||||
'self' => $uinfo[0]['self'],
|
||||
'network' => $uinfo[0]['network'],
|
||||
);
|
||||
];
|
||||
|
||||
// If this is a local user and it uses Frio, we can get its color preferences.
|
||||
if ($ret['self']) {
|
||||
|
|
@ -847,7 +847,7 @@ function api_item_get_user(App $a, $item)
|
|||
$owner_user = $status_user;
|
||||
}
|
||||
|
||||
return (array($status_user, $owner_user));
|
||||
return ([$status_user, $owner_user]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -860,7 +860,7 @@ function api_item_get_user(App $a, $item)
|
|||
*/
|
||||
function api_walk_recursive(array &$array, callable $callback)
|
||||
{
|
||||
$new_array = array();
|
||||
$new_array = [];
|
||||
|
||||
foreach ($array as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
|
|
@ -918,14 +918,14 @@ function api_create_xml($data, $root_element)
|
|||
$data2 = array_pop($data);
|
||||
$key = key($data2);
|
||||
|
||||
$namespaces = array("" => "http://api.twitter.com",
|
||||
$namespaces = ["" => "http://api.twitter.com",
|
||||
"statusnet" => "http://status.net/schema/api/1/",
|
||||
"friendica" => "http://friendi.ca/schema/api/1/",
|
||||
"georss" => "http://www.georss.org/georss");
|
||||
"georss" => "http://www.georss.org/georss"];
|
||||
|
||||
/// @todo Auto detection of needed namespaces
|
||||
if (in_array($root_element, array("ok", "hash", "config", "version", "ids", "notes", "photos"))) {
|
||||
$namespaces = array();
|
||||
if (in_array($root_element, ["ok", "hash", "config", "version", "ids", "notes", "photos"])) {
|
||||
$namespaces = [];
|
||||
}
|
||||
|
||||
if (is_array($data2)) {
|
||||
|
|
@ -933,7 +933,7 @@ function api_create_xml($data, $root_element)
|
|||
}
|
||||
|
||||
if ($key == "0") {
|
||||
$data4 = array();
|
||||
$data4 = [];
|
||||
$i = 1;
|
||||
|
||||
foreach ($data2 as $item) {
|
||||
|
|
@ -943,7 +943,7 @@ function api_create_xml($data, $root_element)
|
|||
$data2 = $data4;
|
||||
}
|
||||
|
||||
$data3 = array($root_element => $data2);
|
||||
$data3 = [$root_element => $data2];
|
||||
|
||||
$ret = XML::fromArray($data3, $xml, false, $namespaces);
|
||||
return $ret;
|
||||
|
|
@ -1021,7 +1021,7 @@ function api_account_verify_credentials($type)
|
|||
unset($user_info["uid"]);
|
||||
unset($user_info["self"]);
|
||||
|
||||
return api_format_data("user", $type, array('user' => $user_info));
|
||||
return api_format_data("user", $type, ['user' => $user_info]);
|
||||
}
|
||||
|
||||
/// @TODO move to top of file or somewhere better
|
||||
|
|
@ -1301,17 +1301,17 @@ function api_media_upload()
|
|||
throw new InternalServerErrorException();
|
||||
}
|
||||
|
||||
$returndata = array();
|
||||
$returndata = [];
|
||||
$returndata["media_id"] = $media["id"];
|
||||
$returndata["media_id_string"] = (string)$media["id"];
|
||||
$returndata["size"] = $media["size"];
|
||||
$returndata["image"] = array("w" => $media["width"],
|
||||
$returndata["image"] = ["w" => $media["width"],
|
||||
"h" => $media["height"],
|
||||
"image_type" => $media["type"]);
|
||||
"image_type" => $media["type"]];
|
||||
|
||||
logger("Media uploaded: " . print_r($returndata, true), LOGGER_DEBUG);
|
||||
|
||||
return array("media" => $returndata);
|
||||
return ["media" => $returndata];
|
||||
}
|
||||
|
||||
/// @TODO move to top of file or somewhere better
|
||||
|
|
@ -1367,7 +1367,7 @@ function api_status_show($type)
|
|||
$geo = "geo";
|
||||
}
|
||||
|
||||
$status_info = array(
|
||||
$status_info = [
|
||||
'created_at' => api_date($lastwall['created']),
|
||||
'id' => intval($lastwall['id']),
|
||||
'id_str' => (string) $lastwall['id'],
|
||||
|
|
@ -1394,7 +1394,7 @@ function api_status_show($type)
|
|||
'statusnet_html' => $converted["html"],
|
||||
'statusnet_conversation_id' => $lastwall['parent'],
|
||||
'external_url' => System::baseUrl() . "/display/" . $lastwall['guid'],
|
||||
);
|
||||
];
|
||||
|
||||
if (count($converted["attachments"]) > 0) {
|
||||
$status_info["attachments"] = $converted["attachments"];
|
||||
|
|
@ -1421,7 +1421,7 @@ function api_status_show($type)
|
|||
return $status_info;
|
||||
}
|
||||
|
||||
return api_format_data("statuses", $type, array('status' => $status_info));
|
||||
return api_format_data("statuses", $type, ['status' => $status_info]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1468,7 +1468,7 @@ function api_users_show($type)
|
|||
$geo = "geo";
|
||||
}
|
||||
|
||||
$user_info['status'] = array(
|
||||
$user_info['status'] = [
|
||||
'text' => $converted["text"],
|
||||
'truncated' => false,
|
||||
'created_at' => api_date($lastwall['created']),
|
||||
|
|
@ -1485,7 +1485,7 @@ function api_users_show($type)
|
|||
'statusnet_html' => $converted["html"],
|
||||
'statusnet_conversation_id' => $lastwall['parent'],
|
||||
'external_url' => System::baseUrl() . "/display/" . $lastwall['guid'],
|
||||
);
|
||||
];
|
||||
|
||||
if (count($converted["attachments"]) > 0) {
|
||||
$user_info["status"]["attachments"] = $converted["attachments"];
|
||||
|
|
@ -1508,7 +1508,7 @@ function api_users_show($type)
|
|||
unset($user_info["uid"]);
|
||||
unset($user_info["self"]);
|
||||
|
||||
return api_format_data("user", $type, array('user' => $user_info));
|
||||
return api_format_data("user", $type, ['user' => $user_info]);
|
||||
}
|
||||
|
||||
/// @TODO move to top of file or somewhere better
|
||||
|
|
@ -1527,7 +1527,7 @@ function api_users_search($type)
|
|||
{
|
||||
$a = get_app();
|
||||
|
||||
$userlist = array();
|
||||
$userlist = [];
|
||||
|
||||
if (x($_GET, 'q')) {
|
||||
$r = q("SELECT id FROM `contact` WHERE `uid` = 0 AND `name` = '%s'", dbesc($_GET["q"]));
|
||||
|
|
@ -1547,7 +1547,7 @@ function api_users_search($type)
|
|||
$userlist[] = $user_info;
|
||||
}
|
||||
}
|
||||
$userlist = array("users" => $userlist);
|
||||
$userlist = ["users" => $userlist];
|
||||
} else {
|
||||
throw new BadRequestException("User not found.");
|
||||
}
|
||||
|
|
@ -1573,7 +1573,7 @@ api_register_func('api/users/search', 'api_users_search');
|
|||
*/
|
||||
function api_users_lookup($type)
|
||||
{
|
||||
$users = array();
|
||||
$users = [];
|
||||
|
||||
if (x($_REQUEST['user_id'])) {
|
||||
foreach (explode(',', $_REQUEST['user_id']) as $id) {
|
||||
|
|
@ -1587,7 +1587,7 @@ function api_users_lookup($type)
|
|||
throw new NotFoundException;
|
||||
}
|
||||
|
||||
return api_format_data("users", $type, array('users' => $users));
|
||||
return api_format_data("users", $type, ['users' => $users]);
|
||||
}
|
||||
|
||||
/// @TODO move to top of file or somewhere better
|
||||
|
|
@ -1605,7 +1605,7 @@ api_register_func('api/users/lookup', 'api_users_lookup', true);
|
|||
*/
|
||||
function api_search($type)
|
||||
{
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
if (!x($_REQUEST, 'q')) {
|
||||
throw new BadRequestException("q parameter is required.");
|
||||
|
|
@ -1726,7 +1726,7 @@ function api_statuses_home_timeline($type)
|
|||
$ret = api_format_items($r, $user_info, false, $type);
|
||||
|
||||
// Set all posts from the query above to seen
|
||||
$idarray = array();
|
||||
$idarray = [];
|
||||
foreach ($r as $item) {
|
||||
$idarray[] = intval($item["id"]);
|
||||
}
|
||||
|
|
@ -1741,7 +1741,7 @@ function api_statuses_home_timeline($type)
|
|||
}
|
||||
}
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
switch ($type) {
|
||||
case "atom":
|
||||
case "rss":
|
||||
|
|
@ -1848,7 +1848,7 @@ function api_statuses_public_timeline($type)
|
|||
|
||||
$ret = api_format_items($r, $user_info, false, $type);
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
switch ($type) {
|
||||
case "atom":
|
||||
case "rss":
|
||||
|
|
@ -1920,7 +1920,7 @@ function api_statuses_networkpublic_timeline($type)
|
|||
|
||||
$ret = api_format_items($r, $user_info, false, $type);
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
switch ($type) {
|
||||
case "atom":
|
||||
case "rss":
|
||||
|
|
@ -1998,10 +1998,10 @@ function api_statuses_show($type)
|
|||
$ret = api_format_items($r, $user_info, false, $type);
|
||||
|
||||
if ($conversation) {
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
return api_format_data("statuses", $type, $data);
|
||||
} else {
|
||||
$data = array('status' => $ret[0]);
|
||||
$data = ['status' => $ret[0]];
|
||||
return api_format_data("status", $type, $data);
|
||||
}
|
||||
}
|
||||
|
|
@ -2091,7 +2091,7 @@ function api_conversation_show($type)
|
|||
|
||||
$ret = api_format_items($r, $user_info, false, $type);
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
return api_format_data("statuses", $type, $data);
|
||||
}
|
||||
|
||||
|
|
@ -2294,7 +2294,7 @@ function api_statuses_mentions($type)
|
|||
|
||||
$ret = api_format_items($r, $user_info, false, $type);
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
switch ($type) {
|
||||
case "atom":
|
||||
case "rss":
|
||||
|
|
@ -2390,7 +2390,7 @@ function api_statuses_user_timeline($type)
|
|||
|
||||
$ret = api_format_items($r, $user_info, true, $type);
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
switch ($type) {
|
||||
case "atom":
|
||||
case "rss":
|
||||
|
|
@ -2468,7 +2468,7 @@ function api_favorites_create_destroy($type)
|
|||
$rets = api_format_items($item, $user_info, false, $type);
|
||||
$ret = $rets[0];
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
switch ($type) {
|
||||
case "atom":
|
||||
case "rss":
|
||||
|
|
@ -2499,7 +2499,7 @@ function api_favorites($type)
|
|||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
$called_api = array();
|
||||
$called_api = [];
|
||||
|
||||
$user_info = api_get_user($a);
|
||||
|
||||
|
|
@ -2508,7 +2508,7 @@ function api_favorites($type)
|
|||
logger('api_favorites: self:' . $user_info['self']);
|
||||
|
||||
if ($user_info['self'] == 0) {
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
} else {
|
||||
$sql_extra = "";
|
||||
|
||||
|
|
@ -2550,7 +2550,7 @@ function api_favorites($type)
|
|||
$ret = api_format_items($r, $user_info, false, $type);
|
||||
}
|
||||
|
||||
$data = array('status' => $ret);
|
||||
$data = ['status' => $ret];
|
||||
switch ($type) {
|
||||
case "atom":
|
||||
case "rss":
|
||||
|
|
@ -2574,7 +2574,7 @@ api_register_func('api/favorites', 'api_favorites', true);
|
|||
function api_format_messages($item, $recipient, $sender)
|
||||
{
|
||||
// standard meta information
|
||||
$ret = array(
|
||||
$ret = [
|
||||
'id' => $item['id'],
|
||||
'sender_id' => $sender['id'] ,
|
||||
'text' => "",
|
||||
|
|
@ -2587,7 +2587,7 @@ function api_format_messages($item, $recipient, $sender)
|
|||
'title' => "",
|
||||
'friendica_seen' => $item['seen'],
|
||||
'friendica_parent_uri' => $item['parent-uri'],
|
||||
);
|
||||
];
|
||||
|
||||
// "uid" and "self" are only needed for some internal stuff, so remove it from here
|
||||
unset($ret["sender"]["uid"]);
|
||||
|
|
@ -2648,14 +2648,14 @@ function api_convert_item($item)
|
|||
$statushtml = trim(bbcode($body, false, false));
|
||||
|
||||
// Workaround for clients with limited HTML parser functionality
|
||||
$search = array("<br>", "<blockquote>", "</blockquote>",
|
||||
$search = ["<br>", "<blockquote>", "</blockquote>",
|
||||
"<h1>", "</h1>", "<h2>", "</h2>",
|
||||
"<h3>", "</h3>", "<h4>", "</h4>",
|
||||
"<h5>", "</h5>", "<h6>", "</h6>");
|
||||
$replace = array("<br>", "<br><blockquote>", "</blockquote><br>",
|
||||
"<h5>", "</h5>", "<h6>", "</h6>"];
|
||||
$replace = ["<br>", "<br><blockquote>", "</blockquote><br>",
|
||||
"<br><h1>", "</h1><br>", "<br><h2>", "</h2><br>",
|
||||
"<br><h3>", "</h3><br>", "<br><h4>", "</h4><br>",
|
||||
"<br><h5>", "</h5><br>", "<br><h6>", "</h6><br>");
|
||||
"<br><h5>", "</h5><br>", "<br><h6>", "</h6><br>"];
|
||||
$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('|<a href="([^"]*)">([^<]*)</a>|', $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
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function diaspora2bb($s) {
|
|||
$s = preg_replace('/^([^\*]+)\*([^\*]*)$/im', '$1\*$2', $s);
|
||||
|
||||
// The parser cannot handle paragraphs correctly
|
||||
$s = str_replace(array('</p>', '<p>', '<p dir="ltr">'), array('<br>', '<br>', '<br>'), $s);
|
||||
$s = str_replace(['</p>', '<p>', '<p dir="ltr">'], ['<br>', '<br>', '<br>'], $s);
|
||||
|
||||
// Escaping the hash tags
|
||||
$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("</a><blockquote>"), array("</a><br><blockquote>"), $Text);
|
||||
$Text = str_replace(["</a><blockquote>"], ["</a><br><blockquote>"], $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
|
||||
|
|
|
|||
|
|
@ -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('<br />', '<br />'), $Text);
|
||||
$Text = str_replace(["\r","\n"], ['<br />', '<br />'], $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."<html><body>".$Text."</body></html>");
|
||||
$doc->encoding = 'UTF-8';
|
||||
$Text = $doc->saveHTML();
|
||||
$Text = str_replace(array("<html><body>", "</body></html>", $doctype, $encoding), array("", "", "", ""), $Text);
|
||||
$Text = str_replace(["<html><body>", "</body></html>", $doctype, $encoding], ["", "", "", ""], $Text);
|
||||
|
||||
$Text = str_replace('<br></li>', '</li>', $Text);
|
||||
|
||||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
|
|
@ -102,9 +102,9 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
|
|||
$options = str_replace('</select>','', $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 .= "<script type='text/javascript'>";
|
||||
$o .= "\$(function () {var picker = \$('#id_$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
|
||||
|
|
@ -368,14 +368,14 @@ function relative_date($posted_date, $format = null) {
|
|||
return t('less than a second ago');
|
||||
}
|
||||
|
||||
$a = array( 12 * 30 * 24 * 60 * 60 => array( t('year'), t('years')),
|
||||
30 * 24 * 60 * 60 => array( t('month'), t('months')),
|
||||
7 * 24 * 60 * 60 => array( t('week'), t('weeks')),
|
||||
24 * 60 * 60 => array( t('day'), t('days')),
|
||||
60 * 60 => array( t('hour'), t('hours')),
|
||||
60 => array( t('minute'), t('minutes')),
|
||||
1 => array( t('second'), t('seconds'))
|
||||
);
|
||||
$a = [ 12 * 30 * 24 * 60 * 60 => [ t('year'), t('years')],
|
||||
30 * 24 * 60 * 60 => [ t('month'), t('months')],
|
||||
7 * 24 * 60 * 60 => [ t('week'), t('weeks')],
|
||||
24 * 60 * 60 => [ t('day'), t('days')],
|
||||
60 * 60 => [ t('hour'), t('hours')],
|
||||
60 => [ t('minute'), t('minutes')],
|
||||
1 => [ t('second'), t('seconds')]
|
||||
];
|
||||
|
||||
foreach ($a as $secs => $str) {
|
||||
$d = $etime / $secs;
|
||||
|
|
@ -449,9 +449,9 @@ function age($dob, $owner_tz = '', $viewer_tz = '') {
|
|||
*/
|
||||
function get_dim($y, $m) {
|
||||
|
||||
$dim = array( 0,
|
||||
$dim = [ 0,
|
||||
31, 28, 31, 30, 31, 30,
|
||||
31, 31, 30, 31, 30, 31);
|
||||
31, 31, 30, 31, 30, 31];
|
||||
|
||||
if ($m != 2) {
|
||||
return $dim[$m];
|
||||
|
|
@ -498,12 +498,12 @@ function get_first_dim($y,$m) {
|
|||
function cal($y = 0, $m = 0, $links = null, $class = '')
|
||||
{
|
||||
// month table - start at 1 to match human usage.
|
||||
$mtab = array(' ',
|
||||
$mtab = [' ',
|
||||
'January', 'February', 'March',
|
||||
'April' , 'May' , 'June',
|
||||
'July' , 'August' , 'September',
|
||||
'October', 'November', 'December'
|
||||
);
|
||||
];
|
||||
|
||||
$thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
|
||||
$thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
|
||||
|
|
@ -515,7 +515,7 @@ function cal($y = 0, $m = 0, $links = null, $class = '')
|
|||
$m = intval($thismonth);
|
||||
}
|
||||
|
||||
$dn = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
|
||||
$dn = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
$f = get_first_dim($y, $m);
|
||||
$l = get_dim($y, $m);
|
||||
$d = 1;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class dba {
|
|||
private static $errorno = 0;
|
||||
private static $affected_rows = 0;
|
||||
private static $in_transaction = false;
|
||||
private static $relation = array();
|
||||
private static $relation = [];
|
||||
|
||||
public static function connect($serveraddr, $user, $pass, $db, $install = false) {
|
||||
if (!is_null(self::$db)) {
|
||||
|
|
@ -157,7 +157,7 @@ class dba {
|
|||
}
|
||||
|
||||
// Only do the explain on "select", "update" and "delete"
|
||||
if (!in_array(strtolower(substr($query, 0, 6)), array("select", "update", "delete"))) {
|
||||
if (!in_array(strtolower(substr($query, 0, 6)), ["select", "update", "delete"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -253,8 +253,8 @@ class dba {
|
|||
* @return string The input SQL string modified if necessary.
|
||||
*/
|
||||
public static function clean_query($sql) {
|
||||
$search = array("\t", "\n", "\r", " ");
|
||||
$replace = array(' ', ' ', ' ', ' ');
|
||||
$search = ["\t", "\n", "\r", " "];
|
||||
$replace = [' ', ' ', ' ', ' '];
|
||||
do {
|
||||
$oldsql = $sql;
|
||||
$sql = str_replace($search, $replace, $sql);
|
||||
|
|
@ -324,7 +324,7 @@ class dba {
|
|||
|
||||
// Renumber the array keys to be sure that they fit
|
||||
$i = 0;
|
||||
$args = array();
|
||||
$args = [];
|
||||
foreach ($params AS $param) {
|
||||
// Avoid problems with some MySQL servers and boolean values. See issue #3645
|
||||
if (is_bool($param)) {
|
||||
|
|
@ -408,7 +408,7 @@ class dba {
|
|||
// There are SQL statements that cannot be executed with a prepared statement
|
||||
$parts = explode(' ', $orig_sql);
|
||||
$command = strtolower($parts[0]);
|
||||
$can_be_prepared = in_array($command, array('select', 'update', 'insert', 'delete'));
|
||||
$can_be_prepared = in_array($command, ['select', 'update', 'insert', 'delete']);
|
||||
|
||||
// The fallback routine is called as well when there are no arguments
|
||||
if (!$can_be_prepared || (count($args) == 0)) {
|
||||
|
|
@ -437,7 +437,7 @@ class dba {
|
|||
}
|
||||
|
||||
$params = '';
|
||||
$values = array();
|
||||
$values = [];
|
||||
foreach ($args AS $param => $value) {
|
||||
if (is_int($args[$param])) {
|
||||
$params .= 'i';
|
||||
|
|
@ -453,7 +453,7 @@ class dba {
|
|||
|
||||
if (count($values) > 0) {
|
||||
array_unshift($values, $params);
|
||||
call_user_func_array(array($stmt, 'bind_param'), $values);
|
||||
call_user_func_array([$stmt, 'bind_param'], $values);
|
||||
}
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
|
|
@ -564,12 +564,12 @@ class dba {
|
|||
return false;
|
||||
}
|
||||
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
|
||||
$array_element = each($condition);
|
||||
$array_key = $array_element['key'];
|
||||
if (!is_int($array_key)) {
|
||||
$fields = array($array_key);
|
||||
$fields = [$array_key];
|
||||
}
|
||||
|
||||
$stmt = self::select($table, $fields, $condition, ['limit' => 1]);
|
||||
|
|
@ -678,14 +678,14 @@ class dba {
|
|||
// This code works, but is slow
|
||||
|
||||
// Bind the result to a result array
|
||||
$cols = array();
|
||||
$cols = [];
|
||||
|
||||
$cols_num = array();
|
||||
$cols_num = [];
|
||||
for ($x = 0; $x < $stmt->field_count; $x++) {
|
||||
$cols[] = &$cols_num[$x];
|
||||
}
|
||||
|
||||
call_user_func_array(array($stmt, 'bind_result'), $cols);
|
||||
call_user_func_array([$stmt, 'bind_result'], $cols);
|
||||
|
||||
if (!$stmt->fetch()) {
|
||||
return false;
|
||||
|
|
@ -697,7 +697,7 @@ class dba {
|
|||
$result = $stmt->result_metadata();
|
||||
$fields = $result->fetch_fields();
|
||||
|
||||
$columns = array();
|
||||
$columns = [];
|
||||
foreach ($cols_num AS $param => $col) {
|
||||
$columns[$fields[$param]->name] = $col;
|
||||
}
|
||||
|
|
@ -901,7 +901,7 @@ class dba {
|
|||
if ((count($conditions) == 1) && ($field == array_keys($conditions)[0])) {
|
||||
foreach ($rel_def AS $rel_table => $rel_fields) {
|
||||
foreach ($rel_fields AS $rel_field) {
|
||||
$retval = self::delete($rel_table, array($rel_field => array_values($conditions)[0]), true, $callstack);
|
||||
$retval = self::delete($rel_table, [$rel_field => array_values($conditions)[0]], true, $callstack);
|
||||
$commands = array_merge($commands, $retval);
|
||||
}
|
||||
}
|
||||
|
|
@ -911,11 +911,11 @@ class dba {
|
|||
$callstack[$qkey] = true;
|
||||
|
||||
// Fetch all rows that are to be deleted
|
||||
$data = self::select($table, array($field), $conditions);
|
||||
$data = self::select($table, [$field], $conditions);
|
||||
|
||||
while ($row = self::fetch($data)) {
|
||||
// Now we accumulate the delete commands
|
||||
$retval = self::delete($table, array($field => $row[$field]), true, $callstack);
|
||||
$retval = self::delete($table, [$field => $row[$field]], true, $callstack);
|
||||
$commands = array_merge($commands, $retval);
|
||||
}
|
||||
|
||||
|
|
@ -1027,7 +1027,7 @@ class dba {
|
|||
*
|
||||
* @return boolean was the update successfull?
|
||||
*/
|
||||
public static function update($table, $fields, $condition, $old_fields = array()) {
|
||||
public static function update($table, $fields, $condition, $old_fields = []) {
|
||||
|
||||
if (empty($table) || empty($fields) || empty($condition)) {
|
||||
logger('Table, fields and condition have to be set');
|
||||
|
|
@ -1054,7 +1054,7 @@ class dba {
|
|||
$values = array_merge($condition, $fields);
|
||||
return self::insert($table, $values, $do_insert);
|
||||
}
|
||||
$old_fields = array();
|
||||
$old_fields = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1249,7 +1249,7 @@ class dba {
|
|||
return $stmt;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data = [];
|
||||
while ($row = self::fetch($stmt)) {
|
||||
$data[] = $row;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ function notification($params)
|
|||
['uid' => $params['uid']]);
|
||||
|
||||
// There is no need to create notifications for forum accounts
|
||||
if (!DBM::is_result($user) || in_array($user["page-flags"], array(PAGE_COMMUNITY, PAGE_PRVGROUP))) {
|
||||
if (!DBM::is_result($user) || in_array($user["page-flags"], [PAGE_COMMUNITY, PAGE_PRVGROUP])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -386,7 +386,7 @@ function notification($params)
|
|||
|
||||
$subject .= " (".$nickname."@".$hostname.")";
|
||||
|
||||
$h = array(
|
||||
$h = [
|
||||
'params' => $params,
|
||||
'subject' => $subject,
|
||||
'preamble' => $preamble,
|
||||
|
|
@ -396,7 +396,7 @@ function notification($params)
|
|||
'tsitelink' => $tsitelink,
|
||||
'hsitelink' => $hsitelink,
|
||||
'itemlink' => $itemlink
|
||||
);
|
||||
];
|
||||
|
||||
call_hooks('enotify', $h);
|
||||
|
||||
|
|
@ -424,7 +424,7 @@ function notification($params)
|
|||
} while ($dups == true);
|
||||
|
||||
/// @TODO One statement is enough
|
||||
$datarray = array();
|
||||
$datarray = [];
|
||||
$datarray['hash'] = $hash;
|
||||
$datarray['name'] = $params['source_name'];
|
||||
$datarray['name_cache'] = strip_tags(bbcode($params['source_name']));
|
||||
|
|
@ -486,7 +486,7 @@ function notification($params)
|
|||
);
|
||||
if ($p && (count($p) > 1)) {
|
||||
for ($d = 1; $d < count($p); $d ++) {
|
||||
dba::delete('notify', array('id' => $p[$d]['id']));
|
||||
dba::delete('notify', ['id' => $p[$d]['id']]);
|
||||
}
|
||||
|
||||
// only continue on if we stored the first one
|
||||
|
|
@ -497,7 +497,7 @@ function notification($params)
|
|||
}
|
||||
|
||||
$itemlink = System::baseUrl().'/notify/view/'.$notify_id;
|
||||
$msg = replace_macros($epreamble, array('$itemlink' => $itemlink));
|
||||
$msg = replace_macros($epreamble, ['$itemlink' => $itemlink]);
|
||||
$msg_cache = format_notification_message($datarray['name_cache'], strip_tags(bbcode($msg)));
|
||||
q("UPDATE `notify` SET `msg` = '%s', `msg_cache` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc($msg),
|
||||
|
|
@ -546,12 +546,12 @@ function notification($params)
|
|||
}
|
||||
|
||||
// textversion keeps linebreaks
|
||||
$textversion = strip_tags(str_replace("<br>", "\n", html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n",
|
||||
$textversion = strip_tags(str_replace("<br>", "\n", html_entity_decode(bbcode(stripslashes(str_replace(["\\r\\n", "\\r", "\\n"], "\n",
|
||||
$body))),ENT_QUOTES, 'UTF-8')));
|
||||
$htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n\\n", "\\n"),
|
||||
$htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(["\\r\\n", "\\r", "\\n\\n", "\\n"],
|
||||
"<br />\n", $body))), ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$datarray = array();
|
||||
$datarray = [];
|
||||
$datarray['banner'] = $banner;
|
||||
$datarray['product'] = $product;
|
||||
$datarray['preamble'] = $preamble;
|
||||
|
|
@ -584,7 +584,7 @@ function notification($params)
|
|||
|
||||
// load the template for private message notifications
|
||||
$tpl = get_markup_template('email_notify_html.tpl');
|
||||
$email_html_body = replace_macros($tpl, array(
|
||||
$email_html_body = replace_macros($tpl, [
|
||||
'$banner' => $datarray['banner'],
|
||||
'$product' => $datarray['product'],
|
||||
'$preamble' => str_replace("\n", "<br>\n", $datarray['preamble']),
|
||||
|
|
@ -601,11 +601,11 @@ function notification($params)
|
|||
'$title' => $datarray['title'],
|
||||
'$htmlversion' => $datarray['htmlversion'],
|
||||
'$content_allowed' => $content_allowed,
|
||||
));
|
||||
]);
|
||||
|
||||
// load the template for private message notifications
|
||||
$tpl = get_markup_template('email_notify_text.tpl');
|
||||
$email_text_body = replace_macros($tpl, array(
|
||||
$email_text_body = replace_macros($tpl, [
|
||||
'$banner' => $datarray['banner'],
|
||||
'$product' => $datarray['product'],
|
||||
'$preamble' => $datarray['preamble'],
|
||||
|
|
@ -622,11 +622,11 @@ function notification($params)
|
|||
'$title' => $datarray['title'],
|
||||
'$textversion' => $datarray['textversion'],
|
||||
'$content_allowed' => $content_allowed,
|
||||
));
|
||||
]);
|
||||
|
||||
// use the Emailer class to send the message
|
||||
return Emailer::send(
|
||||
array(
|
||||
[
|
||||
'uid' => $params['uid'],
|
||||
'fromName' => $sender_name,
|
||||
'fromEmail' => $sender_email,
|
||||
|
|
@ -635,7 +635,7 @@ function notification($params)
|
|||
'messageSubject' => $datarray['subject'],
|
||||
'htmlVersion' => $email_html_body,
|
||||
'textVersion' => $email_text_body,
|
||||
'additionalMailHeader' => $datarray['headers'])
|
||||
'additionalMailHeader' => $datarray['headers']]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -666,7 +666,7 @@ function check_user_notification($itemid) {
|
|||
* @param str $defaulttype (Optional) Forces a notification with this type.
|
||||
*/
|
||||
function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||
$notification_data = array("uid" => $uid, "profiles" => array());
|
||||
$notification_data = ["uid" => $uid, "profiles" => []];
|
||||
call_hooks('check_item_notification', $notification_data);
|
||||
|
||||
$profiles = $notification_data["profiles"];
|
||||
|
|
@ -688,7 +688,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
|||
// Notifications from Diaspora are often with an URL in the Diaspora format
|
||||
$profiles[] = System::baseUrl()."/u/".$user["nickname"];
|
||||
|
||||
$profiles2 = array();
|
||||
$profiles2 = [];
|
||||
|
||||
foreach ($profiles AS $profile) {
|
||||
// Check for invalid profile urls. 13 should be the shortest possible profile length:
|
||||
|
|
@ -732,7 +732,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
|||
return false;
|
||||
|
||||
// Generate the notification array
|
||||
$params = array();
|
||||
$params = [];
|
||||
$params["uid"] = $uid;
|
||||
$params["notify_flags"] = $user["notify-flags"];
|
||||
$params["language"] = $user["language"];
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ function bbtovcal($s) {
|
|||
*/
|
||||
function bbtoevent($s) {
|
||||
|
||||
$ev = array();
|
||||
$ev = [];
|
||||
|
||||
$match = '';
|
||||
if (preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is", $s, $match)) {
|
||||
|
|
@ -219,7 +219,7 @@ function event_delete($event_id) {
|
|||
return;
|
||||
}
|
||||
|
||||
dba::delete('event', array('id' => $event_id));
|
||||
dba::delete('event', ['id' => $event_id]);
|
||||
logger("Deleted event ".$event_id, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
|
|
@ -364,7 +364,7 @@ function event_store($arr) {
|
|||
$event = $r[0];
|
||||
}
|
||||
|
||||
$item_arr = array();
|
||||
$item_arr = [];
|
||||
|
||||
$item_arr['uid'] = $arr['uid'];
|
||||
$item_arr['contact-id'] = $arr['cid'];
|
||||
|
|
@ -423,7 +423,7 @@ function get_event_strings() {
|
|||
// First day of the week (0 = Sunday).
|
||||
$firstDay = PConfig::get(local_user(), 'system', 'first_day_of_week', 0);
|
||||
|
||||
$i18n = array(
|
||||
$i18n = [
|
||||
"firstDay" => $firstDay,
|
||||
"allday" => t("all-day"),
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ function get_event_strings() {
|
|||
"dtstart_label" => t("Starts:"),
|
||||
"dtend_label" => t("Finishes:"),
|
||||
"location_label" => t("Location:")
|
||||
);
|
||||
];
|
||||
|
||||
return $i18n;
|
||||
}
|
||||
|
|
@ -493,7 +493,7 @@ function get_event_strings() {
|
|||
* @todo We should replace this with a separate update function if there is some time left.
|
||||
*/
|
||||
function event_remove_duplicates($dates) {
|
||||
$dates2 = array();
|
||||
$dates2 = [];
|
||||
|
||||
foreach ($dates as $date) {
|
||||
if ($date['type'] == 'birthday') {
|
||||
|
|
@ -585,7 +585,7 @@ function events_by_date($owner_uid = 0, $event_params, $sql_extra = '') {
|
|||
* @return array Event array for the template.
|
||||
*/
|
||||
function process_events($arr) {
|
||||
$events=array();
|
||||
$events=[];
|
||||
|
||||
$last_date = '';
|
||||
$fmt = t('l, F j');
|
||||
|
|
@ -612,9 +612,9 @@ function process_events($arr) {
|
|||
$copy = null;
|
||||
$drop = null;
|
||||
if (local_user() && local_user() == $rr['uid'] && $rr['type'] == 'event') {
|
||||
$edit = ((! $rr['cid']) ? array(System::baseUrl() . '/events/event/' . $rr['id'], t('Edit event'), '', '') : null);
|
||||
$copy = ((! $rr['cid']) ? array(System::baseUrl() . '/events/copy/' . $rr['id'], t('Duplicate event'), '', '') : null);
|
||||
$drop = array(System::baseUrl() . '/events/drop/' . $rr['id'], t('Delete event'), '', '');
|
||||
$edit = ((! $rr['cid']) ? [System::baseUrl() . '/events/event/' . $rr['id'], t('Edit event'), '', ''] : null);
|
||||
$copy = ((! $rr['cid']) ? [System::baseUrl() . '/events/copy/' . $rr['id'], t('Duplicate event'), '', ''] : null);
|
||||
$drop = [System::baseUrl() . '/events/drop/' . $rr['id'], t('Delete event'), '', ''];
|
||||
}
|
||||
|
||||
$title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
|
||||
|
|
@ -626,7 +626,7 @@ function process_events($arr) {
|
|||
$html = format_event_html($rr);
|
||||
$rr['desc'] = bbcode($rr['desc']);
|
||||
$rr['location'] = bbcode($rr['location']);
|
||||
$events[] = array(
|
||||
$events[] = [
|
||||
'id' => $rr['id'],
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
|
|
@ -641,8 +641,8 @@ function process_events($arr) {
|
|||
'is_first' => $is_first,
|
||||
'item' => $rr,
|
||||
'html' => $html,
|
||||
'plink' => array($rr['plink'], t('link to source'), '', ''),
|
||||
);
|
||||
'plink' => [$rr['plink'], t('link to source'), '', ''],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -849,12 +849,12 @@ function event_export($uid, $format = 'ical') {
|
|||
$file_ext = "";
|
||||
}
|
||||
|
||||
$arr = array(
|
||||
$arr = [
|
||||
'success' => $process,
|
||||
'format' => $format,
|
||||
'extension' => $file_ext,
|
||||
'content' => $res,
|
||||
);
|
||||
];
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
|
@ -900,12 +900,12 @@ function widget_events() {
|
|||
return;
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template("events_aside.tpl"), array(
|
||||
return replace_macros(get_markup_template("events_aside.tpl"), [
|
||||
'$etitle' => t("Export"),
|
||||
'$export_ical' => t("Export calendar as ical"),
|
||||
'$export_csv' => t("Export calendar as csv"),
|
||||
'$user' => $user
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -948,7 +948,7 @@ function format_event_item($item) {
|
|||
|
||||
// Format the event location.
|
||||
$evloc = event_location2array($item['event-location']);
|
||||
$location = array();
|
||||
$location = [];
|
||||
|
||||
if (isset($evloc['name'])) {
|
||||
$location['name'] = prepare_text($evloc['name']);
|
||||
|
|
@ -968,7 +968,7 @@ function format_event_item($item) {
|
|||
$profile_link = Profile::zrl($profile_link);
|
||||
}
|
||||
|
||||
$event = replace_macros(get_markup_template('event_stream_item.tpl'), array(
|
||||
$event = replace_macros(get_markup_template('event_stream_item.tpl'), [
|
||||
'$id' => $item['event-id'],
|
||||
'$title' => prepare_text($item['event-summary']),
|
||||
'$dtstart_label' => t('Starts:'),
|
||||
|
|
@ -994,7 +994,7 @@ function format_event_item($item) {
|
|||
'$hide_map_label' => t('Hide map'),
|
||||
'$map_btn_label' => t('Show map'),
|
||||
'$location' => $location
|
||||
));
|
||||
]);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
|
@ -1017,7 +1017,7 @@ function event_location2array($s = '') {
|
|||
return;
|
||||
}
|
||||
|
||||
$location = array('name' => $s);
|
||||
$location = ['name' => $s];
|
||||
|
||||
// Map tag with location name - e.g. [map]Paris[/map].
|
||||
if (strpos($s, '[/map]') !== false) {
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ class FriendicaSmarty extends Smarty
|
|||
|
||||
// setTemplateDir can be set to an array, which Smarty will parse in order.
|
||||
// The order is thus very important here
|
||||
$template_dirs = array('theme' => "view/theme/$theme/" . SMARTY3_TEMPLATE_FOLDER . "/");
|
||||
$template_dirs = ['theme' => "view/theme/$theme/" . SMARTY3_TEMPLATE_FOLDER . "/"];
|
||||
if (x($a->theme_info, "extends"))
|
||||
$template_dirs = $template_dirs + array('extends' => "view/theme/" . $a->theme_info["extends"] . "/" . SMARTY3_TEMPLATE_FOLDER . "/");
|
||||
$template_dirs = $template_dirs + array('base' => "view/" . SMARTY3_TEMPLATE_FOLDER . "/");
|
||||
$template_dirs = $template_dirs + ['extends' => "view/theme/" . $a->theme_info["extends"] . "/" . SMARTY3_TEMPLATE_FOLDER . "/"];
|
||||
$template_dirs = $template_dirs + ['base' => "view/" . SMARTY3_TEMPLATE_FOLDER . "/"];
|
||||
$this->setTemplateDir($template_dirs);
|
||||
|
||||
$this->setCompileDir('view/smarty3/compiled/');
|
||||
|
|
@ -70,10 +70,10 @@ class FriendicaSmartyEngine implements ITemplateEngine
|
|||
$r['$APP'] = get_app();
|
||||
|
||||
// "middleware": inject variables into templates
|
||||
$arr = array(
|
||||
$arr = [
|
||||
"template" => basename($s->filename),
|
||||
"vars" => $r
|
||||
);
|
||||
];
|
||||
call_hooks("template_vars", $arr);
|
||||
$r = $arr['vars'];
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ function node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb)
|
|||
|
||||
$list = $xpath->query("//".$oldnode);
|
||||
foreach ($list as $oldNode) {
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
if ($oldNode->attributes->length) {
|
||||
foreach ($oldNode->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
|
|
@ -102,14 +102,14 @@ function html2bbcode($message, $basepath = '')
|
|||
);
|
||||
|
||||
$message = str_replace(
|
||||
array(
|
||||
[
|
||||
"<li><p>",
|
||||
"</p></li>",
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
"<li>",
|
||||
"</li>",
|
||||
),
|
||||
],
|
||||
$message
|
||||
);
|
||||
|
||||
|
|
@ -138,23 +138,23 @@ function html2bbcode($message, $basepath = '')
|
|||
}
|
||||
|
||||
$message = $doc->saveHTML();
|
||||
$message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br />", " ", ""), $message);
|
||||
$message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br />", " ", ""], $message);
|
||||
$message = preg_replace('= [\s]*=i', " ", $message);
|
||||
@$doc->loadHTML($message);
|
||||
|
||||
node2bbcode($doc, 'html', array(), "", "");
|
||||
node2bbcode($doc, 'body', array(), "", "");
|
||||
node2bbcode($doc, 'html', [], "", "");
|
||||
node2bbcode($doc, 'body', [], "", "");
|
||||
|
||||
// Outlook-Quote - Variant 1
|
||||
node2bbcode($doc, 'p', array('class'=>'MsoNormal', 'style'=>'margin-left:35.4pt'), '[quote]', '[/quote]');
|
||||
node2bbcode($doc, 'p', ['class'=>'MsoNormal', 'style'=>'margin-left:35.4pt'], '[quote]', '[/quote]');
|
||||
|
||||
// Outlook-Quote - Variant 2
|
||||
node2bbcode($doc, 'div', array('style'=>'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'), '[quote]', '[/quote]');
|
||||
node2bbcode($doc, 'div', ['style'=>'border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt'], '[quote]', '[/quote]');
|
||||
|
||||
// MyBB-Stuff
|
||||
node2bbcode($doc, 'span', array('style'=>'text-decoration: underline;'), '[u]', '[/u]');
|
||||
node2bbcode($doc, 'span', array('style'=>'font-style: italic;'), '[i]', '[/i]');
|
||||
node2bbcode($doc, 'span', array('style'=>'font-weight: bold;'), '[b]', '[/b]');
|
||||
node2bbcode($doc, 'span', ['style'=>'text-decoration: underline;'], '[u]', '[/u]');
|
||||
node2bbcode($doc, 'span', ['style'=>'font-style: italic;'], '[i]', '[/i]');
|
||||
node2bbcode($doc, 'span', ['style'=>'font-weight: bold;'], '[b]', '[/b]');
|
||||
|
||||
/*node2bbcode($doc, 'font', array('face'=>'/([\w ]+)/', 'size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[font=$1][size=$2][color=$3]', '[/color][/size][/font]');
|
||||
node2bbcode($doc, 'font', array('size'=>'/(\d+)/', 'color'=>'/(.+)/'), '[size=$1][color=$2]', '[/color][/size]');
|
||||
|
|
@ -169,7 +169,7 @@ function html2bbcode($message, $basepath = '')
|
|||
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(\d+)[,;].*/'), '[size=$1]', '[/size]');
|
||||
//node2bbcode($doc, 'span', array('style'=>'/.*font-size:\s*(.+?)[,;].*/'), '[size=$1]', '[/size]');
|
||||
|
||||
node2bbcode($doc, 'span', array('style'=>'/.*color:\s*(.+?)[,;].*/'), '[color="$1"]', '[/color]');
|
||||
node2bbcode($doc, 'span', ['style'=>'/.*color:\s*(.+?)[,;].*/'], '[color="$1"]', '[/color]');
|
||||
|
||||
//node2bbcode($doc, 'span', array('style'=>'/.*font-family:\s*(.+?)[,;].*/'), '[font=$1]', '[/font]');
|
||||
|
||||
|
|
@ -180,42 +180,42 @@ function html2bbcode($message, $basepath = '')
|
|||
// Importing the classes - interesting for importing of posts from third party networks that were exported from friendica
|
||||
// Test
|
||||
//node2bbcode($doc, 'span', array('class'=>'/([\w ]+)/'), '[class=$1]', '[/class]');
|
||||
node2bbcode($doc, 'span', array('class'=>'type-link'), '[class=type-link]', '[/class]');
|
||||
node2bbcode($doc, 'span', array('class'=>'type-video'), '[class=type-video]', '[/class]');
|
||||
node2bbcode($doc, 'span', ['class'=>'type-link'], '[class=type-link]', '[/class]');
|
||||
node2bbcode($doc, 'span', ['class'=>'type-video'], '[class=type-video]', '[/class]');
|
||||
|
||||
node2bbcode($doc, 'strong', array(), '[b]', '[/b]');
|
||||
node2bbcode($doc, 'em', array(), '[i]', '[/i]');
|
||||
node2bbcode($doc, 'b', array(), '[b]', '[/b]');
|
||||
node2bbcode($doc, 'i', array(), '[i]', '[/i]');
|
||||
node2bbcode($doc, 'u', array(), '[u]', '[/u]');
|
||||
node2bbcode($doc, 'strong', [], '[b]', '[/b]');
|
||||
node2bbcode($doc, 'em', [], '[i]', '[/i]');
|
||||
node2bbcode($doc, 'b', [], '[b]', '[/b]');
|
||||
node2bbcode($doc, 'i', [], '[i]', '[/i]');
|
||||
node2bbcode($doc, 'u', [], '[u]', '[/u]');
|
||||
|
||||
node2bbcode($doc, 'big', array(), "[size=large]", "[/size]");
|
||||
node2bbcode($doc, 'small', array(), "[size=small]", "[/size]");
|
||||
node2bbcode($doc, 'big', [], "[size=large]", "[/size]");
|
||||
node2bbcode($doc, 'small', [], "[size=small]", "[/size]");
|
||||
|
||||
node2bbcode($doc, 'blockquote', array(), '[quote]', '[/quote]');
|
||||
node2bbcode($doc, 'blockquote', [], '[quote]', '[/quote]');
|
||||
|
||||
node2bbcode($doc, 'br', array(), "\n", '');
|
||||
node2bbcode($doc, 'br', [], "\n", '');
|
||||
|
||||
node2bbcode($doc, 'p', array('class'=>'MsoNormal'), "\n", "");
|
||||
node2bbcode($doc, 'div', array('class'=>'MsoNormal'), "\r", "");
|
||||
node2bbcode($doc, 'p', ['class'=>'MsoNormal'], "\n", "");
|
||||
node2bbcode($doc, 'div', ['class'=>'MsoNormal'], "\r", "");
|
||||
|
||||
node2bbcode($doc, 'span', array(), "", "");
|
||||
node2bbcode($doc, 'span', [], "", "");
|
||||
|
||||
node2bbcode($doc, 'span', array(), "", "");
|
||||
node2bbcode($doc, 'pre', array(), "", "");
|
||||
node2bbcode($doc, 'span', [], "", "");
|
||||
node2bbcode($doc, 'pre', [], "", "");
|
||||
|
||||
node2bbcode($doc, 'div', array(), "\r", "\r");
|
||||
node2bbcode($doc, 'p', array(), "\n", "\n");
|
||||
node2bbcode($doc, 'div', [], "\r", "\r");
|
||||
node2bbcode($doc, 'p', [], "\n", "\n");
|
||||
|
||||
node2bbcode($doc, 'ul', array(), "[list]", "[/list]");
|
||||
node2bbcode($doc, 'ol', array(), "[list=1]", "[/list]");
|
||||
node2bbcode($doc, 'li', array(), "[*]", "");
|
||||
node2bbcode($doc, 'ul', [], "[list]", "[/list]");
|
||||
node2bbcode($doc, 'ol', [], "[list=1]", "[/list]");
|
||||
node2bbcode($doc, 'li', [], "[*]", "");
|
||||
|
||||
node2bbcode($doc, 'hr', array(), "[hr]", "");
|
||||
node2bbcode($doc, 'hr', [], "[hr]", "");
|
||||
|
||||
node2bbcode($doc, 'table', array(), "", "");
|
||||
node2bbcode($doc, 'tr', array(), "\n", "");
|
||||
node2bbcode($doc, 'td', array(), "\t", "");
|
||||
node2bbcode($doc, 'table', [], "", "");
|
||||
node2bbcode($doc, 'tr', [], "\n", "");
|
||||
node2bbcode($doc, 'td', [], "\t", "");
|
||||
//node2bbcode($doc, 'table', array(), "[table]", "[/table]");
|
||||
//node2bbcode($doc, 'th', array(), "[th]", "[/th]");
|
||||
//node2bbcode($doc, 'tr', array(), "[tr]", "[/tr]");
|
||||
|
|
@ -228,26 +228,26 @@ function html2bbcode($message, $basepath = '')
|
|||
//node2bbcode($doc, 'h5', array(), "\n\n[size=small][b]", "[/b][/size]\n");
|
||||
//node2bbcode($doc, 'h6', array(), "\n\n[size=x-small][b]", "[/b][/size]\n");
|
||||
|
||||
node2bbcode($doc, 'h1', array(), "\n\n[h1]", "[/h1]\n");
|
||||
node2bbcode($doc, 'h2', array(), "\n\n[h2]", "[/h2]\n");
|
||||
node2bbcode($doc, 'h3', array(), "\n\n[h3]", "[/h3]\n");
|
||||
node2bbcode($doc, 'h4', array(), "\n\n[h4]", "[/h4]\n");
|
||||
node2bbcode($doc, 'h5', array(), "\n\n[h5]", "[/h5]\n");
|
||||
node2bbcode($doc, 'h6', array(), "\n\n[h6]", "[/h6]\n");
|
||||
node2bbcode($doc, 'h1', [], "\n\n[h1]", "[/h1]\n");
|
||||
node2bbcode($doc, 'h2', [], "\n\n[h2]", "[/h2]\n");
|
||||
node2bbcode($doc, 'h3', [], "\n\n[h3]", "[/h3]\n");
|
||||
node2bbcode($doc, 'h4', [], "\n\n[h4]", "[/h4]\n");
|
||||
node2bbcode($doc, 'h5', [], "\n\n[h5]", "[/h5]\n");
|
||||
node2bbcode($doc, 'h6', [], "\n\n[h6]", "[/h6]\n");
|
||||
|
||||
node2bbcode($doc, 'a', array('href'=>'/mailto:(.+)/'), '[mail=$1]', '[/mail]');
|
||||
node2bbcode($doc, 'a', array('href'=>'/(.+)/'), '[url=$1]', '[/url]');
|
||||
node2bbcode($doc, 'a', ['href'=>'/mailto:(.+)/'], '[mail=$1]', '[/mail]');
|
||||
node2bbcode($doc, 'a', ['href'=>'/(.+)/'], '[url=$1]', '[/url]');
|
||||
|
||||
node2bbcode($doc, 'img', array('src'=>'/(.+)/', 'width'=>'/(\d+)/', 'height'=>'/(\d+)/'), '[img=$2x$3]$1', '[/img]');
|
||||
node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]');
|
||||
node2bbcode($doc, 'img', ['src'=>'/(.+)/', 'width'=>'/(\d+)/', 'height'=>'/(\d+)/'], '[img=$2x$3]$1', '[/img]');
|
||||
node2bbcode($doc, 'img', ['src'=>'/(.+)/'], '[img]$1', '[/img]');
|
||||
|
||||
|
||||
node2bbcode($doc, 'video', array('src'=>'/(.+)/'), '[video]$1', '[/video]');
|
||||
node2bbcode($doc, 'audio', array('src'=>'/(.+)/'), '[audio]$1', '[/audio]');
|
||||
node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), '[iframe]$1', '[/iframe]');
|
||||
node2bbcode($doc, 'video', ['src'=>'/(.+)/'], '[video]$1', '[/video]');
|
||||
node2bbcode($doc, 'audio', ['src'=>'/(.+)/'], '[audio]$1', '[/audio]');
|
||||
node2bbcode($doc, 'iframe', ['src'=>'/(.+)/'], '[iframe]$1', '[/iframe]');
|
||||
|
||||
node2bbcode($doc, 'key', array(), '[code]', '[/code]');
|
||||
node2bbcode($doc, 'code', array(), '[code]', '[/code]');
|
||||
node2bbcode($doc, 'key', [], '[code]', '[/code]');
|
||||
node2bbcode($doc, 'code', [], '[code]', '[/code]');
|
||||
|
||||
$message = $doc->saveHTML();
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ function html2bbcode($message, $basepath = '')
|
|||
|
||||
$message = html_entity_decode($message, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$message = str_replace(array("<"), array("<"), $message);
|
||||
$message = str_replace(["<"], ["<"], $message);
|
||||
|
||||
// remove quotes if they don't make sense
|
||||
$message = preg_replace('=\[/quote\][\s]*\[quote\]=i', "\n", $message);
|
||||
|
|
@ -288,7 +288,7 @@ function html2bbcode($message, $basepath = '')
|
|||
do {
|
||||
$oldmessage = $message;
|
||||
$message = str_replace(
|
||||
array(
|
||||
[
|
||||
"[/size]\n\n",
|
||||
"\n[hr]",
|
||||
"[hr]\n",
|
||||
|
|
@ -297,8 +297,8 @@ function html2bbcode($message, $basepath = '')
|
|||
"\n[/",
|
||||
"[list]\n",
|
||||
"[list=1]\n",
|
||||
"\n[*]"),
|
||||
array(
|
||||
"\n[*]"],
|
||||
[
|
||||
"[/size]\n",
|
||||
"[hr]",
|
||||
"[hr]",
|
||||
|
|
@ -307,14 +307,14 @@ function html2bbcode($message, $basepath = '')
|
|||
"[/",
|
||||
"[list]",
|
||||
"[list=1]",
|
||||
"[*]"),
|
||||
"[*]"],
|
||||
$message
|
||||
);
|
||||
} while ($message != $oldmessage);
|
||||
|
||||
$message = str_replace(
|
||||
array('[b][b]', '[/b][/b]', '[i][i]', '[/i][/i]'),
|
||||
array('[b]', '[/b]', '[i]', '[/i]'),
|
||||
['[b][b]', '[/b][/b]', '[i][i]', '[/i][/i]'],
|
||||
['[b]', '[/b]', '[i]', '[/i]'],
|
||||
$message
|
||||
);
|
||||
|
||||
|
|
@ -378,7 +378,7 @@ function addHostname($body, $basepath)
|
|||
{
|
||||
$URLSearchString = "^\[\]";
|
||||
|
||||
$matches = array("/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
|
||||
$matches = ["/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
|
||||
"/\[url\]([$URLSearchString]*)\[\/url\]/ism",
|
||||
"/\[img\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
|
||||
"/\[img\](.*?)\[\/img\]/ism",
|
||||
|
|
@ -386,7 +386,7 @@ function addHostname($body, $basepath)
|
|||
"/\[zmg\](.*?)\[\/zmg\]/ism",
|
||||
"/\[video\](.*?)\[\/video\]/ism",
|
||||
"/\[audio\](.*?)\[\/audio\]/ism",
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$body = preg_replace_callback(
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ function breaklines($line, $level, $wraplength = 75)
|
|||
|
||||
$wraplen = $wraplength - $level;
|
||||
|
||||
$newlines = array();
|
||||
$newlines = [];
|
||||
|
||||
do {
|
||||
$oldline = $line;
|
||||
|
|
@ -47,7 +47,7 @@ function quotelevel($message, $wraplength = 75)
|
|||
{
|
||||
$lines = explode("\n", $message);
|
||||
|
||||
$newlines = array();
|
||||
$newlines = [];
|
||||
$level = 0;
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
|
|
@ -84,13 +84,13 @@ function collecturls($message)
|
|||
$pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
|
||||
preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
|
||||
|
||||
$urls = array();
|
||||
$urls = [];
|
||||
foreach ($result as $treffer) {
|
||||
$ignore = false;
|
||||
|
||||
// A list of some links that should be ignored
|
||||
$list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
||||
"//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/");
|
||||
$list = ["/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
|
||||
"//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/"];
|
||||
foreach ($list as $listitem) {
|
||||
if (strpos($treffer[1], $listitem) !== false) {
|
||||
$ignore = true;
|
||||
|
|
@ -137,7 +137,7 @@ function html2plain($html, $wraplength = 75, $compact = false)
|
|||
}
|
||||
|
||||
$message = $doc->saveHTML();
|
||||
$message = str_replace(array("\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"), array("<", ">", "<br>", " ", ""), $message);
|
||||
$message = str_replace(["\n<", ">\n", "\r", "\n", "\xC3\x82\xC2\xA0"], ["<", ">", "<br>", " ", ""], $message);
|
||||
$message = preg_replace('= [\s]*=i', " ", $message);
|
||||
|
||||
// Collecting all links
|
||||
|
|
@ -145,8 +145,8 @@ function html2plain($html, $wraplength = 75, $compact = false)
|
|||
|
||||
@$doc->loadHTML($message);
|
||||
|
||||
node2bbcode($doc, 'html', array(), '', '');
|
||||
node2bbcode($doc, 'body', array(), '', '');
|
||||
node2bbcode($doc, 'html', [], '', '');
|
||||
node2bbcode($doc, 'body', [], '', '');
|
||||
|
||||
// MyBB-Auszeichnungen
|
||||
/*
|
||||
|
|
@ -161,33 +161,33 @@ function html2plain($html, $wraplength = 75, $compact = false)
|
|||
*/
|
||||
|
||||
if ($compact) {
|
||||
node2bbcode($doc, 'blockquote', array(), "»", "«");
|
||||
node2bbcode($doc, 'blockquote', [], "»", "«");
|
||||
} else {
|
||||
node2bbcode($doc, 'blockquote', array(), '[quote]', "[/quote]\n");
|
||||
node2bbcode($doc, 'blockquote', [], '[quote]', "[/quote]\n");
|
||||
}
|
||||
|
||||
node2bbcode($doc, 'br', array(), "\n", '');
|
||||
node2bbcode($doc, 'br', [], "\n", '');
|
||||
|
||||
node2bbcode($doc, 'span', array(), "", "");
|
||||
node2bbcode($doc, 'pre', array(), "", "");
|
||||
node2bbcode($doc, 'div', array(), "\r", "\r");
|
||||
node2bbcode($doc, 'p', array(), "\n", "\n");
|
||||
node2bbcode($doc, 'span', [], "", "");
|
||||
node2bbcode($doc, 'pre', [], "", "");
|
||||
node2bbcode($doc, 'div', [], "\r", "\r");
|
||||
node2bbcode($doc, 'p', [], "\n", "\n");
|
||||
|
||||
//node2bbcode($doc, 'ul', array(), "\n[list]", "[/list]\n");
|
||||
//node2bbcode($doc, 'ol', array(), "\n[list=1]", "[/list]\n");
|
||||
node2bbcode($doc, 'li', array(), "\n* ", "\n");
|
||||
node2bbcode($doc, 'li', [], "\n* ", "\n");
|
||||
|
||||
node2bbcode($doc, 'hr', array(), "\n" . str_repeat("-", 70) . "\n", "");
|
||||
node2bbcode($doc, 'hr', [], "\n" . str_repeat("-", 70) . "\n", "");
|
||||
|
||||
node2bbcode($doc, 'tr', array(), "\n", "");
|
||||
node2bbcode($doc, 'td', array(), "\t", "");
|
||||
node2bbcode($doc, 'tr', [], "\n", "");
|
||||
node2bbcode($doc, 'td', [], "\t", "");
|
||||
|
||||
node2bbcode($doc, 'h1', array(), "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h2', array(), "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h3', array(), "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h4', array(), "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h5', array(), "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h6', array(), "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h1', [], "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h2', [], "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h3', [], "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h4', [], "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h5', [], "\n\n*", "*\n");
|
||||
node2bbcode($doc, 'h6', [], "\n\n*", "*\n");
|
||||
|
||||
// Problem: there is no reliable way to detect if it is a link to a tag or profile
|
||||
//node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', ' ', true);
|
||||
|
|
@ -196,12 +196,12 @@ function html2plain($html, $wraplength = 75, $compact = false)
|
|||
//node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', '');
|
||||
//node2bbcode($doc, 'img', array(), '', '');
|
||||
if (!$compact) {
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/'), ' [img]$1', '[/img] ');
|
||||
node2bbcode($doc, 'img', ['src' => '/(.+)/'], ' [img]$1', '[/img] ');
|
||||
} else {
|
||||
node2bbcode($doc, 'img', array('src' => '/(.+)/'), ' ', ' ');
|
||||
node2bbcode($doc, 'img', ['src' => '/(.+)/'], ' ', ' ');
|
||||
}
|
||||
|
||||
node2bbcode($doc, 'iframe', array('src' => '/(.+)/'), ' $1 ', '');
|
||||
node2bbcode($doc, 'iframe', ['src' => '/(.+)/'], ' $1 ', '');
|
||||
|
||||
$message = $doc->saveHTML();
|
||||
|
||||
|
|
|
|||
|
|
@ -133,12 +133,12 @@ function title_is_body($title, $body) {
|
|||
$title = strip_tags($title);
|
||||
$title = trim($title);
|
||||
$title = html_entity_decode($title, ENT_QUOTES, 'UTF-8');
|
||||
$title = str_replace(array("\n", "\r", "\t", " "), array("", "", "", ""), $title);
|
||||
$title = str_replace(["\n", "\r", "\t", " "], ["", "", "", ""], $title);
|
||||
|
||||
$body = strip_tags($body);
|
||||
$body = trim($body);
|
||||
$body = html_entity_decode($body, ENT_QUOTES, 'UTF-8');
|
||||
$body = str_replace(array("\n", "\r", "\t", " "), array("", "", "", ""), $body);
|
||||
$body = str_replace(["\n", "\r", "\t", " "], ["", "", "", ""], $body);
|
||||
|
||||
if (strlen($title) < strlen($body)) {
|
||||
$body = substr($body, 0, strlen($title));
|
||||
|
|
@ -174,8 +174,8 @@ function add_page_info_data($data) {
|
|||
}
|
||||
|
||||
// Escape some bad characters
|
||||
$data["url"] = str_replace(array("[", "]"), array("[", "]"), htmlentities($data["url"], ENT_QUOTES, 'UTF-8', false));
|
||||
$data["title"] = str_replace(array("[", "]"), array("[", "]"), htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false));
|
||||
$data["url"] = str_replace(["[", "]"], ["[", "]"], htmlentities($data["url"], ENT_QUOTES, 'UTF-8', false));
|
||||
$data["title"] = str_replace(["[", "]"], ["[", "]"], htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false));
|
||||
|
||||
$text = "[attachment type='".$data["type"]."'";
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ function add_page_info_data($data) {
|
|||
}
|
||||
|
||||
if (sizeof($data["images"]) > 0) {
|
||||
$preview = str_replace(array("[", "]"), array("[", "]"), htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
|
||||
$preview = str_replace(["[", "]"], ["[", "]"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false));
|
||||
// if the preview picture is larger than 500 pixels then show it in a larger mode
|
||||
// But only, if the picture isn't higher than large (To prevent huge posts)
|
||||
if (!Config::get('system', 'always_show_preview') && ($data["images"][0]["width"] >= 500)
|
||||
|
|
@ -214,8 +214,8 @@ function add_page_info_data($data) {
|
|||
$hashtags = "\n";
|
||||
foreach ($data["keywords"] AS $keyword) {
|
||||
/// @todo make a positive list of allowed characters
|
||||
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"),
|
||||
array("", "", "", "", "", "", "", "", "", "", "", ""), $keyword);
|
||||
$hashtag = str_replace([" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"],
|
||||
["", "", "", "", "", "", "", "", "", "", "", ""], $keyword);
|
||||
$hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url] ";
|
||||
}
|
||||
}
|
||||
|
|
@ -257,8 +257,8 @@ function add_page_keywords($url, $no_photos = false, $photo = "", $keywords = fa
|
|||
$tags = "";
|
||||
if (isset($data["keywords"]) && count($data["keywords"])) {
|
||||
foreach ($data["keywords"] AS $keyword) {
|
||||
$hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
|
||||
array("", "", "", "", "", ""), $keyword);
|
||||
$hashtag = str_replace([" ", "+", "/", ".", "#", "'"],
|
||||
["", "", "", "", "", ""], $keyword);
|
||||
|
||||
if ($tags != "") {
|
||||
$tags .= ", ";
|
||||
|
|
@ -317,7 +317,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
|
|||
$body = $removedlink;
|
||||
}
|
||||
|
||||
$url = str_replace(array('/', '.'), array('\/', '\.'), $matches[1]);
|
||||
$url = str_replace(['/', '.'], ['\/', '\.'], $matches[1]);
|
||||
$removedlink = preg_replace("/\[url\=" . $url . "\](.*?)\[\/url\]/ism", '', $body);
|
||||
if (($removedlink == "") || strstr($body, $removedlink)) {
|
||||
$body = $removedlink;
|
||||
|
|
@ -419,8 +419,8 @@ function uri_to_guid($uri, $host = "") {
|
|||
* @return array Item array with removed conversation data
|
||||
*/
|
||||
function store_conversation($arr) {
|
||||
if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)) && !empty($arr['uri'])) {
|
||||
$conversation = array('item-uri' => $arr['uri'], 'received' => DBM::date());
|
||||
if (in_array(defaults($arr, 'network', NETWORK_PHANTOM), [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS]) && !empty($arr['uri'])) {
|
||||
$conversation = ['item-uri' => $arr['uri'], 'received' => DBM::date()];
|
||||
|
||||
if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) {
|
||||
$conversation['reply-to-uri'] = $arr['parent-uri'];
|
||||
|
|
@ -458,7 +458,7 @@ function store_conversation($arr) {
|
|||
unset($conversation['protocol']);
|
||||
unset($conversation['source']);
|
||||
}
|
||||
if (!dba::update('conversation', $conversation, array('item-uri' => $conversation['item-uri']), $old_conv)) {
|
||||
if (!dba::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) {
|
||||
logger('Conversation: update for '.$conversation['item-uri'].' from '.$conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -581,7 +581,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
* We have to check several networks since Friendica posts could be repeated
|
||||
* via OStatus (maybe Diasporsa as well)
|
||||
*/
|
||||
if (in_array($arr['network'], array(NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""))) {
|
||||
if (in_array($arr['network'], [NETWORK_DIASPORA, NETWORK_DFRN, NETWORK_OSTATUS, ""])) {
|
||||
$r = q("SELECT `id`, `network` FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `network` IN ('%s', '%s', '%s') LIMIT 1",
|
||||
dbesc(trim($arr['uri'])),
|
||||
intval($uid),
|
||||
|
|
@ -740,11 +740,11 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
* On comments the author is the better choice.
|
||||
*/
|
||||
if ($arr['parent-uri'] === $arr['uri']) {
|
||||
$arr["gcontact-id"] = GContact::getId(array("url" => $arr['owner-link'], "network" => $arr['network'],
|
||||
"photo" => $arr['owner-avatar'], "name" => $arr['owner-name']));
|
||||
$arr["gcontact-id"] = GContact::getId(["url" => $arr['owner-link'], "network" => $arr['network'],
|
||||
"photo" => $arr['owner-avatar'], "name" => $arr['owner-name']]);
|
||||
} else {
|
||||
$arr["gcontact-id"] = GContact::getId(array("url" => $arr['author-link'], "network" => $arr['network'],
|
||||
"photo" => $arr['author-avatar'], "name" => $arr['author-name']));
|
||||
$arr["gcontact-id"] = GContact::getId(["url" => $arr['author-link'], "network" => $arr['network'],
|
||||
"photo" => $arr['author-avatar'], "name" => $arr['author-name']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -855,7 +855,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
$self = normalise_link(System::baseUrl() . '/profile/' . $u[0]['nickname']);
|
||||
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
|
||||
if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) {
|
||||
dba::update('thread', array('mention' => true), array('iid' => $parent_id));
|
||||
dba::update('thread', ['mention' => true], ['iid' => $parent_id]);
|
||||
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
|
@ -890,7 +890,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
}
|
||||
|
||||
// On Friendica and Diaspora the GUID is unique
|
||||
if (in_array($arr['network'], array(NETWORK_DFRN, NETWORK_DIASPORA))) {
|
||||
if (in_array($arr['network'], [NETWORK_DFRN, NETWORK_DIASPORA])) {
|
||||
$r = q("SELECT `id` FROM `item` WHERE `guid` = '%s' AND `uid` = %d LIMIT 1",
|
||||
dbesc($arr['guid']),
|
||||
intval($arr['uid'])
|
||||
|
|
@ -919,7 +919,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
$arr["global"] = true;
|
||||
|
||||
// Set the global flag on all items if this was a global item entry
|
||||
dba::update('item', array('global' => true), array('uri' => $arr["uri"]));
|
||||
dba::update('item', ['global' => true], ['uri' => $arr["uri"]]);
|
||||
} else {
|
||||
$isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"]));
|
||||
|
||||
|
|
@ -1030,7 +1030,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
logger('Duplicated post occurred. uri = ' . $arr['uri'] . ' uid = ' . $arr['uid']);
|
||||
|
||||
// Yes, we could do a rollback here - but we are having many users with MyISAM.
|
||||
dba::delete('item', array('id' => $current_post));
|
||||
dba::delete('item', ['id' => $current_post]);
|
||||
dba::commit();
|
||||
return 0;
|
||||
} elseif ($r[0]["entries"] == 0) {
|
||||
|
|
@ -1048,7 +1048,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
}
|
||||
|
||||
// Set parent id
|
||||
dba::update('item', array('parent' => $parent_id), array('id' => $current_post));
|
||||
dba::update('item', ['parent' => $parent_id], ['id' => $current_post]);
|
||||
|
||||
$arr['id'] = $current_post;
|
||||
$arr['parent'] = $parent_id;
|
||||
|
|
@ -1056,9 +1056,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
// update the commented timestamp on the parent
|
||||
// Only update "commented" if it is really a comment
|
||||
if (($arr['verb'] == ACTIVITY_POST) || !Config::get("system", "like_no_comment")) {
|
||||
dba::update('item', array('commented' => datetime_convert(), 'changed' => datetime_convert()), array('id' => $parent_id));
|
||||
dba::update('item', ['commented' => datetime_convert(), 'changed' => datetime_convert()], ['id' => $parent_id]);
|
||||
} else {
|
||||
dba::update('item', array('changed' => datetime_convert()), array('id' => $parent_id));
|
||||
dba::update('item', ['changed' => datetime_convert()], ['id' => $parent_id]);
|
||||
}
|
||||
|
||||
if ($dsprsig) {
|
||||
|
|
@ -1072,8 +1072,8 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
logger("Repaired double encoded signature from handle ".$dsprsig->signer, LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
dba::insert('sign', array('iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
|
||||
'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer));
|
||||
dba::insert('sign', ['iid' => $current_post, 'signed_text' => $dsprsig->signed_text,
|
||||
'signature' => $dsprsig->signature, 'signer' => $dsprsig->signer]);
|
||||
}
|
||||
|
||||
$deleted = tag_deliver($arr['uid'], $current_post);
|
||||
|
|
@ -1132,7 +1132,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
|||
check_user_notification($current_post);
|
||||
|
||||
if ($notify) {
|
||||
Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "Notifier", $notify_type, $current_post);
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], "Notifier", $notify_type, $current_post);
|
||||
}
|
||||
|
||||
return $current_post;
|
||||
|
|
@ -1174,17 +1174,17 @@ function item_set_last_item($arr) {
|
|||
}
|
||||
|
||||
if ($update) {
|
||||
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
|
||||
array('id' => $arr['contact-id']));
|
||||
dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['contact-id']]);
|
||||
}
|
||||
// Now do the same for the system wide contacts with uid=0
|
||||
if (!$arr['private']) {
|
||||
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
|
||||
array('id' => $arr['owner-id']));
|
||||
dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['owner-id']]);
|
||||
|
||||
if ($arr['owner-id'] != $arr['author-id']) {
|
||||
dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
|
||||
array('id' => $arr['author-id']));
|
||||
dba::update('contact', ['success_update' => $arr['received'], 'last-item' => $arr['received']],
|
||||
['id' => $arr['author-id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1299,7 +1299,7 @@ function get_item_id($guid, $uid = 0) {
|
|||
$nick = $r[0]["nickname"];
|
||||
}
|
||||
}
|
||||
return array("nick" => $nick, "id" => $id);
|
||||
return ["nick" => $nick, "id" => $id];
|
||||
}
|
||||
|
||||
// return - test
|
||||
|
|
@ -1369,13 +1369,13 @@ function tag_deliver($uid, $item_id)
|
|||
// mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment)
|
||||
// delete it!
|
||||
logger("tag_deliver: no-mention top-level post to communuty or private group. delete.");
|
||||
dba::delete('item', array('id' => $item_id));
|
||||
dba::delete('item', ['id' => $item_id]);
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$arr = array('item' => $item, 'user' => $u[0], 'contact' => $r[0]);
|
||||
$arr = ['item' => $item, 'user' => $u[0], 'contact' => $r[0]];
|
||||
|
||||
call_hooks('tagged', $arr);
|
||||
|
||||
|
|
@ -1421,7 +1421,7 @@ function tag_deliver($uid, $item_id)
|
|||
);
|
||||
update_thread($item_id);
|
||||
|
||||
Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), 'Notifier', 'tgroup', $item_id);
|
||||
Worker::add(['priority' => PRIORITY_HIGH, 'dont_fork' => true], 'Notifier', 'tgroup', $item_id);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1664,8 +1664,8 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
|||
if (is_array($contact)) {
|
||||
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|
||||
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
|
||||
array('id' => $contact['id'], 'uid' => $importer['uid']));
|
||||
dba::update('contact', ['rel' => CONTACT_IS_FRIEND, 'writable' => true],
|
||||
['id' => $contact['id'], 'uid' => $importer['uid']]);
|
||||
}
|
||||
// send email notification to owner?
|
||||
} else {
|
||||
|
|
@ -1697,22 +1697,22 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
|||
$r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
|
||||
intval($importer['uid'])
|
||||
);
|
||||
if (DBM::is_result($r) && !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) {
|
||||
if (DBM::is_result($r) && !in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
|
||||
// create notification
|
||||
$hash = random_string();
|
||||
|
||||
if (is_array($contact_record)) {
|
||||
dba::insert('intro', array('uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
|
||||
dba::insert('intro', ['uid' => $importer['uid'], 'contact-id' => $contact_record['id'],
|
||||
'blocked' => false, 'knowyou' => false,
|
||||
'hash' => $hash, 'datetime' => datetime_convert()));
|
||||
'hash' => $hash, 'datetime' => datetime_convert()]);
|
||||
}
|
||||
|
||||
Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']);
|
||||
|
||||
if (($r[0]['notify-flags'] & NOTIFY_INTRO) &&
|
||||
in_array($r[0]['page-flags'], array(PAGE_NORMAL))) {
|
||||
in_array($r[0]['page-flags'], [PAGE_NORMAL])) {
|
||||
|
||||
notification(array(
|
||||
notification([
|
||||
'type' => NOTIFY_INTRO,
|
||||
'notify_flags' => $r[0]['notify-flags'],
|
||||
'language' => $r[0]['language'],
|
||||
|
|
@ -1725,10 +1725,10 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
|||
'source_photo' => $contact_record['photo'],
|
||||
'verb' => ($sharing ? ACTIVITY_FRIEND : ACTIVITY_FOLLOW),
|
||||
'otype' => 'intro'
|
||||
));
|
||||
]);
|
||||
|
||||
}
|
||||
} elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) {
|
||||
} elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], [PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY])) {
|
||||
q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1",
|
||||
intval($importer['uid']),
|
||||
dbesc($url)
|
||||
|
|
@ -1738,19 +1738,19 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
|
|||
}
|
||||
}
|
||||
|
||||
function lose_follower($importer, $contact, array $datarray = array(), $item = "") {
|
||||
function lose_follower($importer, $contact, array $datarray = [], $item = "") {
|
||||
|
||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
|
||||
dba::update('contact', array('rel' => CONTACT_IS_SHARING), array('id' => $contact['id']));
|
||||
dba::update('contact', ['rel' => CONTACT_IS_SHARING], ['id' => $contact['id']]);
|
||||
} else {
|
||||
Contact::remove($contact['id']);
|
||||
}
|
||||
}
|
||||
|
||||
function lose_sharer($importer, $contact, array $datarray = array(), $item = "") {
|
||||
function lose_sharer($importer, $contact, array $datarray = [], $item = "") {
|
||||
|
||||
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id']));
|
||||
dba::update('contact', ['rel' => CONTACT_IS_FOLLOWER], ['id' => $contact['id']]);
|
||||
} else {
|
||||
Contact::remove($contact['id']);
|
||||
}
|
||||
|
|
@ -1785,7 +1785,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
|
|||
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
|
||||
|
||||
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
|
||||
dba::update('contact', array('hub-verify' => $verify_token), array('id' => $contact['id']));
|
||||
dba::update('contact', ['hub-verify' => $verify_token], ['id' => $contact['id']]);
|
||||
}
|
||||
|
||||
post_url($url, $params);
|
||||
|
|
@ -1830,7 +1830,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0)
|
|||
// Only embed locally hosted photos
|
||||
$replace = false;
|
||||
$i = basename($image);
|
||||
$i = str_replace(array('.jpg', '.png', '.gif'), array('', '', ''), $i);
|
||||
$i = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $i);
|
||||
$x = strpos($i, '-');
|
||||
|
||||
if ($x) {
|
||||
|
|
@ -1955,13 +1955,13 @@ function enumerate_permissions($obj) {
|
|||
}
|
||||
|
||||
function item_getfeedtags($item) {
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
$matches = false;
|
||||
$cnt = preg_match_all('|\#\[url\=(.*?)\](.*?)\[\/url\]|', $item['tag'], $matches);
|
||||
if ($cnt) {
|
||||
for ($x = 0; $x < $cnt; $x ++) {
|
||||
if ($matches[1][$x]) {
|
||||
$ret[$matches[2][$x]] = array('#', $matches[1][$x], $matches[2][$x]);
|
||||
$ret[$matches[2][$x]] = ['#', $matches[1][$x], $matches[2][$x]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1970,7 +1970,7 @@ function item_getfeedtags($item) {
|
|||
if ($cnt) {
|
||||
for ($x = 0; $x < $cnt; $x ++) {
|
||||
if ($matches[1][$x]) {
|
||||
$ret[] = array('@', $matches[1][$x], $matches[2][$x]);
|
||||
$ret[] = ['@', $matches[1][$x], $matches[2][$x]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2052,7 +2052,7 @@ function item_expire($uid, $days, $network = "", $force = false) {
|
|||
drop_item($item['id'], false);
|
||||
}
|
||||
|
||||
Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "Notifier", "expire", $uid);
|
||||
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "Notifier", "expire", $uid);
|
||||
}
|
||||
|
||||
/// @TODO type-hint is array
|
||||
|
|
@ -2074,7 +2074,7 @@ function drop_items($items) {
|
|||
// multiple threads may have been deleted, send an expire notification
|
||||
|
||||
if ($uid) {
|
||||
Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "Notifier", "expire", $uid);
|
||||
Worker::add(['priority' => PRIORITY_LOW, 'dont_fork' => true], "Notifier", "expire", $uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2126,15 +2126,15 @@ function drop_item($id, $interactive = true) {
|
|||
// <form> can't take arguments in its "action" parameter
|
||||
// so add any arguments as hidden inputs
|
||||
$query = explode_querystring($a->query_string);
|
||||
$inputs = array();
|
||||
$inputs = [];
|
||||
foreach ($query['args'] as $arg) {
|
||||
if (strpos($arg, 'confirm=') === false) {
|
||||
$arg_parts = explode('=', $arg);
|
||||
$inputs[] = array('name' => $arg_parts[0], 'value' => $arg_parts[1]);
|
||||
$inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
|
||||
}
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template('confirm.tpl'), array(
|
||||
return replace_macros(get_markup_template('confirm.tpl'), [
|
||||
'$method' => 'get',
|
||||
'$message' => t('Do you really want to delete this item?'),
|
||||
'$extra_inputs' => $inputs,
|
||||
|
|
@ -2142,7 +2142,7 @@ function drop_item($id, $interactive = true) {
|
|||
'$confirm_url' => $query['base'],
|
||||
'$confirm_name' => 'confirmed',
|
||||
'$cancel' => t('Cancel'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
// Now check how the user responded to the confirmation query
|
||||
if ($_REQUEST['canceled']) {
|
||||
|
|
@ -2152,9 +2152,9 @@ function drop_item($id, $interactive = true) {
|
|||
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
|
||||
|
||||
// delete the item
|
||||
dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
|
||||
'edited' => datetime_convert(), 'changed' => datetime_convert()),
|
||||
array('id' => $item['id']));
|
||||
dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
|
||||
'edited' => datetime_convert(), 'changed' => datetime_convert()],
|
||||
['id' => $item['id']]);
|
||||
|
||||
create_tags_from_item($item['id']);
|
||||
Term::createFromItem($item['id']);
|
||||
|
|
@ -2186,18 +2186,18 @@ function drop_item($id, $interactive = true) {
|
|||
* generate a resource-id and therefore aren't intimately linked to the item.
|
||||
*/
|
||||
if (strlen($item['resource-id'])) {
|
||||
dba::delete('photo', array('resource-id' => $item['resource-id'], 'uid' => $item['uid']));
|
||||
dba::delete('photo', ['resource-id' => $item['resource-id'], 'uid' => $item['uid']]);
|
||||
}
|
||||
|
||||
// If item is a link to an event, nuke the event record.
|
||||
if (intval($item['event-id'])) {
|
||||
dba::delete('event', array('id' => $item['event-id'], 'uid' => $item['uid']));
|
||||
dba::delete('event', ['id' => $item['event-id'], 'uid' => $item['uid']]);
|
||||
}
|
||||
|
||||
// If item has attachments, drop them
|
||||
foreach (explode(", ", $item['attach']) as $attach) {
|
||||
preg_match("|attach/(\d+)|", $attach, $matches);
|
||||
dba::delete('attach', array('id' => $matches[1], 'uid' => $item['uid']));
|
||||
dba::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
|
||||
}
|
||||
|
||||
// The new code splits the queries since the mysql optimizer really has bad problems with subqueries
|
||||
|
|
@ -2225,9 +2225,9 @@ function drop_item($id, $interactive = true) {
|
|||
|
||||
// If it's the parent of a comment thread, kill all the kids
|
||||
if ($item['uri'] == $item['parent-uri']) {
|
||||
dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
|
||||
'edited' => datetime_convert(), 'changed' => datetime_convert()),
|
||||
array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid']));
|
||||
dba::update('item', ['deleted' => true, 'title' => '', 'body' => '',
|
||||
'edited' => datetime_convert(), 'changed' => datetime_convert()],
|
||||
['parent-uri' => $item['parent-uri'], 'uid' => $item['uid']]);
|
||||
|
||||
create_tags_from_itemuri($item['parent-uri'], $item['uid']);
|
||||
Term::createFromItemURI($item['parent-uri'], $item['uid']);
|
||||
|
|
@ -2235,8 +2235,8 @@ function drop_item($id, $interactive = true) {
|
|||
// ignore the result
|
||||
} else {
|
||||
// ensure that last-child is set in case the comment that had it just got wiped.
|
||||
dba::update('item', array('last-child' => false, 'changed' => datetime_convert()),
|
||||
array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid']));
|
||||
dba::update('item', ['last-child' => false, 'changed' => datetime_convert()],
|
||||
['parent-uri' => $item['parent-uri'], 'uid' => $item['uid']]);
|
||||
|
||||
// who is the last child now?
|
||||
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
|
||||
|
|
@ -2244,7 +2244,7 @@ function drop_item($id, $interactive = true) {
|
|||
intval($item['uid'])
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
dba::update('item', array('last-child' => true), array('id' => $r[0]['id']));
|
||||
dba::update('item', ['last-child' => true], ['id' => $r[0]['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2253,7 +2253,7 @@ function drop_item($id, $interactive = true) {
|
|||
$drop_id = intval($item['id']);
|
||||
$priority = ($interactive ? PRIORITY_HIGH : PRIORITY_LOW);
|
||||
|
||||
Worker::add(array('priority' => $priority, 'dont_fork' => true), "Notifier", "drop", $drop_id);
|
||||
Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", "drop", $drop_id);
|
||||
|
||||
if (! $interactive) {
|
||||
return $owner;
|
||||
|
|
@ -2293,14 +2293,14 @@ function list_post_dates($uid, $wall) {
|
|||
|
||||
$dthen = first_post_date($uid, $wall);
|
||||
if (! $dthen) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
// Set the start and end date to the beginning of the month
|
||||
$dnow = substr($dnow, 0, 8) . '01';
|
||||
$dthen = substr($dthen, 0, 8) . '01';
|
||||
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
|
||||
/*
|
||||
* Starting with the current month, get the first and last days of every
|
||||
|
|
@ -2314,9 +2314,9 @@ function list_post_dates($uid, $wall) {
|
|||
$end_month = datetime_convert('', '', $dend, 'Y-m-d');
|
||||
$str = day_translate(datetime_convert('', '', $dnow, 'F'));
|
||||
if (!$ret[$dyear]) {
|
||||
$ret[$dyear] = array();
|
||||
$ret[$dyear] = [];
|
||||
}
|
||||
$ret[$dyear][] = array($str, $end_month, $start_month);
|
||||
$ret[$dyear][] = [$str, $end_month, $start_month];
|
||||
$dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d');
|
||||
}
|
||||
return $ret;
|
||||
|
|
@ -2327,14 +2327,14 @@ function posted_dates($uid, $wall) {
|
|||
|
||||
$dthen = first_post_date($uid, $wall);
|
||||
if (! $dthen) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
// Set the start and end date to the beginning of the month
|
||||
$dnow = substr($dnow, 0, 8) . '01';
|
||||
$dthen = substr($dthen, 0, 8) . '01';
|
||||
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
/*
|
||||
* Starting with the current month, get the first and last days of every
|
||||
* month down to and including the month of the first post
|
||||
|
|
@ -2345,7 +2345,7 @@ function posted_dates($uid, $wall) {
|
|||
$start_month = datetime_convert('', '', $dstart, 'Y-m-d');
|
||||
$end_month = datetime_convert('', '', $dend, 'Y-m-d');
|
||||
$str = day_translate(datetime_convert('', '', $dnow, 'F Y'));
|
||||
$ret[] = array($str, $end_month, $start_month);
|
||||
$ret[] = [$str, $end_month, $start_month];
|
||||
$dnow = datetime_convert('', '', $dnow . ' -1 month', 'Y-m-d');
|
||||
}
|
||||
return $ret;
|
||||
|
|
@ -2380,7 +2380,7 @@ function posted_date_widget($url, $uid, $wall) {
|
|||
$cutoff_year = intval(datetime_convert('',date_default_timezone_get(), 'now', 'Y')) - $visible_years;
|
||||
$cutoff = ((array_key_exists($cutoff_year, $ret))? true : false);
|
||||
|
||||
$o = replace_macros(get_markup_template('posted_date_widget.tpl'),array(
|
||||
$o = replace_macros(get_markup_template('posted_date_widget.tpl'),[
|
||||
'$title' => t('Archives'),
|
||||
'$size' => $visible_years,
|
||||
'$cutoff_year' => $cutoff_year,
|
||||
|
|
@ -2389,6 +2389,6 @@ function posted_date_widget($url, $uid, $wall) {
|
|||
'$dates' => $ret,
|
||||
'$showmore' => t('show more')
|
||||
|
||||
));
|
||||
]);
|
||||
return $o;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ function do_like($item_id, $verb) {
|
|||
// Clean up the Diaspora signatures for this like
|
||||
// Go ahead and do it even if Diaspora support is disabled. We still want to clean up
|
||||
// if it had been enabled in the past
|
||||
dba::delete('sign', array('iid' => $like_item['id']));
|
||||
dba::delete('sign', ['iid' => $like_item['id']]);
|
||||
|
||||
$like_item_id = $like_item['id'];
|
||||
Worker::add(PRIORITY_HIGH, "Notifier", "like", $like_item_id);
|
||||
|
|
@ -208,7 +208,7 @@ EOT;
|
|||
$alink = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
|
||||
$plink = '[url=' . System::baseUrl() . '/display/' . $owner_self_contact['nick'] . '/' . $item['id'] . ']' . $post_type . '[/url]';
|
||||
|
||||
$new_item = array(
|
||||
$new_item = [
|
||||
'guid' => get_guid(32),
|
||||
'uri' => item_new_uri($a->get_hostname(), $item['uid']),
|
||||
'uid' => $item['uid'],
|
||||
|
|
@ -239,7 +239,7 @@ EOT;
|
|||
'visible' => 1,
|
||||
'unseen' => 1,
|
||||
'last-child' => 0
|
||||
);
|
||||
];
|
||||
|
||||
$new_item_id = item_store($new_item);
|
||||
|
||||
|
|
|
|||
102
include/nav.php
102
include/nav.php
|
|
@ -20,7 +20,7 @@ function nav(App $a) {
|
|||
if (!(x($a->page,'nav')))
|
||||
$a->page['nav'] = '';
|
||||
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), array());
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template('nav_head.tpl'), []);
|
||||
|
||||
/*
|
||||
* Placeholder div for popup panel
|
||||
|
|
@ -36,7 +36,7 @@ function nav(App $a) {
|
|||
|
||||
$tpl = get_markup_template('nav.tpl');
|
||||
|
||||
$a->page['nav'] .= replace_macros($tpl, array(
|
||||
$a->page['nav'] .= replace_macros($tpl, [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$sitelocation' => $nav_info['sitelocation'],
|
||||
'$nav' => $nav_info['nav'],
|
||||
|
|
@ -47,7 +47,7 @@ function nav(App $a) {
|
|||
'$apps' => $a->apps,
|
||||
'$clear_notifs' => t('Clear notifications'),
|
||||
'$search_hint' => t('@name, !forum, #tags, content')
|
||||
));
|
||||
]);
|
||||
|
||||
call_hooks('page_header', $a->page['nav']);
|
||||
}
|
||||
|
|
@ -77,31 +77,31 @@ function nav_info(App $a)
|
|||
$sitelocation = $myident . substr(System::baseUrl($ssl_state), strpos(System::baseUrl($ssl_state), '//') + 2 );
|
||||
|
||||
// nav links: array of array('href', 'text', 'extra css classes', 'title')
|
||||
$nav = array();
|
||||
$nav = [];
|
||||
|
||||
// Display login or logout
|
||||
$nav['usermenu'] = array();
|
||||
$nav['usermenu'] = [];
|
||||
$userinfo = null;
|
||||
|
||||
if (local_user()) {
|
||||
$nav['logout'] = array('logout', t('Logout'), '', t('End this session'));
|
||||
$nav['logout'] = ['logout', t('Logout'), '', t('End this session')];
|
||||
|
||||
// user menu
|
||||
$nav['usermenu'][] = array('profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations'));
|
||||
$nav['usermenu'][] = array('profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page'));
|
||||
$nav['usermenu'][] = array('photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos'));
|
||||
$nav['usermenu'][] = array('videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos'));
|
||||
$nav['usermenu'][] = array('events/', t('Events'), '', t('Your events'));
|
||||
$nav['usermenu'][] = array('notes/', t('Personal notes'), '', t('Your personal notes'));
|
||||
$nav['usermenu'][] = ['profile/' . $a->user['nickname'], t('Status'), '', t('Your posts and conversations')];
|
||||
$nav['usermenu'][] = ['profile/' . $a->user['nickname'] . '?tab=profile', t('Profile'), '', t('Your profile page')];
|
||||
$nav['usermenu'][] = ['photos/' . $a->user['nickname'], t('Photos'), '', t('Your photos')];
|
||||
$nav['usermenu'][] = ['videos/' . $a->user['nickname'], t('Videos'), '', t('Your videos')];
|
||||
$nav['usermenu'][] = ['events/', t('Events'), '', t('Your events')];
|
||||
$nav['usermenu'][] = ['notes/', t('Personal notes'), '', t('Your personal notes')];
|
||||
|
||||
// user info
|
||||
$contact = dba::selectFirst('contact', ['micro'], ['uid' => $a->user['uid'], 'self' => true]);
|
||||
$userinfo = array(
|
||||
$userinfo = [
|
||||
'icon' => (DBM::is_result($contact) ? $a->remove_baseurl($contact['micro']) : 'images/person-48.jpg'),
|
||||
'name' => $a->user['username'],
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$nav['login'] = array('login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in'));
|
||||
$nav['login'] = ['login', t('Login'), ($a->module == 'login' ? 'selected' : ''), t('Sign in')];
|
||||
}
|
||||
|
||||
// "Home" should also take you home from an authenticated remote profile connection
|
||||
|
|
@ -111,30 +111,30 @@ function nav_info(App $a)
|
|||
}
|
||||
|
||||
if (($a->module != 'home') && (! (local_user()))) {
|
||||
$nav['home'] = array($homelink, t('Home'), '', t('Home Page'));
|
||||
$nav['home'] = [$homelink, t('Home'), '', t('Home Page')];
|
||||
}
|
||||
|
||||
if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
|
||||
$nav['register'] = array('register', t('Register'), '', t('Create an account'));
|
||||
$nav['register'] = ['register', t('Register'), '', t('Create an account')];
|
||||
}
|
||||
|
||||
$help_url = 'help';
|
||||
|
||||
if (!Config::get('system', 'hide_help')) {
|
||||
$nav['help'] = array($help_url, t('Help'), '', t('Help and documentation'));
|
||||
$nav['help'] = [$help_url, t('Help'), '', t('Help and documentation')];
|
||||
}
|
||||
|
||||
if (count($a->apps) > 0) {
|
||||
$nav['apps'] = array('apps', t('Apps'), '', t('Addon applications, utilities, games'));
|
||||
$nav['apps'] = ['apps', t('Apps'), '', t('Addon applications, utilities, games')];
|
||||
}
|
||||
|
||||
if (local_user() || !Config::get('system', 'local_search')) {
|
||||
$nav['search'] = array('search', t('Search'), '', t('Search site content'));
|
||||
$nav['search'] = ['search', t('Search'), '', t('Search site content')];
|
||||
|
||||
$nav['searchoption'] = array(
|
||||
$nav['searchoption'] = [
|
||||
t('Full Text'),
|
||||
t('Tags'),
|
||||
t('Contacts'));
|
||||
t('Contacts')];
|
||||
|
||||
if (Config::get('system', 'poco_local_search')) {
|
||||
$nav['searchoption'][] = t('Forums');
|
||||
|
|
@ -151,62 +151,62 @@ function nav_info(App $a)
|
|||
}
|
||||
|
||||
if (local_user() || Config::get('system', 'community_page_style') != CP_NO_COMMUNITY_PAGE) {
|
||||
$nav['community'] = array('community', t('Community'), '', t('Conversations on this and other servers'));
|
||||
$nav['community'] = ['community', t('Community'), '', t('Conversations on this and other servers')];
|
||||
}
|
||||
|
||||
if (local_user()) {
|
||||
$nav['events'] = array('events', t('Events'), '', t('Events and Calendar'));
|
||||
$nav['events'] = ['events', t('Events'), '', t('Events and Calendar')];
|
||||
}
|
||||
|
||||
$nav['directory'] = array($gdirpath, t('Directory'), '', t('People directory'));
|
||||
$nav['directory'] = [$gdirpath, t('Directory'), '', t('People directory')];
|
||||
|
||||
$nav['about'] = array('friendica', t('Information'), '', t('Information about this friendica instance'));
|
||||
$nav['about'] = ['friendica', t('Information'), '', t('Information about this friendica instance')];
|
||||
|
||||
// The following nav links are only show to logged in users
|
||||
if (local_user()) {
|
||||
$nav['network'] = array('network', t('Network'), '', t('Conversations from your friends'));
|
||||
$nav['net_reset'] = array('network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters'));
|
||||
$nav['network'] = ['network', t('Network'), '', t('Conversations from your friends')];
|
||||
$nav['net_reset'] = ['network/0?f=&order=comment&nets=all', t('Network Reset'), '', t('Load Network page with no filters')];
|
||||
|
||||
$nav['home'] = array('profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations'));
|
||||
$nav['home'] = ['profile/' . $a->user['nickname'], t('Home'), '', t('Your posts and conversations')];
|
||||
|
||||
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP))) {
|
||||
if (in_array($_SESSION['page_flags'], [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_PRVGROUP])) {
|
||||
// only show friend requests for normal pages. Other page types have automatic friendship.
|
||||
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP))) {
|
||||
$nav['introductions'] = array('notifications/intros', t('Introductions'), '', t('Friend Requests'));
|
||||
if (in_array($_SESSION['page_flags'], [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_PRVGROUP])) {
|
||||
$nav['introductions'] = ['notifications/intros', t('Introductions'), '', t('Friend Requests')];
|
||||
}
|
||||
if (in_array($_SESSION['page_flags'], array(PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE))) {
|
||||
$nav['notifications'] = array('notifications', t('Notifications'), '', t('Notifications'));
|
||||
$nav['notifications']['all'] = array('notifications/system', t('See all notifications'), '', '');
|
||||
$nav['notifications']['mark'] = array('', t('Mark as seen'), '', t('Mark all system notifications seen'));
|
||||
if (in_array($_SESSION['page_flags'], [PAGE_NORMAL, PAGE_SOAPBOX, PAGE_FREELOVE])) {
|
||||
$nav['notifications'] = ['notifications', t('Notifications'), '', t('Notifications')];
|
||||
$nav['notifications']['all'] = ['notifications/system', t('See all notifications'), '', ''];
|
||||
$nav['notifications']['mark'] = ['', t('Mark as seen'), '', t('Mark all system notifications seen')];
|
||||
}
|
||||
}
|
||||
|
||||
$nav['messages'] = array('message', t('Messages'), '', t('Private mail'));
|
||||
$nav['messages']['inbox'] = array('message', t('Inbox'), '', t('Inbox'));
|
||||
$nav['messages']['outbox'] = array('message/sent', t('Outbox'), '', t('Outbox'));
|
||||
$nav['messages']['new'] = array('message/new', t('New Message'), '', t('New Message'));
|
||||
$nav['messages'] = ['message', t('Messages'), '', t('Private mail')];
|
||||
$nav['messages']['inbox'] = ['message', t('Inbox'), '', t('Inbox')];
|
||||
$nav['messages']['outbox'] = ['message/sent', t('Outbox'), '', t('Outbox')];
|
||||
$nav['messages']['new'] = ['message/new', t('New Message'), '', t('New Message')];
|
||||
|
||||
if (is_array($a->identities) && count($a->identities) > 1) {
|
||||
$nav['manage'] = array('manage', t('Manage'), '', t('Manage other pages'));
|
||||
$nav['manage'] = ['manage', t('Manage'), '', t('Manage other pages')];
|
||||
}
|
||||
|
||||
$nav['delegations'] = array('delegate', t('Delegations'), '', t('Delegate Page Management'));
|
||||
$nav['delegations'] = ['delegate', t('Delegations'), '', t('Delegate Page Management')];
|
||||
|
||||
$nav['settings'] = array('settings', t('Settings'), '', t('Account settings'));
|
||||
$nav['settings'] = ['settings', t('Settings'), '', t('Account settings')];
|
||||
|
||||
if (Feature::isEnabled(local_user(), 'multi_profiles')) {
|
||||
$nav['profiles'] = array('profiles', t('Profiles'), '', t('Manage/Edit Profiles'));
|
||||
$nav['profiles'] = ['profiles', t('Profiles'), '', t('Manage/Edit Profiles')];
|
||||
}
|
||||
|
||||
$nav['contacts'] = array('contacts', t('Contacts'), '', t('Manage/edit friends and contacts'));
|
||||
$nav['contacts'] = ['contacts', t('Contacts'), '', t('Manage/edit friends and contacts')];
|
||||
}
|
||||
|
||||
// Show the link to the admin configuration page if user is admin
|
||||
if (is_site_admin()) {
|
||||
$nav['admin'] = array('admin/', t('Admin'), '', t('Site setup and configuration'));
|
||||
$nav['admin'] = ['admin/', t('Admin'), '', t('Site setup and configuration')];
|
||||
}
|
||||
|
||||
$nav['navigation'] = array('navigation/', t('Navigation'), '', t('Site map'));
|
||||
$nav['navigation'] = ['navigation/', t('Navigation'), '', t('Site map')];
|
||||
|
||||
// Provide a banner/logo/whatever
|
||||
$banner = Config::get('system', 'banner');
|
||||
|
|
@ -216,12 +216,12 @@ function nav_info(App $a)
|
|||
|
||||
call_hooks('nav_info', $nav);
|
||||
|
||||
return array(
|
||||
return [
|
||||
'sitelocation' => $sitelocation,
|
||||
'nav' => $nav,
|
||||
'banner' => $banner,
|
||||
'userinfo' => $userinfo,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -230,7 +230,7 @@ function nav_info(App $a)
|
|||
*/
|
||||
function nav_set_selected($item){
|
||||
$a = get_app();
|
||||
$a->nav_sel = array(
|
||||
$a->nav_sel = [
|
||||
'global' => null,
|
||||
'community' => null,
|
||||
'network' => null,
|
||||
|
|
@ -245,6 +245,6 @@ function nav_set_selected($item){
|
|||
'manage' => null,
|
||||
'events' => null,
|
||||
'register' => null,
|
||||
);
|
||||
];
|
||||
$a->nav_sel[$item] = 'selected';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ function fetch_url($url, $binary = false, &$redirects = 0, $timeout = 0, $accept
|
|||
$url,
|
||||
$binary,
|
||||
$redirects,
|
||||
array('timeout'=>$timeout,
|
||||
['timeout'=>$timeout,
|
||||
'accept_content'=>$accept_content,
|
||||
'cookiejar'=>$cookiejar
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
return($ret['body']);
|
||||
|
|
@ -63,9 +63,9 @@ function fetch_url($url, $binary = false, &$redirects = 0, $timeout = 0, $accept
|
|||
* string 'header' => HTTP headers
|
||||
* string 'body' => fetched content
|
||||
*/
|
||||
function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array())
|
||||
function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = [])
|
||||
{
|
||||
$ret = array('return_code' => 0, 'success' => false, 'header' => '', 'info' => '', 'body' => '');
|
||||
$ret = ['return_code' => 0, 'success' => false, 'header' => '', 'info' => '', 'body' => ''];
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array())
|
|||
curl_setopt(
|
||||
$ch,
|
||||
CURLOPT_HTTPHEADER,
|
||||
array('Accept: ' . $opts['accept_content'])
|
||||
['Accept: ' . $opts['accept_content']]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -213,7 +213,7 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array())
|
|||
$newurl = $new_location_info['scheme'] . '://' . $new_location_info['host'] . $old_location_info['path'];
|
||||
}
|
||||
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
|
||||
if (preg_match('/(Location:|URI:)(.*?)\n/i', $header, $matches)) {
|
||||
$newurl = trim(array_pop($matches));
|
||||
|
|
@ -306,7 +306,7 @@ function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
|
|||
|
||||
if (defined('LIGHTTPD')) {
|
||||
if (!is_array($headers)) {
|
||||
$headers = array('Expect:');
|
||||
$headers = ['Expect:'];
|
||||
} else {
|
||||
if (!in_array('Expect:', $headers)) {
|
||||
array_push($headers, 'Expect:');
|
||||
|
|
@ -361,7 +361,7 @@ function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
|
|||
}
|
||||
|
||||
if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
|
||||
$newurl = trim(array_pop($matches));
|
||||
|
||||
|
|
@ -397,7 +397,7 @@ function post_url($url, $params, $headers = null, &$redirects = 0, $timeout = 0)
|
|||
|
||||
function xml_status($st, $message = '')
|
||||
{
|
||||
$result = array('status' => $st);
|
||||
$result = ['status' => $st];
|
||||
|
||||
if ($message != '') {
|
||||
$result['message'] = $message;
|
||||
|
|
@ -409,7 +409,7 @@ function xml_status($st, $message = '')
|
|||
|
||||
header("Content-type: text/xml");
|
||||
|
||||
$xmldata = array("result" => $result);
|
||||
$xmldata = ["result" => $result];
|
||||
|
||||
echo XML::fromArray($xmldata, $xml);
|
||||
|
||||
|
|
@ -433,7 +433,7 @@ function xml_status($st, $message = '')
|
|||
* 'title' => header title
|
||||
* 'description' => optional message
|
||||
*/
|
||||
function http_status_exit($val, $description = array())
|
||||
function http_status_exit($val, $description = [])
|
||||
{
|
||||
$err = '';
|
||||
if ($val >= 400) {
|
||||
|
|
@ -452,9 +452,9 @@ function http_status_exit($val, $description = array())
|
|||
$tpl = get_markup_template('http_status.tpl');
|
||||
echo replace_macros(
|
||||
$tpl,
|
||||
array(
|
||||
[
|
||||
'$title' => $description["title"],
|
||||
'$description' => $description["description"])
|
||||
'$description' => $description["description"]]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -581,7 +581,7 @@ function blocked_url($url)
|
|||
return true;
|
||||
}
|
||||
|
||||
$domain_blocklist = Config::get('system', 'blocklist', array());
|
||||
$domain_blocklist = Config::get('system', 'blocklist', []);
|
||||
if (! $domain_blocklist) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -777,10 +777,10 @@ function fix_contact_ssl_policy(&$contact, $new_policy)
|
|||
}
|
||||
|
||||
if ($ssl_changed) {
|
||||
$fields = array('url' => $contact['url'], 'request' => $contact['request'],
|
||||
$fields = ['url' => $contact['url'], 'request' => $contact['request'],
|
||||
'notify' => $contact['notify'], 'poll' => $contact['poll'],
|
||||
'confirm' => $contact['confirm'], 'poco' => $contact['poco']);
|
||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
||||
'confirm' => $contact['confirm'], 'poco' => $contact['poco']];
|
||||
dba::update('contact', $fields, ['id' => $contact['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -801,12 +801,12 @@ function strip_tracking_query_params($url)
|
|||
foreach ($querydata as $param => $value) {
|
||||
if (in_array(
|
||||
$param,
|
||||
array(
|
||||
[
|
||||
"utm_source", "utm_medium", "utm_term", "utm_content", "utm_campaign",
|
||||
"wt_mc", "pk_campaign", "pk_kwd", "mc_cid", "mc_eid",
|
||||
"fb_action_ids", "fb_action_types", "fb_ref",
|
||||
"awesm", "wtrid",
|
||||
"woo_campaign", "woo_source", "woo_medium", "woo_content", "woo_term")
|
||||
"woo_campaign", "woo_source", "woo_medium", "woo_content", "woo_term"]
|
||||
)
|
||||
) {
|
||||
$pair = $param . "=" . urlencode($value);
|
||||
|
|
@ -820,7 +820,7 @@ function strip_tracking_query_params($url)
|
|||
$pair = $param . "=" . $value;
|
||||
$url = str_replace($pair, "", $url);
|
||||
|
||||
$url = str_replace(array("?&", "&&"), array("?", ""), $url);
|
||||
$url = str_replace(["?&", "&&"], ["?", ""], $url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -932,7 +932,7 @@ function original_url($url, $depth = 1, $fetchbody = false)
|
|||
|
||||
$list = $xpath->query("//meta[@content]");
|
||||
foreach ($list as $node) {
|
||||
$attr = array();
|
||||
$attr = [];
|
||||
if ($node->attributes->length) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
$attr[$attribute->name] = $attribute->value;
|
||||
|
|
@ -967,12 +967,12 @@ function short_link($url)
|
|||
$yourls->set('password', $yourls_password);
|
||||
$yourls->set('ssl', $yourls_ssl);
|
||||
$yourls->set('yourls-url', $yourls_url);
|
||||
$slinky->set_cascade(array($yourls, new Slinky_Ur1ca(), new Slinky_TinyURL()));
|
||||
$slinky->set_cascade([$yourls, new Slinky_Ur1ca(), new Slinky_TinyURL()]);
|
||||
} else {
|
||||
// setup a cascade of shortening services
|
||||
// try to get a short link from these services
|
||||
// in the order ur1.ca, tinyurl
|
||||
$slinky->set_cascade(array(new Slinky_Ur1ca(), new Slinky_TinyURL()));
|
||||
$slinky->set_cascade([new Slinky_Ur1ca(), new Slinky_TinyURL()]);
|
||||
}
|
||||
return $slinky->short();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ function push_lang($language) {
|
|||
if (isset($a->strings) && count($a->strings)) {
|
||||
$a->stringsave = $a->strings;
|
||||
}
|
||||
$a->strings = array();
|
||||
$a->strings = [];
|
||||
load_translation_table($language);
|
||||
$lang = $language;
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ function pop_lang() {
|
|||
if (isset($a->stringsave)) {
|
||||
$a->strings = $a->stringsave;
|
||||
} else {
|
||||
$a->strings = array();
|
||||
$a->strings = [];
|
||||
}
|
||||
|
||||
$lang = $a->langsave;
|
||||
|
|
@ -102,9 +102,9 @@ function pop_lang() {
|
|||
function load_translation_table($lang) {
|
||||
$a = get_app();
|
||||
|
||||
$a->strings = array();
|
||||
$a->strings = [];
|
||||
// load enabled plugins strings
|
||||
$plugins = dba::select('addon', array('name'), array('installed' => true));
|
||||
$plugins = dba::select('addon', ['name'], ['installed' => true]);
|
||||
while ($p = dba::fetch($plugins)) {
|
||||
$name = $p['name'];
|
||||
if (file_exists("addon/$name/lang/$lang/strings.php")) {
|
||||
|
|
@ -217,7 +217,7 @@ function string_plural_select_default($n)
|
|||
* @return array
|
||||
*/
|
||||
function get_available_languages() {
|
||||
$langs = array();
|
||||
$langs = [];
|
||||
$strings_file_paths = glob('view/lang/*/strings.php');
|
||||
|
||||
if (is_array($strings_file_paths) && count($strings_file_paths)) {
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@ require_once "include/network.php";
|
|||
*/
|
||||
function get_old_attachment_data($body) {
|
||||
|
||||
$post = array();
|
||||
$post = [];
|
||||
|
||||
// Simplify image codes
|
||||
$body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
|
||||
|
||||
if (preg_match_all("(\[class=(.*?)\](.*?)\[\/class\])ism",$body, $attached, PREG_SET_ORDER)) {
|
||||
foreach ($attached AS $data) {
|
||||
if (!in_array($data[1], array("type-link", "type-video", "type-photo")))
|
||||
if (!in_array($data[1], ["type-link", "type-video", "type-photo"]))
|
||||
continue;
|
||||
|
||||
$post["type"] = substr($data[1], 5);
|
||||
|
|
@ -63,7 +63,7 @@ function get_old_attachment_data($body) {
|
|||
$post["url"] = $matches[1];
|
||||
$post["title"] = $matches[2];
|
||||
}
|
||||
if (($post["url"] == "") && (in_array($post["type"], array("link", "video")))
|
||||
if (($post["url"] == "") && (in_array($post["type"], ["link", "video"]))
|
||||
&& preg_match("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) {
|
||||
$post["url"] = $matches[1];
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ function get_attachment_data($body)
|
|||
return $data;
|
||||
}
|
||||
|
||||
function get_attached_data($body, $item = array()) {
|
||||
function get_attached_data($body, $item = []) {
|
||||
/*
|
||||
- text:
|
||||
- type: link, video, photo
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use Friendica\Database\DBM;
|
|||
*/
|
||||
function uninstall_plugin($plugin) {
|
||||
logger("Addons: uninstalling " . $plugin);
|
||||
dba::delete('addon', array('name' => $plugin));
|
||||
dba::delete('addon', ['name' => $plugin]);
|
||||
|
||||
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
|
||||
if (function_exists($plugin . '_uninstall')) {
|
||||
|
|
@ -48,15 +48,15 @@ function install_plugin($plugin) {
|
|||
|
||||
$plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0);
|
||||
|
||||
dba::insert('addon', array('name' => $plugin, 'installed' => true,
|
||||
'timestamp' => $t, 'plugin_admin' => $plugin_admin));
|
||||
dba::insert('addon', ['name' => $plugin, 'installed' => true,
|
||||
'timestamp' => $t, 'plugin_admin' => $plugin_admin]);
|
||||
|
||||
// we can add the following with the previous SQL
|
||||
// once most site tables have been updated.
|
||||
// This way the system won't fall over dead during the update.
|
||||
|
||||
if (file_exists('addon/' . $plugin . '/.hidden')) {
|
||||
dba::update('addon', array('hidden' => true), array('name' => $plugin));
|
||||
dba::update('addon', ['hidden' => true], ['name' => $plugin]);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
|
|
@ -75,7 +75,7 @@ function reload_plugins() {
|
|||
if (DBM::is_result($r)) {
|
||||
$installed = $r;
|
||||
} else {
|
||||
$installed = array();
|
||||
$installed = [];
|
||||
}
|
||||
|
||||
$parr = explode(',',$plugins);
|
||||
|
|
@ -102,7 +102,7 @@ function reload_plugins() {
|
|||
$func = $pl . '_install';
|
||||
$func();
|
||||
}
|
||||
dba::update('addon', array('timestamp' => $t), array('id' => $i['id']));
|
||||
dba::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ function reload_plugins() {
|
|||
* @return boolean
|
||||
*/
|
||||
function plugin_enabled($plugin) {
|
||||
return dba::exists('addon', array('installed' => true, 'name' => $plugin));
|
||||
return dba::exists('addon', ['installed' => true, 'name' => $plugin]);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -133,13 +133,13 @@ function plugin_enabled($plugin) {
|
|||
* @return mixed|bool
|
||||
*/
|
||||
function register_hook($hook, $file, $function, $priority=0) {
|
||||
$condition = array('hook' => $hook, 'file' => $file, 'function' => $function);
|
||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||
$exists = dba::exists('hook', $condition);
|
||||
if ($exists) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$r = dba::insert('hook', array('hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority));
|
||||
$r = dba::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]);
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ function register_hook($hook, $file, $function, $priority=0) {
|
|||
* @return array
|
||||
*/
|
||||
function unregister_hook($hook, $file, $function) {
|
||||
$condition = array('hook' => $hook, 'file' => $file, 'function' => $function);
|
||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||
$r = dba::delete('hook', $condition);
|
||||
return $r;
|
||||
}
|
||||
|
|
@ -161,14 +161,14 @@ function unregister_hook($hook, $file, $function) {
|
|||
|
||||
function load_hooks() {
|
||||
$a = get_app();
|
||||
$a->hooks = array();
|
||||
$r = dba::select('hook', array('hook', 'file', 'function'), array(), array('order' => array('priority' => 'desc', 'file')));
|
||||
$a->hooks = [];
|
||||
$r = dba::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
|
||||
|
||||
while ($rr = dba::fetch($r)) {
|
||||
if (! array_key_exists($rr['hook'],$a->hooks)) {
|
||||
$a->hooks[$rr['hook']] = array();
|
||||
$a->hooks[$rr['hook']] = [];
|
||||
}
|
||||
$a->hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
|
||||
$a->hooks[$rr['hook']][] = [$rr['file'],$rr['function']];
|
||||
}
|
||||
dba::close($r);
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ function call_single_hook($a, $name, $hook, &$data = null) {
|
|||
$func($a, $data);
|
||||
} else {
|
||||
// remove orphan hooks
|
||||
$condition = array('hook' => $name, 'file' => $hook[0], 'function' => $hook[1]);
|
||||
$condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]];
|
||||
dba::delete('hook', $condition);
|
||||
}
|
||||
}
|
||||
|
|
@ -251,13 +251,13 @@ function get_plugin_info($plugin) {
|
|||
|
||||
$a = get_app();
|
||||
|
||||
$info=Array(
|
||||
$info=[
|
||||
'name' => $plugin,
|
||||
'description' => "",
|
||||
'author' => array(),
|
||||
'author' => [],
|
||||
'version' => "",
|
||||
'status' => ""
|
||||
);
|
||||
];
|
||||
|
||||
if (!is_file("addon/$plugin/$plugin.php")) return $info;
|
||||
|
||||
|
|
@ -277,9 +277,9 @@ function get_plugin_info($plugin) {
|
|||
if ($k == "author") {
|
||||
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||
if ($r) {
|
||||
$info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
|
||||
$info['author'][] = ['name'=>$m[1], 'link'=>$m[2]];
|
||||
} else {
|
||||
$info['author'][] = array('name'=>$v);
|
||||
$info['author'][] = ['name'=>$v];
|
||||
}
|
||||
} else {
|
||||
if (array_key_exists($k,$info)) {
|
||||
|
|
@ -312,16 +312,16 @@ function get_plugin_info($plugin) {
|
|||
*/
|
||||
|
||||
function get_theme_info($theme) {
|
||||
$info=Array(
|
||||
$info=[
|
||||
'name' => $theme,
|
||||
'description' => "",
|
||||
'author' => array(),
|
||||
'maintainer' => array(),
|
||||
'author' => [],
|
||||
'maintainer' => [],
|
||||
'version' => "",
|
||||
'credits' => "",
|
||||
'experimental' => false,
|
||||
'unsupported' => false
|
||||
);
|
||||
];
|
||||
|
||||
if (file_exists("view/theme/$theme/experimental"))
|
||||
$info['experimental'] = true;
|
||||
|
|
@ -348,16 +348,16 @@ function get_theme_info($theme) {
|
|||
|
||||
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||
if ($r) {
|
||||
$info['author'][] = array('name'=>$m[1], 'link'=>$m[2]);
|
||||
$info['author'][] = ['name'=>$m[1], 'link'=>$m[2]];
|
||||
} else {
|
||||
$info['author'][] = array('name'=>$v);
|
||||
$info['author'][] = ['name'=>$v];
|
||||
}
|
||||
} elseif ($k == "maintainer") {
|
||||
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m);
|
||||
if ($r) {
|
||||
$info['maintainer'][] = array('name'=>$m[1], 'link'=>$m[2]);
|
||||
$info['maintainer'][] = ['name'=>$m[1], 'link'=>$m[2]];
|
||||
} else {
|
||||
$info['maintainer'][] = array('name'=>$v);
|
||||
$info['maintainer'][] = ['name'=>$v];
|
||||
}
|
||||
} else {
|
||||
if (array_key_exists($k,$info)) {
|
||||
|
|
@ -381,7 +381,7 @@ function get_theme_info($theme) {
|
|||
* @return string
|
||||
*/
|
||||
function get_theme_screenshot($theme) {
|
||||
$exts = array('.png','.jpg');
|
||||
$exts = ['.png','.jpg'];
|
||||
foreach ($exts as $ext) {
|
||||
if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) {
|
||||
return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext);
|
||||
|
|
@ -450,11 +450,11 @@ function theme_include($file, $root = '') {
|
|||
$theme = current_theme();
|
||||
$thname = $theme;
|
||||
$ext = substr($file,strrpos($file,'.')+1);
|
||||
$paths = array(
|
||||
$paths = [
|
||||
"{$root}view/theme/$thname/$ext/$file",
|
||||
"{$root}view/theme/$parent/$ext/$file",
|
||||
"{$root}view/$ext/$file",
|
||||
);
|
||||
];
|
||||
foreach ($paths as $p) {
|
||||
// strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php)
|
||||
if (strpos($p,'NOPATH') !== false) {
|
||||
|
|
|
|||
|
|
@ -64,18 +64,18 @@ function post_update_1192() {
|
|||
return false;
|
||||
}
|
||||
|
||||
$item_arr = array();
|
||||
$item_arr = [];
|
||||
foreach ($r AS $item) {
|
||||
$index = $item["author-link"]."-".$item["uid"];
|
||||
$item_arr[$index] = array("author-link" => $item["author-link"],
|
||||
$item_arr[$index] = ["author-link" => $item["author-link"],
|
||||
"uid" => $item["uid"],
|
||||
"network" => $item["network"]);
|
||||
"network" => $item["network"]];
|
||||
}
|
||||
|
||||
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed
|
||||
foreach ($item_arr AS $item) {
|
||||
$gcontact_id = GContact::getId(array("url" => $item['author-link'], "network" => $item['network'],
|
||||
"photo" => $item['author-avatar'], "name" => $item['author-name']));
|
||||
$gcontact_id = GContact::getId(["url" => $item['author-link'], "network" => $item['network'],
|
||||
"photo" => $item['author-avatar'], "name" => $item['author-name']]);
|
||||
q("UPDATE `item` SET `gcontact-id` = %d WHERE `uid` = %d AND `author-link` = '%s' AND `gcontact-id` = 0",
|
||||
intval($gcontact_id), intval($item["uid"]), dbesc($item["author-link"]));
|
||||
}
|
||||
|
|
@ -200,12 +200,12 @@ function post_update_1198() {
|
|||
|
||||
logger("Query done", LOGGER_DEBUG);
|
||||
|
||||
$item_arr = array();
|
||||
$item_arr = [];
|
||||
foreach ($r AS $item) {
|
||||
$index = $item["author-link"]."-".$item["owner-link"]."-".$item["uid"];
|
||||
$item_arr[$index] = array("author-link" => $item["author-link"],
|
||||
$item_arr[$index] = ["author-link" => $item["author-link"],
|
||||
"owner-link" => $item["owner-link"],
|
||||
"uid" => $item["uid"]);
|
||||
"uid" => $item["uid"]];
|
||||
}
|
||||
|
||||
// Set the "gcontact-id" in the item table and add a new gcontact entry if needed
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ function update_queue_time($id) {
|
|||
|
||||
function remove_queue_item($id) {
|
||||
logger('queue: remove queue item ' . $id);
|
||||
dba::delete('queue', array('id' => $id));
|
||||
dba::delete('queue', ['id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@ function cookie_hash($user)
|
|||
* @param int $time
|
||||
* @param array $user Record from "user" table
|
||||
*/
|
||||
function new_cookie($time, $user = array())
|
||||
function new_cookie($time, $user = [])
|
||||
{
|
||||
if ($time != 0) {
|
||||
$time = $time + time();
|
||||
}
|
||||
|
||||
if ($user) {
|
||||
$value = json_encode(array("uid" => $user["uid"],
|
||||
$value = json_encode(["uid" => $user["uid"],
|
||||
"hash" => cookie_hash($user),
|
||||
"ip" => $_SERVER['REMOTE_ADDR']));
|
||||
"ip" => $_SERVER['REMOTE_ADDR']]);
|
||||
} else {
|
||||
$value = "";
|
||||
}
|
||||
|
|
@ -102,12 +102,12 @@ function authenticate_success($user_record, $login_initial = false, $interactive
|
|||
}
|
||||
}
|
||||
|
||||
$r = dba::select('user', array('uid', 'username', 'nickname'),
|
||||
array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false));
|
||||
$r = dba::select('user', ['uid', 'username', 'nickname'],
|
||||
['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
|
||||
if (DBM::is_result($r)) {
|
||||
$a->identities = dba::inArray($r);
|
||||
} else {
|
||||
$a->identities = array();
|
||||
$a->identities = [];
|
||||
}
|
||||
|
||||
$r = dba::p("SELECT `user`.`uid`, `user`.`username`, `user`.`nickname`
|
||||
|
|
@ -137,11 +137,11 @@ function authenticate_success($user_record, $login_initial = false, $interactive
|
|||
header('X-Account-Management-Status: active; name="' . $a->user['username'] . '"; id="' . $a->user['nickname'] . '"');
|
||||
|
||||
if ($login_initial || $login_refresh) {
|
||||
dba::update('user', array('login_date' => datetime_convert()), array('uid' => $_SESSION['uid']));
|
||||
dba::update('user', ['login_date' => datetime_convert()], ['uid' => $_SESSION['uid']]);
|
||||
|
||||
// Set the login date for all identities of the user
|
||||
dba::update('user', array('login_date' => datetime_convert()),
|
||||
array('password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false));
|
||||
dba::update('user', ['login_date' => datetime_convert()],
|
||||
['password' => $master_record['password'], 'email' => $master_record['email'], 'account_removed' => false]);
|
||||
}
|
||||
|
||||
if ($login_initial) {
|
||||
|
|
|
|||
|
|
@ -80,11 +80,11 @@ function ref_session_write($id, $data)
|
|||
}
|
||||
|
||||
if ($session_exists) {
|
||||
$fields = array('data' => $data, 'expire' => $expire);
|
||||
$condition = array("`sid` = ? AND (`data` != ? OR `expire` != ?)", $id, $data, $expire);
|
||||
$fields = ['data' => $data, 'expire' => $expire];
|
||||
$condition = ["`sid` = ? AND (`data` != ? OR `expire` != ?)", $id, $data, $expire];
|
||||
dba::update('session', $fields, $condition);
|
||||
} else {
|
||||
$fields = array('sid' => $id, 'expire' => $default_expire, 'data' => $data);
|
||||
$fields = ['sid' => $id, 'expire' => $default_expire, 'data' => $data];
|
||||
dba::insert('session', $fields);
|
||||
}
|
||||
|
||||
|
|
@ -105,13 +105,13 @@ function ref_session_destroy($id)
|
|||
return true;
|
||||
}
|
||||
|
||||
dba::delete('session', array('sid' => $id));
|
||||
dba::delete('session', ['sid' => $id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
function ref_session_gc()
|
||||
{
|
||||
dba::delete('session', array("`expire` < ?", time()));
|
||||
dba::delete('session', ["`expire` < ?", time()]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ function create_tags_from_item($itemid)
|
|||
// ignore anything in a code block
|
||||
$data = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $data);
|
||||
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
|
||||
$pattern = '/\W\#([^\[].*?)[\s\'".,:;\?!\[\]\/]/ism';
|
||||
if (preg_match_all($pattern, $data, $matches)) {
|
||||
|
|
@ -204,7 +204,7 @@ function tagadelic($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
|
|||
TERM_OBJ_POST
|
||||
);
|
||||
if (!DBM::is_result($r)) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
return tag_calc($r);
|
||||
|
|
@ -238,10 +238,10 @@ function wtagblock($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
|
|||
}
|
||||
|
||||
$tpl = get_markup_template('tagblock_widget.tpl');
|
||||
$o = replace_macros($tpl, array(
|
||||
$o = replace_macros($tpl, [
|
||||
'$title' => t('Tags'),
|
||||
'$tags' => $tags
|
||||
));
|
||||
]);
|
||||
}
|
||||
return $o;
|
||||
}
|
||||
|
|
@ -254,13 +254,13 @@ function wtagblock($uid, $count = 0, $owner_id = 0, $flags = '', $type = TERM_HA
|
|||
*/
|
||||
function tag_calc($arr)
|
||||
{
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
$min = 1e9;
|
||||
$max = -1e9;
|
||||
$x = 0;
|
||||
|
||||
if (!$arr) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach ($arr as $rr) {
|
||||
|
|
|
|||
170
include/text.php
170
include/text.php
|
|
@ -83,7 +83,7 @@ function random_string($size = 64)
|
|||
* @return string Filtered string
|
||||
*/
|
||||
function notags($string) {
|
||||
return str_replace(array("<", ">"), array('[', ']'), $string);
|
||||
return str_replace(["<", ">"], ['[', ']'], $string);
|
||||
|
||||
// High-bit filter no longer used
|
||||
// return str_replace(array("<",">","\xBA","\xBC","\xBE"), array('[',']','','',''), $string);
|
||||
|
|
@ -113,12 +113,12 @@ function autoname($len) {
|
|||
return '';
|
||||
}
|
||||
|
||||
$vowels = array('a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u');
|
||||
$vowels = ['a','a','ai','au','e','e','e','ee','ea','i','ie','o','ou','u'];
|
||||
if (mt_rand(0, 5) == 4) {
|
||||
$vowels[] = 'y';
|
||||
}
|
||||
|
||||
$cons = array(
|
||||
$cons = [
|
||||
'b','bl','br',
|
||||
'c','ch','cl','cr',
|
||||
'd','dr',
|
||||
|
|
@ -139,13 +139,13 @@ function autoname($len) {
|
|||
'w','wh',
|
||||
'x',
|
||||
'z','zh'
|
||||
);
|
||||
];
|
||||
|
||||
$midcons = array('ck','ct','gn','ld','lf','lm','lt','mb','mm', 'mn','mp',
|
||||
'nd','ng','nk','nt','rn','rp','rt');
|
||||
$midcons = ['ck','ct','gn','ld','lf','lm','lt','mb','mm', 'mn','mp',
|
||||
'nd','ng','nk','nt','rn','rp','rt'];
|
||||
|
||||
$noend = array('bl', 'br', 'cl','cr','dr','fl','fr','gl','gr',
|
||||
'kh', 'kl','kr','mn','pl','pr','rh','tr','qu','wh');
|
||||
$noend = ['bl', 'br', 'cl','cr','dr','fl','fr','gl','gr',
|
||||
'kh', 'kl','kr','mn','pl','pr','rh','tr','qu','wh'];
|
||||
|
||||
$start = mt_rand(0,2);
|
||||
if ($start == 0) {
|
||||
|
|
@ -280,14 +280,14 @@ function paginate_data(App $a, $count = null) {
|
|||
}
|
||||
|
||||
$url = $stripped;
|
||||
$data = array();
|
||||
$data = [];
|
||||
|
||||
function _l(&$d, $name, $url, $text, $class = '') {
|
||||
if (strpos($url, '?') === false && ($pos = strpos($url, '&')) !== false) {
|
||||
$url = substr($url, 0, $pos) . '?' . substr($url, $pos + 1);
|
||||
}
|
||||
|
||||
$d[$name] = array('url' => $url, 'text' => $text, 'class' => $class);
|
||||
$d[$name] = ['url' => $url, 'text' => $text, 'class' => $class];
|
||||
}
|
||||
|
||||
if (!is_null($count)) {
|
||||
|
|
@ -313,7 +313,7 @@ function paginate_data(App $a, $count = null) {
|
|||
$numstop = (($pagenum > ($numpages - 7)) ? $numpages : ($numstart + 8));
|
||||
}
|
||||
|
||||
$pages = array();
|
||||
$pages = [];
|
||||
|
||||
for ($i = $numstart; $i <= $numstop; $i++) {
|
||||
if ($i == $a->pager['page']) {
|
||||
|
|
@ -362,7 +362,7 @@ function paginate(App $a) {
|
|||
|
||||
$data = paginate_data($a);
|
||||
$tpl = get_markup_template("paginate.tpl");
|
||||
return replace_macros($tpl, array("pager" => $data));
|
||||
return replace_macros($tpl, ["pager" => $data]);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ function alt_pager(App $a, $i) {
|
|||
|
||||
$data = paginate_data($a, $i);
|
||||
$tpl = get_markup_template("paginate.tpl");
|
||||
return replace_macros($tpl, array('pager' => $data));
|
||||
return replace_macros($tpl, ['pager' => $data]);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -388,10 +388,10 @@ function alt_pager(App $a, $i) {
|
|||
*/
|
||||
function scroll_loader() {
|
||||
$tpl = get_markup_template("scroll_loader.tpl");
|
||||
return replace_macros($tpl, array(
|
||||
return replace_macros($tpl, [
|
||||
'wait' => t('Loading more entries...'),
|
||||
'end' => t('The end')
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -404,7 +404,7 @@ function scroll_loader() {
|
|||
function expand_acl($s) {
|
||||
// turn string array of angle-bracketed elements into numeric array
|
||||
// e.g. "<1><2><3>" => array(1,2,3);
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
|
||||
if (strlen($s)) {
|
||||
$t = str_replace('<', '', $s);
|
||||
|
|
@ -477,7 +477,7 @@ function item_new_uri($hostname, $uid, $guid = "") {
|
|||
|
||||
$uri = "urn:X-dfrn:" . $hostname . ':' . $uid . ':' . $hash;
|
||||
|
||||
$dups = dba::exists('item', array('uri' => $uri));
|
||||
$dups = dba::exists('item', ['uri' => $uri]);
|
||||
} while ($dups == true);
|
||||
|
||||
return $uri;
|
||||
|
|
@ -663,7 +663,7 @@ function attribute_contains($attr, $s) {
|
|||
|
||||
|
||||
/* setup int->string log level map */
|
||||
$LOGGER_LEVELS = array();
|
||||
$LOGGER_LEVELS = [];
|
||||
|
||||
/**
|
||||
* @brief Logs the given message at the given log level
|
||||
|
|
@ -825,7 +825,7 @@ function activity_match($haystack,$needle) {
|
|||
* @return array List of tag and person names
|
||||
*/
|
||||
function get_tags($string) {
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
|
||||
// Convert hashtag links to hashtags
|
||||
$string = preg_replace('/#\[url\=([^\[\]]*)\](.*?)\[\/url\]/ism', '#$2', $string);
|
||||
|
|
@ -834,7 +834,7 @@ function get_tags($string) {
|
|||
$string = preg_replace('/\[code\](.*?)\[\/code\]/sm', '', $string);
|
||||
|
||||
// Force line feeds at bbtags
|
||||
$string = str_replace(array('[', ']'), array("\n[", "]\n"), $string);
|
||||
$string = str_replace(['[', ']'], ["\n[", "]\n"], $string);
|
||||
|
||||
// ignore anything in a bbtag
|
||||
$string = preg_replace('/\[(.*?)\]/sm', '', $string);
|
||||
|
|
@ -942,7 +942,7 @@ function contact_block() {
|
|||
intval($shown)
|
||||
);
|
||||
if (DBM::is_result($r)) {
|
||||
$contacts = array();
|
||||
$contacts = [];
|
||||
foreach ($r AS $contact) {
|
||||
$contacts[] = $contact["id"];
|
||||
}
|
||||
|
|
@ -951,7 +951,7 @@ function contact_block() {
|
|||
|
||||
if (DBM::is_result($r)) {
|
||||
$contacts = sprintf(tt('%d Contact','%d Contacts', $total),$total);
|
||||
$micropro = Array();
|
||||
$micropro = [];
|
||||
foreach ($r as $rr) {
|
||||
$micropro[] = micropro($rr,true,'mpfriend');
|
||||
}
|
||||
|
|
@ -960,14 +960,14 @@ function contact_block() {
|
|||
}
|
||||
|
||||
$tpl = get_markup_template('contact_block.tpl');
|
||||
$o = replace_macros($tpl, array(
|
||||
$o = replace_macros($tpl, [
|
||||
'$contacts' => $contacts,
|
||||
'$nickname' => $a->profile['nickname'],
|
||||
'$viewcontacts' => t('View Contacts'),
|
||||
'$micropro' => $micropro,
|
||||
));
|
||||
]);
|
||||
|
||||
$arr = array('contacts' => $r, 'output' => $o);
|
||||
$arr = ['contacts' => $r, 'output' => $o];
|
||||
|
||||
call_hooks('contact_block_end', $arr);
|
||||
return $o;
|
||||
|
|
@ -1021,7 +1021,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
|
|||
$url = '';
|
||||
}
|
||||
|
||||
return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),array(
|
||||
return replace_macros(get_markup_template(($textmode)?'micropro_txt.tpl':'micropro_img.tpl'),[
|
||||
'$click' => defaults($contact, 'click', ''),
|
||||
'$class' => $class,
|
||||
'$url' => $url,
|
||||
|
|
@ -1031,7 +1031,7 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
|
|||
'$parkle' => $sparkle,
|
||||
'$redir' => $redir,
|
||||
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1054,7 +1054,7 @@ function search($s, $id = 'search-box', $url = 'search', $save = false, $aside =
|
|||
}
|
||||
$save_label = $mode === 'text' ? t('Save') : t('Follow');
|
||||
|
||||
$values = array(
|
||||
$values = [
|
||||
'$s' => htmlspecialchars($s),
|
||||
'$id' => $id,
|
||||
'$action_url' => $url,
|
||||
|
|
@ -1063,13 +1063,13 @@ function search($s, $id = 'search-box', $url = 'search', $save = false, $aside =
|
|||
'$savedsearch' => Feature::isEnabled(local_user(),'savedsearch'),
|
||||
'$search_hint' => t('@name, !forum, #tags, content'),
|
||||
'$mode' => $mode
|
||||
);
|
||||
];
|
||||
|
||||
if (!$aside) {
|
||||
$values['$searchoption'] = array(
|
||||
$values['$searchoption'] = [
|
||||
t("Full Text"),
|
||||
t("Tags"),
|
||||
t("Contacts"));
|
||||
t("Contacts")];
|
||||
|
||||
if (Config::get('system','poco_local_search')) {
|
||||
$values['$searchoption'][] = t("Forums");
|
||||
|
|
@ -1115,14 +1115,14 @@ function get_poke_verbs() {
|
|||
// index is present tense verb
|
||||
// value is array containing past tense verb, translation of present, translation of past
|
||||
|
||||
$arr = array(
|
||||
'poke' => array('poked', t('poke'), t('poked')),
|
||||
'ping' => array('pinged', t('ping'), t('pinged')),
|
||||
'prod' => array('prodded', t('prod'), t('prodded')),
|
||||
'slap' => array('slapped', t('slap'), t('slapped')),
|
||||
'finger' => array('fingered', t('finger'), t('fingered')),
|
||||
'rebuff' => array('rebuffed', t('rebuff'), t('rebuffed')),
|
||||
);
|
||||
$arr = [
|
||||
'poke' => ['poked', t('poke'), t('poked')],
|
||||
'ping' => ['pinged', t('ping'), t('pinged')],
|
||||
'prod' => ['prodded', t('prod'), t('prodded')],
|
||||
'slap' => ['slapped', t('slap'), t('slapped')],
|
||||
'finger' => ['fingered', t('finger'), t('fingered')],
|
||||
'rebuff' => ['rebuffed', t('rebuff'), t('rebuffed')],
|
||||
];
|
||||
call_hooks('poke_verbs', $arr);
|
||||
return $arr;
|
||||
}
|
||||
|
|
@ -1134,12 +1134,12 @@ function get_poke_verbs() {
|
|||
* @return string Translated string.
|
||||
*/
|
||||
function day_translate($s) {
|
||||
$ret = str_replace(array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'),
|
||||
array(t('Monday'), t('Tuesday'), t('Wednesday'), t('Thursday'), t('Friday'), t('Saturday'), t('Sunday')),
|
||||
$ret = str_replace(['Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'],
|
||||
[t('Monday'), t('Tuesday'), t('Wednesday'), t('Thursday'), t('Friday'), t('Saturday'), t('Sunday')],
|
||||
$s);
|
||||
|
||||
$ret = str_replace(array('January','February','March','April','May','June','July','August','September','October','November','December'),
|
||||
array(t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December')),
|
||||
$ret = str_replace(['January','February','March','April','May','June','July','August','September','October','November','December'],
|
||||
[t('January'), t('February'), t('March'), t('April'), t('May'), t('June'), t('July'), t('August'), t('September'), t('October'), t('November'), t('December')],
|
||||
$ret);
|
||||
|
||||
return $ret;
|
||||
|
|
@ -1152,11 +1152,11 @@ function day_translate($s) {
|
|||
* @return string Translated string.
|
||||
*/
|
||||
function day_short_translate($s) {
|
||||
$ret = str_replace(array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'),
|
||||
array(t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'), t('Sun')),
|
||||
$ret = str_replace(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
[t('Mon'), t('Tue'), t('Wed'), t('Thu'), t('Fri'), t('Sat'), t('Sun')],
|
||||
$s);
|
||||
$ret = str_replace(array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov','Dec'),
|
||||
array(t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), ('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec')),
|
||||
$ret = str_replace(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov','Dec'],
|
||||
[t('Jan'), t('Feb'), t('Mar'), t('Apr'), t('May'), ('Jun'), t('Jul'), t('Aug'), t('Sep'), t('Oct'), t('Nov'), t('Dec')],
|
||||
$ret);
|
||||
return $ret;
|
||||
}
|
||||
|
|
@ -1169,7 +1169,7 @@ function day_short_translate($s) {
|
|||
* @return string
|
||||
*/
|
||||
function normalise_link($url) {
|
||||
$ret = str_replace(array('https:', '//www.'), array('http:', '//'), $url);
|
||||
$ret = str_replace(['https:', '//www.'], ['http:', '//'], $url);
|
||||
return rtrim($ret,'/');
|
||||
}
|
||||
|
||||
|
|
@ -1235,8 +1235,8 @@ function put_item_in_cache(&$item, $update = false)
|
|||
$item["body"] = $body;
|
||||
|
||||
if ($update && ($item["id"] > 0)) {
|
||||
dba::update('item', array('rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]),
|
||||
array('id' => $item["id"]), false);
|
||||
dba::update('item', ['rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]],
|
||||
['id' => $item["id"]], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1259,9 +1259,9 @@ function prepare_body(&$item, $attach = false, $preview = false) {
|
|||
|
||||
$searchpath = System::baseUrl() . "/search?tag=";
|
||||
|
||||
$tags = array();
|
||||
$hashtags = array();
|
||||
$mentions = array();
|
||||
$tags = [];
|
||||
$hashtags = [];
|
||||
$mentions = [];
|
||||
|
||||
// In order to provide theme developers more possibilities, event items
|
||||
// are treated differently.
|
||||
|
|
@ -1313,14 +1313,14 @@ function prepare_body(&$item, $attach = false, $preview = false) {
|
|||
put_item_in_cache($item, $update);
|
||||
$s = $item["rendered-html"];
|
||||
|
||||
$prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview);
|
||||
$prep_arr = ['item' => $item, 'html' => $s, 'preview' => $preview];
|
||||
call_hooks('prepare_body', $prep_arr);
|
||||
$s = $prep_arr['html'];
|
||||
|
||||
if (! $attach) {
|
||||
// Replace the blockquotes with quotes that are used in mails.
|
||||
$mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">';
|
||||
$s = str_replace(array('<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'), array($mailquote, $mailquote, $mailquote), $s);
|
||||
$s = str_replace(['<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'], [$mailquote, $mailquote, $mailquote], $s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
|
|
@ -1345,23 +1345,23 @@ function prepare_body(&$item, $attach = false, $preview = false) {
|
|||
if (strpos($mime, 'video') !== false) {
|
||||
if (!$vhead) {
|
||||
$vhead = true;
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), array(
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template('videos_head.tpl'), [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
));
|
||||
$a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), array(
|
||||
]);
|
||||
$a->page['end'] .= replace_macros(get_markup_template('videos_end.tpl'), [
|
||||
'$baseurl' => System::baseUrl(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
$id = end(explode('/', $the_url));
|
||||
$as .= replace_macros(get_markup_template('video_top.tpl'), array(
|
||||
'$video' => array(
|
||||
$as .= replace_macros(get_markup_template('video_top.tpl'), [
|
||||
'$video' => [
|
||||
'id' => $id,
|
||||
'title' => t('View Video'),
|
||||
'src' => $the_url,
|
||||
'mime' => $mime,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
$filetype = strtolower(substr($mime, 0, strpos($mime, '/')));
|
||||
|
|
@ -1431,7 +1431,7 @@ function prepare_body(&$item, $attach = false, $preview = false) {
|
|||
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
|
||||
}
|
||||
|
||||
$prep_arr = array('item' => $item, 'html' => $s);
|
||||
$prep_arr = ['item' => $item, 'html' => $s];
|
||||
call_hooks('prepare_body_final', $prep_arr);
|
||||
|
||||
return $prep_arr['html'];
|
||||
|
|
@ -1485,21 +1485,21 @@ function prepare_text($text) {
|
|||
*/
|
||||
function get_cats_and_terms($item)
|
||||
{
|
||||
$categories = array();
|
||||
$folders = array();
|
||||
$categories = [];
|
||||
$folders = [];
|
||||
|
||||
$matches = false;
|
||||
$first = true;
|
||||
$cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
$categories[] = array(
|
||||
$categories[] = [
|
||||
'name' => xmlify(file_tag_decode($mtch[1])),
|
||||
'url' => "#",
|
||||
'removeurl' => ((local_user() == $item['uid'])?'filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""),
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
);
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1514,13 +1514,13 @@ function get_cats_and_terms($item)
|
|||
$cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
|
||||
if ($cnt) {
|
||||
foreach ($matches as $mtch) {
|
||||
$folders[] = array(
|
||||
$folders[] = [
|
||||
'name' => xmlify(file_tag_decode($mtch[1])),
|
||||
'url' => "#",
|
||||
'removeurl' => ((local_user() == $item['uid']) ? 'filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])) : ""),
|
||||
'first' => $first,
|
||||
'last' => false
|
||||
);
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -1530,7 +1530,7 @@ function get_cats_and_terms($item)
|
|||
$folders[count($folders) - 1]['last'] = true;
|
||||
}
|
||||
|
||||
return array($categories, $folders);
|
||||
return [$categories, $folders];
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1543,13 +1543,13 @@ function get_plink($item) {
|
|||
$a = get_app();
|
||||
|
||||
if ($a->user['nickname'] != "") {
|
||||
$ret = array(
|
||||
$ret = [
|
||||
//'href' => "display/" . $a->user['nickname'] . "/" . $item['id'],
|
||||
'href' => "display/" . $item['guid'],
|
||||
'orig' => "display/" . $item['guid'],
|
||||
'title' => t('View on separate page'),
|
||||
'orig_title' => t('view on separate page'),
|
||||
);
|
||||
];
|
||||
|
||||
if (x($item, 'plink')) {
|
||||
$ret["href"] = $a->remove_baseurl($item['plink']);
|
||||
|
|
@ -1557,13 +1557,13 @@ function get_plink($item) {
|
|||
}
|
||||
|
||||
} elseif (x($item, 'plink') && ($item['private'] != 1)) {
|
||||
$ret = array(
|
||||
$ret = [
|
||||
'href' => $item['plink'],
|
||||
'orig' => $item['plink'],
|
||||
'title' => t('link to source'),
|
||||
);
|
||||
];
|
||||
} else {
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
|
@ -1780,11 +1780,11 @@ function item_post_type($item) {
|
|||
// To do this we need to escape these characters if they appear in our tag.
|
||||
|
||||
function file_tag_encode($s) {
|
||||
return str_replace(array('<','>','[',']'),array('%3c','%3e','%5b','%5d'),$s);
|
||||
return str_replace(['<','>','[',']'],['%3c','%3e','%5b','%5d'],$s);
|
||||
}
|
||||
|
||||
function file_tag_decode($s) {
|
||||
return str_replace(array('%3c', '%3e', '%5b', '%5d'), array('<', '>', '[', ']'), $s);
|
||||
return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s);
|
||||
}
|
||||
|
||||
function file_tag_file_query($table,$s,$type = 'file') {
|
||||
|
|
@ -1866,7 +1866,7 @@ function file_tag_update_pconfig($uid, $file_old, $file_new, $type = 'file') {
|
|||
$filetags_updated = $saved;
|
||||
|
||||
// check for new tags to be added as filetags in pconfig
|
||||
$new_tags = array();
|
||||
$new_tags = [];
|
||||
$check_new_tags = explode(",",file_tag_file_to_list($file_new,$type));
|
||||
|
||||
foreach ($check_new_tags as $tag) {
|
||||
|
|
@ -1877,7 +1877,7 @@ function file_tag_update_pconfig($uid, $file_old, $file_new, $type = 'file') {
|
|||
$filetags_updated .= file_tag_list_to_file(implode(",",$new_tags),$type);
|
||||
|
||||
// check for deleted tags to be removed from filetags in pconfig
|
||||
$deleted_tags = array();
|
||||
$deleted_tags = [];
|
||||
$check_deleted_tags = explode(",",file_tag_file_to_list($file_old,$type));
|
||||
|
||||
foreach ($check_deleted_tags as $tag) {
|
||||
|
|
@ -1984,7 +1984,7 @@ function file_tag_unsave_file($uid, $item, $file, $cat = false)
|
|||
}
|
||||
|
||||
function normalise_openid($s) {
|
||||
return trim(str_replace(array('http://', 'https://'), array('', ''), $s), '/');
|
||||
return trim(str_replace(['http://', 'https://'], ['', ''], $s), '/');
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2023,7 +2023,7 @@ function is_a_date_arg($s) {
|
|||
function deindent($text, $chr = "[\t ]", $count = NULL) {
|
||||
$lines = explode("\n", $text);
|
||||
if (is_null($count)) {
|
||||
$m = array();
|
||||
$m = [];
|
||||
$k = 0;
|
||||
while ($k < count($lines) && strlen($lines[$k]) == 0) {
|
||||
$k++;
|
||||
|
|
@ -2039,7 +2039,7 @@ function deindent($text, $chr = "[\t ]", $count = NULL) {
|
|||
}
|
||||
|
||||
function formatBytes($bytes, $precision = 2) {
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB');
|
||||
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
||||
|
||||
$bytes = max($bytes, 0);
|
||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
|
||||
|
|
@ -2087,10 +2087,10 @@ function text_highlight($s, $lang) {
|
|||
// Autoload the library to make constants available
|
||||
class_exists('Text_Highlighter_Renderer_Html');
|
||||
|
||||
$options = array(
|
||||
$options = [
|
||||
'numbers' => HL_NUMBERS_LI,
|
||||
'tabsize' => 4,
|
||||
);
|
||||
];
|
||||
|
||||
$tag_added = false;
|
||||
$s = trim(html_entity_decode($s, ENT_COMPAT));
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ function add_shadow_thread($itemid) {
|
|||
}
|
||||
|
||||
// is it an entry from a connector? Only add an entry for natively connected networks
|
||||
if (!in_array($item["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""))) {
|
||||
if (!in_array($item["network"], [NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS, ""])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ function add_shadow_thread($itemid) {
|
|||
$item[0]['wall'] = 0;
|
||||
$item[0]['contact-id'] = Contact::getIdForURL($item[0]['author-link'], 0);
|
||||
|
||||
if (in_array($item[0]['type'], array("net-comment", "wall-comment"))) {
|
||||
if (in_array($item[0]['type'], ["net-comment", "wall-comment"])) {
|
||||
$item[0]['type'] = 'remote-comment';
|
||||
} elseif ($item[0]['type'] == 'wall') {
|
||||
$item[0]['type'] = 'remote';
|
||||
|
|
@ -165,7 +165,7 @@ function add_shadow_entry($itemid) {
|
|||
$item['wall'] = 0;
|
||||
$item['contact-id'] = Contact::getIdForURL($item['author-link'], 0);
|
||||
|
||||
if (in_array($item['type'], array("net-comment", "wall-comment"))) {
|
||||
if (in_array($item['type'], ["net-comment", "wall-comment"])) {
|
||||
$item['type'] = 'remote-comment';
|
||||
} elseif ($item['type'] == 'wall') {
|
||||
$item['type'] = 'remote';
|
||||
|
|
@ -203,7 +203,7 @@ function update_thread($itemid, $setmention = false) {
|
|||
$sql = "";
|
||||
|
||||
foreach ($item AS $field => $data)
|
||||
if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) {
|
||||
if (!in_array($field, ["guid", "title", "body", "rendered-html", "rendered-hash"])) {
|
||||
if ($sql != "") {
|
||||
$sql .= ", ";
|
||||
}
|
||||
|
|
@ -261,7 +261,7 @@ function delete_thread($itemid, $itemuri = "") {
|
|||
intval($item["uid"])
|
||||
);
|
||||
if (!DBM::is_result($r)) {
|
||||
dba::delete('item', array('uri' => $itemuri, 'uid' => 0));
|
||||
dba::delete('item', ['uri' => $itemuri, 'uid' => 0]);
|
||||
logger("delete_thread: Deleted shadow for item ".$itemuri, LOGGER_DEBUG);
|
||||
}
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ function delete_thread($itemid, $itemuri = "") {
|
|||
function update_threads() {
|
||||
logger("update_threads: start");
|
||||
|
||||
$messages = dba::select('item', array('id'), array("`id` = `parent`"));
|
||||
$messages = dba::select('item', ['id'], ["`id` = `parent`"]);
|
||||
|
||||
logger("update_threads: fetched messages: ".dba::num_rows($messages));
|
||||
|
||||
|
|
@ -301,8 +301,8 @@ function update_shadow_copy() {
|
|||
logger("start");
|
||||
|
||||
$condition = "`uid` != 0 AND `network` IN ('', ?, ?, ?) AND `visible` AND NOT `deleted` AND NOT `moderated` AND NOT `private`";
|
||||
$messages = dba::select('thread', array('iid'), array($condition, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS),
|
||||
array('order' => 'created'));
|
||||
$messages = dba::select('thread', ['iid'], [$condition, NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS],
|
||||
['order' => 'created']);
|
||||
|
||||
logger("fetched messages: ".dba::num_rows($messages));
|
||||
while ($message = dba::fetch($messages))
|
||||
|
|
|
|||
22
index.php
22
index.php
|
|
@ -163,16 +163,16 @@ $a->page['end'] = '';
|
|||
|
||||
|
||||
if (! x($_SESSION, 'sysmsg')) {
|
||||
$_SESSION['sysmsg'] = array();
|
||||
$_SESSION['sysmsg'] = [];
|
||||
}
|
||||
|
||||
if (! x($_SESSION, 'sysmsg_info')) {
|
||||
$_SESSION['sysmsg_info'] = array();
|
||||
$_SESSION['sysmsg_info'] = [];
|
||||
}
|
||||
|
||||
// Array for informations about last received items
|
||||
if (! x($_SESSION, 'last_updated')) {
|
||||
$_SESSION['last_updated'] = array();
|
||||
$_SESSION['last_updated'] = [];
|
||||
}
|
||||
/*
|
||||
* check_config() is responsible for running update scripts. These automatically
|
||||
|
|
@ -197,7 +197,7 @@ nav_set_selected('nothing');
|
|||
//Don't populate apps_menu if apps are private
|
||||
$privateapps = Config::get('config', 'private_addons');
|
||||
if ((local_user()) || (! $privateapps === "1")) {
|
||||
$arr = array('app_menu' => $a->apps);
|
||||
$arr = ['app_menu' => $a->apps];
|
||||
|
||||
call_hooks('app_menu', $arr);
|
||||
|
||||
|
|
@ -294,8 +294,8 @@ if (strlen($a->module)) {
|
|||
$tpl = get_markup_template("404.tpl");
|
||||
$a->page['content'] = replace_macros(
|
||||
$tpl,
|
||||
array(
|
||||
'$message' => t('Page not found.'))
|
||||
[
|
||||
'$message' => t('Page not found.')]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -362,14 +362,14 @@ if ($a->module_loaded) {
|
|||
}
|
||||
|
||||
if (! $a->error) {
|
||||
$arr = array('content' => $a->page['content']);
|
||||
$arr = ['content' => $a->page['content']];
|
||||
call_hooks($a->module . '_mod_content', $arr);
|
||||
$a->page['content'] = $arr['content'];
|
||||
if ($a->module_class) {
|
||||
$arr = array('content' => call_user_func([$a->module_class, 'content']));
|
||||
$arr = ['content' => call_user_func([$a->module_class, 'content'])];
|
||||
} else if (function_exists($a->module . '_content')) {
|
||||
$func = $a->module . '_content';
|
||||
$arr = array('content' => $func($a));
|
||||
$arr = ['content' => $func($a)];
|
||||
}
|
||||
call_hooks($a->module . '_mod_aftercontent', $arr);
|
||||
$a->page['content'] .= $arr['content'];
|
||||
|
|
@ -440,9 +440,9 @@ if ($a->is_mobile || $a->is_tablet) {
|
|||
}
|
||||
$a->page['footer'] = replace_macros(
|
||||
get_markup_template("toggle_mobile_footer.tpl"),
|
||||
array(
|
||||
[
|
||||
'$toggle_link' => $link,
|
||||
'$toggle_text' => t('toggle mobile'))
|
||||
'$toggle_text' => t('toggle mobile')]
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function wk_social_relay()
|
|||
$scope = SR_SCOPE_NONE;
|
||||
}
|
||||
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
|
||||
if ($scope == SR_SCOPE_TAGS) {
|
||||
$server_tags = Config::get('system', 'relay_server_tags');
|
||||
|
|
@ -59,16 +59,16 @@ function wk_social_relay()
|
|||
}
|
||||
}
|
||||
|
||||
$taglist = array();
|
||||
$taglist = [];
|
||||
foreach ($tags AS $tag) {
|
||||
$taglist[] = $tag;
|
||||
}
|
||||
|
||||
$relay = array(
|
||||
$relay = [
|
||||
"subscribe" => $subscribe,
|
||||
"scope" => $scope,
|
||||
"tags" => $taglist
|
||||
);
|
||||
];
|
||||
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($relay, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
|
|
|
|||
460
mod/admin.php
460
mod/admin.php
|
|
@ -158,46 +158,46 @@ function admin_content(App $a)
|
|||
// apc_delete($toDelete);
|
||||
//}
|
||||
// Header stuff
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template('admin/settings_head.tpl'), array());
|
||||
$a->page['htmlhead'] .= replace_macros(get_markup_template('admin/settings_head.tpl'), []);
|
||||
|
||||
/*
|
||||
* Side bar links
|
||||
*/
|
||||
$aside_tools = array();
|
||||
$aside_tools = [];
|
||||
// array(url, name, extra css classes)
|
||||
// not part of $aside to make the template more adjustable
|
||||
$aside_sub = array(
|
||||
'site' => array("admin/site/" , t("Site") , "site"),
|
||||
'users' => array("admin/users/" , t("Users") , "users"),
|
||||
'plugins' => array("admin/plugins/" , t("Plugins") , "plugins"),
|
||||
'themes' => array("admin/themes/" , t("Themes") , "themes"),
|
||||
'features' => array("admin/features/" , t("Additional features") , "features"),
|
||||
'dbsync' => array("admin/dbsync/" , t('DB updates') , "dbsync"),
|
||||
'queue' => array("admin/queue/" , t('Inspect Queue') , "queue"),
|
||||
'contactblock' => array("admin/contactblock/", t('Contact Blocklist') , "contactblock"),
|
||||
'blocklist' => array("admin/blocklist/" , t('Server Blocklist') , "blocklist"),
|
||||
'federation' => array("admin/federation/" , t('Federation Statistics'), "federation"),
|
||||
'deleteitem' => array("admin/deleteitem/" , t('Delete Item') , 'deleteitem'),
|
||||
);
|
||||
$aside_sub = [
|
||||
'site' => ["admin/site/" , t("Site") , "site"],
|
||||
'users' => ["admin/users/" , t("Users") , "users"],
|
||||
'plugins' => ["admin/plugins/" , t("Plugins") , "plugins"],
|
||||
'themes' => ["admin/themes/" , t("Themes") , "themes"],
|
||||
'features' => ["admin/features/" , t("Additional features") , "features"],
|
||||
'dbsync' => ["admin/dbsync/" , t('DB updates') , "dbsync"],
|
||||
'queue' => ["admin/queue/" , t('Inspect Queue') , "queue"],
|
||||
'contactblock' => ["admin/contactblock/", t('Contact Blocklist') , "contactblock"],
|
||||
'blocklist' => ["admin/blocklist/" , t('Server Blocklist') , "blocklist"],
|
||||
'federation' => ["admin/federation/" , t('Federation Statistics'), "federation"],
|
||||
'deleteitem' => ["admin/deleteitem/" , t('Delete Item') , 'deleteitem'],
|
||||
];
|
||||
|
||||
/* get plugins admin page */
|
||||
|
||||
$r = q("SELECT `name` FROM `addon` WHERE `plugin_admin` = 1 ORDER BY `name`");
|
||||
$aside_tools['plugins_admin'] = array();
|
||||
$aside_tools['plugins_admin'] = [];
|
||||
foreach ($r as $h) {
|
||||
$plugin = $h['name'];
|
||||
$aside_tools['plugins_admin'][] = array("admin/plugins/" . $plugin, $plugin, "plugin");
|
||||
$aside_tools['plugins_admin'][] = ["admin/plugins/" . $plugin, $plugin, "plugin"];
|
||||
// temp plugins with admin
|
||||
$a->plugins_admin[] = $plugin;
|
||||
}
|
||||
|
||||
$aside_tools['logs'] = array("admin/logs/", t("Logs"), "logs");
|
||||
$aside_tools['viewlogs'] = array("admin/viewlogs/", t("View Logs"), 'viewlogs');
|
||||
$aside_tools['diagnostics_probe'] = array('probe/', t('probe address'), 'probe');
|
||||
$aside_tools['diagnostics_webfinger'] = array('webfinger/', t('check webfinger'), 'webfinger');
|
||||
$aside_tools['logs'] = ["admin/logs/", t("Logs"), "logs"];
|
||||
$aside_tools['viewlogs'] = ["admin/viewlogs/", t("View Logs"), 'viewlogs'];
|
||||
$aside_tools['diagnostics_probe'] = ['probe/', t('probe address'), 'probe'];
|
||||
$aside_tools['diagnostics_webfinger'] = ['webfinger/', t('check webfinger'), 'webfinger'];
|
||||
|
||||
$t = get_markup_template('admin/aside.tpl');
|
||||
$a->page['aside'] .= replace_macros($t, array(
|
||||
$a->page['aside'] .= replace_macros($t, [
|
||||
'$admin' => $aside_tools,
|
||||
'$subpages' => $aside_sub,
|
||||
'$admtxt' => t('Admin'),
|
||||
|
|
@ -206,7 +206,7 @@ function admin_content(App $a)
|
|||
'$diagnosticstxt' => t('diagnostics'),
|
||||
'$h_pending' => t('User registrations waiting for confirmation'),
|
||||
'$admurl' => "admin/"
|
||||
));
|
||||
]);
|
||||
|
||||
// Page content
|
||||
$o = '';
|
||||
|
|
@ -282,25 +282,25 @@ function admin_content(App $a)
|
|||
function admin_page_blocklist(App $a)
|
||||
{
|
||||
$blocklist = Config::get('system', 'blocklist');
|
||||
$blocklistform = array();
|
||||
$blocklistform = [];
|
||||
if (is_array($blocklist)) {
|
||||
foreach ($blocklist as $id => $b) {
|
||||
$blocklistform[] = array(
|
||||
'domain' => array("domain[$id]", t('Blocked domain'), $b['domain'], '', t('The blocked domain'), 'required', '', ''),
|
||||
'reason' => array("reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this domain.') . '(' . $b['domain'] . ')', 'required', '', ''),
|
||||
'delete' => array("delete[$id]", t("Delete domain") . ' (' . $b['domain'] . ')', False, t("Check to delete this entry from the blocklist"))
|
||||
);
|
||||
$blocklistform[] = [
|
||||
'domain' => ["domain[$id]", t('Blocked domain'), $b['domain'], '', t('The blocked domain'), 'required', '', ''],
|
||||
'reason' => ["reason[$id]", t("Reason for the block"), $b['reason'], t('The reason why you blocked this domain.') . '(' . $b['domain'] . ')', 'required', '', ''],
|
||||
'delete' => ["delete[$id]", t("Delete domain") . ' (' . $b['domain'] . ')', False, t("Check to delete this entry from the blocklist")]
|
||||
];
|
||||
}
|
||||
}
|
||||
$t = get_markup_template('admin/blocklist.tpl');
|
||||
return replace_macros($t, array(
|
||||
return replace_macros($t, [
|
||||
'$title' => t('Administration'),
|
||||
'$page' => t('Server Blocklist'),
|
||||
'$intro' => t('This page can be used to define a black list of servers from the federated network that are not allowed to interact with your node. For all entered domains you should also give a reason why you have blocked the remote server.'),
|
||||
'$public' => t('The list of blocked servers will be made publically available on the /friendica page so that your users and people investigating communication problems can find the reason easily.'),
|
||||
'$addtitle' => t('Add new entry to block list'),
|
||||
'$newdomain' => array('newentry_domain', t('Server Domain'), '', t('The domain of the new server to add to the block list. Do not include the protocol.'), 'required', '', ''),
|
||||
'$newreason' => array('newentry_reason', t('Block reason'), '', t('The reason why you blocked this domain.'), 'required', '', ''),
|
||||
'$newdomain' => ['newentry_domain', t('Server Domain'), '', t('The domain of the new server to add to the block list. Do not include the protocol.'), 'required', '', ''],
|
||||
'$newreason' => ['newentry_reason', t('Block reason'), '', t('The reason why you blocked this domain.'), 'required', '', ''],
|
||||
'$submit' => t('Add Entry'),
|
||||
'$savechanges' => t('Save changes to the blocklist'),
|
||||
'$currenttitle' => t('Current Entries in the Blocklist'),
|
||||
|
|
@ -311,7 +311,7 @@ function admin_page_blocklist(App $a)
|
|||
'$baseurl' => System::baseUrl(true),
|
||||
'$confirm_delete' => t('Delete entry from blocklist?'),
|
||||
'$form_security_token' => get_form_security_token("admin_blocklist")
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -330,24 +330,24 @@ function admin_page_blocklist_post(App $a)
|
|||
if (x($_POST['page_blocklist_save'])) {
|
||||
// Add new item to blocklist
|
||||
$blocklist = Config::get('system', 'blocklist');
|
||||
$blocklist[] = array(
|
||||
$blocklist[] = [
|
||||
'domain' => notags(trim($_POST['newentry_domain'])),
|
||||
'reason' => notags(trim($_POST['newentry_reason']))
|
||||
);
|
||||
];
|
||||
Config::set('system', 'blocklist', $blocklist);
|
||||
info(t('Server added to blocklist.') . EOL);
|
||||
} else {
|
||||
// Edit the entries from blocklist
|
||||
$blocklist = array();
|
||||
$blocklist = [];
|
||||
foreach ($_POST['domain'] as $id => $domain) {
|
||||
// Trimming whitespaces as well as any lingering slashes
|
||||
$domain = notags(trim($domain, "\x00..\x1F/"));
|
||||
$reason = notags(trim($_POST['reason'][$id]));
|
||||
if (!x($_POST['delete'][$id])) {
|
||||
$blocklist[] = array(
|
||||
$blocklist[] = [
|
||||
'domain' => $domain,
|
||||
'reason' => $reason
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
Config::set('system', 'blocklist', $blocklist);
|
||||
|
|
@ -409,7 +409,7 @@ function admin_page_contactblock(App $a)
|
|||
$contacts = dba::inArray($statement);
|
||||
|
||||
$t = get_markup_template('admin/contactblock.tpl');
|
||||
$o = replace_macros($t, array(
|
||||
$o = replace_macros($t, [
|
||||
// strings //
|
||||
'$title' => t('Administration'),
|
||||
'$page' => t('Remote Contact Blocklist'),
|
||||
|
|
@ -434,7 +434,7 @@ function admin_page_contactblock(App $a)
|
|||
'$total_contacts' => tt('%s total blocked contact', '%s total blocked contacts', $total),
|
||||
'$paginate' => paginate($a),
|
||||
'$contacturl' => ['contact_url', t("Profile URL"), '', t("URL of the remote contact to block.")],
|
||||
));
|
||||
]);
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
|
@ -452,16 +452,16 @@ function admin_page_deleteitem(App $a)
|
|||
{
|
||||
$t = get_markup_template('admin/deleteitem.tpl');
|
||||
|
||||
return replace_macros($t, array(
|
||||
return replace_macros($t, [
|
||||
'$title' => t('Administration'),
|
||||
'$page' => t('Delete Item'),
|
||||
'$submit' => t('Delete this Item'),
|
||||
'$intro1' => t('On this page you can delete an item from your node. If the item is a top level posting, the entire thread will be deleted.'),
|
||||
'$intro2' => t('You need to know the GUID of the item. You can find it e.g. by looking at the display URL. The last part of http://example.com/display/123456 is the GUID, here 123456.'),
|
||||
'$deleteitemguid' => array('deleteitemguid', t("GUID"), '', t("The GUID of the item you want to delete."), 'required', 'autofocus'),
|
||||
'$deleteitemguid' => ['deleteitemguid', t("GUID"), '', t("The GUID of the item you want to delete."), 'required', 'autofocus'],
|
||||
'$baseurl' => System::baseUrl(),
|
||||
'$form_security_token' => get_form_security_token("admin_deleteitem")
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -490,7 +490,7 @@ function admin_page_deleteitem_post(App $a)
|
|||
// Now that we have the GUID get all IDs of the associated entries in the
|
||||
// item table of the DB and drop those items, which will also delete the
|
||||
// associated threads.
|
||||
$r = dba::select('item', array('id'), array('guid' => $guid));
|
||||
$r = dba::select('item', ['id'], ['guid' => $guid]);
|
||||
while ($row = dba::fetch($r)) {
|
||||
drop_item($row['id'], false);
|
||||
}
|
||||
|
|
@ -526,8 +526,8 @@ function admin_page_federation(App $a)
|
|||
// off one % two of them are needed in the query
|
||||
// Add more platforms if you like, when one returns 0 known nodes it is not
|
||||
// displayed on the stats page.
|
||||
$platforms = array('Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome');
|
||||
$colors = array(
|
||||
$platforms = ['Friendi%%a', 'Diaspora', '%%red%%', 'Hubzilla', 'BlaBlaNet', 'GNU Social', 'StatusNet', 'Mastodon', 'Pleroma', 'socialhome'];
|
||||
$colors = [
|
||||
'Friendi%%a' => '#ffc018', // orange from the logo
|
||||
'Diaspora' => '#a1a1a1', // logo is black and white, makes a gray
|
||||
'%%red%%' => '#c50001', // fire red from the logo
|
||||
|
|
@ -538,8 +538,8 @@ function admin_page_federation(App $a)
|
|||
'Mastodon' => '#1a9df9', // blue from the Mastodon logo
|
||||
'Pleroma' => '#E46F0F', // Orange from the text that is used on Pleroma instances
|
||||
'socialhome' => '#52056b' // lilac from the Django Image used at the Socialhome homepage
|
||||
);
|
||||
$counts = array();
|
||||
];
|
||||
$counts = [];
|
||||
$total = 0;
|
||||
$users = 0;
|
||||
|
||||
|
|
@ -567,15 +567,15 @@ function admin_page_federation(App $a)
|
|||
// to the version string for the displayed list.
|
||||
foreach ($v as $key => $value) {
|
||||
if ($v[$key]['version'] == '') {
|
||||
$v[$key] = array('total' => $v[$key]['total'], 'version' => t('unknown'));
|
||||
$v[$key] = ['total' => $v[$key]['total'], 'version' => t('unknown')];
|
||||
}
|
||||
}
|
||||
// in the DB the Diaspora versions have the format x.x.x.x-xx the last
|
||||
// part (-xx) should be removed to clean up the versions from the "head
|
||||
// commit" information and combined into a single entry for x.x.x.x
|
||||
if ($p == 'Diaspora') {
|
||||
$newV = array();
|
||||
$newVv = array();
|
||||
$newV = [];
|
||||
$newVv = [];
|
||||
foreach ($v as $vv) {
|
||||
$newVC = $vv['total'];
|
||||
$newVV = $vv['version'];
|
||||
|
|
@ -590,7 +590,7 @@ function admin_page_federation(App $a)
|
|||
}
|
||||
}
|
||||
foreach ($newV as $key => $value) {
|
||||
array_push($newVv, array('total' => $value, 'version' => $key));
|
||||
array_push($newVv, ['total' => $value, 'version' => $key]);
|
||||
}
|
||||
$v = $newVv;
|
||||
}
|
||||
|
|
@ -599,8 +599,8 @@ function admin_page_federation(App $a)
|
|||
// DB version stamp; those should be operated out and versions be
|
||||
// conbined
|
||||
if ($p == 'Friendi%%a') {
|
||||
$newV = array();
|
||||
$newVv = array();
|
||||
$newV = [];
|
||||
$newVv = [];
|
||||
foreach ($v as $vv) {
|
||||
$newVC = $vv['total'];
|
||||
$newVV = $vv['version'];
|
||||
|
|
@ -616,7 +616,7 @@ function admin_page_federation(App $a)
|
|||
}
|
||||
}
|
||||
foreach ($newV as $key => $value) {
|
||||
array_push($newVv, array('total' => $value, 'version' => $key));
|
||||
array_push($newVv, ['total' => $value, 'version' => $key]);
|
||||
}
|
||||
$v = $newVv;
|
||||
}
|
||||
|
|
@ -626,7 +626,7 @@ function admin_page_federation(App $a)
|
|||
|
||||
// the 3rd array item is needed for the JavaScript graphs as JS does
|
||||
// not like some characters in the names of variables...
|
||||
$counts[$p] = array($c[0], $v, str_replace(array(' ', '%'), '', $p), $colors[$p]);
|
||||
$counts[$p] = [$c[0], $v, str_replace([' ', '%'], '', $p), $colors[$p]];
|
||||
}
|
||||
|
||||
// some helpful text
|
||||
|
|
@ -635,7 +635,7 @@ function admin_page_federation(App $a)
|
|||
|
||||
// load the template, replace the macros and return the page content
|
||||
$t = get_markup_template('admin/federation.tpl');
|
||||
return replace_macros($t, array(
|
||||
return replace_macros($t, [
|
||||
'$title' => t('Administration'),
|
||||
'$page' => t('Federation Statistics'),
|
||||
'$intro' => $intro,
|
||||
|
|
@ -645,7 +645,7 @@ function admin_page_federation(App $a)
|
|||
'$version' => FRIENDICA_VERSION,
|
||||
'$legendtext' => t('Currently this node is aware of %d nodes with %d registered users from the following platforms:', $total, $users),
|
||||
'$baseurl' => System::baseUrl(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -670,7 +670,7 @@ function admin_page_queue(App $a)
|
|||
ORDER BY `q`.`cid`, `q`.`created`;");
|
||||
|
||||
$t = get_markup_template('admin/queue.tpl');
|
||||
return replace_macros($t, array(
|
||||
return replace_macros($t, [
|
||||
'$title' => t('Administration'),
|
||||
'$page' => t('Inspect Queue'),
|
||||
'$count' => count($r),
|
||||
|
|
@ -682,7 +682,7 @@ function admin_page_queue(App $a)
|
|||
'$last_header' => t('Last Tried'),
|
||||
'$info' => t('This page lists the content of the queue for outgoing postings. These are postings the initial delivery failed for. They will be resend later and eventually deleted if the delivery fails permanently.'),
|
||||
'$entries' => $r,
|
||||
| ||||