diff --git a/composer.json b/composer.json
index 4aec72b1a..93218b474 100644
--- a/composer.json
+++ b/composer.json
@@ -36,7 +36,7 @@
"phpmailer/phpmailer": "^5.2",
"spipu/html2pdf": "^5.0",
"symfony/finder": "^3.3",
- "symfony/translation": "^3.2"
+ "symfony/translation": "^3.3"
},
"autoload": {
"psr-4": {
diff --git a/include/top.php b/include/top.php
index 123bb81bc..4c5a8fcda 100644
--- a/include/top.php
+++ b/include/top.php
@@ -119,11 +119,12 @@ if (!empty($debugbarRenderer) && Auth::check()) {
echo $debugbarRenderer->renderHead();
}
+$hide_sidebar = get_var('Nascondere la barra sinistra di default');
echo '
-
+
';
if (Auth::check()) {
@@ -141,7 +142,7 @@ if (Auth::check()) {
-
+
diff --git a/lib/classes/Filter.php b/lib/classes/Filter.php
index 984d998e4..055a2b117 100644
--- a/lib/classes/Filter.php
+++ b/lib/classes/Filter.php
@@ -61,8 +61,9 @@ class Filter
*/
public static function post($property)
{
- if (!empty(self::getPOST()) && isset(self::getPOST()[$property])) {
- return self::getPOST()[$property];
+ $post = self::getPOST();
+ if (!empty($post) && isset($post[$property])) {
+ return $post[$property];
}
}
@@ -89,8 +90,9 @@ class Filter
*/
public static function get($property)
{
- if (!empty(self::getGET()) && isset(self::getGET()[$property])) {
- return self::getGET()[$property];
+ $get = self::getGET();
+ if (!empty($get) && isset($get[$property])) {
+ return $get[$property];
}
}
@@ -111,7 +113,7 @@ class Filter
} else {
$output = trim(self::getPurifier()->purify($input));
- if (!empty($output) && !empty(Translator::getLocaleFormatter())) {
+ if (!empty($output)) {
if (Translator::getLocaleFormatter()->isNumber($output)) {
$output = Translator::numberToEnglish($output);
} elseif (Translator::getLocaleFormatter()->isTimestamp($output)) {
diff --git a/lib/classes/Intl/FileLoader.php b/lib/classes/Intl/FileLoader.php
index 4f0f88f11..c36b06200 100644
--- a/lib/classes/Intl/FileLoader.php
+++ b/lib/classes/Intl/FileLoader.php
@@ -22,8 +22,9 @@ class FileLoader extends \Symfony\Component\Translation\Loader\FileLoader
$result = [];
$extension = strtolower(pathinfo($resource, PATHINFO_EXTENSION));
- if (!empty($extension) && $extension != 'po' && !empty($this->getLoader($extension))) {
- $result = $this->getLoader($extension)->loadResource($resource);
+ $loader = $this->getLoader($extension);
+ if (!empty($extension) && $extension != 'po' && !empty($loader)) {
+ $result = $loader->loadResource($resource);
if (!empty($this->include_filename)) {
$result = array_combine(
diff --git a/lib/classes/Translator.php b/lib/classes/Translator.php
index 71baa4d1f..8a48b600d 100644
--- a/lib/classes/Translator.php
+++ b/lib/classes/Translator.php
@@ -22,22 +22,14 @@ class Translator extends Util\Singleton
public function __construct($default_locale = 'it', $fallback_locales = ['it'])
{
- if (!empty($instance)) {
- throw new Exception();
- }
+ $translator = new Symfony\Component\Translation\Translator($default_locale);
+ $this->locale = $default_locale;
+ $translator->setFallbackLocales($fallback_locales);
- if (version_compare(PHP_VERSION, '5.5.9') >= 0) {
- $translator = new Symfony\Component\Translation\Translator($default_locale);
- $this->locale = $default_locale;
- $translator->setFallbackLocales($fallback_locales);
+ // Imposta la classe per il caricamento
+ $translator->addLoader('default', new Intl\FileLoader());
- // Imposta la classe per il caricamento
- $translator->addLoader('default', new Intl\FileLoader());
-
- $this->translator = $translator;
- }
-
- $instance = $this;
+ $this->translator = $translator;
}
/**
@@ -60,24 +52,22 @@ class Translator extends Util\Singleton
*/
protected function addLocales($path)
{
- if (!empty($this->translator)) {
- // Individua i linguaggi disponibili
- $dirs = glob($path.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
- foreach ($dirs as $dir) {
- $this->addLocale(basename($dir));
- }
+ // Individua i linguaggi disponibili
+ $dirs = glob($path.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR);
+ foreach ($dirs as $dir) {
+ $this->addLocale(basename($dir));
+ }
- // Aggiunge le singole traduzioni
- foreach ($this->locales as $lang) {
- $done = [];
+ // Aggiunge le singole traduzioni
+ foreach ($this->locales as $lang) {
+ $done = [];
- $files = glob($path.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.'*.*');
- foreach ($files as $file) {
- if (!in_array(basename($file), $done)) {
- $this->translator->addResource('default', $file, $lang);
+ $files = glob($path.DIRECTORY_SEPARATOR.$lang.DIRECTORY_SEPARATOR.'*.*');
+ foreach ($files as $file) {
+ if (!in_array(basename($file), $done)) {
+ $this->translator->addResource('default', $file, $lang);
- $done[] = basename($file);
- }
+ $done[] = basename($file);
}
}
}
@@ -125,9 +115,7 @@ class Translator extends Util\Singleton
public function setLocale($locale)
{
if (!empty($locale) && $this->isLocaleAvailable($locale)) {
- if (!empty($this->translator)) {
- $this->translator->setLocale($locale);
- }
+ $this->translator->setLocale($locale);
$this->locale = $locale;
}
}
@@ -164,14 +152,7 @@ class Translator extends Util\Singleton
*/
public static function translate($string, $parameters = [], $operations = [])
{
- $translator = self::getInstance()->getTranslator();
-
- $result = !empty($translator) ? $translator->trans($string, $parameters) : $string;
-
- // Sostituzione di default nel caso il traduttore non sia supportato
- if (empty($translator)) {
- $result = str_replace(array_keys($operations), array_values($operations), $result);
- }
+ $result = self::getInstance()->getTranslator()->trans($string, $parameters);
// Operazioni aggiuntive sul risultato
if (!empty($operations)) {
diff --git a/lib/classes/Update.php b/lib/classes/Update.php
index 734dda66f..0142ea1bf 100644
--- a/lib/classes/Update.php
+++ b/lib/classes/Update.php
@@ -125,9 +125,9 @@ class Update
*/
public static function getUpdate()
{
- if (!empty(self::getTodos())) {
- return self::getTodos()[0];
- }
+ $todos = self::getTodos();
+
+ return !empty($todos) ? $todos()[0] : null;
}
/**
@@ -149,7 +149,9 @@ class Update
*/
public static function isUpdateAvailable()
{
- return !empty(self::getTodos());
+ $todos = self::getTodos();
+
+ return !empty($todos);
}
/**
diff --git a/lib/util.php b/lib/util.php
index f67aaa8c6..771fe7f12 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -2,28 +2,6 @@
use Stringy\Stringy as S;
-if (!function_exists('parse_ini_string')) {
- /**
- * Simulazione di "parse_ini_string".
- *
- * @param unknown $ini
- * @param string $process_sections
- * @param unknown $scanner_mode
- */
- function parse_ini_string($ini, $process_sections = false, $scanner_mode = null)
- {
- // Generate a temporary file.
- $tempname = tempnam('/tmp', 'ini');
- $fp = fopen($tempname, 'w');
- fwrite($fp, $ini);
- $ini = parse_ini_file($tempname, !empty($process_sections));
- fclose($fp);
- @unlink($tempname);
-
- return $ini;
- }
-}
-
if (!function_exists('array_column')) {
/**
* Pluck an array of values from an array.