Skip to content
Merged
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
47 changes: 30 additions & 17 deletions core/modules/mod_articles_category/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static function getList(&$params)
{
// Get an instance of the generic article model
$article = Article::all();
$article->whereEquals('published', Article::STATE_PUBLISHED);
$article->whereEquals('state', Article::STATE_PUBLISHED);
$article->whereEquals('id', (int) $article_id);

$item = $article->row();
Expand Down Expand Up @@ -257,32 +257,39 @@ public static function getList(&$params)
$query->whereEquals('featured', 1);
}

if ($creator = $params->get('created_by', ''))
$creator = $params->get('created_by', '');
if (count($creator) > 0 && implode(',', $creator) != '')
{
$query->whereEquals('created_by', $creator);
}

if ($excluded_articles = $params->get('excluded_articles', ''))
{
$excluded_articles = explode("\r\n", $excluded_articles);
$query->whereRaw('id', 'NOT IN(' . implode(',', $excluded_articles) . ')');
$query->whereRaw('id NOT IN(' . implode(',', $excluded_articles) . ')');
}

$date_filtering = $params->get('date_filtering', 'off');
if ($date_filtering !== 'off')
if ($date_filtering == 'range')
{
$fld = str_replace('a.', '', $params->get('date_field', 'a.created'));

$query->where($fld, '>=', $params->get('start_date_range', '1000-01-01 00:00:00'));
$query->where($fld, '<', $params->get('end_date_range', '9999-12-31 23:59:59'));
}
elseif ($date_filtering == 'relative')
{
$fld = str_replace('a.', '`#__content`.`', $params->get('date_field', 'a.created')) . '`';
if ($relativeDate = $params->get('relative_date', 30))
{
$query->whereRaw($fld, '>= DATE_SUB(' . Date::toSql() . ', INTERVAL ' . $relativeDate . ' DAY)');
$query->whereRaw($fld . " >= DATE_SUB('" . Date::toSql() . "', INTERVAL " . $relativeDate . " DAY)");
}
}

// Filter by language
$query->whereEquals('language', App::get('language.filter'));
if (App::get('language.filter') != '') {
$query->whereEquals('language', App::get('language.filter'));
}

$query->start(0)
->limit((int) $params->get('count', 5));
Expand Down Expand Up @@ -312,12 +319,28 @@ public static function getList(&$params)
$active_article_id = 0;
}

$access = !Component::params('com_content')->get('show_noauth');
$authorised = User::getAuthorisedViewLevels();
// Prepare data for display using display options
foreach ($items as $item)
{
$item->slug = $item->id . ':' . $item->alias;
$item->catslug = $item->catid ? $item->catid . ':' . $item->category_alias : $item->catid;
if ($item->catid)
{

$categories = Category::all();
$categories->whereEquals('id', $item->catid);
$category = $categories->rows()->first();
$item->catslug = $item->catid . ':' . $category->alias;
$item->displayCategoryLink = Route::url(\Components\Content\Site\Helpers\Route::getCategoryRoute($item->catid));
$item->displayCategoryTitle = $show_category ? '<a href="' . $item->displayCategoryLink . '">' . $category->title . '</a>' : '';
}
else
{
$item->catslug = '';
$item->displayCategoryTitle = '';
}

if ($access || in_array($item->access, $authorised))
{
// We know that user has the privilege to view the article
Expand Down Expand Up @@ -350,16 +373,6 @@ public static function getList(&$params)
$item->displayDate = Date::of($item->$show_date_field)->toLocal($show_date_format);
}

if ($item->catid)
{
$item->displayCategoryLink = Route::url(\Components\Content\Site\Helpers\Route::getCategoryRoute($item->catid));
$item->displayCategoryTitle = $show_category ? '<a href="' . $item->displayCategoryLink . '">' . $item->category_title . '</a>' : '';
}
else
{
$item->displayCategoryTitle = $show_category ? $item->category_title : '';
}

$item->displayHits = $show_hits ? $item->hits : '';
$item->displayAuthorName = $show_author ? $item->author : '';
if ($show_introtext)
Expand Down