Skip to content

Commit

Permalink
Support the new scheme in override editor
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed May 24, 2017
1 parent 2827868 commit b9b0e6d
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions administrator/components/com_templates/Model/Template.php
Expand Up @@ -575,30 +575,38 @@ public function getOverridesList()

foreach ($components as $component)
{
if (file_exists($componentPath . '/' . $component . '/views/'))
{
$viewPath = \JPath::clean($componentPath . '/' . $component . '/views/');
}
elseif (file_exists($componentPath . '/' . $component . '/view/'))
{
$viewPath = \JPath::clean($componentPath . '/' . $component . '/view/');
}
else
// Collect the folders with views
$folders = \JFolder::folders($componentPath . '/' . $component, '^view[s]?$', false, true);
$folders = array_merge($folders, \JFolder::folders($componentPath . '/' . $component, '^tmpl?$', false, true));

if (!$folders)
{
$viewPath = '';
continue;
}

if ($viewPath)
foreach ($folders as $folder)
{
$views = \JFolder::folders($viewPath);
// The subfolders are views
$views = \JFolder::folders($folder);

foreach ($views as $view)
{
// Only show the view has layout inside it
if (file_exists($viewPath . $view . '/tmpl'))
// The old scheme, if a view has a tmpl folder
$path = $folder . '/' . $view . '/tmpl';

// The new scheme, the views are directly in the component/tmpl folder
if (!is_dir($path) && substr($folder, -4) == 'tmpl')
{
$path = $folder . '/' . $view;
}

// Check if the folder exists
if (!is_dir($path))
{
$result['components'][$component][] = $this->getOverridesFolder($view, $viewPath);
continue;
}

$result['components'][$component][] = $this->getOverridesFolder($view, $folder . '/');
}
}
}
Expand Down Expand Up @@ -711,7 +719,15 @@ public function createOverride($override)
}
elseif (stristr($override, 'com_') != false && stristr($override, 'layouts') == false)
{
$return = $this->createTemplateOverride(\JPath::clean($override . '/tmpl'), $htmlPath);
$path = $override . '/tmpl';

// View can also be in the top level folder
if (!is_dir($path))
{
$path = $override;
}

$return = $this->createTemplateOverride(\JPath::clean($path), $htmlPath);
}
else
{
Expand Down

0 comments on commit b9b0e6d

Please sign in to comment.