From d186d97915b1f4bef7d1d485fcda78872fe4f571 Mon Sep 17 00:00:00 2001
From: Angel Fernando Quiroz Campos <1697880+AngelFQC@users.noreply.github.com>
Date: Mon, 1 Jul 2024 17:30:56 -0500
Subject: [PATCH] Internal: Remove references to assets/css/theme path - refs
BT#21621
---
assets/vue/AppInstaller.vue | 4 +-
public/main/admin/settings.lib.php | 4 +-
public/main/inc/lib/banner.lib.php | 2 +-
public/main/inc/lib/display.lib.php | 2 +-
public/main/inc/lib/pdf.lib.php | 5 ++-
public/main/inc/lib/template.lib.php | 21 ---------
public/main/lp/learnpath.class.php | 43 +++++++++----------
.../gradebook/custom_certificate.html.twig | 22 +++++-----
.../DataFixtures/SettingsCurrentFixtures.php | 2 +-
9 files changed, 43 insertions(+), 62 deletions(-)
diff --git a/assets/vue/AppInstaller.vue b/assets/vue/AppInstaller.vue
index 10ca32b7a59..ebcfdab18be 100644
--- a/assets/vue/AppInstaller.vue
+++ b/assets/vue/AppInstaller.vue
@@ -6,9 +6,9 @@
href="index.php"
>
+ />
- mirror(
CSS_UPLOAD_PATH,
- api_get_path(SYS_PATH).'web/css/themes/',
+ api_get_path(SYMFONY_SYS_PATH).'var/themes/',
null,
['override' => true]
);
diff --git a/public/main/inc/lib/banner.lib.php b/public/main/inc/lib/banner.lib.php
index 9e51f817d2e..9fb9b5e55e6 100644
--- a/public/main/inc/lib/banner.lib.php
+++ b/public/main/inc/lib/banner.lib.php
@@ -45,7 +45,7 @@ function getCustomTabs()
/**
* Return the active logo of the portal, based on a series of settings.
*
- * @param string $theme The name of the theme folder from web/css/themes/
+ * @param string $theme The name of the theme folder from var/themes/
* @param bool $responsive add class img-responsive
*
* @return string HTML string with logo as an HTML element
diff --git a/public/main/inc/lib/display.lib.php b/public/main/inc/lib/display.lib.php
index 62b3704255a..bd7577efab9 100644
--- a/public/main/inc/lib/display.lib.php
+++ b/public/main/inc/lib/display.lib.php
@@ -695,7 +695,7 @@ public static function return_icon(
if (is_file($alternateCssPath.$theme.$image)) {
$icon = $alternateWebCssPath.$theme.$image;
}
- // Checking the theme icons folder example: app/Resources/public/css/themes/chamilo/icons/XXX
+ // Checking the theme icons folder example: var/themes/chamilo/icons/XXX
if (is_file($alternateCssPath.$theme.$size_extra.$image)) {
$icon = $alternateWebCssPath.$theme.$size_extra.$image;
} elseif (is_file($code_path.'img/icons/'.$size_extra.$image)) {
diff --git a/public/main/inc/lib/pdf.lib.php b/public/main/inc/lib/pdf.lib.php
index e453cd81122..20827a3dc79 100644
--- a/public/main/inc/lib/pdf.lib.php
+++ b/public/main/inc/lib/pdf.lib.php
@@ -3,6 +3,8 @@
/* See license terms in /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
+use Chamilo\CoreBundle\Framework\Container;
+use Chamilo\CoreBundle\ServiceHelper\ThemeHelper;
use Masterminds\HTML5;
use Mpdf\Mpdf;
use Mpdf\Output\Destination;
@@ -476,8 +478,9 @@ public function content_to_pdf(
}
if ($addDefaultCss) {
+ $themeHelper = Container::$container->get(ThemeHelper::class);
$basicStyles = [
- api_get_path(SYS_PUBLIC_PATH).'build/css/themes/'.api_get_visual_theme().'/default.css',
+ $themeHelper->getThemeAssetUrl('default.css'),
];
foreach ($basicStyles as $style) {
$cssContent = file_get_contents($style);
diff --git a/public/main/inc/lib/template.lib.php b/public/main/inc/lib/template.lib.php
index 50ac04c80d4..01c87bf2adc 100644
--- a/public/main/inc/lib/template.lib.php
+++ b/public/main/inc/lib/template.lib.php
@@ -761,27 +761,6 @@ public function set_js_files_post()
}
}
- /**
- * @param string $theme
- *
- * @return string
- */
- public static function getPortalIcon($theme)
- {
- // Default root chamilo favicon
- $icon = 'favicon.ico';
-
- // Added to verify if in the current Chamilo Theme exist a favicon
- $themeUrl = api_get_path(SYS_CSS_PATH).'themes/'.$theme.'/images/';
-
- // If exist pick the current chamilo theme favicon.
- if (is_file($themeUrl.'favicon.ico')) {
- $icon = 'build/css/themes/'.$theme.'/images/favicon.ico';
- }
-
- return $icon;
- }
-
/**
* Show footer js template.
*/
diff --git a/public/main/lp/learnpath.class.php b/public/main/lp/learnpath.class.php
index e7a06d651a4..6eb599bc373 100644
--- a/public/main/lp/learnpath.class.php
+++ b/public/main/lp/learnpath.class.php
@@ -6,6 +6,7 @@
use Chamilo\CoreBundle\Entity\ResourceLink;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Entity\Session as SessionEntity;
+use Chamilo\CoreBundle\ServiceHelper\ThemeHelper;
use Chamilo\CourseBundle\Entity\CLpRelUser;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
@@ -8391,24 +8392,27 @@ public static function getAccumulateWorkTimeTotal($courseId)
/**
* In order to use the lp icon option you need to create the "lp_icon" LP extra field
* and put the images in.
- *
- * @return array
*/
- public static function getIconSelect()
+ public static function getIconSelect(): array
{
- $theme = api_get_visual_theme();
- $path = api_get_path(SYS_PUBLIC_PATH).'css/themes/'.$theme.'/lp_icons/';
+ $theme = Container::$container->get(ThemeHelper::class)->getVisualTheme();
+ $filesystem = Container::$container->get('oneup_flysystem.themes_filesystem');
+
+ if (!$filesystem->directoryExists("$theme/lp_icons")) {
+ return [];
+ }
+
$icons = ['' => get_lang('Please select an option')];
- if (is_dir($path)) {
- $finder = new Finder();
- $finder->files()->in($path);
- $allowedExtensions = ['jpeg', 'jpg', 'png'];
- /** @var SplFileInfo $file */
- foreach ($finder as $file) {
- if (in_array(strtolower($file->getExtension()), $allowedExtensions)) {
- $icons[$file->getFilename()] = $file->getFilename();
- }
+ $iconFiles = $filesystem->listContents("$theme/lp_icons");
+ $allowedExtensions = ['image/jpeg', 'image/jpg', 'image/png'];
+
+ foreach ($iconFiles as $iconFile) {
+ $mimeType = $filesystem->mimeType($iconFile->path());
+
+ if (in_array($mimeType, $allowedExtensions)) {
+ $basename = basename($iconFile->path());
+ $icons[$basename] = $basename;
}
}
@@ -8432,12 +8436,7 @@ public static function getSelectedIcon($lpId)
return $icon;
}
- /**
- * @param int $lpId
- *
- * @return string
- */
- public static function getSelectedIconHtml($lpId)
+ public static function getSelectedIconHtml(int $lpId): string
{
$icon = self::getSelectedIcon($lpId);
@@ -8445,8 +8444,8 @@ public static function getSelectedIconHtml($lpId)
return '';
}
- $theme = api_get_visual_theme();
- $path = api_get_path(WEB_PUBLIC_PATH).'css/themes/'.$theme.'/lp_icons/'.$icon;
+ $themeHelper = Container::$container->get(ThemeHelper::class);
+ $path = $themeHelper->getThemeAssetUrl("lp_icons/$icon");
return Display::img($path);
}
diff --git a/public/main/template/default/gradebook/custom_certificate.html.twig b/public/main/template/default/gradebook/custom_certificate.html.twig
index 214ea306300..cdec2866431 100644
--- a/public/main/template/default/gradebook/custom_certificate.html.twig
+++ b/public/main/template/default/gradebook/custom_certificate.html.twig
@@ -9,30 +9,30 @@
-
+
|
-
+
|
- |
+ |
-
+
|
{{ 'Certificate of participation' | trans | raw }}
|
-
+
|
@@ -42,7 +42,7 @@
|
- |
+ |
{{ complete_name }}
@@ -75,7 +75,7 @@
|
-
+
|
@@ -86,12 +86,12 @@
- |
+
{{ 'Certificate Footer' | trans | raw }}
|
- |
+
|
@@ -99,12 +99,12 @@
|
-
+
|
-
+
|
diff --git a/src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php b/src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
index 4300bcee825..2282c50efb8 100644
--- a/src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
+++ b/src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
@@ -1114,7 +1114,7 @@ public static function getExistingSettings(): array
[
'name' => 'pdf_logo_header',
'title' => 'PDF header logo',
- 'comment' => 'Whether to use the image at css/themes/[your-css]/images/pdf_logo_header.png as the PDF header logo for all PDF exports (instead of the normal portal logo)',
+ 'comment' => 'Whether to use the image at var/themes/[your-theme]/images/pdf_logo_header.png as the PDF header logo for all PDF exports (instead of the normal portal logo)',
],
],
'mail' => [