Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"mailmotor/campaignmonitor-bundle": "^3.0",
"mailmotor/mailchimp-bundle": "^4.0",
"mailmotor/mailmotor-bundle": "^4.0",
"matthiasmullie/minify": "~1.3",
"matthiasmullie/scrapbook": "^1.3",
"pimple/pimple": "^3.2",
"spoon/library": "^4.0",
Expand Down
2 changes: 0 additions & 2 deletions phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ parameters:
- '#Constant ACTION_RIGHTS_LEVEL not found.#'
- '#Constant APPLICATION not found.#'
- '#Constant BACKEND_CACHE_PATH not found.#'
- '#Constant BACKEND_CACHE_URL not found.#'
- '#Constant BACKEND_CORE_PATH not found.#'
- '#Constant BACKEND_MODULES_PATH not found.#'
- '#Constant BACKEND_PATH not found.#'
- '#Constant FRONTEND_CACHE_PATH not found.#'
- '#Constant FRONTEND_CACHE_URL not found.#'
- '#Constant FRONTEND_CORE_PATH not found.#'
- '#Constant FRONTEND_CORE_URL not found.#'
- '#Constant FRONTEND_FILES_PATH not found.#'
Expand Down
2 changes: 0 additions & 2 deletions src/Backend/Cache/MinifiedCss/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions src/Backend/Cache/MinifiedJs/.gitignore

This file was deleted.

7 changes: 3 additions & 4 deletions src/Backend/Core/Engine/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,15 @@ public function addEditor($name, $value = null, $class = null, $classError = nul
$HTML = (bool) $HTML;

// we add JS because we need CKEditor
$this->header->addJS('ckeditor/ckeditor.js', 'Core', false);
$this->header->addJS('ckeditor/adapters/jquery.js', 'Core', false);
$this->header->addJS('ckfinder/ckfinder.js', 'Core', false);
$this->header->addJS('ckeditor/ckeditor.js', 'Core');
$this->header->addJS('ckeditor/adapters/jquery.js', 'Core');
$this->header->addJS('ckfinder/ckfinder.js', 'Core');

// add the internal link lists-file
if (is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . BackendLanguage::getWorkingLanguage() . '.js')) {
$this->header->addJS(
'/src/Frontend/Cache/Navigation/editor_link_list_' . BackendLanguage::getWorkingLanguage() . '.js',
null,
false,
true,
true
);
Expand Down
55 changes: 17 additions & 38 deletions src/Backend/Core/Engine/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Common\Core\Header\Asset;
use Common\Core\Header\AssetCollection;
use Common\Core\Header\JsData;
use Common\Core\Header\Minifier;
use Common\Core\Header\Priority;
use ForkCMS\App\KernelLoader;
use Symfony\Component\HttpKernel\KernelInterface;
Expand Down Expand Up @@ -62,20 +61,8 @@ public function __construct(KernelInterface $kernel)
$this->url = $container->get('url');
$this->template = $container->get('template');

$this->cssFiles = new AssetCollection(
Minifier::css(
$container->getParameter('site.path_www'),
BACKEND_CACHE_URL . '/MinifiedCss/',
BACKEND_CACHE_PATH . '/MinifiedCss/'
)
);
$this->jsFiles = new AssetCollection(
Minifier::js(
$container->getParameter('site.path_www'),
BACKEND_CACHE_URL . '/MinifiedJs/',
BACKEND_CACHE_PATH . '/MinifiedJs/'
)
);
$this->cssFiles = new AssetCollection();
$this->jsFiles = new AssetCollection();
$this->jsData = new JsData(
[
'interface_language' => $this->getInterfaceLanguage(),
Expand All @@ -90,24 +77,24 @@ public function __construct(KernelInterface $kernel)

private function addCoreJs(): void
{
$this->addJS('/js/vendors/jquery.min.js', 'Core', false, true, true, Priority::core());
$this->addJS('/js/vendors/jquery-migrate.min.js', 'Core', false, true, true, Priority::core());
$this->addJS('/js/vendors/jquery-ui.min.js', 'Core', false, true, true, Priority::core());
$this->addJS('/js/vendors/bootstrap.min.js', 'Core', false, true, true, Priority::core());
$this->addJS('/js/vendors/typeahead.bundle.min.js', 'Core', false, true, true, Priority::core());
$this->addJS('/js/vendors/bootstrap-tagsinput.min.js', 'Core', false, true, true, Priority::core());
$this->addJS('jquery/jquery.backend.js', 'Core', true, false, true, Priority::core());
$this->addJS('utils.js', 'Core', true, false, true, Priority::core());
$this->addJS('backend.js', 'Core', true, false, true, Priority::core());
$this->addJS('/js/vendors/jquery.min.js', 'Core', true, true, Priority::core());
$this->addJS('/js/vendors/jquery-migrate.min.js', 'Core', true, true, Priority::core());
$this->addJS('/js/vendors/jquery-ui.min.js', 'Core', true, true, Priority::core());
$this->addJS('/js/vendors/bootstrap.min.js', 'Core', true, true, Priority::core());
$this->addJS('/js/vendors/typeahead.bundle.min.js', 'Core', true, true, Priority::core());
$this->addJS('/js/vendors/bootstrap-tagsinput.min.js', 'Core', true, true, Priority::core());
$this->addJS('jquery/jquery.backend.js', 'Core', false, true, Priority::core());
$this->addJS('utils.js', 'Core', false, true, Priority::core());
$this->addJS('backend.js', 'Core', false, true, Priority::core());
}

private function addCoreCss(): void
{
$this->addCSS('/css/vendors/bootstrap-tagsinput.css', 'Core', true, true, true, Priority::core());
$this->addCSS('/css/vendors/bootstrap-tagsinput-typeahead.css', 'Core', true, true, true, Priority::core());
$this->addCSS('/css/vendors/bootstrap-accessibility.css', 'Core', true, true, true, Priority::core());
$this->addCSS('screen.css', 'Core', false, true, true, Priority::core());
$this->addCSS('debug.css', 'Core', false, true, true, Priority::debug());
$this->addCSS('/css/vendors/bootstrap-tagsinput.css', 'Core', true, true, Priority::core());
$this->addCSS('/css/vendors/bootstrap-tagsinput-typeahead.css', 'Core', true, true, Priority::core());
$this->addCSS('/css/vendors/bootstrap-accessibility.css', 'Core', true, true, Priority::core());
$this->addCSS('screen.css', 'Core', false, true, Priority::core());
$this->addCSS('debug.css', 'Core', false, true, Priority::debug());
}

private function buildPathForModule(string $fileName, string $module, string $subDirectory): string
Expand All @@ -134,7 +121,6 @@ private function buildPathForModule(string $fileName, string $module, string $su
* @param string $module The module wherein the file is located.
* @param bool $overwritePath Should we overwrite the full path?
* An external url will always be handled with $overwritePath as true.
* @param bool $minify Should the CSS be minified?
* @param bool $addTimestamp May we add a timestamp for caching purposes?
* @param Priority $priority the files are added based on the priority
* defaults to standard for full links or core or module for core or module css
Expand All @@ -143,22 +129,19 @@ public function addCSS(
string $file,
?string $module = null,
bool $overwritePath = false,
bool $minify = true,
bool $addTimestamp = true,
?Priority $priority = null
): void {
$module ??= $this->url->getModule();
$isExternalUrl = $this->get('fork.validator.url')->isExternalUrl($file);
$overwritePath = $overwritePath || $isExternalUrl; // external urls always overwrite the path
$minify = $minify && !$isExternalUrl;

$this->cssFiles->add(
new Asset(
$overwritePath ? $file : $this->buildPathForModule($file, $module, 'Layout/Css'),
$addTimestamp,
$priority ?? ($overwritePath ? Priority::standard() : Priority::forModule($module))
),
$minify
)
);
}

Expand All @@ -169,7 +152,6 @@ public function addCSS(
*
* @param string $file The file to load.
* @param string $module The module wherein the file is located.
* @param bool $minify Should the javascript be minified?
* @param bool $overwritePath Should we overwrite the full path?
* An external url will always be handled with $overwritePath as true.
* @param bool $addTimestamp May we add a timestamp for caching purposes?
Expand All @@ -179,23 +161,20 @@ public function addCSS(
public function addJS(
string $file,
?string $module = null,
bool $minify = true,
bool $overwritePath = false,
bool $addTimestamp = true,
?Priority $priority = null
): void {
$module ??= $this->url->getModule();
$isExternalUrl = $this->get('fork.validator.url')->isExternalUrl($file);
$overwritePath = $overwritePath || $isExternalUrl; // external urls always overwrite the path
$minify = $minify && !$isExternalUrl;

$this->jsFiles->add(
new Asset(
$overwritePath ? $file : $this->buildPathForModule($file, $module, 'Js'),
$addTimestamp,
$priority ?? ($overwritePath ? Priority::standard() : Priority::forModule($module))
),
$minify
);
}

Expand Down
2 changes: 2 additions & 0 deletions src/Backend/Modules/FormBuilder/Resources/config/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ services:
public: true

Backend\Modules\FormBuilder\Command\CopyFormWidgetsToOtherLocaleHandler:
arguments:
$database: '@database'
2 changes: 2 additions & 0 deletions src/Backend/Modules/Location/Resources/config/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ services:
public: true

Backend\Modules\Location\Command\CopyLocationWidgetsToOtherLocaleHandler:
arguments:
$database: '@database'
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ public static function parseFiles(): void
$header = Model::get('header');

// Add "fine-uploader" css/js
$header->addCSS('/css/vendors/fine-uploader/fine-uploader-new.min.css', null, true, false);
$header->addCSS('/css/vendors/fine-uploader/fine-uploader-new.min.css', null, true);
$header->addCSS('/css/vendors/cropper.css', null, true);
$header->addJS('/js/vendors/jquery.fine-uploader.min.js', null, false, true);
$header->addJS('/js/vendors/cropper.js', null, true, true);
$header->addJS('/js/vendors/jquery.fine-uploader.min.js', null, true);
$header->addJS('/js/vendors/cropper.js', null, true);

$header->addCSS('MediaLibrary.css', 'MediaLibrary');
$header->addJS('MediaLibraryFolders.js', 'MediaLibrary');
Expand Down
8 changes: 4 additions & 4 deletions src/Backend/Modules/Pages/Actions/Add.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public function execute(): void
parent::execute();

// add js
$this->header->addJS('jstree/jquery.tree.js', null, false);
$this->header->addJS('jstree/lib/jquery.cookie.js', null, false);
$this->header->addJS('jstree/plugins/jquery.tree.cookie.js', null, false);
$this->header->addJS('/js/vendors/SimpleAjaxUploader.min.js', 'Core', false, true);
$this->header->addJS('jstree/jquery.tree.js');
$this->header->addJS('jstree/lib/jquery.cookie.js');
$this->header->addJS('jstree/plugins/jquery.tree.cookie.js');
$this->header->addJS('/js/vendors/SimpleAjaxUploader.min.js', null, true);

// get the templates
$this->templates = BackendExtensionsModel::getTemplates();
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/Modules/Pages/Actions/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function execute(): void
$this->header->addJS('jstree/jquery.tree.js');
$this->header->addJS('jstree/lib/jquery.cookie.js');
$this->header->addJS('jstree/plugins/jquery.tree.cookie.js');
$this->header->addJS('/js/vendors/SimpleAjaxUploader.min.js', null, false, true);
$this->header->addJS('/js/vendors/SimpleAjaxUploader.min.js', null, true);

// get the templates
$this->templates = BackendExtensionsModel::getTemplates();
Expand Down
10 changes: 1 addition & 9 deletions src/Common/Core/Header/AssetCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,8 @@ final class AssetCollection
/** @var Asset[] */
private $assets = [];

public function __construct(private readonly Minifier $minifier)
public function add(Asset $asset): void
{
}

public function add(Asset $asset, bool $minify = true): void
{
if ($minify) {
$asset = $this->minifier->minify($asset);
}

// we already have it we don't need to add it again
if (array_key_exists($asset->getFile(), $this->assets)) {
return;
Expand Down
60 changes: 0 additions & 60 deletions src/Common/Core/Header/Minifier.php

This file was deleted.

8 changes: 4 additions & 4 deletions src/Common/Form/DatePickerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
parent::buildForm($builder, $options);

if ($this->header instanceof BackendHeader) {
$this->header->addJS('/js/vendors/bootstrap-datepicker.min.js', null, false, true, true, Priority::core());
$this->header->addCSS('/css/vendors/bootstrap-datepicker3.standalone.min.css', null, true, false, true, Priority::core());
$this->header->addJS('/js/vendors/bootstrap-datepicker.min.js', null, true, true, Priority::core());
$this->header->addCSS('/css/vendors/bootstrap-datepicker3.standalone.min.css', null, true, true, Priority::core());

return;
}

$this->header->addJS('/js/vendors/bootstrap-datepicker.min.js', false, true, Priority::core());
$this->header->addCSS('/css/vendors/bootstrap-datepicker3.standalone.min.css', false, true, Priority::core());
$this->header->addJS('/js/vendors/bootstrap-datepicker.min.js', true, Priority::core());
$this->header->addCSS('/css/vendors/bootstrap-datepicker3.standalone.min.css', true, Priority::core());
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
13 changes: 6 additions & 7 deletions src/Common/Tests/Core/Header/AssetCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@

use Common\Core\Header\Asset;
use Common\Core\Header\AssetCollection;
use Common\Core\Header\Minifier;
use Common\Core\Header\Priority;
use PHPUnit\Framework\TestCase;

class AssetCollectionTest extends TestCase
{
public function testAddAssetToCollection(): void
{
$assetCollection = new AssetCollection(Minifier::js(__DIR__, __DIR__, __DIR__));
$assetCollection = new AssetCollection();

$asset1 = new Asset(__DIR__ . '/../../../../../js/vendors/jquery-ui.min.js', false, Priority::standard());
$asset2 = new Asset(__DIR__ . '/../../../../../js/vendors/slick.min.js', false, Priority::module());
$asset3 = new Asset(__DIR__ . '/../../../../../js/vendors/photoswipe.min.js', false, Priority::module());
$asset4 = new Asset(__DIR__ . '/../../../../../js/vendors/bootstrap.min.js', false, Priority::core());
$asset5 = new Asset(__DIR__ . '/../../../../../js/vendors/jquery.min.js', false, Priority::core());

$assetCollection->add($asset1, false);
$assetCollection->add($asset2, false);
$assetCollection->add($asset3, false);
$assetCollection->add($asset4, false);
$assetCollection->add($asset5, false);
$assetCollection->add($asset1);
$assetCollection->add($asset2);
$assetCollection->add($asset3);
$assetCollection->add($asset4);
$assetCollection->add($asset5);

$unorderedAssets = $assetCollection->getAssets();
self::assertEquals($asset1, $unorderedAssets[$asset1->getFile()]);
Expand Down
4 changes: 0 additions & 4 deletions src/Console/Core/CacheClearCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->removeFilesInFolder('/src/Frontend/Cache/CompiledTemplates', $io, 'frontend compiled templates');
$this->removeFilesInFolder('/src/Frontend/Cache/Locale', $io, 'frontend cached locale');
$this->removeFilesInFolder('/src/Frontend/Cache/MinifiedCss', $io, 'frontend minified css');
$this->removeFilesInFolder('/src/Frontend/Cache/MinifiedJs', $io, 'frontend minified js');
$this->removeFilesInFolder('/src/Frontend/Cache/Navigation', $io, 'frontend cached navigation');

$this->removeFilesInFolder('/src/Backend/Cache/CompiledTemplates', $io, 'backend compiled templates');
$this->removeFilesInFolder('/src/Backend/Cache/Locale', $io, 'backend cached locale');
$this->removeFilesInFolder('/src/Backend/Cache/MinifiedCss', $io, 'backend minified css');
$this->removeFilesInFolder('/src/Backend/Cache/MinifiedJs', $io, 'backend minified js');

$symfonyCacheClearCommand = $this->getApplication()->find('cache:clear');
$symfonyCacheClearCommand->run(new ArrayInput(['--no-warmup' => true]), $output);
Expand Down
2 changes: 0 additions & 2 deletions src/Frontend/Cache/MinifiedCss/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions src/Frontend/Cache/MinifiedJs/.gitignore

This file was deleted.

Loading
Loading