Skip to content
Closed
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ protected function addToolbar()
// Add a copy template button
elseif ($this->type === 'home')
{
ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
$templatesPath = ((int) $this->template->client_id === 1 ? JPATH_ADMINISTRATOR : JPATH_SITE) . '/templates/';
$templateDetails = $templatesPath . $this->template->name . '/templateDetails.xml';
$templateXML = simplexml_load_file($templateDetails);
if ((string) $templateXML->namespace === '' || $templateXML->namespace === null) {
ToolbarHelper::modal('copyModal', 'icon-copy', 'COM_TEMPLATES_BUTTON_COPY_TEMPLATE');
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion libraries/namespacemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public function create()
$extensions = array_merge(
$this->getNamespaces('component'),
$this->getNamespaces('module'),
$this->getNamespaces('template'),
$this->getNamespaces('plugin'),
$this->getNamespaces('library')
);
Expand Down Expand Up @@ -139,7 +140,7 @@ protected function writeNamespaceFile($elements)
*/
private function getNamespaces(string $type): array
{
if (!in_array($type, ['component', 'module', 'plugin', 'library'], true))
if (!in_array($type, ['component', 'module', 'plugin', 'template', 'library'], true))
{
return [];
}
Expand All @@ -153,6 +154,10 @@ private function getNamespaces(string $type): array
{
$directories = [JPATH_SITE . '/modules', JPATH_ADMINISTRATOR . '/modules'];
}
elseif ($type === 'template')
{
$directories = [JPATH_SITE . '/templates', JPATH_ADMINISTRATOR . '/templates'];
}
elseif ($type === 'plugin')
{
$directories = Folder::folders(JPATH_PLUGINS, '.', false, true);
Expand All @@ -173,6 +178,7 @@ private function getNamespaces(string $type): array

// Strip the com_ from the extension name for components
$name = str_replace('com_', '', $extension, $count);
$name = $type === 'template' ? 'templateDetails' : $name;
$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.
Expand Down