Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f46784b
Make origin toolbar legacy
asika32764 Nov 13, 2017
820e038
Make origin toolbar legacy
asika32764 Nov 13, 2017
dc8ea25
Merge branch '4.0-dev' into new-toolbar
asika32764 Jan 30, 2018
0d79c82
wip new classes
asika32764 Feb 1, 2018
b016229
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into new-toolbar
asika32764 Feb 10, 2018
44af9fe
Child dropdown and separator
asika32764 Feb 11, 2018
b443df0
popup button
asika32764 Feb 11, 2018
365a1d9
popup fix
asika32764 Feb 11, 2018
842e688
More buttons
asika32764 Feb 11, 2018
e514f70
Complete basic butons usage
asika32764 Feb 11, 2018
0334f86
Replace article buttons
asika32764 Feb 11, 2018
d8adb29
Add customHtml()
asika32764 Feb 11, 2018
2f10bc3
classmap fix
asika32764 Feb 11, 2018
40e9fdd
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into new-toolbar
asika32764 Feb 12, 2018
43fec76
Fix customHtml()
asika32764 Feb 12, 2018
b2635b6
Button group and styles
asika32764 Feb 13, 2018
3ce77f3
group class
asika32764 Feb 13, 2018
0e083b2
Merge branch 'new-toolbar' of github.com:asika32764/joomla-cms into n…
asika32764 Feb 14, 2018
fa74198
Optimize imports
asika32764 Feb 14, 2018
467c969
Fix apply button and code style
asika32764 Feb 14, 2018
5bcbeb6
CS part 1
asika32764 Feb 14, 2018
c469bac
CS part2
asika32764 Feb 14, 2018
8a6a498
Update autoloader
asika32764 Feb 14, 2018
99dfee7
Fix log text
asika32764 Feb 14, 2018
9e3bd1a
Use dropdown instead group
asika32764 Feb 15, 2018
fce77c9
Update article view
asika32764 Feb 15, 2018
b30279e
Fix dropdown in other components
asika32764 Feb 15, 2018
64f6461
CS part 3
asika32764 Feb 15, 2018
046290b
CS part 4
asika32764 Feb 15, 2018
7d4d370
CS part 6
asika32764 Feb 15, 2018
d020933
Merge branch '4.0-dev' of github.com:joomla/joomla-cms into new-toolbar
asika32764 Feb 16, 2018
f6cfa39
Docblock
asika32764 Feb 16, 2018
cb3926b
CS fix
asika32764 Feb 16, 2018
f732fb6
typo
asika32764 Feb 16, 2018
a95ffed
Merge branch '4.0-dev' into new-toolbar
asika32764 Feb 16, 2018
95b7dc2
Sync unique id from #19635
asika32764 Feb 16, 2018
d2494d9
Sync formValidation from #19635
asika32764 Feb 16, 2018
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
90 changes: 48 additions & 42 deletions administrator/components/com_content/View/Article/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Button\LinkButton;
use Joomla\CMS\Toolbar\Button\PopupButton;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;

/**
* View to edit an article.
Expand Down Expand Up @@ -119,72 +123,74 @@ protected function addToolbar()
// Built the actions for new and existing records.
$canDo = $this->canDo;

\JToolbarHelper::title(
$toolbar = Toolbar::getInstance();

ToolbarHelper::title(
\JText::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE'))),
'pencil-2 article-add'
);

$saveGroup = $toolbar->dropdownButton('save-group');

// For new records, check the create permission.
if ($isNew && (count($user->getAuthorisedCategories('com_content', 'core.create')) > 0))
{
\JToolbarHelper::saveGroup(
[
['apply', 'article.apply'],
['save', 'article.save'],
['save2new', 'article.save2new']
],
'btn-success'
);

\JToolbarHelper::cancel('article.cancel');
$saveGroup->configure(
function (Toolbar $childBar)
{
$childBar->apply('article.apply');
$childBar->save('article.save');
$childBar->save2new('article.save2new');
}
);
}
else
{
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
$itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId);

$toolbarButtons = [];

// Can't save the record if it's checked out and editable
if (!$checkedOut && $itemEditable)
{
$toolbarButtons[] = ['apply', 'article.apply'];
$toolbarButtons[] = ['save', 'article.save'];

// We can save this record, but check the create permission to see if we can return to make a new one.
if ($canDo->get('core.create'))
{
$toolbarButtons[] = ['save2new', 'article.save2new'];
}
}

// If checked out, we can still save
if ($canDo->get('core.create'))
{
$toolbarButtons[] = ['save2copy', 'article.save2copy'];
}

\JToolbarHelper::saveGroup(
$toolbarButtons,
'btn-success'
);
$saveGroup->configure(
function (Toolbar $childBar) use ($checkedOut, $itemEditable, $canDo)
{
// Can't save the record if it's checked out and editable
if (!$checkedOut && $itemEditable)
{
$childBar->apply('article.apply');
$childBar->save('article.save');

// We can save this record, but check the create permission to see if we can return to make a new one.
if ($canDo->get('core.create'))
{
$childBar->save2new('article.save2new');
}
}

// If checked out, we can still save
if ($canDo->get('core.create'))
{
$childBar->save2copy('article.save2copy');
}
}
);

if (\JComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $itemEditable)
{
\JToolbarHelper::versions('com_content.article', $this->item->id);
$toolbar->versions('com_content.article', $this->item->id);
}

if (!$isNew)
{
\JLoader::register('ContentHelperPreview', JPATH_ADMINISTRATOR . '/components/com_content/helpers/preview.php');
$url = \ContentHelperPreview::url($this->item);
\JToolbarHelper::preview($url, \JText::_('JGLOBAL_PREVIEW'), 'eye', 80, 90);
$toolbar->preview($url, \JText::_('JGLOBAL_PREVIEW'))
->bodyHeight(80)
->modalWidth(90);
}

\JToolbarHelper::cancel('article.cancel', 'JTOOLBAR_CLOSE');
}

\JToolbarHelper::divider();
\JToolbarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER_EDIT');
$toolbar->cancel('article.cancel', 'JTOOLBAR_CLOSE');

$toolbar->divider();
$toolbar->help('JHELP_CONTENT_ARTICLE_MANAGER_EDIT');
}
}
57 changes: 37 additions & 20 deletions administrator/components/com_content/View/Articles/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
defined('_JEXEC') or die;

use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Button\CustomButton;
use Joomla\CMS\Toolbar\Button\PopupButton;
use Joomla\CMS\Toolbar\Button\SeparatorButton;
use Joomla\CMS\Toolbar\Button\StandardButton;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\Content\Administrator\Helper\ContentHelper;

/**
Expand Down Expand Up @@ -154,54 +160,65 @@ protected function addToolbar()
$user = \JFactory::getUser();

// Get the toolbar object instance
$bar = \JToolbar::getInstance('toolbar');
$toolbar = Toolbar::getInstance('toolbar');

\JToolbarHelper::title(\JText::_('COM_CONTENT_ARTICLES_TITLE'), 'stack article');
ToolbarHelper::title(\JText::_('COM_CONTENT_ARTICLES_TITLE'), 'stack article');

if ($canDo->get('core.create') || count($user->getAuthorisedCategories('com_content', 'core.create')) > 0)
{
\JToolbarHelper::addNew('article.add');
$toolbar->addNew('article.add');
}

if ($canDo->get('core.edit.state'))
{
\JToolbarHelper::publish('articles.publish', 'JTOOLBAR_PUBLISH', true);
\JToolbarHelper::unpublish('articles.unpublish', 'JTOOLBAR_UNPUBLISH', true);
\JToolbarHelper::custom('articles.featured', 'featured.png', 'featured_f2.png', 'JFEATURE', true);
\JToolbarHelper::custom('articles.unfeatured', 'unfeatured.png', 'featured_f2.png', 'JUNFEATURE', true);
\JToolbarHelper::archiveList('articles.archive');
\JToolbarHelper::checkin('articles.checkin');
$toolbar->publish('articles.publish')->listCheck(true);

$toolbar->unpublish('articles.unpublish')->listCheck(true);

$toolbar->standardButton('featured')
->text('JFEATURE')
->task('articles.featured')
->listCheck(true);

$toolbar->standardButton('unfeatured')
->text('JUNFEATURE')
->task('articles.unfeatured')
->listCheck(true);

$toolbar->archive('articles.archive')->listCheck(true);

$toolbar->checkin('articles.checkin')->listCheck(true);
}

// Add a batch button
if ($user->authorise('core.create', 'com_content')
&& $user->authorise('core.edit', 'com_content')
&& $user->authorise('core.edit.state', 'com_content'))
{
$title = \JText::_('JTOOLBAR_BATCH');

// Instantiate a new \JLayoutFile instance and render the batch button
$layout = new \JLayoutFile('joomla.toolbar.batch');

$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
$toolbar->popupButton('batch')
->text('JTOOLBAR_BATCH')
->selector('collapseModal')
->listCheck(true);
}

if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete'))
{
\JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'articles.delete', 'JTOOLBAR_EMPTY_TRASH');
$toolbar->delete('articles.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}
elseif ($canDo->get('core.edit.state'))
{
\JToolbarHelper::trash('articles.trash');
$toolbar->trash('articles.trash')->listCheck(true);
}

if ($user->authorise('core.admin', 'com_content') || $user->authorise('core.options', 'com_content'))
{
\JToolbarHelper::preferences('com_content');
$toolbar->preferences('com_content');
}

\JToolbarHelper::help('JHELP_CONTENT_ARTICLE_MANAGER');
$toolbar->help('JHELP_CONTENT_ARTICLE_MANAGER');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion administrator/modules/mod_toolbar/mod_toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Toolbar\Toolbar;

$toolbar = Toolbar::getInstance('toolbar')->render('toolbar');
$toolbar = Toolbar::getInstance('toolbar')->render();

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