From f00567904b632e0e75bad1eea63583ac9f72ebf1 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 29 Jan 2018 16:17:12 +0100 Subject: [PATCH] Minor - update templates, --- main/inc/global.inc.php | 88 +++++++++---------- main/inc/lib/database.lib.php | 10 +-- main/inc/lib/display.lib.php | 1 + main/inc/lib/template.lib.php | 14 +-- main/template/default/layout/head.tpl | 14 ++- .../default/layout/hot_course_item.tpl | 2 + .../default/layout/hot_course_item_popup.tpl | 6 +- main/template/default/layout/hot_courses.tpl | 3 +- main/template/default/layout/menu.tpl | 2 +- .../default/user_portal/grid_session.tpl | 2 + .../views/Layout/base-layout.html.twig | 3 +- 11 files changed, 82 insertions(+), 63 deletions(-) diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index 9fca209c53..a25079f43d 100755 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -14,49 +14,63 @@ use Chamilo\CoreBundle\Framework\Container; * * @package chamilo.include * @todo remove the code that displays the button that links to the install page - * but use a redirect immediately. By doing so the $alreadyInstalled variable can be removed. * */ // Showing/hiding error codes in global error messages. define('SHOW_ERROR_CODES', false); +// Specification for usernames: +// 1. ASCII-letters, digits, "." (dot), "_" (underscore) are acceptable, 40 characters maximum length. +// 2. Empty username is formally valid, but it is reserved for the anonymous user. +// 3. Checking the login_is_email portal setting in order to accept 100 chars maximum +define('USERNAME_MAX_LENGTH', 100); +define('_MPDF_TEMP_PATH', __DIR__.'/../../var/cache/mpdf/'); +define('_MPDF_TTFONTDATAPATH', __DIR__.'/../../var/cache/mpdf/'); + require_once __DIR__.'/../../vendor/autoload.php'; +require_once __DIR__.'/../../public/legacy.php'; + +// Check the PHP version +api_check_php_version(__DIR__.'/'); // Get settings from .env file created when installation Chamilo $envFile = __DIR__.'/../../.env'; if (file_exists($envFile)) { (new Dotenv())->load($envFile); } else { - throw new \RuntimeException('APP_ENV environment variable is not defined. + throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration to load variables from a .env file.'); } $env = $_SERVER['APP_ENV'] ?? 'dev'; $kernel = new Chamilo\Kernel($env, true); -// Include the main Chamilo platform configuration file. -$alreadyInstalled = false; - -require_once __DIR__.'/../../public/legacy.php'; - $request = Sonata\PageBundle\Request\RequestFactory::createFromGlobals( 'host_with_path_by_locale' ); + $response = $kernel->handle($request); +//$kernel->boot(); +//var_dump($request->getBasePath()); if ($kernel->isInstalled()) { require_once $kernel->getConfigurationFile(); } else { $_configuration = []; // Redirects to the main/install/ page - $global_error_code = 2; // The system has not been installed yet. require_once __DIR__.'/../inc/global_error_message.inc.php'; exit; } +$append = $kernel->getUrlAppend(); +/*$baseUrl = '..'; +if (!empty($append)) { + $request->setBaseUrl("/$append/"); +}*/ + $kernel->setApi($_configuration); // Ensure that _configuration is in the global scope before loading @@ -71,48 +85,35 @@ $libraryPath = __DIR__.'/lib/'; // Include the main Chamilo platform library file. require_once $libraryPath.'api.lib.php'; -// Check the PHP version -api_check_php_version(__DIR__.'/'); - -// Specification for usernames: -// 1. ASCII-letters, digits, "." (dot), "_" (underscore) are acceptable, 40 characters maximum length. -// 2. Empty username is formally valid, but it is reserved for the anonymous user. -// 3. Checking the login_is_email portal setting in order to accept 100 chars maximum -define('USERNAME_MAX_LENGTH', 100); -define('_MPDF_TEMP_PATH', __DIR__.'/../../var/cache/mpdf/'); -define('_MPDF_TTFONTDATAPATH', __DIR__.'/../../var/cache/mpdf/'); - -// @todo convert this libs in classes -require_once $libraryPath.'database.constants.inc.php'; -require_once $libraryPath.'text.lib.php'; -require_once $libraryPath.'array.lib.php'; -require_once $libraryPath.'online.inc.php'; -require_once $libraryPath.'banner.lib.php'; -require_once $libraryPath.'fileManage.lib.php'; -require_once $libraryPath.'fileUpload.lib.php'; -require_once $libraryPath.'fileDisplay.lib.php'; -require_once $libraryPath.'course_category.lib.php'; - $container = $kernel->getContainer(); -// Connect Chamilo with the Symfony container -Container::setContainer($container); -Container::setLegacyServices($container); - -$router = $container->get('router'); -$context = $container->get('router.request_context'); +// Fix chamilo URL when used inside a folder: example.com/chamilo $append = $kernel->getUrlAppend(); $baseUrl = '..'; if (!empty($append)) { - $baseUrl = $append; + $router = $container->get('router'); + $requestStack = $container->get('request_stack'); + $context = $container->get('router.request_context'); + + $host = $router->getContext()->getHost(); + $context->setBaseUrl("/$append/"); + $container->set('router.request_context', $context); + + $packages = $container->get('assets.packages'); + $routerContext = $container->get('router')->getContext(); + + $version = new Symfony\Component\Asset\VersionStrategy\EmptyVersionStrategy(); + $newDefault = new Symfony\Component\Asset\PathPackage("/$append/public/", $version); + $packages = $container->get('assets.packages'); + $packages->setDefaultPackage($newDefault); } -$context->setBaseUrl($baseUrl); -$router->setContext($context); -//$container->setParameter('router', $router); -\CourseManager::setCourseManager( - $container->get('chamilo_core.entity.manager.course_manager') -); +// Connect Chamilo with the Symfony container +Container::setContainer($container); +Container::setLegacyServices($container); +//$kernel->boot(); +//var_dump($container->get('assets.context')->getBasePath()); +//var_dump($container->get('assets.empty_package')->getUrl('/build/')); if (!is_dir(_MPDF_TEMP_PATH)) { mkdir(_MPDF_TEMP_PATH, api_get_permissions_for_new_directories(), true); @@ -306,7 +307,6 @@ foreach ($configurationFiles as $file) { } /* LOAD LANGUAGE FILES SECTION */ - // if we use the javascript version (without go button) we receive a get // if we use the non-javascript version (with the go button) we receive a post $user_language = ''; diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index f866f87090..d2a787ac22 100755 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -226,7 +226,8 @@ class Database /** * Frees all the memory associated with the provided result identifier. * @return boolean|null Returns TRUE on success or FALSE on failure. - * Notes: Use this method if you are concerned about how much memory is being used for queries that return large result sets. + * Notes: Use this method if you are concerned about how much memory is being + * used for queries that return large result sets. * Anyway, all associated result memory is automatically freed at the end of the script's execution. */ public static function free_result(Statement $result) @@ -281,7 +282,6 @@ class Database * * @return Statement * - * @throws \Doctrine\DBAL\DBALException */ public static function query($query) { @@ -335,9 +335,9 @@ class Database /** * Database insert - * @param string $table_name - * @param array $attributes - * @param bool $show_query + * @param string $table_name + * @param array $attributes + * @param bool $show_query * * @return false|int */ diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 8c6328bfbf..819b9d843e 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -826,6 +826,7 @@ class Display // When moving this to production, the return_icon() calls should // ask for the SVG version directly $svgIcons = api_get_setting('icons_mode_svg'); + if ($svgIcons == 'true' && $return_only_path == false) { $svgImage = substr($image, 0, -3).'svg'; if (is_file($code_path.$theme.'svg/'.$svgImage)) { diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index b04b04f771..5b5289d957 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -129,6 +129,7 @@ class Template } $this->twig = new Twig_Environment($loader, $options); + //$this->twig = \Chamilo\CoreBundle\Framework\Container::getTemplating(); if ($isTestMode) { $this->twig->addExtension(new Twig_Extension_Debug()); @@ -354,9 +355,6 @@ class Template { $tpl = $this->get_template('layout/layout_1_col.html.twig'); echo \Chamilo\CoreBundle\Framework\Container::getTemplating()->render($tpl, $this->params); - - /*$tpl = $this->get_template('layout/layout_1_col.tpl'); - $this->display($tpl);*/ } /** @@ -366,8 +364,6 @@ class Template { $tpl = $this->get_template('layout/layout_2_col.html.twig'); echo \Chamilo\CoreBundle\Framework\Container::getTemplating()->render($tpl, $this->params); - - //$this->display($tpl); } /** @@ -617,6 +613,8 @@ class Template $this->theme = $this->preview_theme; } + $this->assign('theme', $this->theme); + $this->themeDir = self::getThemeDir($this->theme); // Setting app paths/URLs @@ -762,8 +760,9 @@ class Template $css_file_to_string = null; foreach ($css as $file) { - $css_file_to_string .= api_get_css($file); + // $css_file_to_string .= api_get_css($file); } + // @todo move this somewhere else. Special fix when using tablets in order to see the text near icons if (SHOW_TEXT_NEAR_ICONS == true) { //hack in order to fix the actions buttons @@ -873,9 +872,10 @@ class Template //$js_file_to_string .= ''."\n"; } - $js_file_to_string .= ''."\n"; + /*$js_file_to_string .= ''."\n"; $js_file_to_string .= ''."\n"; $js_file_to_string .= ''."\n"; + */ foreach ($js_files as $file) { //$js_file_to_string .= api_get_js($file); diff --git a/main/template/default/layout/head.tpl b/main/template/default/layout/head.tpl index 4453c0aa86..223252ecd9 100755 --- a/main/template/default/layout/head.tpl +++ b/main/template/default/layout/head.tpl @@ -18,7 +18,18 @@ {{ title_string }} {{ social_meta }} {{ css_static_file_to_string }} -{{ js_file_to_string }} +{#{{ js_file_to_string }}#} + + + + + + + + + + + {{ extra_headers }}