Automatic pass to convert with php-cs-fixer

This commit is contained in:
2023-04-13 21:33:52 +02:00
parent 63b150a493
commit 0111c96f1d
105 changed files with 10478 additions and 8273 deletions

View File

@@ -1,15 +1,17 @@
<?php
/** DomFramework
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
/**
* DomFramework
* @package domframework
* @author Dominique Fournier <dominique@fournier38.fr>
* @license BSD
*/
namespace Domframework;
/** Language class : change the messages
*/
/**
* Language class : change the messages
*/
class Language
{
// Language.php
@@ -26,18 +28,21 @@ class Language
// The languages are always in the format fr_FR (without the codeset)
/** Language cache directory */
/**
* Language cache directory
*/
public $cacheDir = "data/locale";
/** Choose the best language in the browser list and which is available in
* locale path
* @param string|null $repLocale Directory where are stored the translations
* @param string|null $languageCode The coding langugage of the soft
* @return string The choosed locale whithout charset (like fr_FR)
*/
/**
* Choose the best language in the browser list and which is available in
* locale path
* @param string|null $repLocale Directory where are stored the translations
* @param string|null $languageCode The coding langugage of the soft
* @return string The choosed locale whithout charset (like fr_FR)
*/
public function languageSelection($repLocale = "./locale", $languageCode = "fr_FR")
{
$arrAccept = array();
$arrAccept = [];
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
// Analyse de HTTP_ACCEPT_LANGUAGE
// HTTP_ACCEPT_LANGUAGE est de la forme : fr,en;q=0.7,en-us;q=0.3
@@ -128,12 +133,13 @@ class Language
return ($languageCode);
}
/** Return the language recorded in the Cookie. Check if this language is
* @param string $cookieName The cookie name
* @param string|null $repLocale The directory use to store the locale files
* allowed
* @return string The language allowed or FALSE
*/
/**
* Return the language recorded in the Cookie. Check if this language is
* @param string $cookieName The cookie name
* @param string|null $repLocale The directory use to store the locale files
* allowed
* @return string The language allowed or FALSE
*/
public function languageCookie($cookieName, $repLocale = "./locale")
{
if (!isset($_COOKIE[$cookieName])) {
@@ -143,27 +149,29 @@ class Language
if ($listeTranslations === false) {
return false;
}
if (in_array($_COOKIE[$cookieName], $listeTranslations)) {
if (in_array($_COOKIE[$cookieName], $listeTranslations, true)) {
return $_COOKIE[$cookieName];
}
return false;
}
/** Set the cookie with a TTL of one month
* @param string $cookieName The name of the cookie
* @param string $languageCode Language to store
* @param string $sitepath The site path
*/
/**
* Set the cookie with a TTL of one month
* @param string $cookieName The name of the cookie
* @param string $languageCode Language to store
* @param string $sitepath The site path
*/
public function languageCookieSet($cookieName, $languageCode, $sitepath)
{
@setcookie($cookieName, $languageCode, time() + 60 * 60 * 24 * 30, $sitepath);
}
/** Return an array with all the languages available in the $repLocale dir
* The languages are in the format 'en_US' without the codeset.
* @param string|null $repLocale The directory use to store the locale files
* Return FALSE if there is an error
*/
/**
* Return an array with all the languages available in the $repLocale dir
* The languages are in the format 'en_US' without the codeset.
* @param string|null $repLocale The directory use to store the locale files
* Return FALSE if there is an error
*/
public function languageTraductionsList($repLocale = "./locale")
{
if (! is_dir($repLocale) || ! is_readable($repLocale)) {
@@ -183,10 +191,11 @@ class Language
return $list;
}
/** Return the full text of the category
* Return false if it doesn't exists
* @param string $category The category to analyze
*/
/**
* Return the full text of the category
* Return false if it doesn't exists
* @param string $category The category to analyze
*/
private function languageCategoryText($category)
{
$categories[LC_ALL] = "LC_ALL";
@@ -202,14 +211,15 @@ class Language
return $categories[$category];
}
/** This function manage the cache of $package.mo files as Apache cache them
* It return the directory to use
* @param string $languageCode Language with format "fr_FR"
* @param string|null $package The package name of the soft ($package.mo
* file). "messages" by default
* @param string|null $category The folder name LC_MESSAGES by default
* @param string|null $repLocale The folder where all the locales are stored
*/
/**
* This function manage the cache of $package.mo files as Apache cache them
* It return the directory to use
* @param string $languageCode Language with format "fr_FR"
* @param string|null $package The package name of the soft ($package.mo
* file). "messages" by default
* @param string|null $category The folder name LC_MESSAGES by default
* @param string|null $repLocale The folder where all the locales are stored
*/
public function languageCache(
$languageCode,
$package = "messages",
@@ -255,7 +265,8 @@ class Language
filemtime($moFile) > filemtime($link)
) {
// Do not remove immediately the old files : they can be used by Apache
$files = glob($this->cacheDir . "/*/" . $linkEnd);
$files = glob($this->cacheDir . "/
*/" . $linkEnd);
foreach ($files as $file) {
unlink($file);
// Remove the empty dirs. If not empty, do not display an error
@@ -273,13 +284,14 @@ class Language
return $moFile;
}
/** Start the Gettext support with the cached file .mo provided as parameter
* @param string $moFile The .mo file
* @param string $languageCode The language code to use
* @param integer $category the LC_ type to use
* @param string|null $repLocale The locale directory. Use "./locale" if not
* provided
*/
/**
* Start the Gettext support with the cached file .mo provided as parameter
* @param string $moFile The .mo file
* @param string $languageCode The language code to use
* @param integer $category the LC_ type to use
* @param string|null $repLocale The locale directory. Use "./locale" if not
* provided
*/
public function languageActivation(
$moFile,
$languageCode,
@@ -322,11 +334,13 @@ class Language
return false;
}
/** The complete stack of language selection
@param string $package The package name (package.(po|mo) files)
@param string $languageCookie The name of the cookie saved in the browser
@param string $forcedLanguage The name of a forced language
@return string The language with format fr_FR to be used */
/**
* The complete stack of language selection
* @param string $package The package name (package.(po|mo) files)
* @param string $languageCookie The name of the cookie saved in the browser
* @param string $forcedLanguage The name of a forced language
* @return string The language with format fr_FR to be used
*/
public function activeLanguage(
$package,
$languageCookie,
@@ -366,10 +380,12 @@ class Language
return $languageCode;
}
/** Return the language name from the language
Ex. : $languageCode=fr_FR, return France
@param string $languageCode Language with format "fr_FR"
@return string Then language name */
/**
* Return the language name from the language
* Ex. : $languageCode=fr_FR, return France
* @param string $languageCode Language with format "fr_FR"
* @return string Then language name
*/
public function languageName($languageCode)
{
switch ($languageCode) {
@@ -384,11 +400,12 @@ class Language
}
}
/** Return the language subtag for the language
* http://www.iana.org/assignments/language-subtag-registry/
* language-subtag-registry
* @param string $languageCode The language code to convert
*/
/**
* Return the language subtag for the language
* http://www.iana.org/assignments/language-subtag-registry/
* language-subtag-registry
* @param string $languageCode The language code to convert
*/
public function languageSubTag($languageCode)
{
return str_replace("_", "-", $languageCode);