Skip to content

Commit

Permalink
merged issue 5474
Browse files Browse the repository at this point in the history
  • Loading branch information
florian1995 committed Aug 4, 2016
2 parents 1a6a250 + 163b3ba commit 91e79e6
Show file tree
Hide file tree
Showing 15 changed files with 247 additions and 93 deletions.
37 changes: 27 additions & 10 deletions administrator/components/com_categories/models/categories.php
Expand Up @@ -130,7 +130,7 @@ protected function getStoreId($id = '')
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.language');
$id .= ':' . $this->getState('filter.level');
$id .= ':' . $this->getState('filter.tag');
$id .= ':' . serialize($this->getState('filter.tag'));

return parent::getStoreId($id);
}
Expand All @@ -153,7 +153,7 @@ protected function getListQuery()
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.note, a.published, a.access' .
'DISTINCT a.id, a.title, a.alias, a.note, a.published, a.access' .
', a.checked_out, a.checked_out_time, a.created_user_id' .
', a.path, a.parent_id, a.level, a.lft, a.rgt' .
', a.language'
Expand Down Expand Up @@ -247,17 +247,34 @@ protected function getListQuery()
$query->where('a.language = ' . $db->quote($language));
}

// Filter by a single tag.
// Filter by a single or group of tags.
$hasTag = false;
$tagId = $this->getState('filter.tag');

if (is_numeric($tagId))
{
$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId)
->join(
'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote($extension . '.category')
);
$hasTag = true;

$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId);
}
elseif (is_array($tagId))
{
JArrayHelper::toInteger($tagId);
$tagId = implode(',', $tagId);
if (!empty($tagId))
{
$hasTag = true;

$query->where($db->quoteName('tagmap.tag_id') . ' IN (' . $tagId . ')');
}
}

if ($hasTag)
{
$query->join('LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote($extension . '.category')
);
}

// Add the list ordering clause
Expand Down Expand Up @@ -360,7 +377,7 @@ public function getItems()

/**
* Method to load the countItems method from the extensions
*
*
* @param stdClass[] &$items The category items
* @param string $extension The category extension
*
Expand Down
Expand Up @@ -45,12 +45,13 @@
<field
name="tag"
type="tag"
mode="nested"
multiple="true"
class="multipleTags"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
mode="nested"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_TAG</option>
>
</field>

<field
Expand Down
Expand Up @@ -16,6 +16,7 @@

JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('formbehavior.chosen', '.multipleTags', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_TAG')));
JHtml::_('formbehavior.chosen', 'select');

$app = JFactory::getApplication();
Expand Down
57 changes: 45 additions & 12 deletions administrator/components/com_content/models/articles.php
Expand Up @@ -144,11 +144,12 @@ protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . serialize($this->getState('filter.access'));
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.author_id');
$id .= ':' . serialize($this->getState('filter.category_id'));
$id .= ':' . serialize($this->getState('filter.author_id'));
$id .= ':' . $this->getState('filter.language');
$id .= ':' . serialize($this->getState('filter.tag'));

return parent::getStoreId($id);
}
Expand All @@ -172,7 +173,7 @@ protected function getListQuery()
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid' .
'DISTINCT a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid' .
', a.state, a.access, a.created, a.created_by, a.created_by_alias, a.ordering, a.featured, a.language, a.hits' .
', a.publish_up, a.publish_down'
)
Expand Down Expand Up @@ -209,10 +210,18 @@ protected function getListQuery()
}

// Filter by access level.
if ($access = $this->getState('filter.access'))
$access = $this->getState('filter.access');

if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
elseif(is_array($access))
{
JArrayHelper::toInteger($access);
$access = implode(',', $access);
$query->where('a.access IN (' . $access . ')');
}

// Implement View Level Access
if (!$user->authorise('core.admin'))
Expand Down Expand Up @@ -269,6 +278,13 @@ protected function getListQuery()
$query->where('a.created_by ' . $type . (int) $authorId);
}

elseif (is_array($authorId))
{
JArrayHelper::toInteger($categoryId);
$authorId = implode(',', $authorId);
$query->where('a.created_by IN (' . $authorId . ')');
}

// Filter by search in title.
$search = $this->getState('filter.search');

Expand Down Expand Up @@ -296,17 +312,34 @@ protected function getListQuery()
$query->where('a.language = ' . $db->quote($language));
}

// Filter by a single tag.
// Filter by a single or group of tags.
$hasTag = false;
$tagId = $this->getState('filter.tag');

if (is_numeric($tagId))
{
$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId)
->join(
'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article')
);
$hasTag = true;

$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId);
}
elseif (is_array($tagId))
{
JArrayHelper::toInteger($tagId);
$tagId = implode(',', $tagId);
if (!empty($tagId))
{
$hasTag = true;

$query->where($db->quoteName('tagmap.tag_id') . ' IN (' . $tagId . ')');
}
}

if ($hasTag)
{
$query->join('LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article')
);
}

// Add the list ordering clause.
Expand Down
50 changes: 41 additions & 9 deletions administrator/components/com_content/models/featured.php
Expand Up @@ -79,7 +79,7 @@ protected function getListQuery($resolveFKs = true)
$query->select(
$this->getState(
'list.select',
'a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits,' .
'DISTINCT a.id, a.title, a.alias, a.checked_out, a.checked_out_time, a.catid, a.state, a.access, a.created, a.hits,' .
'a.featured, a.language, a.created_by_alias, a.publish_up, a.publish_down'
)
);
Expand Down Expand Up @@ -110,10 +110,18 @@ protected function getListQuery($resolveFKs = true)
->join('LEFT', '#__users AS ua ON ua.id = a.created_by');

// Filter by access level.
if ($access = $this->getState('filter.access'))
$access = $this->getState('filter.access');

if (is_numeric($access))
{
$query->where('a.access = ' . (int) $access);
}
elseif(is_array($access))
{
JArrayHelper::toInteger($access);
$access = implode(',', $access);
$query->where('a.access IN (' . $access . ')');
}

// Filter by published state
$published = $this->getState('filter.published');
Expand Down Expand Up @@ -162,6 +170,13 @@ protected function getListQuery($resolveFKs = true)
$query->where('a.created_by ' . $type . (int) $authorId);
}

elseif (is_array($authorId))
{
JArrayHelper::toInteger($categoryId);
$authorId = implode(',', $authorId);
$query->where('a.created_by IN (' . $authorId . ')');
}

// Filter by search in title.
$search = $this->getState('filter.search');

Expand Down Expand Up @@ -189,17 +204,34 @@ protected function getListQuery($resolveFKs = true)
$query->where('a.language = ' . $db->quote($language));
}

// Filter by a single tag.
// Filter by a single or group of tags.
$hasTag = false;
$tagId = $this->getState('filter.tag');

if (is_numeric($tagId))
{
$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId)
->join(
'LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article')
);
$hasTag = true;

$query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId);
}
elseif (is_array($tagId))
{
JArrayHelper::toInteger($tagId);
$tagId = implode(',', $tagId);
if (!empty($tagId))
{
$hasTag = true;

$query->where($db->quoteName('tagmap.tag_id') . ' IN (' . $tagId . ')');
}
}

if ($hasTag)
{
$query->join('LEFT', $db->quoteName('#__contentitem_tag_map', 'tagmap')
. ' ON ' . $db->quoteName('tagmap.content_item_id') . ' = ' . $db->quoteName('a.id')
. ' AND ' . $db->quoteName('tagmap.type_alias') . ' = ' . $db->quote('com_content.article')
);
}

// Add the list ordering clause.
Expand Down
Expand Up @@ -20,32 +20,35 @@
<field
name="category_id"
type="category"
multiple="true"
class="multipleCategories"
label="JOPTION_FILTER_CATEGORY"
extension="com_content"
description="JOPTION_FILTER_CATEGORY_DESC"
onchange="this.form.submit();"
published="0,1,2"
>
<option value="">JOPTION_SELECT_CATEGORY</option>
</field>
<field
name="access"
type="accesslevel"
multiple="true"
class="multipleAccessLevels"
label="JOPTION_FILTER_ACCESS"
description="JOPTION_FILTER_ACCESS_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_ACCESS</option>
</field>
<field
name="author_id"
type="author"
label="COM_CONTENT_FILTER_AUTHOR"
description="COM_CONTENT_FILTER_AUTHOR_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_AUTHOR</option>
</field>
name="author_id"
type="author"
multiple="true"
class="multipleAuthors"
label="COM_CONTENT_FILTER_AUTHOR"
description="COM_CONTENT_FILTER_AUTHOR_DESC"
onchange="this.form.submit();"
>
</field>
<field
name="language"
type="contentlanguage"
Expand All @@ -60,11 +63,12 @@
name="tag"
type="tag"
mode="nested"
multiple="true"
class="multipleTags"
label="JOPTION_FILTER_TAG"
description="JOPTION_FILTER_TAG_DESC"
onchange="this.form.submit();"
>
<option value="">JOPTION_SELECT_TAG</option>
</field>
<field
name="level"
Expand Down

0 comments on commit 91e79e6

Please sign in to comment.