From 57c0149a53d38b74944da01d1ac6a0344bd743ae Mon Sep 17 00:00:00 2001 From: Monika Date: Tue, 17 Feb 2026 19:00:27 +0530 Subject: [PATCH] gantry changes for native Joomla 5 --- .gitignore | 2 + bin/build | 55 +++- bin/builder/build.xml | 19 +- bin/composer-install | 23 +- bin/composer-update | 23 +- composer.json | 12 +- composer.lock | 13 +- platforms/grav/gantry5/gantry5.php | 4 +- .../com_gantry5/site/fields/particle.php | 5 +- platforms/joomla/install.php | 5 +- .../plg_system_gantry5/fields/warning.php | 9 +- .../joomla/plg_system_gantry5/gantry5.php | 9 +- platforms/wordpress/gantry5/composer.json | 6 - platforms/wordpress/gantry5/composer.lock | 93 +++--- platforms/wordpress/gantry5/gantry5.php | 19 +- src/RealLoader.php | 11 +- src/classes/Gantry/Admin/Events/Event.php | 10 +- .../Gantry/Component/Theme/ThemeTrait.php | 13 +- src/classes/Gantry/Framework/Assignments.php | 4 +- .../classes/Gantry/Framework/Document.php | 271 ++++-------------- .../joomla/classes/Gantry/Framework/Page.php | 17 +- .../classes/Gantry/Framework/Platform.php | 12 +- .../joomla/classes/Gantry/Framework/Theme.php | 9 +- .../Gantry/Joomla/Category/Category.php | 11 +- .../classes/Gantry/Joomla/Contact/Contact.php | 7 - .../classes/Gantry/Joomla/Content/Content.php | 19 +- .../Gantry/Joomla/Content/ContentFinder.php | 36 +-- .../classes/Gantry/Joomla/MenuHelper.php | 39 +-- .../classes/Gantry/Joomla/StyleHelper.php | 35 +-- .../classes/Gantry/Framework/Theme.php | 48 ++-- .../classes/Gantry/Framework/Translator.php | 13 + themes/base/joomla/fields/warning.php | 9 +- .../html/layouts/joomla/system/message.php | 33 +-- themes/helium/joomla/fields/warning.php | 9 +- .../html/layouts/joomla/system/message.php | 11 +- .../hydrogen-demo/common/particles/team.yaml | 2 +- themes/hydrogen/joomla/fields/warning.php | 9 +- .../html/layouts/joomla/system/message.php | 11 +- 38 files changed, 392 insertions(+), 544 deletions(-) diff --git a/.gitignore b/.gitignore index 4e3483ef6..ed10d7032 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ CLAUDE.md # Builds bin/build/tmp bin/build/package +bin/builder/tmp +bin/builder/package dist # Tester diff --git a/bin/build b/bin/build index 286b80a37..fde7b4e4b 100755 --- a/bin/build +++ b/bin/build @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license Dual License: MIT or GNU/GPLv2 and later * @@ -20,11 +20,17 @@ chdir(__DIR__ . '/builder'); $hasVersion = false; $isProd = true; +$hasTmpDir = false; +$hasBuildDir = false; array_shift($argv); foreach ($argv as $arg) { if (strpos($arg, '-') === 0) { if (strpos($arg, '-Dxml.version=') === 0) { $hasVersion = true; + } elseif (strpos($arg, '-Dtmp_dir=') === 0) { + $hasTmpDir = true; + } elseif (strpos($arg, '-Dbuild_dir=') === 0) { + $hasBuildDir = true; } } elseif (strpos($arg, 'dev') !== false) { $isProd = false; @@ -32,6 +38,19 @@ foreach ($argv as $arg) { } $base = dirname(__DIR__); +if (stripos(PHP_OS, 'WIN') === 0) { + $drive = substr($base, 0, 2); + if (preg_match('/^[A-Za-z]:$/', $drive)) { + // Keep Phing working directories short on Windows to avoid MAX_PATH issues. + if (!$hasTmpDir) { + $argv[] = '-Dtmp_dir=' . $drive . '\\g5build\\tmp'; + } + if (!$hasBuildDir) { + $argv[] = '-Dbuild_dir=' . $drive . '\\g5build\\package'; + } + } +} + if (false === $hasVersion) { $file = fopen("{$base}/CHANGELOG.md",'rb'); if (preg_match('/^# (\d\.\d+.\d+(-[a-z0-9.]+)?)\s*$/i', fgets($file), $matches) !== 1) { @@ -58,9 +77,37 @@ if (false === $hasVersion) { } $argv[] = '-Dxml.version=' . $version; + +// Pre-flight: note if PHP intl extension is missing. Build can continue because build.xml +// now uses PHP date fallback, but some environments may still expect intl. +if (!extension_loaded('intl')) { + fwrite(STDERR, "\nWARNING: PHP 'intl' extension is not enabled for CLI.\n"); + fwrite(STDERR, "The build will attempt a fallback (PHP date). Consider enabling 'intl' for full compatibility.\n"); + fwrite(STDERR, "Verify with: php -m | findstr /i intl\n\n"); + // continue without exiting +} } -$command = 'vendor/bin/phing ' . implode(' ', $argv); +// Ensure Phing can create zip archives even if CLI php.ini doesn't load zip by default. +$phpCommand = 'php'; +if (!extension_loaded('zip')) { + $extensionDir = ini_get('extension_dir') ?: ''; + if ($extensionDir && !preg_match('#^([a-zA-Z]:[\\\\/]|[\\\\/])#', $extensionDir)) { + $extensionDir = dirname(PHP_BINARY) . DIRECTORY_SEPARATOR . $extensionDir; + } + $zipExtension = 'zip.' . PHP_SHLIB_SUFFIX; + if (stripos(PHP_OS, 'WIN') === 0) { + $zipExtension = 'php_zip.' . PHP_SHLIB_SUFFIX; + } + + $zipPath = rtrim($extensionDir, '/\\') . DIRECTORY_SEPARATOR . $zipExtension; + if (is_file($zipPath)) { + $phpCommand .= ' -d extension=' . $zipExtension; + } +} + +$escapedArgs = array_map('escapeshellarg', $argv); +$command = $phpCommand . ' vendor/bin/phing ' . implode(' ', $escapedArgs); if (false === system($command, $result) || $result) { throw new \RuntimeException('Failed to run build script'); -} \ No newline at end of file +} diff --git a/bin/builder/build.xml b/bin/builder/build.xml index bbb8d0751..6d5471424 100644 --- a/bin/builder/build.xml +++ b/bin/builder/build.xml @@ -48,12 +48,19 @@ - - - - - - + + + + + + + + + + + + + diff --git a/bin/composer-install b/bin/composer-install index e51c8640d..a34b669a4 100755 --- a/bin/composer-install +++ b/bin/composer-install @@ -28,7 +28,28 @@ function composer_install($folder, $link) { chdir($folder); if ($link && !file_exists('src')) { - symlink('../../../src', 'src'); + $projectRoot = realpath(__DIR__ . '/..'); + $source = $projectRoot ? $projectRoot . DIRECTORY_SEPARATOR . 'src' : __DIR__ . '/..' . DIRECTORY_SEPARATOR . 'src'; + // Try symlink first + try { + @symlink($source, 'src'); + } catch (\Throwable $e) { + // ignore + } + + // Fallback: copy directory when symlink is not available (Windows) + if (!file_exists('src') && $source && is_dir($source)) { + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST); + @mkdir('src'); + foreach ($iterator as $item) { + $dest = 'src' . DIRECTORY_SEPARATOR . ltrim(str_replace($source, '', $item->getPathname()), DIRECTORY_SEPARATOR); + if ($item->isDir()) { + @mkdir($dest); + } else { + copy($item->getPathname(), $dest); + } + } + } } if (false === exec('composer install --no-dev --no-progress --ignore-platform-req=ext-dom --ignore-platform-req=ext-xml --ignore-platform-req=ext-simplexml --ignore-platform-req=ext-xmlwriter', $output, $result) || $result) { echo implode("\n", $output); diff --git a/bin/composer-update b/bin/composer-update index 9ceca2fdc..62dc0f482 100755 --- a/bin/composer-update +++ b/bin/composer-update @@ -28,7 +28,28 @@ function composer_update($folder, $link) { chdir($folder); if ($link && !file_exists('src')) { - symlink('../../../src', 'src'); + $projectRoot = realpath(__DIR__ . '/..'); + $source = $projectRoot ? $projectRoot . DIRECTORY_SEPARATOR . 'src' : __DIR__ . '/..' . DIRECTORY_SEPARATOR . 'src'; + // Try symlink first + try { + @symlink($source, 'src'); + } catch (\Throwable $e) { + // ignore + } + + // Fallback: copy directory when symlink is not available (Windows) + if (!file_exists('src') && $source && is_dir($source)) { + $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST); + @mkdir('src'); + foreach ($iterator as $item) { + $dest = 'src' . DIRECTORY_SEPARATOR . ltrim(str_replace($source, '', $item->getPathname()), DIRECTORY_SEPARATOR); + if ($item->isDir()) { + @mkdir($dest); + } else { + copy($item->getPathname(), $dest); + } + } + } } if (false === exec('composer update --no-dev --no-progress --ignore-platform-req=ext-dom --ignore-platform-req=ext-xml --ignore-platform-req=ext-simplexml --ignore-platform-req=ext-xmlwriter', $output, $result) || $result) { echo implode("\n", $output); diff --git a/composer.json b/composer.json index 02a300a3a..ba83c059e 100644 --- a/composer.json +++ b/composer.json @@ -11,15 +11,15 @@ "ext-mbstring": "*" }, "scripts": { - "install-deps": "bin/composer-install", - "update-deps": "bin/composer-update", + "install-deps": "php bin/composer-install", + "update-deps": "php bin/composer-update", "build-dev": [ - "bin/composer-install", - "bin/build dev" + "php bin/composer-install", + "php bin/build dev" ], "build-prod": [ - "bin/composer-install", - "bin/build prod" + "php bin/composer-install", + "php bin/build prod" ] } } diff --git a/composer.lock b/composer.lock index 5b0abed35..c6d8ba127 100644 --- a/composer.lock +++ b/composer.lock @@ -4,19 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "308366c84bc6bdaf9cdce33025573f48", + "content-hash": "29d67fd1c354e8484bb98f0adfcbb15e", "packages": [], "packages-dev": [], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.6.20", + "php": ">=8.1.0 <8.4.0", "ext-zip": "*", - "ext-json": "*" + "ext-json": "*", + "ext-mbstring": "*" }, - "platform-dev": [], - "plugin-api-version": "2.1.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/platforms/grav/gantry5/gantry5.php b/platforms/grav/gantry5/gantry5.php index d7e39208a..41d1a0f74 100644 --- a/platforms/grav/gantry5/gantry5.php +++ b/platforms/grav/gantry5/gantry5.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license MIT * diff --git a/platforms/joomla/com_gantry5/site/fields/particle.php b/platforms/joomla/com_gantry5/site/fields/particle.php index 8f457bf52..0a4b9e7a3 100644 --- a/platforms/joomla/com_gantry5/site/fields/particle.php +++ b/platforms/joomla/com_gantry5/site/fields/particle.php @@ -24,10 +24,7 @@ use Joomla\CMS\Form\FormField; /** * Class JFormFieldParticle */ -// Compatibility alias for Joomla 4 -// if (!class_exists('JFormFieldParticle') && version_compare(JVERSION, '5.0', '<')) { -// class_alias('ParticleField', 'JFormFieldParticle'); -// } + class JFormFieldParticle extends FormField { diff --git a/platforms/joomla/install.php b/platforms/joomla/install.php index b8a5a696c..35c99a8af 100644 --- a/platforms/joomla/install.php +++ b/platforms/joomla/install.php @@ -37,8 +37,9 @@ class Pkg_Gantry5InstallerScript '0' => '8.2.0' // Preferred version ), 'Joomla!' => array ( - '4.0' => '4.0.0', - '0' => '4.4.0' // Preferred version + // Require Joomla 5+ (minimum 5.0.0) + '5.0' => '5.0.0', + '0' => '5.0.0' // Preferred version ) ); /** diff --git a/platforms/joomla/plg_system_gantry5/fields/warning.php b/platforms/joomla/plg_system_gantry5/fields/warning.php index d50b21e57..d4180a2d7 100644 --- a/platforms/joomla/plg_system_gantry5/fields/warning.php +++ b/platforms/joomla/plg_system_gantry5/fields/warning.php @@ -11,8 +11,8 @@ use Joomla\Database\DatabaseInterface; /** * @package Gantry 5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -110,7 +110,4 @@ HTML; } } -// Compatibility alias for Joomla 4 -if (!class_exists('JFormFieldWarning') && version_compare(JVERSION, '5.0', '<')) { - class_alias('WarningField', 'JFormFieldWarning'); -} +// Joomla 5 only: no legacy alias required diff --git a/platforms/joomla/plg_system_gantry5/gantry5.php b/platforms/joomla/plg_system_gantry5/gantry5.php index 7818d54a0..8c9ad5a52 100644 --- a/platforms/joomla/plg_system_gantry5/gantry5.php +++ b/platforms/joomla/plg_system_gantry5/gantry5.php @@ -3,8 +3,8 @@ /** * @package Gantry 5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -106,11 +106,6 @@ class plgSystemGantry5 extends CMSPlugin public function onAfterRoute() { - if (version_compare(JVERSION, '4.0', '<')) { - // In Joomla 3.9 we need to make sure that user identity has been loaded. - $this->app->loadIdentity(); - } - if ($this->app->isClient('site')) { $this->onAfterRouteSite(); diff --git a/platforms/wordpress/gantry5/composer.json b/platforms/wordpress/gantry5/composer.json index 733d9f693..1f5d800d4 100644 --- a/platforms/wordpress/gantry5/composer.json +++ b/platforms/wordpress/gantry5/composer.json @@ -24,12 +24,6 @@ "require-dev": { "phpunit/phpunit": "^9.0" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/rockettheme/toolbox" - } - ], "autoload": { "psr-4": { "Gantry\\": "src/classes/Gantry" diff --git a/platforms/wordpress/gantry5/composer.lock b/platforms/wordpress/gantry5/composer.lock index 02af40323..8b83ec154 100644 --- a/platforms/wordpress/gantry5/composer.lock +++ b/platforms/wordpress/gantry5/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d98fe9d763708e0c002213c854a5d552", + "content-hash": "4cae021ed9b5ec2c7b35bd94b74893d6", "packages": [ { "name": "altorouter/altorouter", @@ -384,16 +384,16 @@ }, { "name": "pimple/pimple", - "version": "v3.5.0", + "version": "v3.6.1", "source": { "type": "git", "url": "https://github.com/silexphp/Pimple.git", - "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed" + "reference": "020029849cc55ad360066844df8ed880fb20c5bb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a94b3a4db7fb774b3d78dad2315ddc07629e1bed", - "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/020029849cc55ad360066844df8ed880fb20c5bb", + "reference": "020029849cc55ad360066844df8ed880fb20c5bb", "shasum": "" }, "require": { @@ -401,7 +401,7 @@ "psr/container": "^1.1 || ^2.0" }, "require-dev": { - "symfony/phpunit-bridge": "^5.4@dev" + "phpunit/phpunit": "*" }, "type": "library", "extra": { @@ -431,9 +431,9 @@ "dependency injection" ], "support": { - "source": "https://github.com/silexphp/Pimple/tree/v3.5.0" + "source": "https://github.com/silexphp/Pimple/tree/v3.6.1" }, - "time": "2021-10-28T11:13:42+00:00" + "time": "2025-12-31T08:24:29+00:00" }, { "name": "psr/container", @@ -562,36 +562,21 @@ "type": "library", "autoload": { "psr-4": { - "RocketTheme\\Toolbox\\ArrayTraits\\": "ArrayTraits/src", - "RocketTheme\\Toolbox\\Blueprints\\": "Blueprints/src", - "RocketTheme\\Toolbox\\Compat\\": "Compat/src", "RocketTheme\\Toolbox\\DI\\": "DI/src", - "RocketTheme\\Toolbox\\Event\\": "Event/src", "RocketTheme\\Toolbox\\File\\": "File/src", - "RocketTheme\\Toolbox\\ResourceLocator\\": "ResourceLocator/src", + "RocketTheme\\Toolbox\\Event\\": "Event/src", + "RocketTheme\\Toolbox\\Compat\\": "Compat/src", "RocketTheme\\Toolbox\\Session\\": "Session/src", - "RocketTheme\\Toolbox\\StreamWrapper\\": "StreamWrapper/src" + "RocketTheme\\Toolbox\\Blueprints\\": "Blueprints/src", + "RocketTheme\\Toolbox\\ArrayTraits\\": "ArrayTraits/src", + "RocketTheme\\Toolbox\\StreamWrapper\\": "StreamWrapper/src", + "RocketTheme\\Toolbox\\ResourceLocator\\": "ResourceLocator/src" }, "exclude-from-classmap": [ "**/tests/" ] }, - "archive": { - "exclude": [ - "tests" - ] - }, - "scripts": { - "test": [ - "vendor/bin/phpunit run unit" - ], - "test-windows": [ - "vendor\\bin\\phpunit run unit" - ], - "phpstan": [ - "vendor/bin/phpstan analyse -l 8 -c ./tests/phpstan/phpstan.neon . --memory-limit=128M --no-progress" - ] - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -602,8 +587,8 @@ "rockettheme" ], "support": { - "source": "https://github.com/rockettheme/toolbox/tree/1.6.5", - "issues": "https://github.com/rockettheme/toolbox/issues" + "issues": "https://github.com/rockettheme/toolbox/issues", + "source": "https://github.com/rockettheme/toolbox/tree/1.6.5" }, "time": "2023-05-09T18:11:17+00:00" }, @@ -689,16 +674,16 @@ }, { "name": "symfony/deprecation-contracts", - "version": "v3.5.1", + "version": "v3.6.0", "source": { "type": "git", "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6" + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", - "reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62", + "reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62", "shasum": "" }, "require": { @@ -711,7 +696,7 @@ "name": "symfony/contracts" }, "branch-alias": { - "dev-main": "3.5-dev" + "dev-main": "3.6-dev" } }, "autoload": { @@ -736,7 +721,7 @@ "description": "A generic function and convention to trigger deprecation notices", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1" + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0" }, "funding": [ { @@ -752,7 +737,7 @@ "type": "tidelift" } ], - "time": "2024-09-25T14:20:29+00:00" + "time": "2024-09-25T14:21:43+00:00" }, { "name": "symfony/event-dispatcher", @@ -919,7 +904,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -978,7 +963,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.33.0" }, "funding": [ { @@ -989,6 +974,10 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" @@ -1143,16 +1132,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.31.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8" + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", - "reference": "60328e362d4c2c802a54fcbf04f9d3fb892b4cf8", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", "shasum": "" }, "require": { @@ -1203,7 +1192,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.33.0" }, "funding": [ { @@ -1214,12 +1203,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2025-01-02T08:10:11+00:00" }, { "name": "symfony/yaml", @@ -3322,7 +3315,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -3333,9 +3326,9 @@ "ext-xml": "*", "ext-simplexml": "*" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "8.1" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/platforms/wordpress/gantry5/gantry5.php b/platforms/wordpress/gantry5/gantry5.php index 274ddc261..2a2aa6c95 100644 --- a/platforms/wordpress/gantry5/gantry5.php +++ b/platforms/wordpress/gantry5/gantry5.php @@ -93,14 +93,19 @@ function add_gantry5_streams_to_kses($protocols) return $protocols; } -// Initialize plugin language and fallback to en_US if the .mo file can't be found -$domain = 'gantry5'; -$languages_path = basename(GANTRY5_PATH) . '/admin/languages'; +// Initialize plugin language on init to avoid WP 6.7+ early translation notices. +add_action('init', 'gantry5_load_textdomain', 1); -if (load_plugin_textdomain($domain, false, $languages_path) === false) { - add_filter('plugin_locale', 'modify_gantry5_locale', 10, 2); - load_plugin_textdomain($domain, false, $languages_path); - remove_filter('plugin_locale', 'modify_gantry5_locale', 10); +function gantry5_load_textdomain() +{ + $domain = 'gantry5'; + $languages_path = basename(GANTRY5_PATH) . '/admin/languages'; + + if (load_plugin_textdomain($domain, false, $languages_path) === false) { + add_filter('plugin_locale', 'modify_gantry5_locale', 10, 2); + load_plugin_textdomain($domain, false, $languages_path); + remove_filter('plugin_locale', 'modify_gantry5_locale', 10); + } } function modify_gantry5_locale($locale, $domain = null) diff --git a/src/RealLoader.php b/src/RealLoader.php index ff03eb16d..eba36a845 100644 --- a/src/RealLoader.php +++ b/src/RealLoader.php @@ -103,9 +103,10 @@ abstract class RealLoader throw new \LogicException('Please run composer in Gantry 5 Library!'); } - // In PHP >=7.2.5 we need to use newer version of ctype library. - $useNewLibraries = \PHP_VERSION_ID >= 70205 && GANTRY5_PLATFORM !== 'grav'; - if ($useNewLibraries) { + // Load compat libraries only on platforms that still rely on the legacy stack. + // WordPress ships with modern dependencies in vendor/, so prefer those there. + $useCompatLibraries = GANTRY5_PLATFORM !== 'wordpress' && \PHP_VERSION_ID >= 70205 && GANTRY5_PLATFORM !== 'grav'; + if ($useCompatLibraries) { /** @var ClassLoader $loader */ $loader = require "{$lib}/compat/vendor/autoload.php"; $loader->unregister(); @@ -114,8 +115,8 @@ abstract class RealLoader /** @var ClassLoader $loader */ $loader = require $autoload; - // In PHP >=7.2.5 we need to use newer version of Pimple and Twig. - if ($useNewLibraries) { + // On legacy platforms, map Pimple/Twig to compat vendor. + if ($useCompatLibraries) { $loader->setPsr4('Twig\\', "{$lib}/compat/vendor/twig/twig/src"); $loader->set('Twig_', "{$lib}/compat/vendor/twig/twig/lib"); $loader->set('Pimple', "{$lib}/compat/vendor/pimple/pimple/src"); diff --git a/src/classes/Gantry/Admin/Events/Event.php b/src/classes/Gantry/Admin/Events/Event.php index 69dc247d2..b23b4afcd 100644 --- a/src/classes/Gantry/Admin/Events/Event.php +++ b/src/classes/Gantry/Admin/Events/Event.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license Dual License: MIT or GNU/GPLv2 and later * @@ -25,6 +25,12 @@ use Gantry\Framework\Gantry; */ class Event extends \RocketTheme\Toolbox\Event\Event { + /** + * Permanent fix for PHP 8.2 dynamic property warning: + * Creation of dynamic property Event::$types is deprecated. + */ + public array $types = []; + /** @var Gantry */ public $gantry; /** @var RestfulControllerInterface */ diff --git a/src/classes/Gantry/Component/Theme/ThemeTrait.php b/src/classes/Gantry/Component/Theme/ThemeTrait.php index 304c39801..61fd68f8b 100644 --- a/src/classes/Gantry/Component/Theme/ThemeTrait.php +++ b/src/classes/Gantry/Component/Theme/ThemeTrait.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license Dual License: MIT or GNU/GPLv2 and later * @@ -796,7 +796,14 @@ trait ThemeTrait } if ($cached) { - $cacheKey['language'] = $gantry['page']->language; + $language = ''; + if (isset($gantry['page']) && isset($gantry['page']->language)) { + $language = $gantry['page']->language; + } elseif (isset($gantry['site']) && isset($gantry['site']->language)) { + $language = $gantry['site']->language; + } + + $cacheKey['language'] = $language; $cacheKey['attributes'] = $particle; $cacheKey += (array) $item; diff --git a/src/classes/Gantry/Framework/Assignments.php b/src/classes/Gantry/Framework/Assignments.php index c55c92838..24150ea6c 100644 --- a/src/classes/Gantry/Framework/Assignments.php +++ b/src/classes/Gantry/Framework/Assignments.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license Dual License: MIT or GNU/GPLv2 and later * diff --git a/src/platforms/joomla/classes/Gantry/Framework/Document.php b/src/platforms/joomla/classes/Gantry/Framework/Document.php index 640c008e9..7f14775cd 100644 --- a/src/platforms/joomla/classes/Gantry/Framework/Document.php +++ b/src/platforms/joomla/classes/Gantry/Framework/Document.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -18,7 +18,7 @@ use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\Factory; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Version as JVersion; +// Joomla 5-only: no version switch needed here use Joomla\CMS\WebAsset\WebAssetManager; /** @@ -58,8 +58,7 @@ class Document extends HtmlDocument // Make sure that if Bootstap framework is loaded, also load CSS. if ( $framework === 'bootstrap' - || ($framework === 'bootstrap.2' && JVersion::MAJOR_VERSION === 3) - || ($framework === 'bootstrap.5' && JVersion::MAJOR_VERSION >= 4) + || $framework === 'bootstrap.5' ) { /** @var Theme $theme */ $theme = Gantry::instance()['theme']; @@ -174,260 +173,102 @@ class Document extends HtmlDocument protected static function registerJquery() { - if (version_compare(JVERSION, '4.0', '>')) { - if (!static::errorPage()) { - HTMLHelper::_('jquery.framework'); - - return; - } - - /** @var WebAssetManager $wa */ - $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); - - array_map( - static function ($script) use ($wa) { - $asset = $wa->getAsset('script', $script); - - // Workaround for error document type. - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => $asset->getUri(true) - ], - 'head', - 100 - ); - }, - ['jquery', 'jquery-noconflict'] - ); - - return; - } - - // Joomla 3: if (!static::errorPage()) { HTMLHelper::_('jquery.framework'); return; } - // Workaround for error document type. - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/jui/js/jquery.min.js' - ], - 'head', - 100 - ); - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/jui/js/jquery-noconflict.js' - ], - 'head', - 100 - ); - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/jui/js/jquery-migrate.min.js' - ], - 'head', - 100 + /** @var WebAssetManager $wa */ + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); + + array_map( + static function ($script) use ($wa) { + $asset = $wa->getAsset('script', $script); + + // Workaround for error document type. + static::addHeaderTag( + [ + 'tag' => 'script', + 'src' => $asset->getUri(true) + ], + 'head', + 100 + ); + }, + ['jquery', 'jquery-noconflict'] ); } protected static function registerJqueryUiCore() { - if (version_compare(JVERSION, '4.0', '>')) { - //user_error('jQuery UI Core is not supported in Joomla 4, please remove the dependency!', E_USER_DEPRECATED); + // Modern Joomla: delegate to parent sortable implementation + parent::registerJqueryUiSortable(); - parent::registerJqueryUiSortable(); - - return; - } - - if (!static::errorPage()) { - HTMLHelper::_('jquery.ui', ['core']); - - return; - } - - // Workaround for error document type. - static::registerJquery(); - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/jui/js/jquery.ui.core.min.js' - ], - 'head', - 100 - ); + return; } protected static function registerJqueryUiSortable() { - if (version_compare(JVERSION, '4.0', '>')) { - //user_error('jQuery UI Sortable is not supported in Joomla 4, please remove the dependency!', E_USER_DEPRECATED); + parent::registerJqueryUiSortable(); - parent::registerJqueryUiSortable(); - - return; - } - - if (!static::errorPage()) { - HTMLHelper::_('jquery.ui', ['sortable']); - - return; - } - - // Workaround for error document type. - static::registerJqueryUiCore(); - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/jui/js/jquery.ui.sortable.min.js' - ], - 'head', - 100 - ); + return; } protected static function registerBootstrap() { - if (version_compare(JVERSION, '4.0', '>')) { - static::registerBootstrap5(); - } else { - static::registerBootstrap2(); - } + // For Joomla 5 use Bootstrap 5 implementation + static::registerBootstrap5(); } protected static function registerBootstrap2() { - if (version_compare(JVERSION, '4.0', '>')) { - //user_error('Bootstrap 2 is not supported in Joomla 4, using Bootstrap 5 instead!', E_USER_DEPRECATED); - - static::registerBootstrap5(); - - return; - } + // Deprecated in modern Joomla; route to Bootstrap5 implementation + static::registerBootstrap5(); + } + protected static function registerBootstrap5() + { if (!static::errorPage()) { HTMLHelper::_('bootstrap.framework'); return; } - // Workaround for error document type. - static::registerJquery(); - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/jui/js/bootstrap.min.js' - ], - 'head', - 100 + /** @var WebAssetManager $wa */ + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); + + array_map( + static function ($script) use ($wa) { + $asset = $wa->getAsset('script', 'bootstrap.' . $script); + + // Workaround for error document type. + static::addHeaderTag( + [ + 'tag' => 'script', + 'src' => $asset->getUri(true) . '?' . $asset->getVersion() + ], + 'head', + 100 + ); + }, + ['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast'] ); } - protected static function registerBootstrap5() - { - if (version_compare(JVERSION, '4.0', '>')) { - if (!static::errorPage()) { - HTMLHelper::_('bootstrap.framework'); - - return; - } - - /** @var WebAssetManager $wa */ - $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); - - array_map( - static function ($script) use ($wa) { - $asset = $wa->getAsset('script', 'bootstrap.' . $script); - - // Workaround for error document type. - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => $asset->getUri(true) . '?' . $asset->getVersion() - ], - 'head', - 100 - ); - }, - ['alert', 'button', 'carousel', 'collapse', 'dropdown', 'modal', 'offcanvas', 'popover', 'scrollspy', 'tab', 'toast'] - ); - - return; - } - - parent::registerBootstrap5(); - } - protected static function registerMootools() { - if (version_compare(JVERSION, '4.0', '>')) { - //user_error('Mootools is no longer supported in Joomla 4!', E_USER_DEPRECATED); + parent::registerMootools(); - parent::registerMootools(); - - return; - } - - if (!static::errorPage()) { - HTMLHelper::_('behavior.framework'); - - return; - } - - // Workaround for error document type. - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/system/js/mootools-core.js' - ], - 'head', - 99 - ); - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/system/js/core.js' - ], - 'head', - 99 - ); + return; } protected static function registerMootoolsMore() { - if (version_compare(JVERSION, '4.0', '>')) { - //user_error('Mootools is no longer supported in Joomla 4!', E_USER_DEPRECATED); + parent::registerMootoolsMore(); - parent::registerMootoolsMore(); - - return; - } - - if (!static::errorPage()) { - HTMLHelper::_('behavior.framework', true); - - return; - } - - // Workaround for error document type. - static::registerMootools(); - static::addHeaderTag( - [ - 'tag' => 'script', - 'src' => Uri::getInstance()->base(true) . '/media/system/js/mootools-more.js' - ], - 'head', - 99 - ); + return; } /** diff --git a/src/platforms/joomla/classes/Gantry/Framework/Page.php b/src/platforms/joomla/classes/Gantry/Framework/Page.php index 6caf33ba5..f6c8cd7a5 100644 --- a/src/platforms/joomla/classes/Gantry/Framework/Page.php +++ b/src/platforms/joomla/classes/Gantry/Framework/Page.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -146,15 +146,10 @@ class Page extends Base\Page */ public function bodyAttributes($attributes = []) { - if ($this->tmpl === 'component') { - if (version_compare(JVERSION, '4.0', '<')) { - $classes = ['contentpane', 'modal']; - } - } else { - $classes = ['site', $this->option, "view-{$this->view}"]; - $classes[] = $this->layout ? 'layout-' . $this->layout : 'no-layout'; - $classes[] = $this->task ? 'task-' . $this->task : 'no-task'; - } + // Use modern Joomla class set for site and component pages (Joomla 5) + $classes = ['site', $this->option, "view-{$this->view}"]; + $classes[] = $this->layout ? 'layout-' . $this->layout : 'no-layout'; + $classes[] = $this->task ? 'task-' . $this->task : 'no-task'; $classes[] = 'dir-' . $this->direction; if ($this->class) $classes[] = $this->class; if ($this->printing) $classes[] = 'print-mode'; diff --git a/src/platforms/joomla/classes/Gantry/Framework/Platform.php b/src/platforms/joomla/classes/Gantry/Framework/Platform.php index f4b07fc59..d1abb4219 100644 --- a/src/platforms/joomla/classes/Gantry/Framework/Platform.php +++ b/src/platforms/joomla/classes/Gantry/Framework/Platform.php @@ -66,12 +66,9 @@ class Platform extends BasePlatform $this->module_wrapper = '
%s
'; - if (Version::MAJOR_VERSION < 4) { - $this->component_wrapper = '
%s
'; - } else { - $this->features['fontawesome'] = true; - $this->component_wrapper = '
%s
'; - } + // Joomla 5-only: always use modern container/component wrapper and enable fontawesome + $this->features['fontawesome'] = true; + $this->component_wrapper = '
%s
'; } /** @@ -700,7 +697,8 @@ class Platform extends BasePlatform $db = Factory::getDbo(); $userId = $user->id; - $checked_out_default = Version::MAJOR_VERSION < 4 ? 'checked_out != 0' : 'checked_out IS NOT null'; + // Joomla 5: checked_out field is nullable + $checked_out_default = 'checked_out IS NOT null'; // Verify that no items are checked out. $query = $db->getQuery(true) diff --git a/src/platforms/joomla/classes/Gantry/Framework/Theme.php b/src/platforms/joomla/classes/Gantry/Framework/Theme.php index 7fc138f97..0789adfbd 100644 --- a/src/platforms/joomla/classes/Gantry/Framework/Theme.php +++ b/src/platforms/joomla/classes/Gantry/Framework/Theme.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -51,10 +51,7 @@ class Theme extends AbstractTheme if ($enable && !$this->joomla) { $this->joomla = true; - // Workaround for Joomla! 3.x not loading bootstrap when it needs it. - if (version_compare(JVERSION, '4', '<')) { - static::gantry()->load('bootstrap'); - } + // Joomla 5 only: no Joomla 3 bootstrap workaround needed. } return $this->joomla; diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Category/Category.php b/src/platforms/joomla/classes/Gantry/Joomla/Category/Category.php index 262099b78..7f5c75f1e 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Category/Category.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Category/Category.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -82,12 +82,7 @@ class Category extends AbstractObject */ public function route() { - if (version_compare(JVERSION, '4.0', '<')) { - require_once JPATH_SITE . '/components/com_content/helpers/route.php'; - - return Route::_(\ContentHelperRoute::getCategoryRoute($this->id . ':' . $this->alias), false); - } - + // Joomla 5: use namespaced RouteHelper require_once JPATH_SITE . '/components/com_content/src/Helper/RouteHelper.php'; return Route::_(RouteHelper::getCategoryRoute($this->id . ':' . $this->alias), false); diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Contact/Contact.php b/src/platforms/joomla/classes/Gantry/Joomla/Contact/Contact.php index 8f29d3037..ddaf33933 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Contact/Contact.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Contact/Contact.php @@ -42,13 +42,6 @@ class Contact extends AbstractObject */ protected static function getTable() { - if (\JVersion::MAJOR_VERSION === 3) { - require_once JPATH_ADMINISTRATOR . '/components/com_contact/tables/contact.php'; - - static::$table = 'Contact'; - static::$tablePrefix = 'ContactTable'; - } - return parent::getTable(); } } diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Content/Content.php b/src/platforms/joomla/classes/Gantry/Joomla/Content/Content.php index 3c1f667e1..f4bc995ac 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Content/Content.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Content/Content.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -142,13 +142,7 @@ class Content extends AbstractObject public function route() { $category = $this->category(); - - if (version_compare(JVERSION, '4.0', '<')) { - require_once JPATH_SITE . '/components/com_content/helpers/route.php'; - - return htmlspecialchars_decode(Route::_(\ContentHelperRoute::getArticleRoute($this->id . ':' . $this->alias, $category->id . ':' . $category->alias), false), ENT_COMPAT); - } - + // Joomla 5: use namespaced RouteHelper require_once JPATH_SITE . '/components/com_content/src/Helper/RouteHelper.php'; return htmlspecialchars_decode(Route::_(RouteHelper::getArticleRoute($this->id . ':' . $this->alias, $category->id . ':' . $category->alias), false), ENT_COMPAT); @@ -165,12 +159,9 @@ class Content extends AbstractObject $asset = "com_content.article.{$this->id}"; if ($user && ($user->authorise('core.edit', $asset) || $user->authorise('core.edit.own', $asset))) { - if (version_compare(JVERSION, '4.0', '<')) { - return "index.php?option=com_content&task=article.edit&a_id={$this->id}&tmpl=component"; - } - + // Joomla 5: use namespaced RouteHelper and build edit url $contentUrl = RouteHelper::getArticleRoute($this->id . ':' . $this->alias, $this->catid); - $url = $contentUrl . '&task=article.edit&a_id=' . $this->id; + $url = $contentUrl . '&task=article.edit&a_id=' . $this->id; return htmlspecialchars_decode(Route::_($url), ENT_COMPAT); } diff --git a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php index dcd90ddb9..1fb1299dc 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/Content/ContentFinder.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -165,21 +165,15 @@ class ContentFinder extends Finder } // Filter by start and end dates. - if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) { - // Define null and now dates + if (!$user->authorise('core.edit.state', 'com_content') && !$user->authorise('core.edit', 'com_content')) { + // Define now date and use modern datetime null checks (Joomla 5) $nowDate = $this->db->quote(Factory::getDate()->toSql()); - if (version_compare(JVERSION, '4.0', '<')) { - $nullDate = $this->db->quote($this->db->getNullDate()); - $nullDateUp = "a.publish_up = {$nullDate}"; - $nullDateDown = "a.publish_down = {$nullDate}"; - } else { - $nullDateUp = $this->query->isNullDatetime('a.publish_up'); - $nullDateDown = $this->query->isNullDatetime('a.publish_down'); - } + $nullDateUp = $this->query->isNullDatetime('a.publish_up'); + $nullDateDown = $this->query->isNullDatetime('a.publish_down'); $this->query ->where('(' . $nullDateUp . ' OR a.publish_up <= ' . $nowDate . ')') - ->where('(' . $nullDateDown. ' OR a.publish_down >= ' . $nowDate . ')') + ->where('(' . $nullDateDown . ' OR a.publish_down >= ' . $nowDate . ')') ->where('a.state >= 1') ; } @@ -228,10 +222,10 @@ class ContentFinder extends Finder $input = $tagIds['id'][0]; $tagIdsArray = []; $tagNamesArray = []; - + // Separate IDs and names $items = array_map('trim', explode(',', $input)); - + foreach ($items as $item) { if (is_numeric($item)) { $tagIdsArray[] = (int)$item; @@ -239,7 +233,7 @@ class ContentFinder extends Finder $tagNamesArray[] = $item; } } - + // If we have tag names, get their IDs if (!empty($tagNamesArray)) { // Use the same database object as other methods in this class @@ -247,21 +241,21 @@ class ContentFinder extends Finder ->select($this->db->quoteName('id')) ->from($this->db->quoteName('#__tags')) ->where($this->db->quoteName('title') . ' IN (' . implode(',', array_map([$this->db, 'quote'], $tagNamesArray)) . ')'); - + $this->db->setQuery($query); $tagIdsFromNames = $this->db->loadColumn(); - + if (!empty($tagIdsFromNames)) { $tagIdsArray = array_merge($tagIdsArray, $tagIdsFromNames); } } - + if (empty($tagIdsArray)) { return $this; } - + $this->query->join('INNER', '#__contentitem_tag_map AS t ON t.content_item_id = a.id'); - + return $this->where('t.tag_id', 'IN', $tagIdsArray)->where('t.type_alias', '=', 'com_content.article'); } } diff --git a/src/platforms/joomla/classes/Gantry/Joomla/MenuHelper.php b/src/platforms/joomla/classes/Gantry/Joomla/MenuHelper.php index 78f09151c..a5e60f5c3 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/MenuHelper.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/MenuHelper.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -55,10 +55,6 @@ class MenuHelper { $model = static::loadModel(); $table = $model->getTable('MenuType'); - if (!$table) { - // Joomla 3 support. - $table = Table::getInstance('MenuType'); - } if (null !== $id) { if (!is_array($id)) { @@ -80,32 +76,11 @@ class MenuHelper static $model = []; if (!isset($model[$name])) { - if (version_compare(JVERSION, '4', '<')) { - // Joomla 3 support. - $path = JPATH_ADMINISTRATOR . '/components/com_menus/'; - $filename = strtolower($name); - $className = "\\MenusModel{$name}"; - - Table::addIncludePath(JPATH_LIBRARIES . '/legacy/table/'); - Table::addIncludePath("{$path}/tables"); - require_once "{$path}/models/{$filename}.php"; - - /** @var CMSApplication $application */ - $application = Factory::getApplication(); - - // Load language strings. - $language = $application->getLanguage(); - $language->load('com_menus'); - - // Load the model. - $model[$name] = new $className(); - } else { - // Joomla 4 support. - $application = Factory::getApplication(); - $model[$name] = $application->bootComponent('com_menus') - ->getMVCFactory() - ->createModel($name, 'Administrator', ['ignore_request' => true]); - } + // Joomla 5+ (use modern component boot and MVC factory) + $application = Factory::getApplication(); + $model[$name] = $application->bootComponent('com_menus') + ->getMVCFactory() + ->createModel($name, 'Administrator', ['ignore_request' => true]); } return $model[$name]; diff --git a/src/platforms/joomla/classes/Gantry/Joomla/StyleHelper.php b/src/platforms/joomla/classes/Gantry/Joomla/StyleHelper.php index 1732a1d6e..9227e3771 100644 --- a/src/platforms/joomla/classes/Gantry/Joomla/StyleHelper.php +++ b/src/platforms/joomla/classes/Gantry/Joomla/StyleHelper.php @@ -3,8 +3,8 @@ /** * @package Gantry5 * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2021 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -154,32 +154,11 @@ class StyleHelper static $model = []; if (!isset($model[$name])) { - if (version_compare(JVERSION, '4', '<')) { - // Joomla 3 support. - $path = JPATH_ADMINISTRATOR . '/components/com_templates/'; - $filename = strtolower($name); - $className = "\\TemplatesModel{$name}"; - - Table::addIncludePath("{$path}/tables"); - - require_once "{$path}/models/{$filename}.php"; - - /** @var CMSApplication $application */ - $application = Factory::getApplication(); - - // Load language strings. - $language = $application->getLanguage(); - $language->load('com_templates'); - - // Load the model. - $model[$name] = new $className(); - } else { - // Joomla 4 support. - $application = Factory::getApplication(); - $model[$name] = $application->bootComponent('com_templates') - ->getMVCFactory() - ->createModel($name, 'Administrator', ['ignore_request' => true]); - } + // Joomla 5+ (use modern component boot and MVC factory) + $application = Factory::getApplication(); + $model[$name] = $application->bootComponent('com_templates') + ->getMVCFactory() + ->createModel($name, 'Administrator', ['ignore_request' => true]); } return $model[$name]; diff --git a/src/platforms/wordpress/classes/Gantry/Framework/Theme.php b/src/platforms/wordpress/classes/Gantry/Framework/Theme.php index ccae5b0a2..a767ed61b 100644 --- a/src/platforms/wordpress/classes/Gantry/Framework/Theme.php +++ b/src/platforms/wordpress/classes/Gantry/Framework/Theme.php @@ -557,22 +557,8 @@ class Theme extends AbstractTheme $this->preset_styles_init(); - // Load theme text domains - $domain = $this->details()->get('configuration.gantry.engine', 'nucleus'); - $lookup = '/engines/' . $domain . '/languages'; - if (!file_exists(GANTRY5_PATH . $lookup)) { - $lookup = '/engines/wordpress/' . $domain . '/languages'; - } - $lookup = basename(GANTRY5_PATH) . $lookup; - - if (\load_plugin_textdomain($domain, false, $lookup) === false) { - \add_filter('plugin_locale', 'modify_gantry5_locale', 10, 2); - \load_plugin_textdomain($domain, false, $lookup); - \remove_filter('plugin_locale', 'modify_gantry5_locale', 10); - } - - $domain = $this->details()->get('configuration.theme.textdomain', $this->name); - \load_theme_textdomain($domain, $this->path . '/languages'); + // Load text domains on init or later to avoid WP 6.7+ early translation notices. + $this->loadTextDomains(); $this->url = $gantry['site']->theme->link; @@ -612,6 +598,36 @@ class Theme extends AbstractTheme setcookie($name, $value, $expire, $path, $domain); } + protected function loadTextDomains() + { + $engineDomain = $this->details()->get('configuration.gantry.engine', 'nucleus'); + $lookup = '/engines/' . $engineDomain . '/languages'; + if (!file_exists(GANTRY5_PATH . $lookup)) { + $lookup = '/engines/wordpress/' . $engineDomain . '/languages'; + } + $lookup = basename(GANTRY5_PATH) . $lookup; + + $themeDomain = $this->details()->get('configuration.theme.textdomain', $this->name); + $themePath = $this->path . '/languages'; + + $loader = static function () use ($engineDomain, $lookup, $themeDomain, $themePath) { + if (\load_plugin_textdomain($engineDomain, false, $lookup) === false) { + \add_filter('plugin_locale', 'modify_gantry5_locale', 10, 2); + \load_plugin_textdomain($engineDomain, false, $lookup); + \remove_filter('plugin_locale', 'modify_gantry5_locale', 10); + } + + \load_theme_textdomain($themeDomain, $themePath); + }; + + if (\did_action('init')) { + $loader(); + return; + } + + \add_action('init', $loader, 1); + } + /** * Serve particle AJAX requests in '/wp-admin/admin-ajax.php?action=particle'. */ diff --git a/src/platforms/wordpress/classes/Gantry/Framework/Translator.php b/src/platforms/wordpress/classes/Gantry/Framework/Translator.php index 6ff64ca98..5c8e3f709 100644 --- a/src/platforms/wordpress/classes/Gantry/Framework/Translator.php +++ b/src/platforms/wordpress/classes/Gantry/Framework/Translator.php @@ -27,6 +27,19 @@ class Translator extends BaseTranslator */ public function translate($string) { + if (!\did_action('init')) { + $translated = parent::translate($string); + + if (\func_num_args() === 1) { + return $translated; + } + + $args = \func_get_args(); + $args[0] = $translated; + + return sprintf(...$args); + } + static $textdomain; static $enginedomain; diff --git a/themes/base/joomla/fields/warning.php b/themes/base/joomla/fields/warning.php index cd34da19e..59e56a59f 100644 --- a/themes/base/joomla/fields/warning.php +++ b/themes/base/joomla/fields/warning.php @@ -3,8 +3,8 @@ /** * @package Gantry 5 Theme * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -39,7 +39,4 @@ class WarningField extends \Joomla\CMS\Form\FormField } } -// Compatibility alias for Joomla 4 -if (!class_exists('JFormFieldWarning') && version_compare(JVERSION, '5.0', '<')) { - class_alias('WarningField', 'JFormFieldWarning'); -} +// Joomla 5 only: no legacy alias required diff --git a/themes/base/joomla/html/layouts/joomla/system/message.php b/themes/base/joomla/html/layouts/joomla/system/message.php index d134bd766..3369d1f10 100644 --- a/themes/base/joomla/html/layouts/joomla/system/message.php +++ b/themes/base/joomla/html/layouts/joomla/system/message.php @@ -3,8 +3,8 @@ /** * @package Gantry 5 Theme * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. * @license GNU/GPLv2 and later @@ -14,29 +14,6 @@ defined('_JEXEC') or die; -use Joomla\CMS\Language\Text; - -$msgList = $displayData['msgList']; - -?> -
- -
- $msgs) : ?> -
- - × - - -

-
- -

- -
- -
- -
- -
+// Joomla 5: use core system message layout +include JPATH_ROOT . '/layouts/joomla/system/message.php'; +return; diff --git a/themes/helium/joomla/fields/warning.php b/themes/helium/joomla/fields/warning.php index 8c115e0d6..ac81f84e2 100644 --- a/themes/helium/joomla/fields/warning.php +++ b/themes/helium/joomla/fields/warning.php @@ -3,8 +3,8 @@ /** * @package Gantry 5 Theme * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -39,7 +39,4 @@ class WarningField extends \Joomla\CMS\Form\FormField } } -// Compatibility alias for Joomla 4 -if (!class_exists('JFormFieldWarning') && version_compare(JVERSION, '5.0', '<')) { - class_alias('WarningField', 'JFormFieldWarning'); -} +// Joomla 5 only: no legacy alias required diff --git a/themes/helium/joomla/html/layouts/joomla/system/message.php b/themes/helium/joomla/html/layouts/joomla/system/message.php index 2c2c0ccb9..12dec40f1 100644 --- a/themes/helium/joomla/html/layouts/joomla/system/message.php +++ b/themes/helium/joomla/html/layouts/joomla/system/message.php @@ -3,8 +3,8 @@ /** * @package Gantry 5 Theme * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. * @license GNU/GPLv2 and later @@ -16,10 +16,9 @@ defined('_JEXEC') or die; use Joomla\CMS\Language\Text; -if (version_compare(JVERSION, 4.0, '>')) { - include JPATH_ROOT . '/layouts/joomla/system/message.php'; - return; -} +// Joomla 5: use core system message layout +include JPATH_ROOT . '/layouts/joomla/system/message.php'; +return; /** * Joomla 3 version of the system messages. diff --git a/themes/hydrogen-demo/common/particles/team.yaml b/themes/hydrogen-demo/common/particles/team.yaml index 44935cf41..143ee0bc8 100644 --- a/themes/hydrogen-demo/common/particles/team.yaml +++ b/themes/hydrogen-demo/common/particles/team.yaml @@ -57,4 +57,4 @@ form: .description: type: textarea.textarea - label: Name \ No newline at end of file + label: Name diff --git a/themes/hydrogen/joomla/fields/warning.php b/themes/hydrogen/joomla/fields/warning.php index 8c115e0d6..ac81f84e2 100644 --- a/themes/hydrogen/joomla/fields/warning.php +++ b/themes/hydrogen/joomla/fields/warning.php @@ -3,8 +3,8 @@ /** * @package Gantry 5 Theme * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @license GNU/GPLv2 and later * @@ -39,7 +39,4 @@ class WarningField extends \Joomla\CMS\Form\FormField } } -// Compatibility alias for Joomla 4 -if (!class_exists('JFormFieldWarning') && version_compare(JVERSION, '5.0', '<')) { - class_alias('WarningField', 'JFormFieldWarning'); -} +// Joomla 5 only: no legacy alias required diff --git a/themes/hydrogen/joomla/html/layouts/joomla/system/message.php b/themes/hydrogen/joomla/html/layouts/joomla/system/message.php index 2bde237f3..d31d26886 100644 --- a/themes/hydrogen/joomla/html/layouts/joomla/system/message.php +++ b/themes/hydrogen/joomla/html/layouts/joomla/system/message.php @@ -3,8 +3,8 @@ /** * @package Gantry 5 Theme * @author Tiger12 http://tiger12.com - * @originalCreator RocketTheme (Gantry Framework) - * @currentDeveloper Tiger12, LLC + * @originalCreator RocketTheme (Gantry Framework) + * @currentDeveloper Tiger12, LLC * @copyright Copyright (C) 2007 - 2022 Tiger12, LLC * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. * @license GNU/GPLv2 and later @@ -14,10 +14,9 @@ defined('_JEXEC') or die; -if (version_compare(JVERSION, 4.0, '>')) { - include JPATH_ROOT . '/layouts/joomla/system/message.php'; - return; -} +// Joomla 5: use core system message layout +include JPATH_ROOT . '/layouts/joomla/system/message.php'; +return; /** * Joomla 3 version of the system messages.