Skip to content

Commit

Permalink
Merge branch 'release/5.5.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Nov 22, 2021
2 parents 3f4c958 + 2b69fd0 commit 16f5b44
Show file tree
Hide file tree
Showing 21 changed files with 179 additions and 39 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# 5.5.5
## 11/22/2021

1. [Joomla](#joomla)
1. [](#new)
- Added support for displaying Article Particles on random order (#2943)
2. [](#improved)
- Themes: Pass Joomla document to Gantry when rendering php template files
- Update `component.php`, `error.php`, `index.php`, `offline.php` in your theme!
3. [](#bugfix)
- Fixed some SEF URLs being broken/ugly (#2935)
- Fixed `Identifier "errors" is not defined` instead of error page (#2936)
- Fixed fatal error in error page if `Modern routing` is being used (#2924)
- Joomla 4: Fixed missing translations in Particle module settings (#2945)
- Joomla 4: Fixed error page not loading jQuery and Boostrap JS (#2933)

# 5.5.4
## 11/03/2021

Expand Down
1 change: 1 addition & 0 deletions engines/joomla/nucleus/particles/contentarray.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ form:
options:
ASC: Ascending
DESC: Descending
RANDOM: Random
overridable: false

_tab_display:
Expand Down
16 changes: 10 additions & 6 deletions platforms/joomla/com_gantry5/site/gantry5.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,22 @@

// Prevent direct access without menu item.
if (!$menuItem) {
/** @var \Whoops\Run $errors */
$errors = $gantry['errors'];
$errors->unregister();
if (isset($gantry['errors'])) {
/** @var \Whoops\Run $errors */
$errors = $gantry['errors'];
$errors->unregister();
}

throw new Exception(Text::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
}

// Handle non-html formats and error page.
if ($input->getCmd('view') === 'error' || $input->getInt('g5_not_found') || strtolower($input->getCmd('format', 'html')) !== 'html') {
/** @var \Whoops\Run $errors */
$errors = $gantry['errors'];
$errors->unregister();
if (isset($gantry['errors'])) {
/** @var \Whoops\Run $errors */
$errors = $gantry['errors'];
$errors->unregister();
}

throw new Exception(Text::_('JERROR_PAGE_NOT_FOUND'), 404);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
<field
name="moduleclass_sfx"
type="text"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL" />

<field
name="owncache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
description="COM_MODULES_FIELD_CACHING_DESC"
default="0"
>
<option value="1">JGLOBAL_USE_GLOBAL</option>
Expand All @@ -48,8 +46,7 @@
name="cache_time"
type="text"
default="900"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
description="COM_MODULES_FIELD_CACHE_TIME_DESC" />
label="COM_MODULES_FIELD_CACHE_TIME_LABEL" />
</fieldset>
</fields>
</config>
Expand Down
53 changes: 51 additions & 2 deletions src/platforms/joomla/classes/Gantry/Framework/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Version as JVersion;
use Joomla\CMS\WebAsset\WebAssetManager;

/**
* Class Document
Expand Down Expand Up @@ -172,7 +173,31 @@ protected static function registerScripts()
protected static function registerJquery()
{
if (version_compare(JVERSION, '4.0', '>')) {
HTMLHelper::_('jquery.framework');
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;
}
Expand Down Expand Up @@ -308,7 +333,31 @@ protected static function registerBootstrap2()
protected static function registerBootstrap5()
{
if (version_compare(JVERSION, '4.0', '>')) {
HTMLHelper::_('bootstrap.framework');
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;
}
Expand Down
33 changes: 17 additions & 16 deletions src/platforms/joomla/classes/Gantry/Framework/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ public static function decodeJParams($params)
protected function createMenuItem($data, $menuItem = null)
{
if ($menuItem) {
// This logic was originally copied from Joomla 3.4 mod_menu/helper.php (joomla-cms/staging, 2014-11-12).
// This logic was originally copied from Joomla 3.10 mod_menu/helper.php (joomla-cms/staging, 2021-11-09).
// We should keep the contents of the function similar to Joomla in order to review it against any changes.

$id = (int)$menuItem->id;
Expand All @@ -506,7 +506,7 @@ protected function createMenuItem($data, $menuItem = null)
case 'heading':
case 'separator':
// Check if menu item contains a particle.
if (!empty($params['gantry-particle'])) {
if (!empty($params->get('gantry-particle'))) {
$type = 'particle';
}

Expand All @@ -525,23 +525,24 @@ protected function createMenuItem($data, $menuItem = null)
// If this is an alias use the item id stored in the parameters to make the link.
$link = 'index.php?Itemid=' . $params->get('aliasoptions', 0);

// FIXME: Joomla 4: missing multilanguage support
// Get the language of the target menu item when site is multilingual
if (Multilanguage::isEnabled()) {
$menu = $this->application->getMenu();
$newItem = $menu ? $menu->getItem((int) $params->get('aliasoptions')) : null;

// Use language code if not set to ALL
if ($newItem && $newItem->language && $newItem->language !== '*') {
$link .= '&lang=' . $newItem->language;
}
}
break;

case 'component':
default:
$application = $this->application;
$router = $application::getRouter();
$link = 'index.php?Itemid=' . $menuItem->id;

// FIXME: Joomla 4: do we need anything else?
if (version_compare(JVERSION, 4, '<') && $router->getMode() !== JROUTER_MODE_SEF) {
$link .= '&Itemid=' . $menuItem->id;
} else {
$link = 'index.php?Itemid=' . $menuItem->id;

if (isset($menuItem->query['format']) && $application->get('sef_suffix')) {
$link .= '&format=' . $menuItem->query['format'];
}
if (isset($menuItem->query['format']) && $this->application->get('sef_suffix')) {
$link .= '&format=' . $menuItem->query['format'];
}

break;
Expand Down Expand Up @@ -631,8 +632,8 @@ protected function createMenuItem($data, $menuItem = null)
}
if (!$link) {
$url = false;
} elseif (strcasecmp(substr($link, 0, 4), 'http') && strpos($link, 'index.php?') !== false) {
$url = Route::_($link, false, $menuItem->getParams()->get('secure'));
} elseif ((strpos($link, 'index.php?') !== false) && strcasecmp(substr($link, 0, 4), 'http')) {
$url = Route::_($link, false, $params->get('secure'));
} else {
$url = Route::_($link, false);
}
Expand Down
24 changes: 14 additions & 10 deletions src/platforms/joomla/classes/Gantry/Framework/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function __construct($container)

/** @var CMSApplication $application */
$application = Factory::getApplication();
$document = $application->getDocument();
$input = $application->input;

$this->tmpl = $input->getCmd('tmpl', '');
Expand All @@ -94,15 +93,20 @@ public function __construct($container)
$this->sitename = $application->get('sitename');
$this->theme = $templateParams->template;
$this->baseUrl = Uri::base(true);
$this->title = $document->title;
$this->description = $document->description;

// Document has lower case language code, which causes issues with some JS scripts (Snipcart). Use tag instead.
$code = explode('-', $document->getLanguage(), 2);
$language = array_shift($code);
$country = strtoupper(array_shift($code));
$this->language = $language . ($country ? '-' . $country : '');
$this->direction = $document->direction;

// Document doesn't exist in error page if modern routing is being used.
$document = isset($container['platform']->document) ? $container['platform']->document : $application->getDocument();
if ($document) {
$this->title = $document->title;
$this->description = $document->description;

// Document has lower case language code, which causes issues with some JS scripts (Snipcart). Use tag instead.
$code = explode('-', $document->getLanguage(), 2);
$language = array_shift($code);
$country = strtoupper(array_shift($code));
$this->language = $language . ($country ? '-' . $country : '');
$this->direction = $document->direction;
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/platforms/joomla/classes/Gantry/Framework/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Platform extends BasePlatform
public $module_wrapper;
/** @var string */
public $component_wrapper;
/** @var HtmlDocument|null */
public $document;

/** @var string */
protected $name = 'joomla';
Expand Down
6 changes: 6 additions & 0 deletions src/platforms/joomla/classes/Gantry/Joomla/Object/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ public function limit($limit = null)
*/
public function order($by, $direction = 1, $alias = 'a')
{
if ($direction === 'RANDOM') {
$this->query->order('RAND()');

return $this;
}

if (is_numeric($direction)) {
$direction = $direction > 0 ? 'ASC' : 'DESC';
} else {
Expand Down
5 changes: 5 additions & 0 deletions themes/base/joomla/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Gantry\Framework\Platform;
use Gantry\Framework\Theme;
use Joomla\CMS\Factory;

Expand All @@ -21,6 +22,10 @@
}
$gantry = include $className;

/** @var Platform $joomla */
$joomla = $gantry['platform'];
$joomla->document = $this;

/** @var Theme $theme */
$theme = $gantry['theme'];

Expand Down
5 changes: 5 additions & 0 deletions themes/base/joomla/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Gantry\Framework\Platform;
use Gantry\Framework\Theme;
use Joomla\CMS\Factory;

Expand All @@ -21,6 +22,10 @@
}
$gantry = include $className;

/** @var Platform $joomla */
$joomla = $gantry['platform'];
$joomla->document = $this;

/** @var Theme $theme */
$theme = $gantry['theme'];
$app = Factory::getApplication();
Expand Down
5 changes: 5 additions & 0 deletions themes/base/joomla/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Gantry\Framework\Platform;
use Gantry\Framework\Theme;

// Bootstrap Gantry framework or fail gracefully (inside included file).
Expand All @@ -20,6 +21,10 @@
}
$gantry = include $className;

/** @var Platform $joomla */
$joomla = $gantry['platform'];
$joomla->document = $this;

/** @var Theme $theme */
$theme = $gantry['theme'];

Expand Down
5 changes: 5 additions & 0 deletions themes/base/joomla/offline.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Gantry\Framework\Platform;
use Gantry\Framework\Theme;

// Bootstrap Gantry framework or fail gracefully (inside included file).
Expand All @@ -20,6 +21,10 @@
}
$gantry = include $className;

/** @var Platform $joomla */
$joomla = $gantry['platform'];
$joomla->document = $this;

/** @var Theme $theme */
$theme = $gantry['theme'];

Expand Down
5 changes: 5 additions & 0 deletions themes/helium/joomla/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Gantry\Framework\Platform;
use Gantry\Framework\Theme;
use Joomla\CMS\Factory;

Expand All @@ -21,6 +22,10 @@
}
$gantry = include $className;

/** @var Platform $joomla */
$joomla = $gantry['platform'];
$joomla->document = $this;

/** @var Theme $theme */
$theme = $gantry['theme'];

Expand Down
5 changes: 5 additions & 0 deletions themes/helium/joomla/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

defined('_JEXEC') or die;

use Gantry\Framework\Platform;
use Gantry\Framework\Theme;
use Joomla\CMS\Factory;

Expand All @@ -21,6 +22,10 @@
}
$gantry = include $className;

/** @var Platform $joomla */
$joomla = $gantry['platform'];
$joomla->document = $this;

/** @var Theme $theme */
$theme = $gantry['theme'];
$app = Factory::getApplication();
Expand Down

0 comments on commit 16f5b44

Please sign in to comment.