Add a social network plugin

This commit is contained in:
Kazhnuz 2025-07-02 20:43:55 +02:00
parent dcf00a1f71
commit 449a3be3a8
7 changed files with 104 additions and 0 deletions

View file

@ -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');

View file

@ -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) ? "<ul class='social-networks'>" : "";
foreach ($socialList as $key => $name) {
$social = new Social($name, $site->getSocialNetwork($name));
$socialString .= (($list == true) ? "<li class='social'>" : "");
$socialString = $socialString . $social->getLink($emoji);
$socialString .= (($list == true) ? "</li>" : "");
}
$socialString .= (($list == true) ? "</ul>" : "");
return $socialString;
}
public static function title()
{
global $site;

View file

@ -0,0 +1,22 @@
<?php defined('KOBLOG') or die('Koblog CMS.');
class Social {
public $slug;
public $url;
public $emoji;
public $name;
function __construct($name, $url)
{
$this->name = $name;
$this->slug = Text::cleanUrl($name);
$this->emoji = $GLOBALS['SOCIAL_NETWORKS_EMOJI'][$this->slug];
$this->url = $url;
}
function getLink($useEmoji = false) {
return "<a href='". $this->url ."' rel='me'>".($useEmoji ? '<span aria-hidden="true">'.$this->emoji."</span>" : ""). " " . $this->name."</a>";
}
}

View file

@ -0,0 +1,7 @@
{
"plugin-data":
{
"name": "Social Networks",
"description": "Shows the social network list in the sidebar."
}
}

View file

@ -0,0 +1,7 @@
{
"plugin-data":
{
"name": "Réseaux sociaux",
"description": "Affiche la liste des réseaux sociaux dans la barre latérale."
}
}

View file

@ -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"
}

View file

@ -0,0 +1,40 @@
<?php
class pluginSocials extends Plugin {
public function init()
{
$this->dbFields = array(
'label' => 'Social Networks',
);
}
public function form()
{
global $L;
$html = '<div>';
$html .= '<label>' . $L->get('Label') . '</label>';
$html .= '<input name="label" type="text" dir="auto" value="' . $this->getValue('label') . '">';
$html .= '<span class="tip">' . $L->get('This title is almost always used in the sidebar of the site') . '</span>';
$html .= '</div>';
return $html;
}
// Method called on the sidebar of the website
public function siteSidebar()
{
global $L;
global $url;
$html = '<div class="plugin plugin-archives">';
$html .= '<h2 class="plugin-label">' . $this->getValue('label') . '</h2>';
$html .= '<div class="plugin-content">';
$html .= Theme::listSiteSocials(true, true);
$html .= '</div>';
$html .= '</div>';
return $html;
}
}