From a976d0bd2270fc325fd280ca42ccd1a8ac134e3f Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Wed, 29 Oct 2025 15:43:10 +0100 Subject: [PATCH] move getAvailableLanguages() and getLanguages() from translator --- inc/inc.ClassSettings.php | 56 ++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/inc/inc.ClassSettings.php b/inc/inc.ClassSettings.php index 0010964d3..937f79ab6 100644 --- a/inc/inc.ClassSettings.php +++ b/inc/inc.ClassSettings.php @@ -431,17 +431,14 @@ class Settings { /* {{{ */ echo "Your configuration contains errors."; exit; } - -// if (!is_null($this->_maxExecutionTime)) -// ini_set("max_execution_time", $this->_maxExecutionTime); } /* }}} */ /** - * Check if a variable has the string 'true', 'on', 'yes' or 'y' - * and returns true. + * Check if the passed parameter equals to 'true', 'on', 'yes' or 'y' + * and returns true, if it does. * * @param string $var value - * @return true/false + * @return boolean true if $var is 'true', 'on', 'yes' or 'y', otherwise false */ protected static function boolVal($var) { /* {{{ */ $var = strtolower(strval($var)); @@ -459,10 +456,10 @@ class Settings { /* {{{ */ } /* }}} */ /** - * Return ';' seperated string from array + * Create ';' seperated string from array * * @param array $value - * + * @return string */ function arrayToString($value) { /* {{{ */ return implode(";", $value); @@ -472,14 +469,14 @@ class Settings { /* {{{ */ * Return array from ';' seperated string * * @param string $value - * + * @return array */ function stringToArray($value) { /* {{{ */ return explode(";", $value); } /* }}} */ /** - * set $_viewOnlineFileTypes + * Set $_viewOnlineFileTypes * * @param string $stringValue string value * @@ -489,7 +486,7 @@ class Settings { /* {{{ */ } /* }}} */ /** - * get $_viewOnlineFileTypes in a string value + * Get $_viewOnlineFileTypes in a string value * * @return string value * @@ -499,7 +496,7 @@ class Settings { /* {{{ */ } /* }}} */ /** - * set $_editOnlineFileTypes + * Set $_editOnlineFileTypes * * @param string $stringValue string value * @@ -509,7 +506,7 @@ class Settings { /* {{{ */ } /* }}} */ /** - * get $_editOnlineFileTypes in a string value + * Get $_editOnlineFileTypes in a string value * * @return string value * @@ -522,8 +519,7 @@ class Settings { /* {{{ */ * Load config file * * @param string $configFilePath config file path - * - * @return true/false + * @return boolean true, if loading was successful, otherwise false */ public function load($configFilePath) { /* {{{ */ $contents = file_get_contents($configFilePath); @@ -1304,7 +1300,7 @@ class Settings { /* {{{ */ // Save return $xml->asXML($configFilePath); - } /* }}} */ + } /* }}} */ /** * search and return Config File Path @@ -1855,5 +1851,33 @@ class Settings { /* {{{ */ return $this->getBaseUrl().$this->_httpRoot; } /* }}} */ + public function getAvailableLanguages() { /* {{{ */ + $languages = array(); + + $path = $this->_rootDir . "languages/"; + $handle = opendir($path); + + while ($entry = readdir($handle) ) + { + if ($entry == ".." || $entry == ".") { + continue; + } elseif (is_dir($path . $entry)) { + array_push($languages, $entry); + } + } + closedir($handle); + + asort($languages); + return $languages; + } /* }}} */ + + function getLanguages() { /* {{{ */ + if($this->_availablelanguages) { + return $this->_availablelanguages; + } + + return getAvailableLanguages(); + } /* }}} */ + } /* }}} */