From 770a65e15c26e7e8bbe8e8b98cd0c7b9b3ffb1f1 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 20:19:51 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20an=20array=20for=20t?= =?UTF-8?q?he=20site=20socials?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/admin/views/settings.php | 21 ++++++++++++++++++++- bl-kernel/functions.php | 7 +++++++ bl-kernel/site.class.php | 15 ++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php index a9a02f22..0f2d6022 100644 --- a/bl-kernel/admin/views/settings.php +++ b/bl-kernel/admin/views/settings.php @@ -19,7 +19,7 @@ p('General') ?> p('Advanced') ?> p('SEO') ?> - p('Social Networks') >; ?> + p('Social Networks') ?> p('Images') ?> p('Language') ?> p('Logo') ?> @@ -400,6 +400,25 @@ echo Bootstrap::formInputHidden(array( ?> +
+ g('Social Networks')); + + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $value) { + echo Bootstrap::formInputText(array( + 'name' => Text::cleanUrl($value), + 'label' => $value, + 'value' => $site->getSocialNetwork($value), + 'class' => '', + 'placeholder' => '', + 'tip' => '' + )); + } + + echo Bootstrap::cardEnd(); + ?> +
+
setCustomFields($args['customFields']); } + foreach ($GLOBALS['SOCIAL_NETWORKS'] as $key => $social) { + $socialKey = Text::cleanUrl($social); + if (isset($args[$socialKey])) { + $site->setSocialNetwork($socialKey, $args[$socialKey]); + } + } + if ($site->set($args)) { // Check current order-by if changed it reorder the content if ($site->orderBy() != ORDER_BY) { diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php index 495031ac..d340895b 100644 --- a/bl-kernel/site.class.php +++ b/bl-kernel/site.class.php @@ -58,7 +58,8 @@ class Site extends dbJSON 'avatarQuality' => 100, 'logo' => '', 'markdownParser' => true, - 'customFields' => '{}' + 'customFields' => '{}', + 'socials' => array() ); function __construct() @@ -479,4 +480,16 @@ class Site extends dbJSON $customFields = Sanitize::htmlDecode($this->getField('customFields')); return json_decode($customFields, true); } + + public function setSocialNetwork($social, $url) { + $key = Text::cleanUrl($social); + if ($this->getField('socials') == NULL) { + $this->db['socials'] = array(); + } + $this->db['socials'][$key] = $url; + } + + public function getSocialNetwork($social) { + return $this->getField('socials')[Text::cleanUrl($social)]; + } }