Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Redo the com_templates #32896

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
224f765
One view to rule them all
dgrammatiko Jul 29, 2021
414789f
cs
dgrammatiko Jul 29, 2021
1ff4b0a
alpha sort
dgrammatiko Mar 28, 2021
c159cc0
meh
dgrammatiko Mar 28, 2021
415fb8f
oops
dgrammatiko Mar 28, 2021
1ed2a88
Add install template logic
dgrammatiko Mar 28, 2021
7c761d2
remove the extra link
dgrammatiko Mar 28, 2021
baaa48c
comments
dgrammatiko Mar 28, 2021
4d7a420
CS
dgrammatiko Mar 28, 2021
9c85899
wow
dgrammatiko Mar 28, 2021
7c0d794
Update administrator/components/com_templates/tmpl/styles/default.php
dgrammatiko Mar 31, 2021
ad44fd2
Update administrator/components/com_templates/tmpl/styles/default.php
dgrammatiko Mar 31, 2021
77db502
Update administrator/components/com_templates/tmpl/styles/default.php
dgrammatiko Mar 31, 2021
5844981
Update administrator/components/com_templates/tmpl/styles/default.php
dgrammatiko Mar 31, 2021
de389fe
Update administrator/components/com_templates/tmpl/styles/default.php
dgrammatiko Mar 31, 2021
0575528
Update administrator/components/com_templates/tmpl/styles/default.php
dgrammatiko Mar 31, 2021
fb54cf0
Update QuickIconHelper.php
brianteeman Apr 1, 2021
6424ffe
preview per style
dgrammatiko Mar 31, 2021
054dbee
layouts
dgrammatiko Mar 31, 2021
f96a563
more
dgrammatiko Mar 31, 2021
06a4e97
more
dgrammatiko Apr 1, 2021
4c2827c
more
dgrammatiko Apr 1, 2021
e4f608f
more
dgrammatiko Aug 27, 2021
71bd46d
oops
dgrammatiko Apr 2, 2021
4fb68f3
CS
dgrammatiko Apr 2, 2021
ebf8b49
CS
dgrammatiko Apr 2, 2021
7706369
Wire some actions
dgrammatiko Apr 2, 2021
84bde4a
use the existing code (no ajax)
dgrammatiko Jul 29, 2021
0f194a5
more links
dgrammatiko Apr 3, 2021
d3ab3ab
x
dgrammatiko Apr 7, 2021
cfc6b78
x
dgrammatiko Apr 8, 2021
4fc8079
fixes
dgrammatiko Apr 20, 2021
a3c8567
Fix the thumbnails, save inheritable, parent in the db manifest data
dgrammatiko May 6, 2021
055d7f0
overrides creator init
dgrammatiko Sep 4, 2021
63400c8
update
dgrammatiko Jul 29, 2021
cb40a8e
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
d3e36c5
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
dd05ad1
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
1fe07f2
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
f972a3a
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
de5e65b
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
1b818e2
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
967121d
Update administrator/components/com_templates/src/Controller/Template…
dgrammatiko Aug 20, 2021
0ec1b3c
tb
dgrammatiko Aug 21, 2021
f493e7b
zzz
dgrammatiko Aug 27, 2021
34e9e58
Overrides creator as a custom element
dgrammatiko Sep 4, 2021
501bcf5
CS
dgrammatiko Sep 4, 2021
748b462
JS CS
dgrammatiko Sep 4, 2021
a525cfb
Strings clean up
dgrammatiko Sep 4, 2021
68e7c21
Info modal + overrides fixes
dgrammatiko Sep 4, 2021
87f7d64
JS CS
dgrammatiko Sep 4, 2021
06be3d9
- code cleanup
dgrammatiko Sep 5, 2021
96f3b86
- Fixes
dgrammatiko Sep 5, 2021
723eb5e
JS CS
dgrammatiko Sep 5, 2021
5553d25
Some clean up
dgrammatiko Sep 6, 2021
9b90085
More intuitive template name/action
dgrammatiko Sep 6, 2021
effdc84
JS Cleanup
dgrammatiko Sep 6, 2021
bb20f5f
Meh, do not disable ESLint when we can fix the CS
dgrammatiko Sep 6, 2021
b190981
c
dgrammatiko Sep 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions administrator/components/com_menus/presets/alternate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -463,18 +463,11 @@
type="component"
element="com_templates"
link="index.php?option=com_templates">
<menuitem
title="MOD_MENU_COM_TEMPLATES_SUBMENU_STYLES"
type="component"
element="com_templates"
link="index.php?option=com_templates&amp;view=styles&amp;client_id=0"
/>

<menuitem
title="MOD_MENU_COM_TEMPLATES_SUBMENU_TEMPLATES"
type="component"
element="com_templates"
link="index.php?option=com_templates&amp;view=templates"
link="index.php?option=com_templates&amp;view=templates&amp;client_id=0"
/>

<menuitem
Expand Down
19 changes: 3 additions & 16 deletions administrator/components/com_menus/presets/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -219,34 +219,21 @@
icon="paint-brush"
permission="core.manage;com_templates"
>
<menuitem
title="MOD_MENU_TEMPLATE_SITE_TEMPLATES"
type="component"
element="com_templates"
link="index.php?option=com_templates&amp;view=templates&amp;client_id=0"
/>

<menuitem
title="MOD_MENU_TEMPLATE_SITE_STYLES"
title="MOD_MENU_TEMPLATES_SITE"
type="component"
element="com_templates"
link="index.php?option=com_templates&amp;view=styles&amp;client_id=0"
link="index.php?option=com_templates&amp;view=templates&amp;client_id=0"
/>

<menuitem
title="MOD_MENU_TEMPLATE_ADMIN_TEMPLATES"
title="MOD_MENU_TEMPLATES_ADMIN"
type="component"
element="com_templates"
link="index.php?option=com_templates&amp;view=templates&amp;client_id=1"
/>

<menuitem
title="MOD_MENU_TEMPLATE_ADMIN_STYLES"
type="component"
element="com_templates"
link="index.php?option=com_templates&amp;view=styles&amp;client_id=1"
/>

<menuitem
title="MOD_MENU_CONFIGURATION_MAILS"
type="component"
Expand Down
104 changes: 104 additions & 0 deletions administrator/components/com_templates/layouts/card-footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

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

extract($displayData);
?>
<div class="card-footer">
<h3>Styles:</h3>
<?php foreach ($item->styles as $style) : ?>
<div class="list-group d-flex">
<div class="d-flex justify-content-between">
<a href="<?php echo Route::_('index.php?option=com_templates&task=style.edit&id=' . (int) $style->id); ?>" class="btn btn-link">
<?php echo $style->title; ?>
</a>

<div>
<?php if ($style->home == '0') : ?>
<button class="js-action-exec btn btn-link" type="button" data-task="templates.setDefault" data-item="<?php echo (int) $style->id; ?>">
<span class="icon-star me-2" aria-hidden="true"></span>
<span class="visually-hidden"><?php echo Text::_('COM_TEMPLATES_STYLE_IS_DEFAULT'); ?></span>
</button>
<?php elseif ($style->home == '1'):?>
<strong class="text-success btn btn-transparent">
<span class="icon-star icon-md me-2" aria-hidden="true"></span>
<span class="visually-hidden"><?php echo Text::_('COM_TEMPLATES_STYLE_IS_DEFAULT'); ?></span>
</strong>
<?php elseif ($canChange):?>
<a href="<?php echo Route::_('index.php?option=com_templates&task=templates.unsetDefault&cid[]=' . $style->id . '&' . Session::getFormToken() . '=1'); ?>" class="btn btn-link">
<?php echo Text::sprintf('COM_TEMPLATES_GRID_UNSET_LANGUAGE', $style->language_title); ?>
</a>
<?php else : ?>
<span class="btn btn-transparent">
<?php echo Text::sprintf('COM_TEMPLATES_STYLES_PAGES_ALL_LANGUAGE', $this->escape($style->language_title)); ?>
</span>
<?php endif; ?>
<?php if (((int) $style->home !== 0 && (int) $style->home !== 1) && $style->image):?>
<small class="ms-2">
<?php echo HTMLHelper::_('image', 'mod_languages/' . $style->image . '.gif', $style->language_title, array('title' => Text::sprintf('COM_TEMPLATES_STYLES_PAGES_ALL_LANGUAGE', $style->language_title)), true); ?>
</small>
<?php elseif ((int) $style->assigned > 0) : // $style->assigned > 0?>
<small class="ms-2">
<span class="icon-check-circle" aria-hidden="true"></span>
<span class="visually-hidden"><?php echo Text::sprintf('COM_TEMPLATES_STYLES_PAGES_SELECTED', $style->assigned); ?></span>
</small>
<?php endif; ?>

<?php if ($clientId === 0) : // Preview ?>
<a href="<?php echo Route::_( Uri::root() . 'index.php?tp=1&templateStyle=' . (int) $style->id); ?>" target="_blank" class="btn btn-link">
<span class="visually-hidden"><?php echo Text::_('COM_TEMPLATES_PREVIEW'); ?></span>
</a>
<?php endif; ?>
<?php if($canCreate || $canDelete) : ?>
<div class="dropdown d-inline-block">
<button class="btn btn-link dropdown-toggle" type="button" id="dropdown-<?php echo $style->title; ?>" data-bs-toggle="dropdown" aria-expanded="false">
<?php echo Text::_('JTOOLBAR_CHANGE_STATUS'); ?>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdown-<?php echo $style->title; ?>">
<li>
<a href="<?php echo Route::_('index.php?option=com_templates&task=style.edit&id=' . (int) $style->id . '&' . Session::getFormToken() . '=1'); ?>" class="btn btn-link">
<span class="icon-pencil" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_STYLE_EDIT'); ?></span>
</a>
</li>
<?php if($canCreate) : ?>
<li>

<button class="js-action-exec-new btn btn-link"
type="button"
data-task="<?php echo (int) $style->inheritable === 1 && $style->parent === '' ? 'templates.createChild' : 'templates.duplicate' ?>"
data-item="<?php echo (int) $style->id; ?>">
<span class="icon-copy" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_STYLE_DUPLICATE'); ?></span>
</button>
</li>
<?php endif; ?>
<?php if($canDelete) : ?>
<li>
<button class="js-action-exec btn btn-link" type="button" data-task="templates.delete" data-item="<?php echo (int) $style->id; ?>">
<span class="icon-trash" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_STYLE_DELETE'); ?></span>
</button>
</li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
123 changes: 123 additions & 0 deletions administrator/components/com_templates/layouts/card-header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

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

extract($displayData);
?>

<div class="card-header d-flex flex-row align-items-center">
<div class="card-title flex-grow-1 align-self-center">
<div class="dropdown d-inline-block">
<button class="btn btn-link dropdown-toggle" type="button" id="template-info-<?php echo (int) $item->extensionId; ?>" data-bs-toggle="dropdown" aria-expanded="false">
<?php echo ucfirst($this->escape($item->templateName)); ?>
</button>
<ul class="dropdown-menu" aria-labelledby="template-info-<?php echo (int) $item->extensionId; ?>">
<li class="list-group-item">
<span class="text-muted"><?php echo Text::_('COM_TEMPLATES_CREATED'); ?>: </span> <?php echo $this->escape($item->creationDate); ?>
</li>

<?php if ($author = $item->author) : ?>
<li class="list-group-item">
<span class="text-muted"><?php echo Text::_('COM_TEMPLATES_AUTHOR'); ?>: </span><?php echo $this->escape($author); ?>
</li>
<?php endif; ?>

<?php if ($email = $item->authorEmail) : ?>
<li class="list-group-item">
<span class="text-muted"><?php echo Text::_('COM_TEMPLATES_AUTHOR_EMAIL'); ?>: </span>
<a href="mailto: <?php echo $this->escape($email); ?>">
<?php echo $this->escape($email); ?>
</a>
</li>
<?php endif; ?>

<?php if ($description = (string) $item->description) : ?>
<li class="list-group-item">
<button class="js-action-exec-modal btn btn-link p-0" type="button" data-info-task="templates.getDescription" data-name="<?php echo $this->escape($item->templateName); ?>" data-id="<?php echo $this->escape($item->extensionId); ?>" data-client="<?php echo (int) $item->client; ?>" data-token="<?php echo Session::getFormToken(); ?>">
<span class="icon-info" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_INFO'); ?></span>
</button>
</li>
<?php endif; ?>

<?php if ($email = $item->authorUrl) : ?>
<li class="list-group-item">
<span class="text-muted"><?php echo Text::_('COM_TEMPLATES_AUTHOR_EMAIL'); ?>: </span> <?php echo $this->escape($email); ?>
</li>
<?php endif; ?>
</ul>
</div>

<?php if ($version = $item->version) : ?>
<small class="template-version small text-muted ms-1">v<?php echo $this->escape($version); ?></small>
<?php endif; ?>
</div>

<div class="card-header-right">
<?php if (!(bool) $item->inheritable || $item->parent !== '') : ?>
<small class="small text-muted ms-2"><?php echo Text::_('COM_TEMPLATES_LEGACY'); ?></small>
<?php endif; ?>

<?php if ($canCreate || $canDelete) : ?>
<div class="dropdown d-inline-block">
<button class="btn btn-link dropdown-toggle" type="button" id="template-actions-<?php echo (int) $item->extensionId; ?>" data-bs-toggle="dropdown" aria-expanded="false">
<span class="icon-cog" aria-hidden="true"></span>
<span class="visually-hidden"><?php echo Text::_('COM_TEMPLATES_EDIT'); ?></span>
</button>
<ul class="dropdown-menu" aria-labelledby="template-actions-<?php echo (int) $item->extensionId; ?>">
<li>
<a href="<?php echo Route::_('index.php?option=com_templates&view=template&id=' . (int) $item->extensionId . '&' . Session::getFormToken() . '=1'); ?>" class="btn btn-link">
<span class="icon-pencil" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATE_EDIT_FILES'); ?></span>
</a>
</li>
<?php if ($canCreate) : ?>
<li>
<button class="js-action-exec-modal btn btn-link" type="button" data-create-new="true" data-task="templates.forkTemplate" data-item="<?php echo (int) $item->extensionId; ?>" data-client="<?php echo (int) $item->client; ?>" data-token="<?php echo Session::getFormToken(); ?>">
<span class="icon-copy" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_FORK'); ?></span>
</button>
</li>
<?php endif; ?>
<?php if ($canCreate) : ?>
<li>
<button class="js-action-exec-modal btn btn-link" type="button" data-override="true" data-item="<?php echo (int) $item->extensionId; ?>" data-client="<?php echo (int) $item->client; ?>" data-token="<?php echo Session::getFormToken(); ?>">
<span class="icon-copy" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_NEW_OVERRIDE'); ?></span>
</button>
</li>
<?php endif; ?>
<?php if ($canDelete) : ?>
<li>
<button class="js-action-exec-uninstall btn btn-link" type="button" data-task="templates.uninstallTemplate" data-item="<?php echo (int) $item->extensionId; ?>" data-client="<?php echo (int) $item->client; ?>" data-name="<?php echo $this->escape($item->templateName); ?>">
<span class="icon-trash" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_DISABLE'); ?></span>
</button>
</li>
<?php endif; ?>
<?php if ($canDelete) : ?>
<li>
<button class="js-action-exec-uninstall btn btn-link" type="button" data-task="templates.uninstallTemplate" data-item="<?php echo (int) $item->extensionId; ?>" data-client="<?php echo (int) $item->client; ?>" data-name="<?php echo $this->escape($item->templateName); ?>">
<span class="icon-trash" aria-hidden="true"></span>
<span class="ms-1"><?php echo Text::_('COM_TEMPLATES_UNINSTALL'); ?></span>
</button>
</li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
</div>
</div>
44 changes: 44 additions & 0 deletions administrator/components/com_templates/layouts/card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_templates
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Layout\LayoutHelper;

extract($displayData);

$options = [
'clientId' => $clientId,
'canChange' => $canChange,
'canDelete' => $canDelete,
'canEdit' => $canEdit,
'canCreate' => $canCreate,
'item' => $item,
'i' => $i
];
?>
<div class="template-style card text-dark bg-light">
<?php
/**
* @see: administrator/components/com_templates/layouts/card-header.php
*/
echo LayoutHelper::render('card-header', $options);
?>
<div class="card-media">
<div class="template-thumbnail">
<img src="<?php echo str_replace('thumbnail', 'preview', $item->thumbnail); ?>?v=<?php echo $item->version; ?>" width="600" height="400" alt="<?php echo $item->templateName; ?>" style="max-width:100%">
</div>
</div>
<?php
/**
* @see: administrator/components/com_templates/layouts/card-footer.php
*/
echo LayoutHelper::render('card-footer', $options);
?>
</div>
Loading