Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
93 changes: 0 additions & 93 deletions administrator/components/com_tags/Model/TagsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Joomla\CMS\Categories\CategoryServiceInterface;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\ListModel;

Expand Down Expand Up @@ -229,97 +228,6 @@ protected function getListQuery()
return $query;
}

/**
* Method override to check-in a record or an array of record
*
* @param mixed $pks The ID of the primary key or an array of IDs
*
* @return mixed Boolean false if there is an error, otherwise the count of records checked in.
*
* @since 3.0.1
*/
public function checkin($pks = array())
{
$pks = (array) $pks;

/* @var \Joomla\Component\Tags\Administrator\Table\Tag $table */
$table = $this->getTable();
$count = 0;

if (empty($pks))
{
$pks = array((int) $this->getState($this->getName() . '.id'));
}

// Check in all items.
foreach ($pks as $pk)
{
if ($table->load($pk))
{
if ($table->checked_out > 0)
{
// Only attempt to check the row in if it exists.
if ($pk)
{
$user = Factory::getUser();

// Get an instance of the row to checkin.
$table = $this->getTable();

if (!$table->load($pk))
{
$this->setError($table->getError());

return false;
}

// Check if this is the user having previously checked out the row.
if ($table->checked_out > 0 && $table->checked_out != $user->get('id') && !$user->authorise('core.admin', 'com_checkin'))
{
$this->setError(Text::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'));

return false;
}

// Attempt to check the row in.
if (!$table->checkin($pk))
{
$this->setError($table->getError());

return false;
}
}

$count++;
}
}
else
{
$this->setError($table->getError());

return false;
}
}

return $count;
}

/**
* Method to get a table object, load it if necessary.
*
* @param string $type The table name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return \Joomla\CMS\Table\Table A Table object
*
* @since 3.1
*/
public function getTable($type = 'Tag', $prefix = 'Administrator', $config = array())
{
return parent::getTable($type, $prefix, $config);
}

/**
* Method to get an array of data items.
*
Expand Down Expand Up @@ -354,7 +262,6 @@ public function getItems()
public function countItems(&$items, $extension)
{
$parts = explode('.', $extension);
$section = null;

if (count($parts) < 2)
{
Expand Down
28 changes: 8 additions & 20 deletions administrator/components/com_tags/View/Tag/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,15 @@ public function display($tpl = null)
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->canDo = ContentHelper::getActions('com_tags');
$this->assoc = $this->get('Assoc');

// Check for errors.
if (count($errors = $this->get('Errors')))
{
throw new \JViewGenericdataexception(implode("\n", $errors), 500);
}

Factory::getApplication()->input->set('hidemainmenu', true);
$this->addToolbar();

parent::display($tpl);
}

Expand All @@ -96,26 +94,18 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$userId = $user->get('id');
$isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);

// Need to load the menu language file as mod_menu hasn't been loaded yet.
$lang = Factory::getLanguage();
$lang->load('com_tags', JPATH_BASE, null, false, true)
|| $lang->load('com_tags', JPATH_ADMINISTRATOR . '/components/com_tags', null, false, true);
$canDo = ContentHelper::getActions('com_tags');

// Get the results for each action.
$canDo = $this->canDo;
$title = Text::_('COM_TAGS_BASE_' . ($isNew ? 'ADD' : 'EDIT') . '_TITLE');
ToolbarHelper::title($isNew ? Text::_('COM_TAGS_MANAGER_TAG_NEW') : Text::_('COM_TAGS_MANAGER_TAG_EDIT'), 'tag');

/**
* Prepare the toolbar.
*/
ToolbarHelper::title($title, ' fa fa-tag');

// For new records, check the create permission.
// Build the actions for new and existing records.
if ($isNew)
{
ToolbarHelper::saveGroup(
Expand All @@ -129,8 +119,6 @@ protected function addToolbar()

ToolbarHelper::cancel('tag.cancel');
}

// If not checked out, can save the item.
else
{
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
Expand All @@ -144,13 +132,14 @@ protected function addToolbar()
$toolbarButtons[] = ['apply', 'tag.apply'];
$toolbarButtons[] = ['save', 'tag.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', 'tag.save2new'];
}
}

// If an existing item, can save to a copy.
// If checked out, we can still save
if ($canDo->get('core.create'))
{
$toolbarButtons[] = ['save2copy', 'tag.save2copy'];
Expand All @@ -171,6 +160,5 @@ protected function addToolbar()

ToolbarHelper::divider();
ToolbarHelper::help('JHELP_COMPONENTS_TAGS_MANAGER_EDIT');
ToolbarHelper::divider();
}
}
91 changes: 38 additions & 53 deletions administrator/components/com_tags/View/Tags/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
Expand Down Expand Up @@ -65,14 +63,6 @@ class HtmlView extends BaseHtmlView
*/
public $activeFilters;

/**
* Array used for displaying the levels filter
*
* @return \stdClass[]
* @since 4.0.0
*/
protected $f_levels;

/**
* Execute and display a template script.
*
Expand Down Expand Up @@ -100,21 +90,6 @@ public function display($tpl = null)
$this->ordering[$item->parent_id][] = $item->id;
}

// Levels filter.
$options = array();
$options[] = HTMLHelper::_('select.option', '1', Text::_('J1'));
$options[] = HTMLHelper::_('select.option', '2', Text::_('J2'));
$options[] = HTMLHelper::_('select.option', '3', Text::_('J3'));
$options[] = HTMLHelper::_('select.option', '4', Text::_('J4'));
$options[] = HTMLHelper::_('select.option', '5', Text::_('J5'));
$options[] = HTMLHelper::_('select.option', '6', Text::_('J6'));
$options[] = HTMLHelper::_('select.option', '7', Text::_('J7'));
$options[] = HTMLHelper::_('select.option', '8', Text::_('J8'));
$options[] = HTMLHelper::_('select.option', '9', Text::_('J9'));
$options[] = HTMLHelper::_('select.option', '10', Text::_('J10'));

$this->f_levels = $options;

// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
Expand All @@ -140,61 +115,71 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
$state = $this->get('State');
$canDo = ContentHelper::getActions('com_tags');
$user = Factory::getUser();

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

ToolbarHelper::title(Text::_('COM_TAGS_MANAGER_TAGS'), 'tags');

if ($canDo->get('core.create'))
{
ToolbarHelper::addNew('tag.add');
$toolbar->addNew('tag.add');
}

if ($canDo->get('core.edit.state'))
if ($canDo->get('core.edit.state') || $user->authorise('core.admin'))
{
ToolbarHelper::publish('tags.publish', 'JTOOLBAR_PUBLISH', true);
ToolbarHelper::unpublish('tags.unpublish', 'JTOOLBAR_UNPUBLISH', true);
ToolbarHelper::archiveList('tags.archive');
}
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
->icon('fa fa-globe')
->buttonClass('btn btn-info')
->listCheck(true);

if ($canDo->get('core.admin'))
{
ToolbarHelper::checkin('tags.checkin');
}
$childBar = $dropdown->getChildToolbar();

// Add a batch button
if ($user->authorise('core.create', 'com_tags')
&& $user->authorise('core.edit', 'com_tags')
&& $user->authorise('core.edit.state', 'com_tags'))
{
$title = Text::_('JTOOLBAR_BATCH');
if ($canDo->get('core.edit.state'))
{
$childBar->publish('tags.publish')->listCheck(true);
$childBar->unpublish('tags.unpublish')->listCheck(true);
$childBar->archive('tags.archive')->listCheck(true);
}

// Instantiate a new FileLayout instance and render the batch button
$layout = new FileLayout('joomla.toolbar.batch');
if ($user->authorise('core.admin'))
{
$childBar->checkin('tags.checkin')->listCheck(true);
}

$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
if ($canDo->get('core.edit.state'))
{
$childBar->trash('tags.trash')->listCheck(true);
}
}

if ($state->get('filter.published') == -2 && $canDo->get('core.delete'))
// Add a batch button
if ($canDo->get('core.create') && $canDo->get('core.edit') && $canDo->get('core.edit.state'))
{
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'tags.delete', 'JTOOLBAR_EMPTY_TRASH');
$toolbar->popupButton('batch')
->text('JTOOLBAR_BATCH')
->selector('collapseModal')
->listCheck(true);
}
elseif ($canDo->get('core.edit.state'))

if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete'))
{
ToolbarHelper::trash('tags.trash');
$toolbar->delete('tags.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
->listCheck(true);
}

if ($canDo->get('core.admin') || $canDo->get('core.options'))
{
ToolbarHelper::preferences('com_tags');
$toolbar->preferences('com_tags');
}

ToolbarHelper::help('JHELP_COMPONENTS_TAGS_MANAGER');
$toolbar->help('JHELP_COMPONENTS_TAGS_MANAGER');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions administrator/language/en-GB/en-GB.com_tags.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ COM_TAGS_ALL="All"
COM_TAGS_ALL_TAGS_DESCRIPTION_LABEL="Heading Description"
COM_TAGS_ALL_TAGS_MEDIA_LABEL="Heading Image File"
COM_TAGS_ANY="Any"
COM_TAGS_BASE_ADD_TITLE="Tags: New"
COM_TAGS_BASE_EDIT_TITLE="Tags: Edit"
COM_TAGS_BASIC_FIELDSET_LABEL="Options"
COM_TAGS_BATCH_CANNOT_CREATE="You are not allowed to create new tags."
COM_TAGS_BATCH_CANNOT_EDIT="You are not allowed to edit tags."
Expand Down Expand Up @@ -73,6 +71,8 @@ COM_TAGS_LIST_ALL_SELECTION_OPTIONS="Selection Options"
COM_TAGS_LIST_MAX_CHARACTERS_LABEL="Maximum Characters"
COM_TAGS_LIST_MAX_LABEL="Maximum Items"
COM_TAGS_LIST_SELECTION_OPTIONS="Item Selection Options"
COM_TAGS_MANAGER_TAG_EDIT="Tags: Edit"
COM_TAGS_MANAGER_TAG_NEW="Tags: New"
COM_TAGS_MANAGER_TAGS="Tags"
COM_TAGS_MATCH_COUNT="Number of matching tags"
COM_TAGS_N_ITEMS_ARCHIVED="%d tags archived."
Expand Down
6 changes: 6 additions & 0 deletions libraries/src/Form/Field/TagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ protected function getInput()
$this->value = explode(',', $this->value);
}

// Integer is given
if (is_int($this->value))
{
$this->value = array($this->value);
}

$data['value'] = $this->value;
}

Expand Down