forked from friendica/friendica-addons
Use ?? instead of the parameter for the default value
This commit is contained in:
parent
dcd097b5b0
commit
58fce248c1
1 changed files with 10 additions and 10 deletions
|
@ -296,7 +296,7 @@ function tumblr_addon_admin(string &$o)
|
||||||
'$submit' => DI::l10n()->t('Save Settings'),
|
'$submit' => DI::l10n()->t('Save Settings'),
|
||||||
'$consumer_key' => ['consumer_key', DI::l10n()->t('Consumer Key'), DI::config()->get('tumblr', 'consumer_key'), ''],
|
'$consumer_key' => ['consumer_key', DI::l10n()->t('Consumer Key'), DI::config()->get('tumblr', 'consumer_key'), ''],
|
||||||
'$consumer_secret' => ['consumer_secret', DI::l10n()->t('Consumer Secret'), DI::config()->get('tumblr', 'consumer_secret'), ''],
|
'$consumer_secret' => ['consumer_secret', DI::l10n()->t('Consumer Secret'), DI::config()->get('tumblr', 'consumer_secret'), ''],
|
||||||
'$max_tags' => ['max_tags', DI::l10n()->t('Maximum tags'), DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS), DI::l10n()->t('Maximum number of tags that a user can follow. Enter 0 to deactivate the feature.')],
|
'$max_tags' => ['max_tags', DI::l10n()->t('Maximum tags'), DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS, DI::l10n()->t('Maximum number of tags that a user can follow. Enter 0 to deactivate the feature.')],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,14 +313,14 @@ function tumblr_settings(array &$data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post', false);
|
$enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post') ?? false;
|
||||||
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', false);
|
$def_enabled = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default') ?? false;
|
||||||
$import = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'import', false);
|
$import = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'import') ?? false;
|
||||||
$tags = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'tags');
|
$tags = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'tumblr', 'tags') ?? [];
|
||||||
|
|
||||||
$max_tags = DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS);
|
$max_tags = DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS;
|
||||||
|
|
||||||
$tags_str = implode(', ', $tags ?? []);
|
$tags_str = implode(', ', $tags);
|
||||||
$cachekey = 'tumblr-blogs-' . DI::userSession()->getLocalUserId();
|
$cachekey = 'tumblr-blogs-' . DI::userSession()->getLocalUserId();
|
||||||
$blogs = DI::cache()->get($cachekey);
|
$blogs = DI::cache()->get($cachekey);
|
||||||
if (empty($blogs)) {
|
if (empty($blogs)) {
|
||||||
|
@ -387,7 +387,7 @@ function tumblr_settings_post(array &$b)
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', intval($_POST['tumblr_bydefault']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'post_by_default', intval($_POST['tumblr_bydefault']));
|
||||||
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'import', intval($_POST['tumblr_import']));
|
DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'tumblr', 'import', intval($_POST['tumblr_import']));
|
||||||
|
|
||||||
$max_tags = DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS);
|
$max_tags = DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS;
|
||||||
$tags = [];
|
$tags = [];
|
||||||
foreach (explode(',', $_POST['tags']) as $tag) {
|
foreach (explode(',', $_POST['tags']) as $tag) {
|
||||||
if (count($tags) < $max_tags) {
|
if (count($tags) < $max_tags) {
|
||||||
|
@ -707,11 +707,11 @@ function tumblr_get_post_from_uri(string $uri): array
|
||||||
*/
|
*/
|
||||||
function tumblr_fetch_tags(int $uid)
|
function tumblr_fetch_tags(int $uid)
|
||||||
{
|
{
|
||||||
if (!DI::config()->get('tumblr', 'max_tags', TUMBLR_DEFAULT_MAXIMUM_TAGS)) {
|
if (!DI::config()->get('tumblr', 'max_tags') ?? TUMBLR_DEFAULT_MAXIMUM_TAGS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (DI::pConfig()->get($uid, 'tumblr', 'tags', []) as $tag) {
|
foreach (DI::pConfig()->get($uid, 'tumblr', 'tags') ?? [] as $tag) {
|
||||||
$data = tumblr_get($uid, 'tagged', ['tag' => $tag]);
|
$data = tumblr_get($uid, 'tagged', ['tag' => $tag]);
|
||||||
foreach (array_reverse($data->response) as $post) {
|
foreach (array_reverse($data->response) as $post) {
|
||||||
$id = tumblr_process_post($post, $uid, Item::PR_TAG);
|
$id = tumblr_process_post($post, $uid, Item::PR_TAG);
|
||||||
|
|
Loading…
Reference in a new issue