Merge pull request #21405 from Quatadah/adding-smileys

Management of smileys in website pages #21358
This commit is contained in:
Laurent Destailleur 2022-07-06 14:58:12 +02:00 committed by GitHub
commit a8cd94e0f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -213,6 +213,53 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
return $content;
}
/**
* Converts smiley string into the utf8 sequence.
* @param string $content Content to replace
* @return string Replacement of all smiley strings with their utf8 code
* @see dolWebsiteOutput()
*/
function dolReplaceSmileyCodeWithUTF8($content)
{
$map = array(
":face_with_tears_of_joy:" => "\xF0\x9F\x98\x82",
":grinning_face_with_smiling_eyes:" => "\xF0\x9F\x98\x81",
":smiling_face_with_open_mouth:" => "\xF0\x9F\x98\x83",
":smiling_face_with_open_mouth_and_cold_sweat:" => "\xF0\x9F\x98\x85",
":smiling_face_with_open_mouth_and_tightly_closed_eyes:" => "\xF0\x9F\x98\x86",
":winking_face:" => "\xF0\x9F\x98\x89",
":smiling_face_with_smiling_eyes:" => "\xF0\x9F\x98\x8A",
":face_savouring_delicious_food:" => "\xF0\x9F\x98\x8B",
":relieved_face:" => "\xF0\x9F\x98\x8C",
":smiling_face_with_heart_shaped_eyes:" => "\xF0\x9F\x98\x8D",
":smiling_face_with_sunglasses:" => "\xF0\x9F\x98\x8E",
":smirking_face:" => "\xF0\x9F\x98\x8F",
":neutral_face:" => "\xF0\x9F\x98\x90",
":expressionless_face:" => "\xF0\x9F\x98\x91",
":unamused_face:" => "\xF0\x9F\x98\x92",
":face_with_cold_sweat:" => "\xF0\x9F\x98\x93",
":pensive_face:" => "\xF0\x9F\x98\x94",
":confused_face:" => "\xF0\x9F\x98\x95",
":confounded_face:" => "\xF0\x9F\x98\x96",
":kissing_face:" => "\xF0\x9F\x98\x97",
":face_throwing_a_kiss:" => "\xF0\x9F\x98\x98",
":kissing_face_with_smiling_eyes:" => "\xF0\x9F\x98\x99",
":kissing_face_with_closed_eyes:" => "\xF0\x9F\x98\x9A",
":face_with_stuck_out_tongue:" => "\xF0\x9F\x98\x9B",
":face_with_stuck_out_tongue_and_winking_eye:" => "\xF0\x9F\x98\x9C",
":face_with_stuck_out_tongue_and_tightly_closed_eyes:" => "\xF0\x9F\x98\x9D",
":disappointed_face:" => "\xF0\x9F\x98\x9E",
":worried_face:" => "\xF0\x9F\x98\x9F",
":angry_face:" => "\xF0\x9F\x98\xA0",
":face_with_symbols_on_mouth:" => "\xF0\x9F\x98\xA1",
);
foreach ($map as $key => $value) {
$content = str_replace($key, $value, $content);
}
return $content;
}
/**
* Render a string of an HTML content and output it.
* Used to ouput the page when viewed from a server (Dolibarr or Apache).
@ -369,6 +416,8 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
$content = str_replace('<body id="bodywebsite" class="bodywebsite', '<body id="bodywebsite" class="bodywebsite '.$conf->global->WEBSITE_ADD_CSS_TO_BODY, $content);
}
$content = dolReplaceSmileyCodeWithUTF8($content);
dol_syslog("dolWebsiteOutput end");
print $content;