Couleur du texte dans les en-têtes des tableaux
This commit is contained in:
parent
a8e261f517
commit
eea0234792
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
class helper {
|
||||
class helper
|
||||
{
|
||||
|
||||
/** Statut de la réécriture d'URL (pour éviter de lire le contenu du fichier .htaccess à chaque self::baseUrl()) */
|
||||
public static $rewriteStatus = null;
|
||||
@ -23,7 +24,8 @@ class helper {
|
||||
* Traduire le message dans la langue déterminée
|
||||
*/
|
||||
|
||||
public static function translate($text) {
|
||||
public static function translate($text)
|
||||
{
|
||||
|
||||
// Captation
|
||||
/*
|
||||
@ -46,14 +48,13 @@ class helper {
|
||||
* Cette fonction est utilisée par user
|
||||
*/
|
||||
|
||||
public static function getIp($anon = 4) {
|
||||
public static function getIp($anon = 4)
|
||||
{
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
}
|
||||
elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
@ -72,13 +73,16 @@ class helper {
|
||||
* @return mixed données récupérées
|
||||
*/
|
||||
|
||||
public static function getUrlContents ($url) {
|
||||
public static function getUrlContents($url)
|
||||
{
|
||||
// Ejecter free.fr
|
||||
if (strpos(self::baseUrl(), 'free.fr') > 0) {
|
||||
return false;
|
||||
}
|
||||
if(function_exists('file_get_contents') &&
|
||||
ini_get('allow_url_fopen') ){
|
||||
if (
|
||||
function_exists('file_get_contents') &&
|
||||
ini_get('allow_url_fopen')
|
||||
) {
|
||||
$url_get_contents_data = @file_get_contents($url); // Masque un warning éventuel
|
||||
} elseif (function_exists('curl_version')) {
|
||||
$ch = curl_init();
|
||||
@ -87,9 +91,11 @@ class helper {
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
$url_get_contents_data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}elseif(function_exists('fopen') &&
|
||||
} elseif (
|
||||
function_exists('fopen') &&
|
||||
function_exists('stream_get_contents') &&
|
||||
ini_get('allow_url_fopen')){
|
||||
ini_get('allow_url_fopen')
|
||||
) {
|
||||
$handle = fopen($url, "r");
|
||||
$url_get_contents_data = stream_get_contents($handle);
|
||||
} else {
|
||||
@ -105,7 +111,8 @@ class helper {
|
||||
* @param string $sort Type de tri à appliquer au tableau (SORT_ASC, SORT_DESC, ou null)
|
||||
* @return array
|
||||
*/
|
||||
public static function arraycolumn($array, $column, $sort = null) {
|
||||
public static function arraycolumn($array, $column, $sort = null)
|
||||
{
|
||||
$newArray = [];
|
||||
if (empty($array) === false) {
|
||||
$newArray = array_map(function ($element) use ($column) {
|
||||
@ -126,7 +133,8 @@ class helper {
|
||||
/**
|
||||
* Compatibilité avec les anciens modules
|
||||
*/
|
||||
public static function arrayCollumn($array, $column, $sort = null) {
|
||||
public static function arrayCollumn($array, $column, $sort = null)
|
||||
{
|
||||
return (helper::arrayColumn($array, $column, $sort));
|
||||
}
|
||||
|
||||
@ -139,7 +147,8 @@ class helper {
|
||||
* @return string nom du fichier de sauvegarde
|
||||
*/
|
||||
|
||||
public static function autoBackup($folder, $filter = ['backup','tmp'] ) {
|
||||
public static function autoBackup($folder, $filter = ['backup', 'tmp'])
|
||||
{
|
||||
// Creation du ZIP
|
||||
$baseName = str_replace('/', '', helper::baseUrl(false, false));
|
||||
$baseName = empty($baseName) ? 'ZwiiCMS' : $baseName;
|
||||
@ -177,7 +186,8 @@ class helper {
|
||||
* du nom réel
|
||||
* du numéro de version
|
||||
*/
|
||||
public static function getModules() {
|
||||
public static function getModules()
|
||||
{
|
||||
$modules = array();
|
||||
$dirs = array_diff(scandir('module'), array('..', '.'));
|
||||
foreach ($dirs as $key => $value) {
|
||||
@ -225,7 +235,6 @@ class helper {
|
||||
'delete' => $delete,
|
||||
'dataDirectory' => $dataDirectory
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
// on ne fait rien
|
||||
}
|
||||
@ -240,10 +249,11 @@ class helper {
|
||||
* Retourne true si le protocole est en TLS
|
||||
* @return bool
|
||||
*/
|
||||
public static function isHttps() {
|
||||
public static function isHttps()
|
||||
{
|
||||
if (
|
||||
(empty($_SERVER['HTTPS']) === false AND $_SERVER['HTTPS'] !== 'off')
|
||||
OR $_SERVER['SERVER_PORT'] === 443
|
||||
(empty($_SERVER['HTTPS']) === false and $_SERVER['HTTPS'] !== 'off')
|
||||
or $_SERVER['SERVER_PORT'] === 443
|
||||
) {
|
||||
return true;
|
||||
} else {
|
||||
@ -258,7 +268,8 @@ class helper {
|
||||
* @param bool $host Affiche ou non l'host
|
||||
* @return string
|
||||
*/
|
||||
public static function baseUrl($queryString = true, $host = true) {
|
||||
public static function baseUrl($queryString = true, $host = true)
|
||||
{
|
||||
// Protocole
|
||||
$protocol = helper::isHttps() === true ? 'https://' : 'http://';
|
||||
// Host
|
||||
@ -268,10 +279,9 @@ class helper {
|
||||
// Pathinfo
|
||||
$pathInfo = pathinfo($_SERVER['PHP_SELF']);
|
||||
// Querystring
|
||||
if($queryString AND helper::checkRewrite() === false) {
|
||||
if ($queryString and helper::checkRewrite() === false) {
|
||||
$queryString = '?';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$queryString = '';
|
||||
}
|
||||
return $host . rtrim($pathInfo['dirname'], ' ' . DIRECTORY_SEPARATOR) . '/' . $queryString;
|
||||
@ -281,7 +291,8 @@ class helper {
|
||||
* Check le statut de l'URL rewriting
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkRewrite() {
|
||||
public static function checkRewrite()
|
||||
{
|
||||
// N'interroge que le serveur Apache
|
||||
if (strpos($_SERVER["SERVER_SOFTWARE"], 'Apache') > 0) {
|
||||
self::$rewriteStatus === false;
|
||||
@ -299,7 +310,8 @@ class helper {
|
||||
* Renvoie le numéro de version de Zwii est en ligne
|
||||
* @return string
|
||||
*/
|
||||
public static function getOnlineVersion() {
|
||||
public static function getOnlineVersion()
|
||||
{
|
||||
return (helper::getUrlContents(common::ZWII_UPDATE_URL . common::ZWII_UPDATE_CHANNEL . '/version'));
|
||||
}
|
||||
|
||||
@ -308,12 +320,12 @@ class helper {
|
||||
* Check si une nouvelle version de Zwii est disponible
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkNewVersion() {
|
||||
public static function checkNewVersion()
|
||||
{
|
||||
$version = helper::getOnlineVersion();
|
||||
if (!empty($version)) {
|
||||
return ((version_compare(common::ZWII_VERSION, $version)) === -1);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -324,7 +336,8 @@ class helper {
|
||||
* @param string $rgba Code rgba de la couleur
|
||||
* @return array
|
||||
*/
|
||||
public static function colorVariants($rgba) {
|
||||
public static function colorVariants($rgba)
|
||||
{
|
||||
preg_match('#\(+(.*)\)+#', $rgba, $matches);
|
||||
$rgba = explode(', ', $matches[1]);
|
||||
return [
|
||||
@ -332,7 +345,12 @@ class helper {
|
||||
'darken' => 'rgba(' . max(0, $rgba[0] - 15) . ',' . max(0, $rgba[1] - 15) . ',' . max(0, $rgba[2] - 15) . ',' . $rgba[3] . ')',
|
||||
'veryDarken' => 'rgba(' . max(0, $rgba[0] - 20) . ',' . max(0, $rgba[1] - 20) . ',' . max(0, $rgba[2] - 20) . ',' . $rgba[3] . ')',
|
||||
'text' => self::relativeLuminanceW3C($rgba) > .22 ? "#222" : "#DDD",
|
||||
'rgb' => 'rgb(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ')'
|
||||
'rgb' => 'rgb(' . $rgba[0] . ',' . $rgba[1] . ',' . $rgba[2] . ')',
|
||||
'invert' => 'rgba (' .
|
||||
($rgba[0] < 128 ? 255 : 0) . ',' .
|
||||
($rgba[1] < 128 ? 255 : 0) . ',' .
|
||||
($rgba[1] < 128 ? 255 : 0) . ',' .
|
||||
($rgba[0] < 128 ? 255 : 0) . ')'
|
||||
];
|
||||
}
|
||||
|
||||
@ -340,7 +358,8 @@ class helper {
|
||||
* Supprime un cookie
|
||||
* @param string $cookieKey Clé du cookie à supprimer
|
||||
*/
|
||||
public static function deleteCookie($cookieKey) {
|
||||
public static function deleteCookie($cookieKey)
|
||||
{
|
||||
unset($_COOKIE[$cookieKey]);
|
||||
setcookie($cookieKey, '', time() - 3600, helper::baseUrl(false, false), '', false, true);
|
||||
}
|
||||
@ -351,7 +370,8 @@ class helper {
|
||||
* @param int $filter Type de filtre à appliquer
|
||||
* @return string
|
||||
*/
|
||||
public static function filter($text, $filter) {
|
||||
public static function filter($text, $filter)
|
||||
{
|
||||
$text = trim($text);
|
||||
switch ($filter) {
|
||||
case self::FILTER_BOOLEAN:
|
||||
@ -419,7 +439,8 @@ class helper {
|
||||
* @param array $array Tableau à vérifier
|
||||
* @return string
|
||||
*/
|
||||
public static function increment($key, $array = []) {
|
||||
public static function increment($key, $array = [])
|
||||
{
|
||||
// Pas besoin d'incrémenter si la clef n'existe pas
|
||||
if ($array === []) {
|
||||
return $key;
|
||||
@ -429,7 +450,7 @@ class helper {
|
||||
// Si la clef est numérique elle est incrémentée
|
||||
if (is_numeric($key)) {
|
||||
$newKey = $key;
|
||||
while(array_key_exists($newKey, $array) OR in_array($newKey, $array)) {
|
||||
while (array_key_exists($newKey, $array) or in_array($newKey, $array)) {
|
||||
$newKey++;
|
||||
}
|
||||
}
|
||||
@ -437,7 +458,7 @@ class helper {
|
||||
else {
|
||||
$i = 2;
|
||||
$newKey = $key;
|
||||
while(array_key_exists($newKey, $array) OR in_array($newKey, $array)) {
|
||||
while (array_key_exists($newKey, $array) or in_array($newKey, $array)) {
|
||||
$newKey = $key . '-' . $i;
|
||||
$i++;
|
||||
}
|
||||
@ -451,7 +472,8 @@ class helper {
|
||||
* @param string $css Css à minimiser
|
||||
* @return string
|
||||
*/
|
||||
public static function minifyCss($css) {
|
||||
public static function minifyCss($css)
|
||||
{
|
||||
// Supprime les commentaires
|
||||
$css = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $css);
|
||||
// Supprime les tabulations, espaces, nouvelles lignes, etc...
|
||||
@ -468,7 +490,8 @@ class helper {
|
||||
* @param string $js Js à minimiser
|
||||
* @return string
|
||||
*/
|
||||
public static function minifyJs($js) {
|
||||
public static function minifyJs($js)
|
||||
{
|
||||
// Supprime les commentaires
|
||||
$js = preg_replace('/\\/\\*[^*]*\\*+([^\\/][^*]*\\*+)*\\/|\s*(?<![\:\=])\/\/.*/', '', $js);
|
||||
// Supprime les tabulations, espaces, nouvelles lignes, etc...
|
||||
@ -486,7 +509,8 @@ class helper {
|
||||
* @param null|int $sufix Suffixe de l'url
|
||||
* @return array
|
||||
*/
|
||||
public static function pagination($array, $url, $item, $sufix = null) {
|
||||
public static function pagination($array, $url, $item, $sufix = null)
|
||||
{
|
||||
// Scinde l'url
|
||||
$url = explode('/', $url);
|
||||
// Url de pagination
|
||||
@ -524,7 +548,8 @@ class helper {
|
||||
/**
|
||||
* Calcul de la luminance relative d'une couleur
|
||||
*/
|
||||
public static function relativeLuminanceW3C($rgba) {
|
||||
public static function relativeLuminanceW3C($rgba)
|
||||
{
|
||||
// Conversion en sRGB
|
||||
$RsRGB = $rgba[0] / 255;
|
||||
$GsRGB = $rgba[1] / 255;
|
||||
@ -546,7 +571,8 @@ class helper {
|
||||
* @param array $exclude Clés à ignorer ($key)
|
||||
* @return string
|
||||
*/
|
||||
public static function sprintAttributes(array $array = [], array $exclude = []) {
|
||||
public static function sprintAttributes(array $array = [], array $exclude = [])
|
||||
{
|
||||
$exclude = array_merge(
|
||||
[
|
||||
'before',
|
||||
@ -558,7 +584,7 @@ class helper {
|
||||
);
|
||||
$attributes = [];
|
||||
foreach ($array as $key => $value) {
|
||||
if(($value OR $value === 0) AND in_array($key, $exclude) === false) {
|
||||
if (($value or $value === 0) and in_array($key, $exclude) === false) {
|
||||
// Désactive le message de modifications non enregistrées pour le champ
|
||||
if ($key === 'noDirty') {
|
||||
$attributes[] = 'data-no-dirty';
|
||||
@ -584,7 +610,8 @@ class helper {
|
||||
* @param int $length (voir substr de PHP pour fonctionnement)
|
||||
* @return string
|
||||
*/
|
||||
public static function subword($text, $start, $length) {
|
||||
public static function subword($text, $start, $length)
|
||||
{
|
||||
$text = trim($text);
|
||||
if (strlen($text) > $length) {
|
||||
$text = mb_substr($text, $start, $length);
|
||||
@ -599,7 +626,8 @@ class helper {
|
||||
* @param string $payload la chaine à coder
|
||||
* @return string
|
||||
*/
|
||||
public static function encrypt($key, $payload) {
|
||||
public static function encrypt($key, $payload)
|
||||
{
|
||||
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
|
||||
$encrypted = openssl_encrypt($payload, 'aes-256-cbc', $key, 0, $iv);
|
||||
return base64_encode($encrypted . '::' . $iv);
|
||||
@ -611,9 +639,9 @@ class helper {
|
||||
* @param string $garble la chaine à décoder
|
||||
* @return string
|
||||
*/
|
||||
public static function decrypt($key, $garble) {
|
||||
public static function decrypt($key, $garble)
|
||||
{
|
||||
list($encrypted_data, $iv) = explode('::', base64_decode($garble), 2);
|
||||
return openssl_decrypt($encrypted_data, 'aes-256-cbc', $key, 0, $iv);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2681,9 +2681,11 @@ class core extends common
|
||||
$css .= 'body h1, h2, h3, h4 a, h5, h6 {font-family:' . $fonts[$this->getData(['admin', 'fontTitle'])] . ';color:' . $this->getData(['admin', 'colorTitle']) . ';}';
|
||||
|
||||
// TinyMCE
|
||||
$css .= 'body:not(.editorWysiwyg),span .zwiico-help {color:' . $this->getData(['admin', 'colorText']) . ';}';
|
||||
$css .= 'table thead tr, table thead tr .zwiico-help{ background-color:' . $this->getData(['admin', 'colorText']) . '; color:' . $colors['text'] . ';}';
|
||||
$css .= 'table thead th { color: ' . $this->getData(['admin', 'colorText']) . '; filter: invert(100%);}';
|
||||
$colors = helper::colorVariants($this->getData(['admin', 'colorText']));
|
||||
$css .= 'body:not(.editorWysiwyg),span .zwiico-help {color:' . $colors['normal'] . ';}';
|
||||
echo $colors['invert'];
|
||||
$css .= 'table thead tr, table thead tr .zwiico-help{ background-color:' . $colors['normal'] . '; color:' . $colors['text'] . ';}';
|
||||
$css .= 'table thead th { color:' . $colors['text'] . ';}';
|
||||
$colors = helper::colorVariants($this->getData(['admin', 'backgroundColorButton']));
|
||||
$css .= 'input[type="checkbox"]:checked + label::before,.speechBubble{background-color:' . $colors['normal'] . ';color:' . $colors['text'] . ';}';
|
||||
$css .= '.speechBubble::before {border-color:' . $colors['normal'] . ' transparent transparent transparent;}';
|
||||
|
Loading…
Reference in New Issue
Block a user