34 public $socialnetworks;
48 $nbofnetworks = count($socialnetworks);
50 foreach ($socialnetworks as $key => $value) {
51 if (!empty(
$object->socialnetworks[$key])) {
56 if ($nbofnetworks > 1) {
57 print
'<tr><td colspan="'.$colspan.
'"><br><a class="paddingtop paddingbottom socialnetworklnk onreposition" id="socialnetworklnk" href="#"></a>';
61 print
' <a class="paddingtop paddingbottom socialnetworklnk onreposition" href="#"><span class="badge badge-secondary socialnetworklnk">'.$nbactive.
'</span></a>';
65 foreach ($socialnetworks as $key => $value) {
66 if ($value[
'active'] || $nbofnetworks == 1) {
67 print
'<tr class="soc_network">';
68 print
'<td><label for="'.$value[
'label'].
'">'.$form->editfieldkey($value[
'label'], $key,
'',
$object, 0).
'</label></td>';
69 print
'<td colspan="3">';
70 if (!empty($value[
'icon'])) {
71 print
'<span class="fab '.$value[
'icon'].
' pictofixedwidth"></span>';
73 print
'<input type="text" name="'.$key.
'" id="'.$key.
'" class="minwidth100 maxwidth300 widthcentpercentminusx" maxlength="80" value="'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alphanohtml') : (empty(
$object->socialnetworks[$key]) ?
'' :
$object->socialnetworks[$key])).
'">';
76 } elseif (!empty(
$object->socialnetworks[$key])) {
77 print
'<input type="hidden" name="'.$key.
'" value="'.
$object->socialnetworks[$key].
'">';
81 if ($nbofnetworks > 1) {
82 print
'<script nonce="'.getNonce().
'" type="text/javascript">
83 $("document").ready(function() { toogleSocialNetwork(false); });
85 jQuery(".socialnetworklnk").click(function() {
86 console.log("Click on link");
87 toogleSocialNetwork(true);
91 function toogleSocialNetwork(chgCookieState) {
92 const lnk = $("#socialnetworklnk");
93 const items = $(".soc_network");
94 var cookieState = document.cookie.split(";").some((item) => item.trim().startsWith("DOLUSER_SOCIALNETWORKS_SHOW=true")) == true;
96 if (!chgCookieState) cookieState = !cookieState ;
100 lnk.text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"ShowSocialNetworks")).
'...");
101 if (chgCookieState) { document.cookie = "DOLUSER_SOCIALNETWORKS_SHOW=false; SameSite=Strict"};
104 lnk.text("'.
dol_escape_js($langs->transnoentitiesnoconv(
"HideSocialNetworks")).
'...");
105 if (chgCookieState) { document.cookie = "DOLUSER_SOCIALNETWORKS_SHOW=true; SameSite=Strict";}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
showSocialNetwork($socialnetworks, $colspan=4)
Show social network part if the module is enabled with hiding functionality.
trait CommonSocialNetworks
Superclass for social networks.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...