diff --git a/administrator/components/com_content/models/articles.php b/administrator/components/com_content/models/articles.php index 9cbf323a94948..5865db973fa91 100644 --- a/administrator/components/com_content/models/articles.php +++ b/administrator/components/com_content/models/articles.php @@ -99,26 +99,36 @@ protected function populateState($ordering = 'a.id', $direction = 'desc') $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); $this->setState('filter.search', $search); - $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access'); - $this->setState('filter.access', $access); - - $authorId = $app->getUserStateFromRequest($this->context . '.filter.author_id', 'filter_author_id'); - $this->setState('filter.author_id', $authorId); - $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); $this->setState('filter.published', $published); - $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); - $this->setState('filter.category_id', $categoryId); - $level = $this->getUserStateFromRequest($this->context . '.filter.level', 'filter_level'); $this->setState('filter.level', $level); $language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', ''); $this->setState('filter.language', $language); - $tag = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', ''); - $this->setState('filter.tag', $tag); + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access'); + $authorId = $this->getUserStateFromRequest($this->context . '.filter.author_id', 'filter_author_id'); + $categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id'); + $tag = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag', ''); + + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + + $authorId = $app->input->post->get('author_id'); + $this->setState('filter.author_id', $authorId); + + $categoryId = $app->input->post->get('category_id'); + $this->setState('filter.category_id', $categoryId); + + $tag = $app->input->post->get('tag'); + $this->setState('filter.tag', $tag); + } // List state information. parent::populateState($ordering, $direction); @@ -148,11 +158,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); } @@ -167,17 +178,17 @@ protected function getStoreId($id = '') protected function getListQuery() { // Create a new query object. - $db = $this->getDbo(); + $db = $this->getDbo(); $query = $db->getQuery(true); - $user = JFactory::getUser(); + $user = JFactory::getUser(); // Select the required fields from the table. $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.created_by, a.created_by_alias, a.modified, a.ordering, a.featured, a.language, a.hits' . - ', a.publish_up, a.publish_down' + '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.modified, a.ordering, a.featured, a.language, a.hits' . + ', a.publish_up, a.publish_down' ) ); $query->from('#__content AS a'); @@ -223,10 +234,17 @@ 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)) + { + $access = ArrayHelper::toInteger($access); + $access = implode(',', $access); + $query->where('a.access IN (' . $access . ')'); + } // Filter by access level on categories. if (!$user->authorise('core.admin')) @@ -248,22 +266,24 @@ protected function getListQuery() $query->where('(a.state = 0 OR a.state = 1)'); } + // Filter by a single or group of categories. - $baselevel = 1; + $baselevel = 1; $categoryId = $this->getState('filter.category_id'); if (is_numeric($categoryId)) { - $categoryTable= JTable::getInstance('Category', 'JTable'); + $categoryTable = JTable::getInstance('Category', 'JTable'); $categoryTable->load($categoryId); - $rgt = $categoryTable->rgt; - $lft = $categoryTable->lft; + $rgt = $categoryTable->rgt; + $lft = $categoryTable->lft; $baselevel = (int) $categoryTable->level; $query->where('c.lft >= ' . (int) $lft) ->where('c.rgt <= ' . (int) $rgt); } elseif (is_array($categoryId)) { + $categoryId = ArrayHelper::toInteger($categoryId); $query->where('a.catid IN (' . implode(',', ArrayHelper::toInteger($categoryId)) . ')'); } @@ -281,6 +301,12 @@ protected function getListQuery() $type = $this->getState('filter.author_id.include', true) ? '= ' : '<>'; $query->where('a.created_by ' . $type . (int) $authorId); } + elseif (is_array($authorId)) + { + $authorId = ArrayHelper::toInteger($authorId); + $authorId = implode(',', $authorId); + $query->where('a.created_by IN (' . $authorId . ')'); + } // Filter by search in title. $search = $this->getState('filter.search'); @@ -309,18 +335,34 @@ protected function getListQuery() $query->where('a.language = ' . $db->quote($language)); } - // Filter by a single tag. - $tagId = $this->getState('filter.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)) + { + $tagId = ArrayHelper::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. @@ -342,7 +384,7 @@ protected function getListQuery() public function getAuthors() { // Create a new query object. - $db = $this->getDbo(); + $db = $this->getDbo(); $query = $db->getQuery(true); // Construct the query diff --git a/administrator/components/com_content/models/forms/filter_articles.xml b/administrator/components/com_content/models/forms/filter_articles.xml index e41c8d0d5e00f..44286c2970a75 100644 --- a/administrator/components/com_content/models/forms/filter_articles.xml +++ b/administrator/components/com_content/models/forms/filter_articles.xml @@ -24,32 +24,32 @@ type="category" label="JOPTION_FILTER_CATEGORY" description="JOPTION_FILTER_CATEGORY_DESC" + multiple="true" + class="multipleCategories" extension="com_content" onchange="this.form.submit();" published="0,1,2" - > - - + /> - - + /> - - + /> - - + /> - + + diff --git a/administrator/components/com_content/models/forms/filter_featured.xml b/administrator/components/com_content/models/forms/filter_featured.xml index fe5b19b2a7155..019f17bc5dbcc 100644 --- a/administrator/components/com_content/models/forms/filter_featured.xml +++ b/administrator/components/com_content/models/forms/filter_featured.xml @@ -2,100 +2,101 @@
+ name="published" + type="status" + label="COM_CONTENT_FILTER_PUBLISHED" + description="COM_CONTENT_FILTER_PUBLISHED_DESC" + onchange="this.form.submit();" + > - - + name="category_id" + type="category" + label="JOPTION_FILTER_CATEGORY" + description="JOPTION_FILTER_CATEGORY_DESC" + multiple="true" + class="multipleCategories" + extension="com_content" + onchange="this.form.submit();" + /> - + name="level" + type="integer" + label="JOPTION_FILTER_LEVEL" + description="JOPTION_FILTER_LEVEL_DESC" + first="1" + last="10" + step="1" + languages="*" + onchange="this.form.submit();" + > + - - + name="author_id" + type="author" + label="COM_CONTENT_FILTER_AUTHOR" + description="COM_CONTENT_FILTER_AUTHOR_DESC" + multiple="true" + class="multipleAuthors" + onchange="this.form.submit();" + /> + name="access" + type="accesslevel" + label="JOPTION_FILTER_ACCESS" + description="JOPTION_FILTER_ACCESS_DESC" + multiple="true" + class="multipleAccessLevels" + onchange="this.form.submit();" + /> + + - - + name="tag" + type="tag" + label="JOPTION_FILTER_TAG" + description="JOPTION_FILTER_TAG_DESC" + multiple="true" + class="multipleTags" + mode="nested" + onchange="this.form.submit();" + /> - - - + name="fullordering" + type="list" + label="COM_CONTENT_LIST_FULL_ORDERING" + description="COM_CONTENT_LIST_FULL_ORDERING_DESC" + onchange="this.form.submit();" + default="a.title ASC" + > @@ -128,13 +129,13 @@
diff --git a/administrator/components/com_content/views/articles/tmpl/default.php b/administrator/components/com_content/views/articles/tmpl/default.php index 6afa9bef0fa63..b737ac1ef0233 100644 --- a/administrator/components/com_content/views/articles/tmpl/default.php +++ b/administrator/components/com_content/views/articles/tmpl/default.php @@ -13,6 +13,10 @@ JHtml::_('bootstrap.tooltip'); JHtml::_('behavior.multiselect'); +JHtml::_('formbehavior.chosen', '.multipleTags', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_TAG'))); +JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_CATEGORY'))); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_ACCESS'))); +JHtml::_('formbehavior.chosen', '.multipleAuthors', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_AUTHOR'))); JHtml::_('formbehavior.chosen', 'select'); $app = JFactory::getApplication(); diff --git a/administrator/components/com_content/views/featured/tmpl/default.php b/administrator/components/com_content/views/featured/tmpl/default.php index cd7c4ed7ff5c3..a9d455e2c656b 100644 --- a/administrator/components/com_content/views/featured/tmpl/default.php +++ b/administrator/components/com_content/views/featured/tmpl/default.php @@ -13,6 +13,10 @@ JHtml::_('bootstrap.tooltip'); JHtml::_('behavior.multiselect'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_ACCESS'))); +JHtml::_('formbehavior.chosen', '.multipleAuthors', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_AUTHOR'))); +JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_CATEGORY'))); +JHtml::_('formbehavior.chosen', '.multipleTags', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_TAG'))); JHtml::_('formbehavior.chosen', 'select'); $user = JFactory::getUser(); diff --git a/administrator/components/com_modules/views/module/tmpl/edit.php b/administrator/components/com_modules/views/module/tmpl/edit.php index cb792ef98dcc2..20c2502e03468 100644 --- a/administrator/components/com_modules/views/module/tmpl/edit.php +++ b/administrator/components/com_modules/views/module/tmpl/edit.php @@ -15,6 +15,8 @@ JHtml::_('behavior.combobox'); JHtml::_('behavior.keepalive'); JHtml::_('formbehavior.chosen', '#jform_position', null, array('disable_search_threshold' => 0 )); +JHtml::_('formbehavior.chosen', '.multipleCategories', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_CATEGORY'))); +JHtml::_('formbehavior.chosen', '.multipleTags', null, array('placeholder_text_multiple' => JText::_('JOPTION_SELECT_TAG'))); JHtml::_('formbehavior.chosen', 'select'); $hasContent = empty($this->item->module) || isset($this->item->xml->customContent); diff --git a/administrator/components/com_newsfeeds/models/newsfeeds.php b/administrator/components/com_newsfeeds/models/newsfeeds.php index 161b87625d3d6..06348ee0ce4f3 100644 --- a/administrator/components/com_newsfeeds/models/newsfeeds.php +++ b/administrator/components/com_newsfeeds/models/newsfeeds.php @@ -46,6 +46,7 @@ public function __construct($config = array()) 'numarticles', 'tag', 'level', 'c.level', + 'tag', ); $assoc = JLanguageAssociations::isEnabled(); @@ -130,8 +131,8 @@ protected function getStoreId($id = '') $id .= ':' . $this->getState('filter.category_id'); $id .= ':' . $this->getState('filter.access'); $id .= ':' . $this->getState('filter.language'); - $id .= ':' . $this->getState('filter.tag'); $id .= ':' . $this->getState('filter.level'); + $id .= ':' . serialize($this->getState('filter.tag')); return parent::getStoreId($id); } @@ -153,9 +154,9 @@ protected function getListQuery() $query->select( $this->getState( 'list.select', - 'a.id, a.name, a.alias, a.checked_out, a.checked_out_time, a.catid,' . - ' a.numarticles, a.cache_time, a.created_by,' . - ' a.published, a.access, a.ordering, a.language, a.publish_up, a.publish_down' + 'DISTINCT a.id, a.name, a.alias, a.checked_out, a.checked_out_time, a.catid,' . + ' a.numarticles, a.cache_time, a.created_by,' . + ' a.published, a.access, a.ordering, a.language, a.publish_up, a.publish_down' ) ); $query->from($db->quoteName('#__newsfeeds', 'a')); @@ -248,21 +249,38 @@ protected function getListQuery() $query->where($db->quoteName('a.language') . ' = ' . $db->quote($language)); } - // Filter by a single tag. - $tagId = $this->getState('filter.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_newsfeeds.newsfeed') - ); + $hasTag = true; + + $query->where($db->quoteName('tagmap.tag_id') . ' = ' . (int) $tagId); + } + elseif (is_array($tagId)) + { + ArrayHelper::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_newsfeeds.newsfeed') + ); } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'a.name'); + $orderCol = $this->state->get('list.ordering', 'a.name'); $orderDirn = $this->state->get('list.direction', 'ASC'); if ($orderCol == 'a.ordering' || $orderCol == 'category_title') diff --git a/administrator/language/en-GB/en-GB.ini b/administrator/language/en-GB/en-GB.ini index a8cf190e4412f..a9094d063569c 100644 --- a/administrator/language/en-GB/en-GB.ini +++ b/administrator/language/en-GB/en-GB.ini @@ -855,6 +855,7 @@ JOPTION_ACCESS_SHOW_ALL_ACCESS="Show All Access" JOPTION_ACCESS_SHOW_ALL_GROUPS="Show All Groups" JOPTION_ACCESS_SHOW_ALL_LEVELS="Show All Access Levels" JOPTION_ALL_CATEGORIES="- All Categories -" +JOPTION_ALL_TAGS="- All Tags -" JOPTION_ANY_CATEGORY="Any Category" JOPTION_ANY="Any" JOPTION_DO_NOT_USE="- None Selected -" diff --git a/components/com_content/models/articles.php b/components/com_content/models/articles.php index 882750a50e91a..6ec51502bf046 100644 --- a/components/com_content/models/articles.php +++ b/components/com_content/models/articles.php @@ -51,7 +51,8 @@ public function __construct($config = array()) 'publish_down', 'a.publish_down', 'images', 'a.images', 'urls', 'a.urls', - 'filter_tag' + 'filter_tag', + 'tag' ); } @@ -163,6 +164,7 @@ protected function getStoreId($id = '') $id .= ':' . $this->getState('filter.start_date_range'); $id .= ':' . $this->getState('filter.end_date_range'); $id .= ':' . $this->getState('filter.relative_date'); + $id .= ':' . serialize($this->getState('filter.tag')); return parent::getStoreId($id); } @@ -180,32 +182,32 @@ protected function getListQuery() $user = JFactory::getUser(); // Create a new query object. - $db = $this->getDbo(); + $db = $this->getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select( $this->getState( 'list.select', - 'a.id, a.title, a.alias, a.introtext, a.fulltext, ' . - 'a.checked_out, a.checked_out_time, ' . - 'a.catid, a.created, a.created_by, a.created_by_alias, ' . - // Published/archived article in archive category is treats as archive article - // If category is not published then force 0 - 'CASE WHEN c.published = 2 AND a.state > 0 THEN 2 WHEN c.published != 1 THEN 0 ELSE a.state END as state,' . - // Use created if modified is 0 - 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' . - 'a.modified_by, uam.name as modified_by_name,' . - // Use created if publish_up is 0 - 'CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' . - 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' . - 'a.hits, a.xreference, a.featured, a.language, ' . ' ' . $query->length('a.fulltext') . ' AS readmore' + 'DISTINCT a.id, a.title, a.alias, a.introtext, a.fulltext, ' . + 'a.checked_out, a.checked_out_time, ' . + 'a.catid, a.created, a.created_by, a.created_by_alias, ' . + // Published/archived article in archive category is treats as archive article + // If category is not published then force 0 + 'CASE WHEN c.published = 2 AND a.state > 0 THEN 2 WHEN c.published != 1 THEN 0 ELSE a.state END as state,' . + // Use created if modified is 0 + 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' . + 'a.modified_by, uam.name as modified_by_name,' . + // Use created if publish_up is 0 + 'CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' . + 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' . + 'a.hits, a.xreference, a.featured, a.language, ' . ' ' . $query->length('a.fulltext') . ' AS readmore' ) ); $query->from('#__content AS a'); - $params = $this->getState('params'); + $params = $this->getState('params'); $orderby_sec = $params->get('orderby_sec'); // Join over the frontpage articles if required. @@ -233,7 +235,6 @@ protected function getListQuery() // Join over the users for the author and modified_by names. $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author") ->select('ua.email AS author_email') - ->join('LEFT', '#__users AS ua ON ua.id = a.created_by') ->join('LEFT', '#__users AS uam ON uam.id = a.modified_by'); @@ -312,7 +313,7 @@ protected function getListQuery() { $articleId = ArrayHelper::toInteger($articleId); $articleId = implode(',', $articleId); - $type = $this->getState('filter.article_id.include', true) ? 'IN' : 'NOT IN'; + $type = $this->getState('filter.article_id.include', true) ? 'IN' : 'NOT IN'; $query->where('a.id ' . $type . ' (' . $articleId . ')'); } @@ -325,7 +326,7 @@ protected function getListQuery() // Add subcategory check $includeSubcategories = $this->getState('filter.subcategories', false); - $categoryEquals = 'a.catid ' . $type . (int) $categoryId; + $categoryEquals = 'a.catid ' . $type . (int) $categoryId; if ($includeSubcategories) { @@ -364,12 +365,12 @@ protected function getListQuery() } // Filter by author - $authorId = $this->getState('filter.author_id'); + $authorId = $this->getState('filter.author_id'); $authorWhere = ''; if (is_numeric($authorId)) { - $type = $this->getState('filter.author_id.include', true) ? '= ' : '<> '; + $type = $this->getState('filter.author_id.include', true) ? '= ' : '<> '; $authorWhere = 'a.created_by ' . $type . (int) $authorId; } elseif (is_array($authorId)) @@ -379,18 +380,18 @@ protected function getListQuery() if ($authorId) { - $type = $this->getState('filter.author_id.include', true) ? 'IN' : 'NOT IN'; + $type = $this->getState('filter.author_id.include', true) ? 'IN' : 'NOT IN'; $authorWhere = 'a.created_by ' . $type . ' (' . $authorId . ')'; } } // Filter by author alias - $authorAlias = $this->getState('filter.author_alias'); + $authorAlias = $this->getState('filter.author_alias'); $authorAliasWhere = ''; if (is_string($authorAlias)) { - $type = $this->getState('filter.author_alias.include', true) ? '= ' : '<> '; + $type = $this->getState('filter.author_alias.include', true) ? '= ' : '<> '; $authorAliasWhere = 'a.created_by_alias ' . $type . $db->quote($authorAlias); } elseif (is_array($authorAlias)) @@ -408,7 +409,7 @@ protected function getListQuery() if ($authorAlias) { - $type = $this->getState('filter.author_alias.include', true) ? 'IN' : 'NOT IN'; + $type = $this->getState('filter.author_alias.include', true) ? 'IN' : 'NOT IN'; $authorAliasWhere = 'a.created_by_alias ' . $type . ' (' . $authorAlias . ')'; } @@ -442,16 +443,16 @@ protected function getListQuery() // Filter by Date Range or Relative Date $dateFiltering = $this->getState('filter.date_filtering', 'off'); - $dateField = $this->getState('filter.date_field', 'a.created'); + $dateField = $this->getState('filter.date_field', 'a.created'); switch ($dateFiltering) { case 'range': $startDateRange = $db->quote($this->getState('filter.start_date_range', $nullDate)); - $endDateRange = $db->quote($this->getState('filter.end_date_range', $nullDate)); + $endDateRange = $db->quote($this->getState('filter.end_date_range', $nullDate)); $query->where( '(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField . - ' <= ' . $endDateRange . ')' + ' <= ' . $endDateRange . ')' ); break; @@ -459,7 +460,7 @@ protected function getListQuery() $relativeDate = (int) $this->getState('filter.relative_date', 0); $query->where( $dateField . ' >= DATE_SUB(' . $nowDate . ', INTERVAL ' . - $relativeDate . ' DAY)' + $relativeDate . ' DAY)' ); break; @@ -472,16 +473,16 @@ protected function getListQuery() if (is_object($params) && ($params->get('filter_field') !== 'hide') && ($filter = $this->getState('list.filter'))) { // Clean filter variable - $filter = StringHelper::strtolower($filter); + $filter = StringHelper::strtolower($filter); $hitsFilter = (int) $filter; - $filter = $db->quote('%' . $db->escape($filter, true) . '%', false); + $filter = $db->quote('%' . $db->escape($filter, true) . '%', false); switch ($params->get('filter_field')) { case 'author': $query->where( 'LOWER( CASE WHEN a.created_by_alias > ' . $db->quote(' ') . - ' THEN a.created_by_alias ELSE ua.name END ) LIKE ' . $filter . ' ' + ' THEN a.created_by_alias ELSE ua.name END ) LIKE ' . $filter . ' ' ); break; @@ -503,17 +504,34 @@ protected function getListQuery() $query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); } - // Filter by a single tag. - $tagId = $this->getState('filter.tag'); + // Filter by a single or group of tags. + $hasTag = false; + $tagId = $this->getState('filter.tag'); - if (!empty($tagId) && is_numeric($tagId)) + 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)) + { + ArrayHelper::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. @@ -533,12 +551,12 @@ protected function getListQuery() */ public function getItems() { - $items = parent::getItems(); - $user = JFactory::getUser(); + $items = parent::getItems(); + $user = JFactory::getUser(); $userId = $user->get('id'); - $guest = $user->get('guest'); + $guest = $user->get('guest'); $groups = $user->getAuthorisedViewLevels(); - $input = JFactory::getApplication()->input; + $input = JFactory::getApplication()->input; // Get the global params $globalParams = JComponentHelper::getParams('com_content', true); @@ -550,7 +568,7 @@ public function getItems() // Unpack readmore and layout params $item->alternative_readmore = $articleParams->get('alternative_readmore'); - $item->layout = $articleParams->get('layout'); + $item->layout = $articleParams->get('layout'); $item->params = clone $this->getState('params'); @@ -562,7 +580,7 @@ public function getItems() { // Create an array of just the params set to 'use_article' $menuParamsArray = $this->getState('params')->toArray(); - $articleArray = array(); + $articleArray = array(); foreach ($menuParamsArray as $key => $value) { diff --git a/modules/mod_articles_news/helper.php b/modules/mod_articles_news/helper.php index 59f8e215b020a..565b3b64b1898 100644 --- a/modules/mod_articles_news/helper.php +++ b/modules/mod_articles_news/helper.php @@ -58,6 +58,9 @@ public static function getList(&$params) // Filter by language $model->setState('filter.language', $app->getLanguageFilter()); + // Filer by tag + $model->setState('filter.tag', $params->get('tag'), array()); + // Featured switch switch ($params->get('show_featured')) { diff --git a/modules/mod_articles_news/mod_articles_news.xml b/modules/mod_articles_news/mod_articles_news.xml index a329b1bf0e438..da78c44eb73f6 100644 --- a/modules/mod_articles_news/mod_articles_news.xml +++ b/modules/mod_articles_news/mod_articles_news.xml @@ -18,68 +18,78 @@ en-GB.mod_articles_news.ini en-GB.mod_articles_news.sys.ini - +
- - + name="catid" + type="category" + label="JCATEGORY" + description="MOD_ARTICLES_NEWS_FIELD_CATEGORY_DESC" + extension="com_content" + multiple="true" + class="multipleCategories" + default="" + size="10" + /> + + + name="image" + type="radio" + label="MOD_ARTICLES_NEWS_FIELD_IMAGES_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_IMAGES_DESC" + class="btn-group btn-group-yesno" + default="0" + > + name="item_title" + type="radio" + label="MOD_ARTICLES_NEWS_FIELD_TITLE_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_TITLE_DESC" + class="btn-group btn-group-yesno" + default="0" + > + name="link_titles" + type="list" + label="MOD_ARTICLES_NEWS_FIELD_LINKTITLE_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_LINKTITLE_DESC" + class="chzn-color" + showon="item_title:1" + > + name="item_heading" + type="list" + label="MOD_ARTICLES_NEWS_TITLE_HEADING" + description="MOD_ARTICLES_NEWS_TITLE_HEADING_DESCRIPTION" + default="h4" + showon="item_title:1" + > @@ -88,80 +98,80 @@ + name="triggerevents" + type="radio" + label="MOD_ARTICLES_NEWS_FIELD_TRIGGEREVENTS_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_TRIGGEREVENTS_DESC" + class="btn-group btn-group-yesno" + default="1" + > + name="showLastSeparator" + type="radio" + label="MOD_ARTICLES_NEWS_FIELD_SEPARATOR_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_SEPARATOR_DESC" + class="btn-group btn-group-yesno" + default="1" + > + name="show_introtext" + type="radio" + label="MOD_ARTICLES_NEWS_FIELD_SHOWINTROTEXT_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_SHOWINTROTEXT_DESC" + default="1" + class="btn-group btn-group-yesno" + > + name="readmore" + type="radio" + label="MOD_ARTICLES_NEWS_FIELD_READMORE_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_READMORE_DESC" + class="btn-group btn-group-yesno" + default="0" + > + name="show_featured" + type="list" + label="MOD_ARTICLES_NEWS_FIELD_FEATURED_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_FEATURED_DESC" + default="" + > + name="ordering" + type="list" + label="MOD_ARTICLES_NEWS_FIELD_ORDERING_LABEL" + description="MOD_ARTICLES_NEWS_FIELD_ORDERING_DESC" + default="a.publish_up" + > @@ -171,13 +181,13 @@ + name="direction" + type="list" + label="JGLOBAL_ORDER_DIRECTION_LABEL" + description="JGLOBAL_ORDER_DIRECTION_DESC" + default="1" + showon="ordering:a.publish_up,a.created,a.modified,a.ordering,a.hits" + > @@ -185,43 +195,43 @@
+ name="cache" + type="list" + label="COM_MODULES_FIELD_CACHING_LABEL" + description="COM_MODULES_FIELD_CACHING_DESC" + default="1" + > + name="cachemode" + type="hidden" + default="itemid" + >