From 449a3be3a80bc18626cf9e9402da522449f830ab Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 2 Jul 2025 20:43:55 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20a=20social=20network=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/boot/init.php | 1 + bl-kernel/helpers/theme.class.php | 16 ++++++++++ bl-kernel/social.class.php | 22 ++++++++++++++ bl-plugins/socials/languages/en.json | 7 +++++ bl-plugins/socials/languages/fr_FR.json | 7 +++++ bl-plugins/socials/metadata.json | 11 +++++++ bl-plugins/socials/plugin.php | 40 +++++++++++++++++++++++++ 7 files changed, 104 insertions(+) create mode 100644 bl-kernel/social.class.php create mode 100644 bl-plugins/socials/languages/en.json create mode 100644 bl-plugins/socials/languages/fr_FR.json create mode 100644 bl-plugins/socials/metadata.json create mode 100644 bl-plugins/socials/plugin.php diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 06644836..ddd10687 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -106,6 +106,7 @@ include(PATH_KERNEL . 'url.class.php'); include(PATH_KERNEL . 'login.class.php'); include(PATH_KERNEL . 'parsedown.class.php'); include(PATH_KERNEL . 'security.class.php'); +include(PATH_KERNEL . 'social.class.php'); // Include functions include(PATH_KERNEL . 'functions.php'); diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index 990141bb..2835b4e1 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -20,6 +20,22 @@ class Theme return $GLOBALS['SOCIAL_NETWORKS_EMOJI'][Text::cleanUrl($socialNetwork)]; } + public static function listSiteSocials($list = true, $emoji = false) { + global $site; + $socialList = Theme::socialNetworks(); + + $socialString = ($list == true) ? "" : ""); + return $socialString; + } + public static function title() { global $site; diff --git a/bl-kernel/social.class.php b/bl-kernel/social.class.php new file mode 100644 index 00000000..ea57b883 --- /dev/null +++ b/bl-kernel/social.class.php @@ -0,0 +1,22 @@ +name = $name; + $this->slug = Text::cleanUrl($name); + $this->emoji = $GLOBALS['SOCIAL_NETWORKS_EMOJI'][$this->slug]; + $this->url = $url; + } + + function getLink($useEmoji = false) { + return "".($useEmoji ? '" : ""). " " . $this->name.""; + } + +} \ No newline at end of file diff --git a/bl-plugins/socials/languages/en.json b/bl-plugins/socials/languages/en.json new file mode 100644 index 00000000..0b8c8ded --- /dev/null +++ b/bl-plugins/socials/languages/en.json @@ -0,0 +1,7 @@ +{ + "plugin-data": + { + "name": "Social Networks", + "description": "Shows the social network list in the sidebar." + } +} diff --git a/bl-plugins/socials/languages/fr_FR.json b/bl-plugins/socials/languages/fr_FR.json new file mode 100644 index 00000000..c815606c --- /dev/null +++ b/bl-plugins/socials/languages/fr_FR.json @@ -0,0 +1,7 @@ +{ + "plugin-data": + { + "name": "Réseaux sociaux", + "description": "Affiche la liste des réseaux sociaux dans la barre latérale." + } +} diff --git a/bl-plugins/socials/metadata.json b/bl-plugins/socials/metadata.json new file mode 100644 index 00000000..891c2ded --- /dev/null +++ b/bl-plugins/socials/metadata.json @@ -0,0 +1,11 @@ +{ + "author": "Koblog", + "email": "", + "website": "https://plugins.koblog.com", + "version": "kb_0.0.1", + "releaseDate": "2024-08-23", + "license": "MIT", + "compatible": "kb_0.0.1", + "notes": "", + "type": "widget" +} diff --git a/bl-plugins/socials/plugin.php b/bl-plugins/socials/plugin.php new file mode 100644 index 00000000..44a533e7 --- /dev/null +++ b/bl-plugins/socials/plugin.php @@ -0,0 +1,40 @@ +dbFields = array( + 'label' => 'Social Networks', + ); + } + + public function form() + { + global $L; + + $html = '
'; + $html .= ''; + $html .= ''; + $html .= '' . $L->get('This title is almost always used in the sidebar of the site') . ''; + $html .= '
'; + + return $html; + } + + // Method called on the sidebar of the website + public function siteSidebar() + { + global $L; + global $url; + + $html = '
'; + $html .= '

' . $this->getValue('label') . '

'; + $html .= '
'; + $html .= Theme::listSiteSocials(true, true); + $html .= '
'; + $html .= '
'; + return $html; + } + +} \ No newline at end of file