From f9cefea9eaa68e3093b5b03e585c70f1ac33b1de Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 29 Nov 2018 15:52:53 +0100 Subject: [PATCH] Minor - format code, remove unused code, fix php warning, fix URL --- main/inc/lib/internationalization.lib.php | 80 ------------------- plugin/vchamilo/plugin.php | 2 +- src/CoreBundle/Controller/IndexController.php | 1 + src/CoreBundle/Framework/Container.php | 1 + src/CoreBundle/Menu/NavBuilder.php | 2 +- 5 files changed, 4 insertions(+), 82 deletions(-) diff --git a/main/inc/lib/internationalization.lib.php b/main/inc/lib/internationalization.lib.php index 13f7ed2e45..2310d41556 100755 --- a/main/inc/lib/internationalization.lib.php +++ b/main/inc/lib/internationalization.lib.php @@ -72,7 +72,6 @@ function get_lang($variable) return $variable; } - //return $variable; // Using symfony $defaultDomain = 'messages'; $translated = Container::getTranslator()->trans( @@ -95,85 +94,6 @@ function get_lang($variable) } return $translated; - - // For serving some old hacks: - // By manipulating this global variable the translation may - // be done in different languages too (not the elegant way). - global $language_interface; - // Because of possibility for manipulations of the global - // variable $language_interface, we need its initial value. - global $language_interface_initial_value; - global $used_lang_vars, $_configuration; - // add language_measure_frequency to your main/inc/conf/configuration.php in order to generate language - // variables frequency measurements (you can then see them trhough main/cron/lang/langstats.php) - // The $langstats object is instanciated at the end of main/inc/global.inc.php - if (isset($_configuration['language_measure_frequency']) && - $_configuration['language_measure_frequency'] == 1 - ) { - require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; - global $langstats; - $langstats->add_use($variable, ''); - } - - if (!isset($used_lang_vars)) { - $used_lang_vars = []; - } - - // Caching results from some API functions, for speed. - static $initialized, $show_special_markup; - if (!isset($initialized)) { - $test_server_mode = api_get_setting('server_type') === 'test'; - $show_special_markup = api_get_setting('hide_dltt_markup') != 'true' || $test_server_mode; - $initialized = true; - } - - // Combining both ways for requesting specific language. - if (empty($language)) { - $language = $language_interface; - } - $lang_postfix = isset($is_interface_language) && $is_interface_language ? '' : '('.$language.')'; - - $is_interface_language = $language == $language_interface_initial_value; - - // This is a cache for already translated language variables. By using it, we avoid repetitive translations, gaining speed. - static $cache; - - // Looking up into the cache for existing translation. - if (isset($cache[$language][$variable])) { - // There is a previously saved translation, returning it. - //return $cache[$language][$variable]; - $ret = $cache[$language][$variable]; - $used_lang_vars[$variable.$lang_postfix] = $ret; - - return $ret; - } - - // There is no cached translation, we have to retrieve it: - // - from a global variable (the faster way) - on production server mode; - // - from a local variable after reloading the language files - on test server mode or when requested language - // is different than the genuine interface language. - $read_global_variables = $is_interface_language; - - if ($read_global_variables) { - if (isset($GLOBALS[$variable])) { - $langvar = $GLOBALS[$variable]; - } elseif (isset($GLOBALS["lang$variable"])) { - $langvar = $GLOBALS["lang$variable"]; - } else { - if (!$returnEmptyIfNotFound) { - $langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable; - } else { - return ''; - } - } - } - if (empty($langvar) || !is_string($langvar)) { - $langvar = $show_special_markup ? SPECIAL_OPENING_TAG.$variable.SPECIAL_CLOSING_TAG : $variable; - } - $ret = $cache[$language][$variable] = $langvar; - $used_lang_vars[$variable.$lang_postfix] = $ret; - - return $ret; } /** diff --git a/plugin/vchamilo/plugin.php b/plugin/vchamilo/plugin.php index 9de9e8b3b5..30989c1d7c 100644 --- a/plugin/vchamilo/plugin.php +++ b/plugin/vchamilo/plugin.php @@ -54,7 +54,7 @@ $form_settings = [ $form->setDefaults($form_settings); -$wwwroot = $_configuration['root_web']; +$wwwroot = isset($_configuration['root_web']) ? $_configuration['root_web'] : ''; //A simple select $options = [0 => $plugin->get_lang('no'), 1 => $plugin->get_lang('yes')]; diff --git a/src/CoreBundle/Controller/IndexController.php b/src/CoreBundle/Controller/IndexController.php index 2c9ce93bd6..d67191cced 100644 --- a/src/CoreBundle/Controller/IndexController.php +++ b/src/CoreBundle/Controller/IndexController.php @@ -13,6 +13,7 @@ use Symfony\Component\Routing\Annotation\Route; * author Julio Montoya . * * @package Chamilo\CoreBundle\Controller + * */ class IndexController extends BaseController { diff --git a/src/CoreBundle/Framework/Container.php b/src/CoreBundle/Framework/Container.php index c20b52ee8b..0e422e181f 100644 --- a/src/CoreBundle/Framework/Container.php +++ b/src/CoreBundle/Framework/Container.php @@ -34,6 +34,7 @@ class Container public static $environment; public static $urlGenerator; public static $checker; + /** @var TranslatorInterface */ public static $translator; public static $mailer; public static $template; diff --git a/src/CoreBundle/Menu/NavBuilder.php b/src/CoreBundle/Menu/NavBuilder.php index 86cf117fa5..ab160fdf65 100644 --- a/src/CoreBundle/Menu/NavBuilder.php +++ b/src/CoreBundle/Menu/NavBuilder.php @@ -280,7 +280,7 @@ class NavBuilder implements ContainerAwareInterface [ 'label' => $translator->trans('Plugins'), 'route' => 'legacy_main', - 'routeParameters' => ['name' => 'admin/settings.php?category=Plugins'], + 'routeParameters' => ['name' => 'admin/settings.php', 'category' => 'Plugins'], ] ); $menu['administrator']->addChild(