1
1
Fork 0

Replace deprecated defaults() calls with ?? and ?: in include/ and view/

This commit is contained in:
Hypolite Petovan 2019-10-16 08:43:59 -04:00
parent c0b78a9720
commit 8b836189d4
11 changed files with 30 additions and 30 deletions

View file

@ -322,7 +322,7 @@ function api_call(App $a)
$stamp = microtime(true); $stamp = microtime(true);
$return = call_user_func($info['func'], $type); $return = call_user_func($info['func'], $type);
$duration = (float) (microtime(true) - $stamp); $duration = floatval(microtime(true) - $stamp);
Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]); Logger::info(API_LOG_PREFIX . 'username {username}', ['module' => 'api', 'action' => 'call', 'username' => $a->user['username'], 'duration' => round($duration, 2)]);

View file

@ -1208,7 +1208,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$new_post' => L10n::t('New Post'), '$new_post' => L10n::t('New Post'),
'$return_path' => $query_str, '$return_path' => $query_str,
'$action' => 'item', '$action' => 'item',
'$share' => defaults($x, 'button', L10n::t('Share')), '$share' => ($x['button'] ?? '') ?: L10n::t('Share'),
'$upload' => L10n::t('Upload photo'), '$upload' => L10n::t('Upload photo'),
'$shortupload' => L10n::t('upload photo'), '$shortupload' => L10n::t('upload photo'),
'$attach' => L10n::t('Attach file'), '$attach' => L10n::t('Attach file'),
@ -1225,17 +1225,17 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
'$shortsetloc' => L10n::t('set location'), '$shortsetloc' => L10n::t('set location'),
'$noloc' => L10n::t('Clear browser location'), '$noloc' => L10n::t('Clear browser location'),
'$shortnoloc' => L10n::t('clear location'), '$shortnoloc' => L10n::t('clear location'),
'$title' => defaults($x, 'title', ''), '$title' => $x['title'] ?? '',
'$placeholdertitle' => L10n::t('Set title'), '$placeholdertitle' => L10n::t('Set title'),
'$category' => defaults($x, 'category', ''), '$category' => $x['category'] ?? '',
'$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? L10n::t("Categories \x28comma-separated list\x29") : '', '$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? L10n::t("Categories \x28comma-separated list\x29") : '',
'$wait' => L10n::t('Please wait'), '$wait' => L10n::t('Please wait'),
'$permset' => L10n::t('Permission settings'), '$permset' => L10n::t('Permission settings'),
'$shortpermset' => L10n::t('permissions'), '$shortpermset' => L10n::t('permissions'),
'$wall' => $notes_cid ? 0 : 1, '$wall' => $notes_cid ? 0 : 1,
'$posttype' => $notes_cid ? Item::PT_PERSONAL_NOTE : Item::PT_ARTICLE, '$posttype' => $notes_cid ? Item::PT_PERSONAL_NOTE : Item::PT_ARTICLE,
'$content' => defaults($x, 'content', ''), '$content' => $x['content'] ?? '',
'$post_id' => defaults($x, 'post_id', ''), '$post_id' => $x['post_id'] ?? '',
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$defloc' => $x['default_location'], '$defloc' => $x['default_location'],
'$visitor' => $x['visitor'], '$visitor' => $x['visitor'],
@ -1527,9 +1527,9 @@ function get_responses(array $conv_responses, array $response_verbs, array $item
$ret = []; $ret = [];
foreach ($response_verbs as $v) { foreach ($response_verbs as $v) {
$ret[$v] = []; $ret[$v] = [];
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], 0); $ret[$v]['count'] = $conv_responses[$v][$item['uri']] ?? 0;
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', []); $ret[$v]['list'] = $conv_responses[$v][$item['uri'] . '-l'] ?? [];
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0'); $ret[$v]['self'] = $conv_responses[$v][$item['uri'] . '-self'] ?? '0';
if (count($ret[$v]['list']) > MAX_LIKERS) { if (count($ret[$v]['list']) > MAX_LIKERS) {
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS); $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-' array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'

View file

@ -46,10 +46,10 @@ function notification($params)
return false; return false;
} }
$params['notify_flags'] = defaults($params, 'notify_flags', $user['notify-flags']); $params['notify_flags'] = ($params['notify_flags'] ?? '') ?: $user['notify-flags'];
$params['language'] = defaults($params, 'language' , $user['language']); $params['language'] = ($params['language'] ?? '') ?: $user['language'];
$params['to_name'] = defaults($params, 'to_name' , $user['username']); $params['to_name'] = ($params['to_name'] ?? '') ?: $user['username'];
$params['to_email'] = defaults($params, 'to_email' , $user['email']); $params['to_email'] = ($params['to_email'] ?? '') ?: $user['email'];
// from here on everything is in the recipients language // from here on everything is in the recipients language
L10n::pushLang($params['language']); L10n::pushLang($params['language']);
@ -456,17 +456,17 @@ function notification($params)
if (!isset($params['subject'])) { if (!isset($params['subject'])) {
Logger::warning('subject isn\'t set.', ['type' => $params['type']]); Logger::warning('subject isn\'t set.', ['type' => $params['type']]);
} }
$subject = defaults($params, 'subject', ''); $subject = $params['subject'] ?? '';
if (!isset($params['preamble'])) { if (!isset($params['preamble'])) {
Logger::warning('preamble isn\'t set.', ['type' => $params['type'], 'subject' => $subject]); Logger::warning('preamble isn\'t set.', ['type' => $params['type'], 'subject' => $subject]);
} }
$preamble = defaults($params, 'preamble', ''); $preamble = $params['preamble'] ?? '';
if (!isset($params['body'])) { if (!isset($params['body'])) {
Logger::warning('body isn\'t set.', ['type' => $params['type'], 'subject' => $subject, 'preamble' => $preamble]); Logger::warning('body isn\'t set.', ['type' => $params['type'], 'subject' => $subject, 'preamble' => $preamble]);
} }
$body = defaults($params, 'body', ''); $body = $params['body'] ?? '';
$show_in_notification_page = false; $show_in_notification_page = false;
} }
@ -613,11 +613,11 @@ function notification($params)
$datarray['siteurl'] = $siteurl; $datarray['siteurl'] = $siteurl;
$datarray['type'] = $params['type']; $datarray['type'] = $params['type'];
$datarray['parent'] = $parent_id; $datarray['parent'] = $parent_id;
$datarray['source_name'] = defaults($params, 'source_name', ''); $datarray['source_name'] = $params['source_name'] ?? '';
$datarray['source_link'] = defaults($params, 'source_link', ''); $datarray['source_link'] = $params['source_link'] ?? '';
$datarray['source_photo'] = defaults($params, 'source_photo', ''); $datarray['source_photo'] = $params['source_photo'] ?? '';
$datarray['uid'] = $params['uid']; $datarray['uid'] = $params['uid'];
$datarray['username'] = defaults($params, 'to_name', ''); $datarray['username'] = $params['to_name'] ?? '';
$datarray['hsitelink'] = $hsitelink; $datarray['hsitelink'] = $hsitelink;
$datarray['tsitelink'] = $tsitelink; $datarray['tsitelink'] = $tsitelink;
$datarray['hitemlink'] = '<a href="'.$itemlink.'">'.$itemlink.'</a>'; $datarray['hitemlink'] = '<a href="'.$itemlink.'">'.$itemlink.'</a>';

View file

@ -42,7 +42,7 @@ function add_page_info_data(array $data, $no_photos = false)
$data["type"] = "link"; $data["type"] = "link";
} }
$data["title"] = defaults($data, "title", ""); $data["title"] = $data["title"] ?? '';
if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) { if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) {
return ""; return "";

View file

@ -10,7 +10,7 @@ if (file_exists("$THEMEPATH/style.css")) {
echo file_get_contents("$THEMEPATH/style.css"); echo file_get_contents("$THEMEPATH/style.css");
} }
$uid = defaults($_REQUEST, 'puid', 0); $uid = $_REQUEST['puid'] ?? 0;
$s_colorset = Config::get('duepuntozero', 'colorset'); $s_colorset = Config::get('duepuntozero', 'colorset');
$colorset = PConfig::get($uid, 'duepuntozero', 'colorset'); $colorset = PConfig::get($uid, 'duepuntozero', 'colorset');

View file

@ -132,7 +132,7 @@ function frio_form($arr)
'$nav_icon_color' => array_key_exists('nav_icon_color', $disable) ? '' : ['frio_nav_icon_color', L10n::t('Navigation bar icon color '), $arr['nav_icon_color'], '', false], '$nav_icon_color' => array_key_exists('nav_icon_color', $disable) ? '' : ['frio_nav_icon_color', L10n::t('Navigation bar icon color '), $arr['nav_icon_color'], '', false],
'$link_color' => array_key_exists('link_color', $disable) ? '' : ['frio_link_color', L10n::t('Link color'), $arr['link_color'], '', false], '$link_color' => array_key_exists('link_color', $disable) ? '' : ['frio_link_color', L10n::t('Link color'), $arr['link_color'], '', false],
'$background_color' => array_key_exists('background_color', $disable) ? '' : ['frio_background_color', L10n::t('Set the background color'), $arr['background_color'], '', false], '$background_color' => array_key_exists('background_color', $disable) ? '' : ['frio_background_color', L10n::t('Set the background color'), $arr['background_color'], '', false],
'$contentbg_transp' => array_key_exists('contentbg_transp', $disable) ? '' : ['frio_contentbg_transp', L10n::t('Content background opacity'), defaults($arr, 'contentbg_transp', 100), ''], '$contentbg_transp' => array_key_exists('contentbg_transp', $disable) ? '' : ['frio_contentbg_transp', L10n::t('Content background opacity'), ($arr['contentbg_transp'] ?? 0) ?: 100, ''],
'$background_image' => array_key_exists('background_image', $disable) ? '' : ['frio_background_image', L10n::t('Set the background image'), $arr['background_image'], $background_image_help, false], '$background_image' => array_key_exists('background_image', $disable) ? '' : ['frio_background_image', L10n::t('Set the background image'), $arr['background_image'], $background_image_help, false],
'$bg_image_options_title' => L10n::t('Background image style'), '$bg_image_options_title' => L10n::t('Background image style'),
'$bg_image_options' => Image::get_options($arr), '$bg_image_options' => Image::get_options($arr),

View file

@ -28,7 +28,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
<html> <html>
<head> <head>
<title><?php if (!empty($page['title'])) echo $page['title'] ?></title> <title><?php if (!empty($page['title'])) echo $page['title'] ?></title>
<meta request="<?php echo htmlspecialchars(defaults($_REQUEST, 'pagename', '')) ?>"> <meta request="<?php echo htmlspecialchars($_REQUEST['pagename'] ?? '') ?>">
<script type="text/javascript">var baseurl = "<?php echo System::baseUrl(); ?>";</script> <script type="text/javascript">var baseurl = "<?php echo System::baseUrl(); ?>";</script>
<script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script> <script type="text/javascript">var frio = "<?php echo 'view/theme/frio'; ?>";</script>
<?php <?php
@ -141,7 +141,7 @@ $is_singleuser_class = $is_singleuser ? "is-singleuser" : "is-not-singleuser";
</main> </main>
<footer> <footer>
<?php echo defaults($page, 'footer', ''); ?> <?php echo $page['footer'] ?? ''; ?>
</footer> </footer>
<?php } ?> <!-- End of condition if $minimal else the rest --> <?php } ?> <!-- End of condition if $minimal else the rest -->
</body> </body>

View file

@ -22,7 +22,7 @@ function load_page(App $a)
require 'view/theme/frio/none.php'; require 'view/theme/frio/none.php';
} else { } else {
$template = 'view/theme/' . $a->getCurrentTheme() . '/' $template = 'view/theme/' . $a->getCurrentTheme() . '/'
. defaults($a->page, 'template', 'default' ) . '.php'; . (($a->page['template'] ?? '') ?: 'default' ) . '.php';
if (file_exists($template)) { if (file_exists($template)) {
require_once $template; require_once $template;
} else { } else {

View file

@ -6,7 +6,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Model\Profile; use Friendica\Model\Profile;
$uid = defaults($_REQUEST, 'puid', 0); $uid = $_REQUEST['puid'] ?? 0;
$color = false; $color = false;
$quattro_align = false; $quattro_align = false;

View file

@ -7,7 +7,7 @@ use Friendica\Core\Config;
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
use Friendica\Model\Profile; use Friendica\Model\Profile;
$uid = defaults($_REQUEST, 'puid', 0); $uid = $_REQUEST['puid'] ?? 0;
$style = PConfig::get($uid, 'vier', 'style'); $style = PConfig::get($uid, 'vier', 'style');

View file

@ -29,7 +29,7 @@ function vier_init(App $a)
Renderer::setActiveTemplateEngine('smarty3'); Renderer::setActiveTemplateEngine('smarty3');
if (!empty($a->argv[0]) && $a->argv[0] . defaults($a->argv, 1, '') === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) { if (!empty($a->argv[0]) && ($a->argv[0] . ($a->argv[1] ?? '')) === ('profile' . $a->user['nickname']) || $a->argv[0] === 'network' && local_user()) {
vier_community_info(); vier_community_info();
$a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n"; $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
@ -191,7 +191,7 @@ function vier_community_info()
//Community_Pages at right_aside //Community_Pages at right_aside
if ($show_pages && local_user()) { if ($show_pages && local_user()) {
$cid = defaults($_GET, 'cid', null); $cid = $_GET['cid'] ?? null;
//sort by last updated item //sort by last updated item
$lastitem = true; $lastitem = true;