diff --git a/Code/Lib/Channel.php b/Code/Lib/Channel.php index 7518899e7..81ead526b 100644 --- a/Code/Lib/Channel.php +++ b/Code/Lib/Channel.php @@ -756,7 +756,7 @@ class Channel ); } - xchan_change_key($oldxchan, $newxchan, $stored); + xchan_change_key($oldxchan, $newxchan); Run::Summon([ 'Notifier', 'keychange', $channel['channel_id'] ]); diff --git a/Code/Lib/Libsync.php b/Code/Lib/Libsync.php index 5f0282470..ea09e2ee7 100644 --- a/Code/Lib/Libsync.php +++ b/Code/Lib/Libsync.php @@ -1290,6 +1290,6 @@ class Libsync ); } - xchan_change_key($oldxchan, $newxchan, $arr['keychange']); + xchan_change_key($oldxchan, $newxchan); } } diff --git a/Code/Module/Display.php b/Code/Module/Display.php index 066c5e40b..2fc917e08 100644 --- a/Code/Module/Display.php +++ b/Code/Module/Display.php @@ -469,7 +469,7 @@ class Display extends Controller if ($item['item_private']) { continue; } - $atom .= atom_entry($item, $type, [], [], true, '', false); + $atom .= atom_entry($item, $type, [], [], true, ''); } } diff --git a/Code/Nomad/NomadHandler.php b/Code/Nomad/NomadHandler.php index d5190af7b..e41b9cff5 100644 --- a/Code/Nomad/NomadHandler.php +++ b/Code/Nomad/NomadHandler.php @@ -140,7 +140,7 @@ class NomadHandler implements IHandler // if ! $update create a linked identity - xchan_change_key($xchan, $newxchan, $data); + xchan_change_key($xchan, $newxchan); $ret['success'] = true; return $ret; diff --git a/Code/Render/Theme.php b/Code/Render/Theme.php index 1bafe4f05..9ac306a1c 100644 --- a/Code/Render/Theme.php +++ b/Code/Render/Theme.php @@ -227,27 +227,27 @@ class Theme } } - public static function get_template($s, $root = '') + public static function get_template($filename, $root = '') { $testroot = ($root=='') ? $testroot = "ROOT" : $root; $t = App::template_engine(); - if (isset(App::$override_markup_templates[$testroot][$s]["content"])) { - return App::$override_markup_templates[$testroot][$s]["content"]; + if (isset(App::$override_markup_templates[$testroot][$filename]["content"])) { + return App::$override_markup_templates[$testroot][$filename]["content"]; } else { - if (isset(App::$override_markup_templates[$testroot][$s]["root"]) && - isset(App::$override_markup_templates[$testroot][$s]["file"])) { - $s = App::$override_markup_templates[$testroot][$s]["file"]; - $root = App::$override_markup_templates[$testroot][$s]["root"]; + if (isset(App::$override_markup_templates[$testroot][$filename]["root"]) && + isset(App::$override_markup_templates[$testroot][$filename]["file"])) { + $filename = App::$override_markup_templates[$testroot][$filename]["file"]; + $root = App::$override_markup_templates[$testroot][$filename]["root"]; } elseif (App::$override_templateroot) { $newroot = App::$override_templateroot.$root; if ($newroot != '' && !str_ends_with($newroot, '/')) { $newroot .= '/'; } - $template = $t->get_template($s, $newroot); + $template = $t->get_template($filename, $newroot); } - $template = $t->get_template($s, $root); + $template = $t->get_template($filename, $root); return $template; } } diff --git a/Code/Widget/Settings_menu.php b/Code/Widget/Settings_menu.php index b934a101a..03c8d2ce1 100644 --- a/Code/Widget/Settings_menu.php +++ b/Code/Widget/Settings_menu.php @@ -75,14 +75,6 @@ class Settings_menu implements WidgetInterface 'selected' => '' ]; -// if(Features::enabled(local_channel(),'oauth_clients')) { -// $tabs[] = array( -// 'label' => t('OAuth1 apps'), -// 'url' => z_root() . '/settings/oauth', -// 'selected' => ((argv(1) === 'oauth') ? 'active' : ''), -// ); -// } - if (Apps::system_app_installed(local_channel(), 'Clients')) { $tabs[] = [ 'label' => t('Client apps'), @@ -91,41 +83,15 @@ class Settings_menu implements WidgetInterface ]; } -// if(Features::enabled(local_channel(),'access_tokens')) { -// $tabs[] = array( -// 'label' => t('Guest Access Tokens'), -// 'url' => z_root() . '/settings/tokens', -// 'selected' => ((argv(1) === 'tokens') ? 'active' : ''), -// ); -// } - - if(Apps::system_app_installed(local_channel(),'Roles')) { + if(Apps::system_app_installed(local_channel(),'Roles')) { $tabs[] = [ 'label' => t('Permission Roles'), 'url' => z_root() . '/settings/permcats', 'selected' => ((argv(1) === 'permcats') ? 'active' : ''), ]; - } + } - -// if($role === false || $role === 'custom') { -// $tabs[] = array( -// 'label' => t('Connection Default Permissions'), -// 'url' => z_root() . '/defperms', -// 'selected' => '' -// ); -// } - -// if(Features::enabled(local_channel(),'channel_sources')) { -// $tabs[] = array( -// 'label' => t('Channel Sources'), -// 'url' => z_root() . '/sources', -// 'selected' => '' -// ); -// } - - $tabtpl = Theme::get_template("generic_links_widget.tpl"); - return replace_macros($tabtpl, [ + return replace_macros(Theme::get_template('generic_links_widget.tpl'), [ '$title' => t('Settings'), '$class' => 'settings-widget', '$items' => $tabs, diff --git a/Code/Widget/Suggestedchats.php b/Code/Widget/Suggestedchats.php index db59d3683..9715ee5d0 100644 --- a/Code/Widget/Suggestedchats.php +++ b/Code/Widget/Suggestedchats.php @@ -37,9 +37,9 @@ class Suggestedchats implements WidgetInterface $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']); } } - return replace_macros(Theme::get_template('bookmarkedchats.tpl'), array( + return replace_macros(Theme::get_template('bookmarkedchats.tpl'), [ '$header' => t('Suggested Chatrooms'), '$rooms' => $r - )); + ]); } } diff --git a/Code/Widget/Suggestions.php b/Code/Widget/Suggestions.php index 274394344..e6c1e882d 100644 --- a/Code/Widget/Suggestions.php +++ b/Code/Widget/Suggestions.php @@ -27,7 +27,7 @@ class Suggestions implements WidgetInterface // Get two random entries from the top 20 returned. // We'll grab the first one and the one immediately following. - // This will throw some entropy into the situation so you won't + // This will throw some entropy into the situation, so you won't // be looking at the same two mug shots every time the widget runs $index = ((count($r) > 2) ? mt_rand(0, count($r) - 2) : 0); @@ -52,12 +52,10 @@ class Suggestions implements WidgetInterface ]; } - $o = replace_macros(Theme::get_template('suggest_widget.tpl'), [ + return replace_macros(Theme::get_template('suggest_widget.tpl'), [ '$title' => t('Suggestions'), '$more' => t('See more...'), '$entries' => $arguments ]); - - return $o; } } diff --git a/include/config.php b/include/config.php index fd07cf83c..c3a5b1b4a 100644 --- a/include/config.php +++ b/include/config.php @@ -1,4 +1,4 @@ - array($id, $label, $input_text, (($required) ? t('Required') : ''), (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'), - )); + $o .= replace_macros($tpl, [ + '$field' => [$id, $label, $input_text, (($required) ? t('Required') : ''), (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'], + ]); $o .= ""; return $o; @@ -290,14 +290,14 @@ function relative_date($posted_date, $format = null) return sprintf(t('less than a second %s'), $direction); } - $a = array( 12 * 30 * 24 * 60 * 60 => 'y', + $a = [12 * 30 * 24 * 60 * 60 => 'y', 30 * 24 * 60 * 60 => 'm', 7 * 24 * 60 * 60 => 'w', 24 * 60 * 60 => 'd', 60 * 60 => 'h', 60 => 'i', 1 => 's' - ); + ]; foreach ($a as $secs => $str) { @@ -315,31 +315,16 @@ function relative_date($posted_date, $format = null) function plural_dates($k, $n) { - switch ($k) { - case 'y': - return tt('year', 'years', $n, 'relative_date'); - break; - case 'm': - return tt('month', 'months', $n, 'relative_date'); - break; - case 'w': - return tt('week', 'weeks', $n, 'relative_date'); - break; - case 'd': - return tt('day', 'days', $n, 'relative_date'); - break; - case 'h': - return tt('hour', 'hours', $n, 'relative_date'); - break; - case 'i': - return tt('minute', 'minutes', $n, 'relative_date'); - break; - case 's': - return tt('second', 'seconds', $n, 'relative_date'); - break; - default: - return; - } + return match ($k) { + 'y' => tt('year', 'years', $n, 'relative_date'), + 'm' => tt('month', 'months', $n, 'relative_date'), + 'w' => tt('week', 'weeks', $n, 'relative_date'), + 'd' => tt('day', 'days', $n, 'relative_date'), + 'h' => tt('hour', 'hours', $n, 'relative_date'), + 'i' => tt('minute', 'minutes', $n, 'relative_date'), + 's' => tt('second', 'seconds', $n, 'relative_date'), + default => '', + }; } /** @@ -490,7 +475,7 @@ function cal($y = 0, $m = 0, $links = false, $class = '') $day = str_replace(' ', ' ', sprintf('%2.2d', $d)); if ($started) { if (is_array($links) && isset($links[$d])) { - $o .= "$day"; + $o .= "$day"; } else { $o .= $day; } @@ -594,7 +579,7 @@ function update_birthdays() $z = event_store_event($ev); if ($z) { - $item_id = event_store_item($ev, $z); + event_store_item($ev, $z); q( "update abook set abook_dob = '%s' where abook_id = %d", dbesc(intval($rr['abook_dob']) + 1 . substr($rr['abook_dob'], 4)), diff --git a/include/feedutils.php b/include/feedutils.php index 0bb674dce..e36c2b8ee 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -98,7 +98,7 @@ function get_feed_for($channel, $observer_hash, $params) $feed_author = ''; - $atom .= replace_macros($feed_template, array( + $atom .= replace_macros($feed_template, [ '$version' => xmlify(Code\Lib\System::get_project_version()), '$generator' => xmlify(Code\Lib\System::get_project_name()), '$generator_uri' => z_root(), @@ -107,7 +107,7 @@ function get_feed_for($channel, $observer_hash, $params) '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)), '$author' => $feed_author, '$profile_page' => xmlify($channel['xchan_url']), - )); + ]); $x = [ @@ -161,7 +161,7 @@ function get_feed_for($channel, $observer_hash, $params) continue; } - $atom .= atom_entry($item, $type, null, $owner, true, '', $params['compat']); + $atom .= atom_entry($item, $type, null, $owner, true, ''); } } @@ -287,18 +287,17 @@ function compat_photos_list($s) /** * @brief Create an item for the Atom feed. * - * @see get_feed_for() - * * @param array $item * @param string $type - * @param array $author + * @param array|null $author * @param array $owner * @param string $comment default false * @param number $cid default 0 - * @param bool $compat default false * @return void|string + *@see get_feed_for() + * */ -function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0, $compat = false) +function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0) { if (! $item['parent']) { diff --git a/include/misc.php b/include/misc.php index fcf38321d..fcf9702ec 100644 --- a/include/misc.php +++ b/include/misc.php @@ -30,7 +30,7 @@ use Symfony\Component\Uid\Uuid; * * @return string substituted string */ -function replace_macros($s, $r) +function replace_macros($template, $map) { $arr = [ 'template' => $s, diff --git a/include/network.php b/include/network.php index afa12f587..c479c009c 100644 --- a/include/network.php +++ b/include/network.php @@ -105,12 +105,12 @@ function http_status_exit($val, $msg = '') function unparse_url($parsed_url) { $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; - $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; + $host = $parsed_url['host'] ?? ''; $port = ((isset($parsed_url['port']) && intval($parsed_url['port'])) ? ':' . intval($parsed_url['port']) : ''); - $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; + $user = $parsed_url['user'] ?? ''; $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; $pass = ($user || $pass) ? "$pass@" : ''; - $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; + $path = $parsed_url['path'] ?? ''; $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; return "$scheme$user$pass$host$port$path$query$fragment"; @@ -422,11 +422,8 @@ function xml2array($contents, $namespaces = true, $get_attributes = 1, $priority return []; } - //Initializations + // Initializations $xml_array = []; - $parents = []; - $opened_tags = []; - $arr = []; $current = &$xml_array; // Reference @@ -600,8 +597,6 @@ function email_header_encode($in_str, $charset = 'UTF-8', $header = 'Subject') */ function discover_resource(string $resource, $protocol = '', $verify = true) { - $network = null; - $x = Webfinger::exec($resource); $address = EMPTY_STR; @@ -1398,7 +1393,7 @@ function get_request_string($url) $m = parse_url($url); if ($m) { - return ( (isset($m['path']) ? $m['path'] : '/' ) . (isset($m['query']) ? '?' . $m['query'] : '') ); + return ( ($m['path'] ?? '/') . (isset($m['query']) ? '?' . $m['query'] : '') ); } return ''; diff --git a/include/xchan.php b/include/xchan.php index 5933878f9..f96dad708 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -109,7 +109,7 @@ function xchan_store($arr) continue; } - if (in_array($columns, 'xchan_' . $k)) { + if (in_array('xchan_' . $k, $columns)) { $x['xchan_' . $k] = escape_tags($v); } } @@ -273,7 +273,7 @@ function xchan_keychange_acl($table, $column, $oldxchan, $newxchan) } -function xchan_change_key($oldx, $newx, $data) +function xchan_change_key($oldx, $newx) { $tables = [