Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow hide theme for email and page constructors Mautic 5 #13539

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
03601c7
added toggle and a condition to check
Syrgak-Alan Mar 4, 2024
d0169a9
recommended condition
Syrgak-Alan Mar 4, 2024
554f25e
check first if feature property exists in config.json file
Syrgak-Alan Mar 6, 2024
0df7564
Merge branch 'mautic:5.x' into 5.x
Syrgak-Alan Mar 6, 2024
a5b450e
adding check if theme is external and if yes add property
Syrgak-Alan Mar 6, 2024
ef1d6e0
Merge branch '5.x' of github.com:Syrgak-Alan/mautic into 5.x
Syrgak-Alan Mar 6, 2024
b0cd58d
Update composer.json
Syrgak-Alan Mar 6, 2024
1dd1c0c
Update config.json
Syrgak-Alan Mar 6, 2024
329ddc5
display in themes list but not on email creating page
Syrgak-Alan Mar 6, 2024
803c71b
Merge branch '5.x' of github.com:Syrgak-Alan/mautic into 5.x
Syrgak-Alan Mar 6, 2024
466bb0f
Merge branch '5.x' into 5.x
Syrgak-Alan Mar 6, 2024
e9e0416
Merge branch 'mautic:5.x' into 5.x
Syrgak-Alan Mar 11, 2024
977cb9b
reseting back to core the config files
Syrgak-Alan Mar 11, 2024
dc3c624
Merge branch '5.x' of github.com:Syrgak-Alan/mautic into 5.x
Syrgak-Alan Mar 11, 2024
10a3e68
deleted visibility check
Syrgak-Alan Mar 11, 2024
cecce37
adding checking condition
Syrgak-Alan Mar 11, 2024
b9db26f
Merge branch '5.x' into Allow_hide_theme
Syrgak-Alan Mar 12, 2024
30a9588
Merge branch 'mautic:5.x' into Allow_hide_theme
Syrgak-Alan Mar 14, 2024
2e87379
Merge branch 'mautic:5.x' into Allow_hide_theme
Syrgak-Alan Mar 15, 2024
1687fb2
Merge branch 'mautic:5.x' into Allow_hide_theme
Syrgak-Alan Mar 18, 2024
322f37d
changed condition in template to 'hide' property
Syrgak-Alan Mar 18, 2024
f0ec88a
added icon to themes list
Syrgak-Alan Mar 18, 2024
75726f1
now form themes also hidden after toggling
Syrgak-Alan Mar 20, 2024
1f4231e
Merge branch 'mautic:5.x' into Allow_hide_theme
Syrgak-Alan Mar 20, 2024
05127fd
fix phpstan issue
Syrgak-Alan Mar 20, 2024
275343f
Merge branch 'mautic:5.x' into Allow_hide_theme
Syrgak-Alan Mar 21, 2024
12ed364
phpstan issue
Syrgak-Alan Mar 21, 2024
14cad36
phpstan issue2
Syrgak-Alan Mar 21, 2024
774c9e8
phpstan issue resolved
Syrgak-Alan Mar 21, 2024
bffa33b
phpstan issue resolved2
Syrgak-Alan Mar 21, 2024
8855b0f
phpstan issue resolved3
Syrgak-Alan Mar 21, 2024
06c3bd8
phpstan issue resolved4
Syrgak-Alan Mar 21, 2024
60e30d1
Merge branch '5.x' into Allow_hide_theme
RCheesley Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/bundles/CoreBundle/Form/Type/ThemeListType.php
Expand Up @@ -23,9 +23,16 @@ public function configureOptions(OptionsResolver $resolver): void
$resolver->setDefaults(
[
'choices' => function (Options $options): array {
$themes = $this->themeHelper->getInstalledThemes($options['feature']);
$themes = $this->themeHelper->getInstalledThemes($options['feature'], false, true);
$themes['mautic_code_mode'] = 'Code Mode';

// Hide themes that are marked as hidden
foreach ($this->themeHelper->getInstalledThemes($options['feature'], true, true) as $themeKey => $themeInfo) {
if (in_array('hide', $themeInfo['config']) && true === $themeInfo['config']['hide']) {
unset($themes[$themeKey]);
}
}

return array_flip($themes);
},
'expanded' => false,
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/CoreBundle/Helper/ThemeHelper.php
Expand Up @@ -222,6 +222,9 @@ public function checkForTwigTemplate($template): string
return $this->findThemeWithTemplate($template);
}

/**
* @return array<mixed>
*/
public function getInstalledThemes($specificFeature = 'all', $extended = false, $ignoreCache = false, $includeDirs = true)
{
// Use a concatenated key since $includeDirs changes what's returned ($includeDirs used by API controller to prevent from exposing file paths)
Expand Down
2 changes: 1 addition & 1 deletion app/bundles/CoreBundle/Helper/ThemeHelperInterface.php
Expand Up @@ -84,7 +84,7 @@ public function checkForTwigTemplate($template);
* @param bool $ignoreCache true to get the fresh info
* @param bool $includeDirs true to get the theme dir details
*
* @return array<string[]>|string[]
* @return array<mixed>
*/
public function getInstalledThemes($specificFeature = 'all', $extended = false, $ignoreCache = false, $includeDirs = true);

Expand Down
Expand Up @@ -26,53 +26,55 @@
</div>
{% for themeKey, themeInfo in themes %}
{% set isSelected = active is same as themeKey %}
{% if not isSelected or themeInfo.config.features is not defined or type in themeInfo.config.features %}
{% if (themeInfo.dir ~ '/thumbnail_' ~ type ~ '.png') is file %}
{% set thumbnailName, hasThumbnail = 'thumbnail_' ~ type ~ '.png', true %}
{% else %}
{% set thumbnailName = 'thumbnail.png' %}
{% set hasThumbnail = is_file(themeInfo.dir ~ '/' ~ thumbnailName) %}
{% endif %}
{% set thumbnailUrl = getAssetUrl(themeInfo.themesLocalDir ~ '/' ~ themeKey ~ '/' ~ thumbnailName) %}
<div class="col-md-3 theme-list">
<div class="panel panel-default {% if isSelected %}theme-selected{% endif %}">
<div class="panel-body text-center">
<h3>{{ themeInfo.name }}</h3>
{% if hasThumbnail %}
<a href="#" data-toggle="modal" data-target="#theme-{{ themeKey }}">
<div style="background-image: url({{ thumbnailUrl }});background-repeat:no-repeat;background-size:contain; background-position:center; width: 100%; height: 250px"></div>
</a>
{% else %}
<div class="panel-body text-center" style="height: 250px">
<i class="fa fa-file-image-o fa-5x text-muted" aria-hidden="true" style="padding-top: 75px; color: #E4E4E4;"></i>
{% if not isSelected or themeInfo.config.features is not defined or type in themeInfo.config.features %}
{% if themeInfo.config.hide is not defined or not themeInfo.config.hide is same as(true) %}
{% if (themeInfo.dir ~ '/thumbnail_' ~ type ~ '.png') is file %}
{% set thumbnailName, hasThumbnail = 'thumbnail_' ~ type ~ '.png', true %}
{% else %}
{% set thumbnailName = 'thumbnail.png' %}
{% set hasThumbnail = is_file(themeInfo.dir ~ '/' ~ thumbnailName) %}
{% endif %}
{% set thumbnailUrl = getAssetUrl(themeInfo.themesLocalDir ~ '/' ~ themeKey ~ '/' ~ thumbnailName) %}
<div class="col-md-3 theme-list">
<div class="panel panel-default {% if isSelected %}theme-selected{% endif %}">
<div class="panel-body text-center">
<h3>{{ themeInfo.name }}</h3>
{% if hasThumbnail %}
<a href="#" data-toggle="modal" data-target="#theme-{{ themeKey }}">
<div style="background-image: url({{ thumbnailUrl }});background-repeat:no-repeat;background-size:contain; background-position:center; width: 100%; height: 250px"></div>
</a>
{% else %}
<div class="panel-body text-center" style="height: 250px">
<i class="fa fa-file-image-o fa-5x text-muted" aria-hidden="true" style="padding-top: 75px; color: #E4E4E4;"></i>
</div>
{% endif %}
<a href="#" type="button" data-theme="{{ themeKey }}" class="select-theme-link btn btn-default {% if isSelected %}hide{% endif %}" onclick="mQuery('#dynamic-content-tab').addClass('hidden')">
Select
</a>
<button type="button" class="select-theme-selected btn btn-default {% if not isSelected %}hide{% endif %}" disabled="disabled">
Selected
</button>
</div>
{% endif %}
<a href="#" type="button" data-theme="{{ themeKey }}" class="select-theme-link btn btn-default {% if isSelected %}hide{% endif %}" onclick="mQuery('#dynamic-content-tab').addClass('hidden')">
Select
</a>
<button type="button" class="select-theme-selected btn btn-default {% if not isSelected %}hide{% endif %}" disabled="disabled">
Selected
</button>
</div>
</div>
{% if hasThumbnail %}
<!-- Modal -->
<div class="modal fade" id="theme-{{ themeKey }}" tabindex="-1" role="dialog" aria-labelledby="{{ themeKey }}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="{{ themeKey }}">{{ themeInfo.name }}</h4>
</div>
<div class="modal-body">
<div style="background-image: url({{ thumbnailUrl }});background-repeat:no-repeat;background-size:contain; background-position:center; width: 100%; height: 600px"></div>
</div>
{% if hasThumbnail %}
<!-- Modal -->
<div class="modal fade" id="theme-{{ themeKey }}" tabindex="-1" role="dialog" aria-labelledby="{{ themeKey }}">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="{{ themeKey }}">{{ themeInfo.name }}</h4>
</div>
<div class="modal-body">
<div style="background-image: url({{ thumbnailUrl }});background-repeat:no-repeat;background-size:contain; background-position:center; width: 100%; height: 600px"></div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
{% endif %}
</div>
{% endif %}
{% endif %}
{% endfor %}
<div class="clearfix"></div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions app/bundles/CoreBundle/Resources/views/Theme/list.html.twig
Expand Up @@ -96,6 +96,9 @@
<td>
<div>
{{ item['name']|e }} ({{ item['key']|e }})
{% if item['config']['hide'] is defined and item['config']['hide'] is same as(true) %}
<i class="fa fa-eye-slash"></i>
{% endif %}
</div>
</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion themes/skyline/composer.json
Expand Up @@ -10,4 +10,4 @@
"require": {
"mautic/core-lib": "^5.0"
}
}
}