Skip to content

Commit

Permalink
Internal: Remove references to assets/css/theme path - refs BT#21621
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jul 1, 2024
1 parent 7ed9ca3 commit d186d97
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 62 deletions.
4 changes: 2 additions & 2 deletions assets/vue/AppInstaller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
href="index.php"
>
<img
:src="'/themes/chamilo/images/header-logo.svg'"
alt="Chamilo"
src="/build/css/themes/chamilo/images/header-logo.png"
>
/>
</a>
<ol>
<li
Expand Down
4 changes: 2 additions & 2 deletions public/main/admin/settings.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @since Chamilo 1.8.7
*/
define('CSS_UPLOAD_PATH', api_get_path(SYS_PATH).'Resources/public/css/themes/');
define('CSS_UPLOAD_PATH', api_get_path(SYMFONY_SYS_PATH).'var/themes/');

/**
* This function allows easy activating and inactivating of regions.
Expand Down Expand Up @@ -389,7 +389,7 @@ function uploadStylesheet($values, $picture)
$fs = new Filesystem();
$fs->mirror(
CSS_UPLOAD_PATH,
api_get_path(SYS_PATH).'web/css/themes/',
api_get_path(SYMFONY_SYS_PATH).'var/themes/',
null,
['override' => true]
);
Expand Down
2 changes: 1 addition & 1 deletion public/main/inc/lib/banner.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion public/main/inc/lib/display.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
5 changes: 4 additions & 1 deletion public/main/inc/lib/pdf.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 0 additions & 21 deletions public/main/inc/lib/template.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
43 changes: 21 additions & 22 deletions public/main/lp/learnpath.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -8432,21 +8436,16 @@ 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);

if (empty($icon)) {
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);
}
Expand Down
22 changes: 11 additions & 11 deletions public/main/template/default/gradebook/custom_certificate.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3">
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/cuadro.png' }}">
<img src="{{ theme_asset('images/cuadre.png') }}">
</td>
</tr>
<tr>
<td>
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/cuadro.png' }}">
<img src="{{ theme_asset('images/cuadro.png') }}">
</td>
<td>
<table border="0" bgcolor="#92c647" cellpadding="0" cellspacing="0" align="center" width="100%">
<tr>
<td style="border-collapse: collapse; padding: 0;" bgcolor="#92c647"><img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/header_top.png' }}" style="display: block;"></td>
<td style="border-collapse: collapse; padding: 0;" bgcolor="#92c647"><img src="{{ theme_asset('images/header_top.png') }}" style="display: block;"></td>
</tr>
<tr>
<td style="border-collapse: collapse; padding: 0;">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td style="border-collapse: collapse; padding: 0;" bgcolor="#92c647" width=58 height=91>
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/lado-b.png' }}" style="display:block;">
<img src="{{ theme_asset('images/lado-b.png') }}" style="display:block;">
</td>
<td bgcolor="#92c647" width=700 height=91 style="font-family:CourierSans-Light; font-weight: bold; line-height: 47px; color:#FFF; padding-bottom: 10px; font-size: 45px;">
{{ 'Certificate of participation' | trans | raw }}
</td>
<td style="border-collapse: collapse; padding: 0;" bgcolor="#92c647" width=58 height=91>
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/lado-header.png' }}" style="display:block;">
<img src="{{ theme_asset('/images/lado-header.png') }}" style="display:block;">
</td>
</tr>
</table>
Expand All @@ -42,7 +42,7 @@
<td style="border-collapse: collapse; padding: 0;">
<table bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="0" width="100%" height=900>
<tr>
<td bgcolor="#92c647" height=755 style="border-collapse: collapse; padding: 0;"><img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/lado-a.png' }}" style="display:block;"></td>
<td bgcolor="#92c647" height=755 style="border-collapse: collapse; padding: 0;"><img src="{{ theme_asset('images/lado-a.png') }}" style="display:block;"></td>
<td height=755 style="font-family:CourierSans-Light; line-height: 22px; color:#40ad49; padding: 40px; font-size: 18px;" valign="top">
<h3 style="color: #672290; font-size: 24px;">
{{ complete_name }}
Expand Down Expand Up @@ -75,7 +75,7 @@
<br />
</td>
<td height=755 bgcolor="#92c647" style="border-collapse: collapse; padding: 0;">
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/lado-b.png' }}" style="display:block;">
<img src="{{ theme_asset('images/lado-b.png') }}" style="display:block;">
</td>
</tr>
</table>
Expand All @@ -86,25 +86,25 @@
<table border="0" cellspacing="0" cellpadding="0" width="100%" height="91">
<tr>
<td bgcolor="#92c647" width=58 height=91 style="border-collapse: collapse; padding: 0;">
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/lado-b.png' }}" style="display:block;"></td>
<img src="{{ theme_asset('images/lado-b.png') }}" style="display:block;"></td>
<td bgcolor="#92c647" width=500 height=91 style="border-collapse: collapse; padding: 0; font-family:CourierSans-Light; line-height: 18px; color:#FFF;">
{{ 'Certificate Footer' | trans | raw }}
</td>
<td bgcolor="#92c647" width=245 height=91 style="border-collapse: collapse; padding: 0;">
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/lado-footer.png' }}" style="display:block; "></td>
<img src="{{ theme_asset('images/lado-footer.png') }}" style="display:block; "></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td>
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/cuadro.png' }}">
<img src="{{ theme_asset('images/cuadro.png') }}">
</td>
</tr>
<tr>
<td colspan="3">
<img src="{{ url('index') ~ 'build/css/themes/' ~ stylesheet_name ~ '/images/cuadro.png' }}">
<img src="{{ theme_asset('images/cuadro.png') }}">
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)',

Check warning on line 1117 in src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php

View check run for this annotation

Codecov / codecov/patch

src/CoreBundle/DataFixtures/SettingsCurrentFixtures.php#L1117

Added line #L1117 was not covered by tests
],
],
'mail' => [
Expand Down

0 comments on commit d186d97

Please sign in to comment.