Fix code style

This commit is contained in:
Art4 2025-02-04 12:59:21 +00:00
parent e596a0b624
commit 9f086c40e4
3 changed files with 57 additions and 57 deletions

View file

@ -7,7 +7,6 @@
namespace Friendica\Content; namespace Friendica\Content;
use Friendica\Core\Addon;
use Friendica\Core\Cache\Enum\Duration; use Friendica\Core\Cache\Enum\Duration;
use Friendica\Core\Protocol; use Friendica\Core\Protocol;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
@ -33,13 +32,13 @@ class Widget
*/ */
public static function follow(string $value = ''): string public static function follow(string $value = ''): string
{ {
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), array( return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), [
'$connect' => DI::l10n()->t('Add New Contact'), '$connect' => DI::l10n()->t('Add New Contact'),
'$desc' => DI::l10n()->t('Enter address or web location'), '$desc' => DI::l10n()->t('Enter address or web location'),
'$hint' => DI::l10n()->t('Example: bob@example.com, http://example.com/barbara'), '$hint' => DI::l10n()->t('Example: bob@example.com, http://example.com/barbara'),
'$value' => $value, '$value' => $value,
'$follow' => DI::l10n()->t('Connect') '$follow' => DI::l10n()->t('Connect')
)); ]);
} }
/** /**
@ -60,21 +59,21 @@ class Widget
} }
} }
$nv = []; $nv = [];
$nv['findpeople'] = DI::l10n()->t('Find People'); $nv['findpeople'] = DI::l10n()->t('Find People');
$nv['desc'] = DI::l10n()->t('Enter name or interest'); $nv['desc'] = DI::l10n()->t('Enter name or interest');
$nv['label'] = DI::l10n()->t('Connect/Follow'); $nv['label'] = DI::l10n()->t('Connect/Follow');
$nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing'); $nv['hint'] = DI::l10n()->t('Examples: Robert Morgenstein, Fishing');
$nv['findthem'] = DI::l10n()->t('Find'); $nv['findthem'] = DI::l10n()->t('Find');
$nv['suggest'] = DI::l10n()->t('Friend Suggestions'); $nv['suggest'] = DI::l10n()->t('Friend Suggestions');
$nv['similar'] = DI::l10n()->t('Similar Interests'); $nv['similar'] = DI::l10n()->t('Similar Interests');
$nv['random'] = DI::l10n()->t('Random Profile'); $nv['random'] = DI::l10n()->t('Random Profile');
$nv['inv'] = DI::l10n()->t('Invite Friends'); $nv['inv'] = DI::l10n()->t('Invite Friends');
$nv['directory'] = DI::l10n()->t('Global Directory'); $nv['directory'] = DI::l10n()->t('Global Directory');
$nv['global_dir'] = OpenWebAuth::getZrlUrl($global_dir, true); $nv['global_dir'] = OpenWebAuth::getZrlUrl($global_dir, true);
$nv['local_directory'] = DI::l10n()->t('Local Directory'); $nv['local_directory'] = DI::l10n()->t('Local Directory');
$aside = []; $aside = [];
$aside['$nv'] = $nv; $aside['$nv'] = $nv;
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/peoplefind.tpl'), $aside); return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/peoplefind.tpl'), $aside);
@ -178,7 +177,7 @@ class Widget
private static function filter(string $type, string $title, string $desc, string $all, string $baseUrl, array $options, string $selected = null): string private static function filter(string $type, string $title, string $desc, string $all, string $baseUrl, array $options, string $selected = null): string
{ {
$queryString = parse_url($baseUrl, PHP_URL_QUERY); $queryString = parse_url($baseUrl, PHP_URL_QUERY);
$queryArray = []; $queryArray = [];
if ($queryString) { if ($queryString) {
parse_str($queryString, $queryArray); parse_str($queryString, $queryArray);
@ -286,8 +285,8 @@ class Widget
return ''; return '';
} }
$networks = self::unavailableNetworks(); $networks = self::unavailableNetworks();
$query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"; $query = "`uid` = ? AND NOT `deleted` AND `network` != '' AND NOT `network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")";
$condition = array_merge([$query], array_merge([DI::userSession()->getLocalUserId()], $networks)); $condition = array_merge([$query], array_merge([DI::userSession()->getLocalUserId()], $networks));
$r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]); $r = DBA::select('contact', ['network'], $condition, ['group_by' => ['network'], 'order' => ['network']]);
@ -477,7 +476,7 @@ class Widget
$ret = []; $ret = [];
$cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall; $cachekey = 'Widget::postedByYear' . $uid . '-' . (int)$wall;
$dthen = DI::cache()->get($cachekey); $dthen = DI::cache()->get($cachekey);
if (empty($dthen)) { if (empty($dthen)) {
$dthen = Item::firstPostDate($uid, $wall); $dthen = Item::firstPostDate($uid, $wall);
DI::cache()->set($cachekey, $dthen, Duration::HOUR); DI::cache()->set($cachekey, $dthen, Duration::HOUR);
@ -490,30 +489,30 @@ class Widget
if ($dthen) { if ($dthen) {
// Set the start and end date to the beginning of the month // Set the start and end date to the beginning of the month
$cutoffday = $dthen; $cutoffday = $dthen;
$thisday = substr($dnow, 4); $thisday = substr($dnow, 4);
$nextday = date('Y-m-d', strtotime($dnow . ' + 1 day')); $nextday = date('Y-m-d', strtotime($dnow . ' + 1 day'));
$nextday = substr($nextday, 4); $nextday = substr($nextday, 4);
$dnow = substr($dnow, 0, 8) . '01'; $dnow = substr($dnow, 0, 8) . '01';
$dthen = substr($dthen, 0, 8) . '01'; $dthen = substr($dthen, 0, 8) . '01';
/* /*
* Starting with the current month, get the first and last days of every * Starting with the current month, get the first and last days of every
* month down to and including the month of the first post * month down to and including the month of the first post
*/ */
while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) { while (substr($dnow, 0, 7) >= substr($dthen, 0, 7)) {
$dyear = intval(substr($dnow, 0, 4)); $dyear = intval(substr($dnow, 0, 4));
$dstart = substr($dnow, 0, 8) . '01'; $dstart = substr($dnow, 0, 8) . '01';
$dend = substr($dnow, 0, 8) . Temporal::getDaysInMonth(intval($dnow), intval(substr($dnow, 5))); $dend = substr($dnow, 0, 8) . Temporal::getDaysInMonth(intval($dnow), intval(substr($dnow, 5)));
$start_month = DateTimeFormat::utc($dstart, 'Y-m-d'); $start_month = DateTimeFormat::utc($dstart, 'Y-m-d');
$end_month = DateTimeFormat::utc($dend, 'Y-m-d'); $end_month = DateTimeFormat::utc($dend, 'Y-m-d');
$str = DI::l10n()->getDay(DateTimeFormat::utc($dnow, 'F')); $str = DI::l10n()->getDay(DateTimeFormat::utc($dnow, 'F'));
if (empty($ret[$dyear])) { if (empty($ret[$dyear])) {
$ret[$dyear] = []; $ret[$dyear] = [];
} }
$ret[$dyear][] = [$str, $end_month, $start_month]; $ret[$dyear][] = [$str, $end_month, $start_month];
$dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d'); $dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d');
} }
} }
@ -522,21 +521,21 @@ class Widget
} }
$cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years; $cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
$cutoff = array_key_exists($cutoff_year, $ret); $cutoff = array_key_exists($cutoff_year, $ret);
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'), [ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'), [
'$title' => DI::l10n()->t('Archives'), '$title' => DI::l10n()->t('Archives'),
'$size' => $visible_years, '$size' => $visible_years,
'$cutoff_year' => $cutoff_year, '$cutoff_year' => $cutoff_year,
'$cutoff' => $cutoff, '$cutoff' => $cutoff,
'$url' => $url, '$url' => $url,
'$dates' => $ret, '$dates' => $ret,
'$showless' => DI::l10n()->t('show less'), '$showless' => DI::l10n()->t('show less'),
'$showmore' => DI::l10n()->t('show more'), '$showmore' => DI::l10n()->t('show more'),
'$onthisdate' => DI::l10n()->t('On this date'), '$onthisdate' => DI::l10n()->t('On this date'),
'$thisday' => $thisday, '$thisday' => $thisday,
'$nextday' => $nextday, '$nextday' => $nextday,
'$cutoffday' => $cutoffday '$cutoffday' => $cutoffday
]); ]);
return $o; return $o;

View file

@ -138,7 +138,7 @@ class StorageManager
// Try the filesystem backend // Try the filesystem backend
case Type\Filesystem::getName(): case Type\Filesystem::getName():
return new Type\FilesystemConfig($this->config, $this->l10n); return new Type\FilesystemConfig($this->config, $this->l10n);
// try the database backend // try the database backend
case Type\Database::getName(): case Type\Database::getName():
return false; return false;
default: default:
@ -185,11 +185,11 @@ class StorageManager
$storageConfig = new Type\FilesystemConfig($this->config, $this->l10n); $storageConfig = new Type\FilesystemConfig($this->config, $this->l10n);
$this->backendInstances[$name] = new Type\Filesystem($storageConfig->getStoragePath()); $this->backendInstances[$name] = new Type\Filesystem($storageConfig->getStoragePath());
break; break;
// try the database backend // try the database backend
case Type\Database::getName(): case Type\Database::getName():
$this->backendInstances[$name] = new Type\Database($this->dba); $this->backendInstances[$name] = new Type\Database($this->dba);
break; break;
// at least, try if there's an addon for the backend // at least, try if there's an addon for the backend
case Type\SystemResource::getName(): case Type\SystemResource::getName():
$this->backendInstances[$name] = new Type\SystemResource(); $this->backendInstances[$name] = new Type\SystemResource();
break; break;
@ -228,11 +228,13 @@ class StorageManager
*/ */
public function isValidBackend(string $name = null, array $validBackends = null): bool public function isValidBackend(string $name = null, array $validBackends = null): bool
{ {
$validBackends = $validBackends ?? array_merge($this->validBackends, $validBackends = $validBackends ?? array_merge(
[ $this->validBackends,
Type\SystemResource::getName(), [
Type\ExternalResource::getName(), Type\SystemResource::getName(),
]); Type\ExternalResource::getName(),
]
);
return in_array($name, $validBackends); return in_array($name, $validBackends);
} }

View file

@ -8,7 +8,6 @@
namespace Friendica\Test; namespace Friendica\Test;
use Friendica\Capabilities\ICanCreateResponses; use Friendica\Capabilities\ICanCreateResponses;
use Friendica\Core\Addon;
use Friendica\Core\Addon\AddonHelper; use Friendica\Core\Addon\AddonHelper;
use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\Hook; use Friendica\Core\Hook;
@ -125,7 +124,7 @@ abstract class ApiTestCase extends FixtureTestCase
file_put_contents( file_put_contents(
$tmpFile, $tmpFile,
base64_decode( base64_decode(
// Empty 1x1 px PNG image // Empty 1x1 px PNG image
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==' 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=='
) )
); );