Skip to content

Commit

Permalink
Merge branch '4.0-dev' into 4.0_sticky-header
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Jan 21, 2020
2 parents f5c1f72 + 03b81dc commit 9b669f6
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 98 deletions.
29 changes: 16 additions & 13 deletions administrator/components/com_menus/tmpl/item/edit_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,25 @@

echo LayoutHelper::render('joomla.menu.edit_modules', $this); ?>

<table class="table">
<table class="table" id="modules_assigned">
<caption id="captionTable" class="sr-only">
<?php echo Text::_('COM_MENUS_MODULES_TABLE_CAPTION'); ?>
</caption>
<thead>
<tr>
<th>
<th scope="col" style="width:40%">
<?php echo Text::_('COM_MENUS_HEADING_ASSIGN_MODULE'); ?>
</th>
<th class="text-center">
<th scope="col" style="width:15%">
<?php echo Text::_('COM_MENUS_HEADING_LEVELS'); ?>
</th>
<th class="text-center">
<th scope="col" style="width:15%">
<?php echo Text::_('COM_MENUS_HEADING_POSITION'); ?>
</th>
<th class="text-center">
<th scope="col">
<?php echo Text::_('COM_MENUS_HEADING_DISPLAY'); ?>
</th>
<th class="text-center">
<th scope="col">
<?php echo Text::_('COM_MENUS_HEADING_PUBLISHED_ITEMS'); ?>
</th>
</tr>
Expand All @@ -87,23 +90,23 @@
<?php else : ?>
<?php $status = 'unpublished '; ?>
<?php endif; ?>
<tr class="<?php echo $no; ?><?php echo $status; ?>row<?php echo $i % 2; ?>" id="tr-<?php echo $module->id; ?>">
<td id="<?php echo $module->id; ?>" style="width:40%">
<tr class="<?php echo $no; ?><?php echo $status; ?>row<?php echo $i % 2; ?>">
<th scope="row">
<button type="button"
data-target="#moduleEditModal"
class="btn btn-link module-edit-link"
title="<?php echo Text::_('COM_MENUS_EDIT_MODULE_SETTINGS'); ?>"
id="title-<?php echo $module->id; ?>"
data-module-id="<?php echo $module->id; ?>">
<?php echo $this->escape($module->title); ?></button>
</td>
<td id="access-<?php echo $module->id; ?>" style="width:15%" class="text-center">
</th>
<td>
<?php echo $this->escape($module->access_title); ?>
</td>
<td id="position-<?php echo $module->id; ?>" style="width:15%" class="text-center">
<td>
<?php echo $this->escape($module->position); ?>
</td>
<td id="menus-<?php echo $module->id; ?>" style="width:15%" class="text-center">
<td>
<?php if (is_null($module->menuid)) : ?>
<?php if ($module->except) : ?>
<span class="badge badge-success">
Expand All @@ -128,7 +131,7 @@ class="btn btn-link module-edit-link"
</span>
<?php endif; ?>
</td>
<td id="status-<?php echo $module->id; ?>" class="text-center">
<td>
<?php if ($module->published) : ?>
<span class="badge badge-success">
<?php echo Text::_('JYES'); ?>
Expand Down
2 changes: 1 addition & 1 deletion administrator/language/en-GB/com_banners.ini
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ COM_BANNERS_FIELD_NAME_LABEL="Name"
COM_BANNERS_FIELD_PUBLISH_DOWN_LABEL="Finish Publishing"
COM_BANNERS_FIELD_PUBLISH_UP_LABEL="Start Publishing"
COM_BANNERS_FIELD_PURCHASETYPE_LABEL="Purchase Type"
COM_BANNERS_FIELD_STICKY_DESC="Whether or not the Banner is 'pinned'. If one or more Banners in a Category are pinned, they will take priority over Banners that are not pinned. For example, if two Banners in a Category are pinned and a third Banner is not pinned, the third Banner will not display if the module setting is 'Pinned, Randomise'. Only the two pinned Banners will display."
COM_BANNERS_FIELD_STICKY_DESC="If one or more Banners in a Category are pinned, they will take priority over Banners that are not pinned. For example, if two Banners in a Category are pinned and a third Banner is not pinned, the third Banner will not display if the module setting is 'Pinned, Randomise'. Only the two pinned Banners will display."
COM_BANNERS_FIELD_STICKY_LABEL="Pinned"
COM_BANNERS_FIELD_TRACKCLICK_LABEL="Track Clicks"
COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL="Track Impressions"
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_menus.ini
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ COM_MENUS_MENUS_TABLE_CAPTION="Table of Menus"
; %1$s is for module title, %2$s is for access-title, %3$s is for position
COM_MENUS_MODULE_ACCESS_POSITION="%1$s <small>(%2$s in %3$s)</small>"
COM_MENUS_MODULES="Modules"
COM_MENUS_MODULES_TABLE_CAPTION="Table of Module Assignments"
COM_MENUS_N_ITEMS_CHECKED_IN_1="Menu item checked in."
COM_MENUS_N_ITEMS_CHECKED_IN_MORE="%d menu items checked in."
COM_MENUS_N_ITEMS_DELETED="%d menu items deleted."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

// Load Bootstrap JS for dropdowns.
HTMLHelper::_('bootstrap.framework');

$hideLinks = $app->input->getBool('hidemainmenu');
?>
<?php if ($app->getIdentity()->authorise('core.manage', 'com_postinstall')) : ?>
Expand Down
5 changes: 4 additions & 1 deletion administrator/modules/mod_user/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@

defined('_JEXEC') or die;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Uri\Uri;

// Load Bootstrap JS for dropdowns.
HTMLHelper::_('bootstrap.framework');

$hideLinks = $app->input->getBool('hidemainmenu');
?>

<div class="header-item-content dropdown header-profile d-flex">
<button class="dropdown-toggle d-flex flex-column align-items-stretch <?php echo ($hideLinks ? 'disabled' : ''); ?>" data-toggle="dropdown" type="button" <?php echo ($hideLinks ? 'disabled' : ''); ?>
title="<?php echo Text::_('MOD_USER_MENU'); ?>">
Expand Down
170 changes: 92 additions & 78 deletions libraries/namespacemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,12 @@ public function ensureMapFileExists()
*/
public function create()
{
$extensions = $this->getNamespaces('administrator/components');
$extensions = array_merge($extensions, $this->getNamespaces('api/components'));
$extensions = array_merge($extensions, $this->getNamespaces('modules'));
$extensions = array_merge($extensions, $this->getNamespaces('administrator/modules'));

foreach (Folder::folders(JPATH_ROOT . '/plugins') as $pluginGroup)
{
$extensions = array_merge($extensions, $this->getNamespaces('/plugins/' . $pluginGroup));
}
$extensions = array_merge(
$this->getNamespaces('component'),
$this->getNamespaces('module'),
$this->getNamespaces('plugin'),
$this->getNamespaces('library')
);

$this->writeNamespaceFile($extensions);

Expand Down Expand Up @@ -130,112 +127,129 @@ protected function writeNamespaceFile($elements)
}

/**
* Get an array of namespaces with their respective path for the given extension directory.
* Get an array of namespaces with their respective path for the given extension type.
*
* @param string $dir The directory
* @param string $type The extension type
*
* @return array
*
* @since 4.0.0
*/
private function getNamespaces(string $dir): array
private function getNamespaces(string $type): array
{
// If it is not a dir return
if (!is_dir(JPATH_ROOT . '/' . $dir))
if (!in_array($type, ['component', 'module', 'plugin', 'library'], true))
{
return [];
}

// The extensions
// Select directories containing extension manifest files.
if ($type === 'component')
{
$directories = [JPATH_ADMINISTRATOR . '/components'];
}
elseif ($type === 'module')
{
$directories = [JPATH_SITE . '/modules', JPATH_ADMINISTRATOR . '/modules'];
}
elseif ($type === 'plugin')
{
$directories = Folder::folders(JPATH_PLUGINS, '.', false, true);
}
else
{
$directories = [JPATH_LIBRARIES];
}

$extensions = [];

// Loop over the extension type directory
foreach (Folder::folders(JPATH_ROOT . '/' . $dir) as $extension)
foreach ($directories as $directory)
{
// If it is a file we can't handle, ignore it
if (strpos($extension, 'mod_') !== 0 && strpos($extension, 'com_') !== 0 && strpos($dir, '/plugins/') !== 0)
foreach (Folder::folders($directory) as $extension)
{
continue;
}
// Compile the extension path
$extensionPath = $directory . '/' . $extension . '/';

// Compile the extension path
$extensionPath = JPATH_ROOT . '/' . $dir . '/' . $extension . '/';
// Strip the com_ from the extension name for components
$name = str_replace('com_', '', $extension, $count);
$file = $extensionPath . $name . '.xml';

// Strip the com_ from the extension name for components
$name = str_replace('com_', '', $extension, $count);
$file = $extensionPath . $name . '.xml';

// If there is no manifest file, ignore. If it was a component check if the xml was named with the com_
// prefix.
if (!file_exists($file))
{
if (!$count)
// If there is no manifest file, ignore. If it was a component check if the xml was named with the com_ prefix.
if (!file_exists($file))
{
continue;
if (!$count)
{
continue;
}

$file = $extensionPath . $extension . '.xml';

if (!file_exists($file))
{
continue;
}
}

$file = $extensionPath . $extension . '.xml';
// Load the manifest file
$xml = simplexml_load_file($file);

if (!file_exists($file))
// When invalid, ignore
if (!$xml)
{
continue;
}
}

// Load the manifest file
$xml = simplexml_load_file($file);
// The namespace node
$namespaceNode = $xml->namespace;

// When invalid, ignore
if (!$xml)
{
continue;
}
// The namespace string
$namespace = (string) $namespaceNode;

// The namespace node
$namespaceNode = $xml->namespace;
// Ignore when the string is empty
if (!$namespace)
{
continue;
}

// The namespace string
$namespace = (string) $namespaceNode;
// Normalize the namespace string
$namespace = str_replace('\\', '\\\\', $namespace) . '\\\\';
$namespacePath = rtrim($extensionPath . $namespaceNode->attributes()->path, '/');

// Ignore when the string is empty
if (!$namespace)
{
continue;
}
if ($type === 'plugin' || $type === 'library')
{
$baseDir = $type === 'plugin' ? 'JPATH_PLUGINS . \'' : 'JPATH_LIBRARIES . \'';
$path = str_replace($type === 'plugin' ? JPATH_PLUGINS : JPATH_LIBRARIES, '', $namespacePath);

// The namespace path
$namespacePath = '/' . $dir . '/' . $extension . '/';
// Set the namespace
$extensions[$namespace] = $baseDir . $path . '\'';

// Normalize the namespace string
$namespace = str_replace('\\', '\\\\', $namespace) . '\\\\';
$path = str_replace('administrator/', '', $namespacePath);
continue;
}

// Add the site path when a component
if (strpos($extension, 'com_') === 0)
{
$extensions[$namespace . 'Site\\\\'] = 'JPATH_SITE . \'' . $path . $namespaceNode->attributes()->path . '\'';
// Check if we need to use administrator path
$isAdministrator = strpos($namespacePath, JPATH_ADMINISTRATOR) === 0;
$path = str_replace($isAdministrator ? JPATH_ADMINISTRATOR : JPATH_SITE, '', $namespacePath);

if (is_dir(JPATH_API . $path))
// Add the site path when a component
if ($type === 'component')
{
$extensions[$namespace . 'Api\\\\'] = 'JPATH_API . \'' . $path . $namespaceNode->attributes()->path . '\'';
if (is_dir(JPATH_SITE . $path))
{
$extensions[$namespace . 'Site\\\\'] = 'JPATH_SITE . \'' . $path . '\'';
}

if (is_dir(JPATH_API . $path))
{
$extensions[$namespace . 'Api\\\\'] = 'JPATH_API . \'' . $path . '\'';
}
}
}

// Add the application specific segment when not a plugin
if (strpos($dir, '/plugins/') !== 0)
{
$baseDir = strpos($namespacePath, 'administrator/') ? 'JPATH_ADMINISTRATOR . \'' : 'JPATH_SITE . \'';
$namespace .= strpos($namespacePath, 'administrator/') ? 'Administrator\\\\' : 'Site\\\\';
}
else
{
// Start in the plugin directory and remove the plugin prefix from the path
$baseDir = 'JPATH_PLUGINS . \'';
$path = substr($path, 9);
}
// Add the application specific segment when a component or module
$baseDir = $isAdministrator ? 'JPATH_ADMINISTRATOR . \'' : 'JPATH_SITE . \'';
$namespace .= $isAdministrator ? 'Administrator\\\\' : 'Site\\\\';

// Set the namespace
$extensions[$namespace] = $baseDir . $path . $namespaceNode->attributes()->path . '\'';
// Set the namespace
$extensions[$namespace] = $baseDir . $path . '\'';
}
}

// Return the namespaces
Expand Down
14 changes: 12 additions & 2 deletions libraries/src/Dispatcher/AbstractModuleDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ public function dispatch()
// Execute the layout without the module context
$loader = static function (array $displayData)
{
extract($displayData);
require ModuleHelper::getLayoutPath($displayData['module']->module, $displayData['params']->get('layout', 'default'));
// If $displayData doesn't exist in extracted data, unset the variable.
if (!\array_key_exists('displayData', $displayData))
{
extract($displayData);
unset($displayData);
}
else
{
extract($displayData);
}

require ModuleHelper::getLayoutPath($module->module, $params->get('layout', 'default'));
};

$loader($displayData);
Expand Down
12 changes: 11 additions & 1 deletion libraries/src/Dispatcher/ModuleDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ public function dispatch()
// Execute the layout without the module context
$loader = static function ($path, array $displayData)
{
extract($displayData);
// If $displayData doesn't exist in extracted data, unset the variable.
if (!\array_key_exists('displayData', $displayData))
{
extract($displayData);
unset($displayData);
}
else
{
extract($displayData);
}

include $path;
};

Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Form/FormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ public function validate($value, $group = null, \Joomla\Registry\Registry $input
{
$subForm = $this->loadSubForm();

if ($this->multiple)
if ($this->multiple && $value)
{
foreach ($value as $key => $val)
{
Expand Down

0 comments on commit 9b669f6

Please sign in to comment.