29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-30 00:53:41 +00:00

[com_content] - add articles ordering by votes, ratings (#11225)

This commit is contained in:
Nicola Galgano 2016-09-18 17:43:26 +02:00 committed by George Wilson
parent 0db39fccae
commit 0d708ec6a6
26 changed files with 278 additions and 38 deletions

View File

@ -829,6 +829,24 @@
<option value="0">JHIDE</option>
</field>
<field name="list_show_votes"
type="list"
default="0"
label="JGLOBAL_LIST_VOTES_LABEL"
description="JGLOBAL_LIST_VOTES_DESC">
<option value="1" requires="vote">JSHOW</option>
<option value="0" requires="vote">JHIDE</option>
</field>
<field name="list_show_ratings"
type="list"
default="0"
label="JGLOBAL_LIST_RATINGS_LABEL"
description="JGLOBAL_LIST_RATINGS_DESC">
<option value="1" requires="vote">JSHOW</option>
<option value="0" requires="vote">JHIDE</option>
</field>
</fieldset>
<fieldset name="shared"
@ -873,6 +891,14 @@
value="rhits">JGLOBAL_LEAST_HITS</option>
<option
value="order">JGLOBAL_ARTICLE_MANAGER_ORDER</option>
<option
value="vote" requires="vote">JGLOBAL_VOTES_DESC</option>
<option
value="rvote" requires="vote">JGLOBAL_VOTES_ASC</option>
<option
value="rank" requires="vote"> JGLOBAL_RATINGS_DESC</option>
<option
value="rrank" requires="vote">JGLOBAL_RATINGS_ASC</option>
</field>
<field name="order_date" type="list"

View File

@ -200,13 +200,24 @@ class ContentModelArticles extends JModelList
$query->select('ua.name AS author_name')
->join('LEFT', '#__users AS ua ON ua.id = a.created_by');
// Join on voting table
$assogroup = 'a.id, l.title, l.image, uc.name, ag.title, c.title, ua.name';
if (JPluginHelper::isEnabled('content', 'vote'))
{
$assogroup .= ', v.rating_sum, v.rating_count';
$query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating,
COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
}
// Join over the associations.
if (JLanguageAssociations::isEnabled())
{
$query->select('COUNT(asso2.id)>1 as association')
->join('LEFT', '#__associations AS asso ON asso.id = a.id AND asso.context=' . $db->quote('com_content.item'))
->join('LEFT', '#__associations AS asso2 ON asso2.key = asso.key')
->group('a.id, l.title, l.image, uc.name, ag.title, c.title, ua.name');
->group($assogroup);
}
// Filter by access level.
@ -313,23 +324,13 @@ class ContentModelArticles extends JModelList
$orderCol = $this->state->get('list.ordering', 'a.id');
$orderDirn = $this->state->get('list.direction', 'desc');
if ($orderCol == 'a.ordering' || $orderCol == 'category_title')
if (JPluginHelper::isEnabled('content', 'vote'))
{
$orderCol = 'c.title ' . $orderDirn . ', a.ordering';
$orderCol = empty($this->state->get('list.fullordering', 'a.id')) ? 'a.id' : $this->state->get('list.fullordering', 'a.id');
$orderDirn = '';
}
// SQL server change
if ($orderCol == 'language')
{
$orderCol = 'l.title';
}
if ($orderCol == 'access_level')
{
$orderCol = 'ag.title';
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
$query->order($db->escape($orderCol) . ' ' . $orderDirn);
return $query;
}

View File

@ -109,6 +109,14 @@ class ContentModelFeatured extends ContentModelArticles
$query->select('ua.name AS author_name')
->join('LEFT', '#__users AS ua ON ua.id = a.created_by');
// Join on voting table
if (JPluginHelper::isEnabled('content', 'vote'))
{
$query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating,
COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
}
// Filter by access level.
if ($access = $this->getState('filter.access'))
{

View File

@ -112,6 +112,10 @@
<option value="a.created DESC">JDATE_DESC</option>
<option value="a.hits ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits DESC">JGLOBAL_HITS_DESC</option>
<option value="rating_count ASC" requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rating_count DESC" requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rating ASC" requires="vote">JGLOBAL_RATINGS_ASC</option>
<option value="rating DESC" requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>

View File

@ -107,6 +107,10 @@
<option value="a.created DESC">JDATE_DESC</option>
<option value="a.hits ASC">JGLOBAL_HITS_ASC</option>
<option value="a.hits DESC">JGLOBAL_HITS_DESC</option>
<option value="rating_count ASC" requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rating_count DESC" requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rating ASC" requires="vote">JGLOBAL_RATINGS_ASC</option>
<option value="rating DESC" requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
</field>

View File

@ -18,7 +18,7 @@ JHtml::_('formbehavior.chosen', 'select');
$app = JFactory::getApplication();
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listOrder = str_replace(' ' . $this->state->get('list.direction'), '', $this->state->get('list.fullordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'a.ordering';
$columns = 10;
@ -86,6 +86,16 @@ $assoc = JLanguageAssociations::isEnabled();
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php if ($this->vote) : ?>
<?php $columns++; ?>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_VOTES', 'rating_count', $listDirn, $listOrder); ?>
</th>
<?php $columns++; ?>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_RATINGS', 'rating', $listDirn, $listOrder); ?>
</th>
<?php endif;?>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
@ -199,8 +209,22 @@ $assoc = JLanguageAssociations::isEnabled();
<?php echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="hidden-phone">
<?php echo (int) $item->hits; ?>
<span class="badge badge-info">
<?php echo (int) $item->hits; ?>
</span>
</td>
<?php if ($this->vote) : ?>
<td class="hidden-phone">
<span class="badge badge-success" >
<?php echo (int) $item->rating_count; ?>
</span>
</td>
<td class="hidden-phone">
<span class="badge badge-warning" >
<?php echo (int) $item->rating; ?>
</span>
</td>
<?php endif; ?>
<td class="hidden-phone">
<?php echo (int) $item->id; ?>
</td>

View File

@ -85,6 +85,7 @@ class ContentViewArticles extends JViewLegacy
$this->authors = $this->get('Authors');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->vote = JPluginHelper::isEnabled('content', 'vote');
// Check for errors.
if (count($errors = $this->get('Errors')))

View File

@ -17,7 +17,7 @@ JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listOrder = str_replace(' ' . $this->state->get('list.direction'), '', $this->state->get('list.fullordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_content.article');
$saveOrder = $listOrder == 'fp.ordering';
@ -77,6 +77,14 @@ if ($saveOrder)
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php if ($this->vote) : ?>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_VOTES', 'rating_count', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGLOBAL_RATINGS', 'rating', $listDirn, $listOrder); ?>
</th>
<?php endif;?>
<th width="1%" class="nowrap hidden-phone">
<?php echo JHtml::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
@ -184,8 +192,22 @@ if ($saveOrder)
<?php echo JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC4')); ?>
</td>
<td class="center hidden-phone">
<span class="badge badge-info">
<?php echo (int) $item->hits; ?>
</span>
</td>
<?php if ($this->vote) : ?>
<td class="hidden-phone">
<span class="badge badge-success" >
<?php echo (int) $item->rating_count; ?>
</span>
</td>
<td class="hidden-phone">
<span class="badge badge-warning" >
<?php echo (int) $item->rating; ?>
</span>
</td>
<?php endif; ?>
<td class="center hidden-phone">
<?php echo (int) $item->id; ?>
</td>

View File

@ -82,6 +82,7 @@ class ContentViewFeatured extends JViewLegacy
$this->authors = $this->get('Authors');
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');
$this->vote = JPluginHelper::isEnabled('content', 'vote');
// Check for errors.
if (count($errors = $this->get('Errors')))

View File

@ -412,8 +412,12 @@ JGLOBAL_LIST_HITS_DESC="Show or hide article hits in the list of articles."
JGLOBAL_LIST_HITS_LABEL="Show Hits in List"
JGLOBAL_LIST_LAYOUT_OPTIONS="List Layouts"
JGLOBAL_LIST_NOTE="(<span>Note</span>: %s)"
JGLOBAL_LIST_RATINGS_DESC="Whether to show article ratings in the list of articles."
JGLOBAL_LIST_RATINGS_LABEL="Show Ratings in List"
JGLOBAL_LIST_TITLE_DESC="If Show, Category Title will show in the list of categories."
JGLOBAL_LIST_TITLE_LABEL="Category Title"
JGLOBAL_LIST_VOTES_DESC="Whether to show article votes in the list of articles."
JGLOBAL_LIST_VOTES_LABEL="Show Votes in List"
JGLOBAL_LOOKING_FOR="Looking for"
JGLOBAL_LT="&lt;"
JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC="The number of subcategory levels to display."
@ -466,6 +470,9 @@ JGLOBAL_PERMISSIONS_ANCHOR="Set Permissions"
JGLOBAL_PREVIEW="Preview"
JGLOBAL_PUBLISHED_DATE="Published Date"
JGLOBAL_RANDOM_ORDER="Random Order"
JGLOBAL_RATINGS="Ratings"
JGLOBAL_RATINGS_ASC="Ratings ascending"
JGLOBAL_RATINGS_DESC="Ratings descending"
JGLOBAL_RECORD_NUMBER="Record ID: %d"
JGLOBAL_REMEMBER_ME="Remember Me"
JGLOBAL_RIGHT="Right"
@ -577,6 +584,9 @@ JGLOBAL_USE_GLOBAL="Use Global"
JGLOBAL_USERNAME="Username"
JGLOBAL_VALIDATION_FORM_FAILED="Invalid form"
JGLOBAL_VIEW_SITE="View Site"
JGLOBAL_VOTES="Votes"
JGLOBAL_VOTES_ASC="Votes ascending"
JGLOBAL_VOTES_DESC="Votes descending"
JGLOBAL_WARNJAVASCRIPT="Warning! JavaScript must be enabled for proper operation of the Administrator Backend."
JGLOBAL_WIDTH="Width"

View File

@ -40,13 +40,13 @@ abstract class ModLatestHelper
switch ($params->get('ordering'))
{
case 'm_dsc':
$model->setState('list.ordering', 'modified DESC, created');
$model->setState('list.fullordering', 'modified DESC, created');
$model->setState('list.direction', 'DESC');
break;
case 'c_dsc':
default:
$model->setState('list.ordering', 'created');
$model->setState('list.fullordering', 'created');
$model->setState('list.direction', 'DESC');
break;
}

View File

@ -37,7 +37,7 @@ abstract class ModPopularHelper
' a.created, a.hits');
// Set Ordering filter
$model->setState('list.ordering', 'a.hits');
$model->setState('list.fullordering', 'a.hits DESC');
$model->setState('list.direction', 'DESC');
// Set Category Filter

View File

@ -109,6 +109,38 @@ class ContentHelperQuery
$orderby = JFactory::getDbo()->getQuery(true)->Rand();
break;
case 'vote' :
$orderby = 'a.id DESC ';
if (JPluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating_count DESC ';
}
break;
case 'rvote' :
$orderby = 'a.id ASC ';
if (JPluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating_count ASC ';
}
break;
case 'rank' :
$orderby = 'a.id DESC ';
if (JPluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating DESC ';
}
break;
case 'rrank' :
$orderby = 'a.id ASC ';
if (JPluginHelper::isEnabled('content', 'vote'))
{
$orderby = 'rating ASC ';
}
break;
default :
$orderby = 'a.ordering';
break;

View File

@ -254,9 +254,13 @@ class ContentModelArticles extends JModelList
$query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
// Join on voting table
$query->select('ROUND(v.rating_sum / v.rating_count, 0) AS rating, v.rating_count as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
if (JPluginHelper::isEnabled('content', 'vote'))
{
// Join on voting table
$query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating,
COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count')
->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
}
// Join to check for category published state in parent categories up the tree
$query->select('c.published, CASE WHEN badcats.id is null THEN c.published ELSE 0 END AS parents_published');

View File

@ -30,6 +30,10 @@
<option value="hits">JGLOBAL_MOST_HITS</option>
<option value="rhits">JGLOBAL_LEAST_HITS</option>
<option value="order">JGLOBAL_ARTICLE_MANAGER_ORDER</option>
<option value="vote" requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rvote" requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rank" requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="rrank" requires="vote">JGLOBAL_RATINGS_ASC</option>
</field>
<field name="order_date" type="list"

View File

@ -257,6 +257,10 @@
<option value="hits">JGLOBAL_MOST_HITS</option>
<option value="rhits">JGLOBAL_LEAST_HITS</option>
<option value="order">JGLOBAL_ORDERING</option>
<option value="vote" requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rvote" requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rank" requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="rrank" requires="vote">JGLOBAL_RATINGS_ASC</option>
</field>
<field name="order_date" type="list"

View File

@ -263,6 +263,10 @@
<option value="rhits">JGLOBAL_LEAST_HITS</option>
<option value="random">JGLOBAL_RANDOM_ORDER</option>
<option value="order">JGLOBAL_ORDERING</option>
<option value="vote" requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rvote" requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rank" requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="rrank" requires="vote">JGLOBAL_RATINGS_ASC</option>
</field>
<field

View File

@ -200,6 +200,30 @@
<option value="1">JSHOW</option>
</field>
<field name="list_show_votes"
type="list"
class="btn-group btn-group-yesno"
default="0"
label="JGLOBAL_LIST_VOTES_LABEL"
description="JGLOBAL_LIST_VOTES_DESC"
>
<option value="" requires="vote">JGLOBAL_USE_GLOBAL</option>
<option value="1" requires="vote">JSHOW</option>
<option value="0" requires="vote">JHIDE</option>
</field>
<field name="list_show_ratings"
type="list"
class="btn-group btn-group-yesno"
default="0"
label="JGLOBAL_LIST_RATINGS_LABEL"
description="JGLOBAL_LIST_RATINGS_DESC"
>
<option value="" requires="vote">JGLOBAL_USE_GLOBAL</option>
<option value="1" requires="vote">JSHOW</option>
<option value="0" requires="vote">JHIDE</option>
</field>
<field
name="spacer1"
type="spacer"
@ -233,6 +257,10 @@
<option value="rhits">JGLOBAL_LEAST_HITS</option>
<option value="random">JGLOBAL_RANDOM_ORDER</option>
<option value="order">JGLOBAL_ORDERING</option>
<option value="vote" requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rvote" requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rank" requires="vote"> JGLOBAL_RATINGS_DESC</option>
<option value="rrank" requires="vote">JGLOBAL_RATINGS_ASC</option>
</field>
<field name="order_date" type="list"

View File

@ -81,6 +81,8 @@ if (!empty($this->items))
$headerDate = '';
$headerAuthor = '';
$headerHits = '';
$headerVotes = '';
$headerRatings = '';
$headerEdit = '';
?>
<?php if ($this->params->get('show_headings')) : ?>
@ -89,6 +91,8 @@ if (!empty($this->items))
$headerDate = 'headers="categorylist_header_date"';
$headerAuthor = 'headers="categorylist_header_author"';
$headerHits = 'headers="categorylist_header_hits"';
$headerVotes = 'headers="categorylist_header_votes"';
$headerRatings = 'headers="categorylist_header_ratings"';
$headerEdit = 'headers="categorylist_header_edit"';
?>
<thead>
@ -117,6 +121,16 @@ if (!empty($this->items))
<?php echo JHtml::_('grid.sort', 'JGLOBAL_HITS', 'a.hits', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if (($this->params->get('list_show_votes', 0)) && ($this->vote)) : ?>
<th id="categorylist_header_votes">
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_VOTES', 'rating_count', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if (($this->params->get('list_show_ratings', 0)) && ($this->vote)) : ?>
<th id="categorylist_header_ratings">
<?php echo JHtml::_('grid.sort', 'COM_CONTENT_RATINGS', 'rating', $listDirn, $listOrder); ?>
</th>
<?php endif; ?>
<?php if ($isEditable) : ?>
<th id="categorylist_header_edit"><?php echo JText::_('COM_CONTENT_EDIT_ITEM'); ?></th>
<?php endif; ?>
@ -215,12 +229,28 @@ if (!empty($this->items))
<span class="badge badge-info">
<?php echo JText::sprintf('JGLOBAL_HITS_COUNT', $article->hits); ?>
</span>
</td>
<?php endif; ?>
<?php if ($isEditable) : ?>
<td <?php echo $headerEdit; ?> class="list-edit">
<?php if ($article->params->get('access-edit')) : ?>
<?php echo JHtml::_('icon.edit', $article, $params); ?>
</td>
<?php endif; ?>
<?php if (($this->params->get('list_show_votes', 0)) && ($this->vote)) : ?>
<td <?php echo $headerVotes; ?> class="list-votes">
<span class="badge badge-success">
<?php echo JText::sprintf('COM_CONTENT_VOTES_COUNT', $article->rating_count); ?>
</span>
</td>
<?php endif; ?>
<?php if (($this->params->get('list_show_ratings', 0)) && ($this->vote)) : ?>
<td <?php echo $headerRatings; ?> class="list-ratings">
<span class="badge badge-warning">
<?php echo JText::sprintf('COM_CONTENT_RATINGS_COUNT', $article->rating); ?>
</span>
</td>
<?php endif; ?>
<?php if ($isEditable) : ?>
<td <?php echo $headerEdit; ?> class="list-edit">
<?php if ($article->params->get('access-edit')) : ?>
<?php echo JHtml::_('icon.edit', $article, $params); ?>
<?php endif; ?>
</td>
<?php endif; ?>
</td>
<?php endif; ?>
@ -249,5 +279,5 @@ if (!empty($this->items))
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
</form>

View File

@ -77,6 +77,7 @@ class ContentViewCategory extends JViewCategory
$numLeading = $params->def('num_leading_articles', 1);
$numIntro = $params->def('num_intro_articles', 4);
$numLinks = $params->def('num_links', 4);
$this->vote = JPluginHelper::isEnabled('content', 'vote');
// Compute the article slugs and prepare introtext (runs content plugins).
foreach ($this->items as $item)

View File

@ -91,6 +91,10 @@
<option value="hits">JGLOBAL_MOST_HITS</option>
<option value="rhits">JGLOBAL_LEAST_HITS</option>
<option value="order">JGLOBAL_ORDERING</option>
<option value="vote" requires="vote">JGLOBAL_VOTES_DESC</option>
<option value="rvote" requires="vote">JGLOBAL_VOTES_ASC</option>
<option value="rank" requires="vote">JGLOBAL_RATINGS_DESC</option>
<option value="rrank" requires="vote">JGLOBAL_RATINGS_ASC</option>
</field>
<field name="order_date" type="list"

View File

@ -88,3 +88,7 @@ COM_CONTENT_LEFT="Left"
COM_CONTENT_RIGHT="Right"
COM_CONTENT_FIELD_URL_LINK_TEXT_LABEL="Link Text"
COM_CONTENT_IMAGES_AND_URLS="Images and Links"
COM_CONTENT_RATINGS="Rating"
COM_CONTENT_RATINGS_COUNT="Rating: %s"
COM_CONTENT_VOTES="Vote"
COM_CONTENT_VOTES_COUNT="Vote: %s"

View File

@ -88,9 +88,11 @@ MOD_ARTICLES_CATEGORY_OPTION_ONLYFEATURED_VALUE="Only"
MOD_ARTICLES_CATEGORY_OPTION_ORDERING_VALUE="Article Order"
MOD_ARTICLES_CATEGORY_OPTION_ORDERINGFEATURED_VALUE="Featured Articles Order"
MOD_ARTICLES_CATEGORY_OPTION_RANDOM_VALUE="Random"
MOD_ARTICLES_CATEGORY_OPTION_RATING_VALUE="Rating"
MOD_ARTICLES_CATEGORY_OPTION_RELATIVEDAY_VALUE="Relative Date"
MOD_ARTICLES_CATEGORY_OPTION_STARTPUBLISHING_VALUE="Start Publishing Date"
MOD_ARTICLES_CATEGORY_OPTION_FINISHPUBLISHING_VALUE="Finish Publishing Date"
MOD_ARTICLES_CATEGORY_OPTION_VOTE_VALUE="Vote"
MOD_ARTICLES_CATEGORY_OPTION_YEAR_VALUE="Year"
MOD_ARTICLES_CATEGORY_READ_MORE="Read more: "
MOD_ARTICLES_CATEGORY_READ_MORE_TITLE="Read More ..."

View File

@ -117,6 +117,12 @@ class JFormFieldList extends JFormField
{
continue;
}
// Requires vote plugin enabled
if (in_array('vote', $requires) && !JPluginHelper::isEnabled('content', 'vote'))
{
continue;
}
}
$value = (string) $option['value'];

View File

@ -167,14 +167,28 @@ abstract class ModArticlesCategoryHelper
// Ordering
$ordering = $params->get('article_ordering', 'a.ordering');
if (trim($ordering) == 'random')
switch ($ordering)
{
$articles->setState('list.ordering', JFactory::getDbo()->getQuery(true)->Rand());
}
else
{
$articles->setState('list.ordering', $params->get('article_ordering', 'a.ordering'));
$articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC'));
case 'random':
$articles->setState('list.ordering', JFactory::getDbo()->getQuery(true)->Rand());
break;
case 'rating_count':
case 'rating':
$articles->setState('list.ordering', $ordering);
$articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC'));
if (!JPluginHelper::isEnabled('content', 'vote'))
{
$articles->setState('list.ordering', 'a.ordering');
}
break;
default:
$articles->setState('list.ordering', $ordering);
$articles->setState('list.direction', $params->get('article_ordering_direction', 'ASC'));
break;
}
// New Parameters

View File

@ -295,6 +295,8 @@
<option value="publish_up">MOD_ARTICLES_CATEGORY_OPTION_STARTPUBLISHING_VALUE</option>
<option value="a.publish_down">MOD_ARTICLES_CATEGORY_OPTION_FINISHPUBLISHING_VALUE</option>
<option value="random">MOD_ARTICLES_CATEGORY_OPTION_RANDOM_VALUE</option>
<option value="rating_count" requires="vote">MOD_ARTICLES_CATEGORY_OPTION_VOTE_VALUE</option>
<option value="rating" requires="vote">MOD_ARTICLES_CATEGORY_OPTION_RATING_VALUE</option>
</field>
<field