Skip to content

Commit

Permalink
resynch
Browse files Browse the repository at this point in the history
  • Loading branch information
alikon committed Jul 21, 2016
1 parent 50c1ab7 commit 74f875a
Show file tree
Hide file tree
Showing 25 changed files with 258 additions and 32 deletions.
26 changes: 26 additions & 0 deletions administrator/components/com_content/config.xml
Expand Up @@ -788,6 +788,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"
Expand Down Expand Up @@ -832,6 +850,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"
Expand Down
32 changes: 13 additions & 19 deletions administrator/components/com_content/models/articles.php
Expand Up @@ -199,13 +199,23 @@ protected function getListQuery()
$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 = 'a.id, l.title, l.image, uc.name, ag.title, c.title, ua.name, 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.
Expand Down Expand Up @@ -310,26 +320,10 @@ protected function getListQuery()
}

// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'a.id');
$orderCol = empty($this->state->get('list.fullordering', 'a.id')) ? 'a.id' : $this->state->get('list.fullordering', 'a.id');
$orderDirn = $this->state->get('list.direction', 'desc');

if ($orderCol == 'a.ordering' || $orderCol == 'category_title')
{
$orderCol = 'c.title ' . $orderDirn . ', a.ordering';
}

// 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));

return $query;
}
Expand Down
7 changes: 7 additions & 0 deletions administrator/components/com_content/models/featured.php
Expand Up @@ -109,6 +109,13 @@ protected function getListQuery($resolveFKs = true)
$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'))
{
Expand Down
Expand Up @@ -114,6 +114,10 @@
<option value="a.hits DESC">JGLOBAL_HITS_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_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>
</field>
<field
name="limit"
Expand Down
Expand Up @@ -109,6 +109,10 @@
<option value="a.hits DESC">JGLOBAL_HITS_DESC</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_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>
</field>
<field
name="limit"
Expand Down
Expand Up @@ -18,7 +18,7 @@
$app = JFactory::getApplication();
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listOrder = $this->escape($this->state->get('list.ordering', 'a.id'));
$listDirn = $this->escape($this->state->get('list.direction'));
$saveOrder = $listOrder == 'a.ordering';
$columns = 10;
Expand Down Expand Up @@ -86,6 +86,16 @@
<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>
Expand Down Expand Up @@ -199,8 +209,22 @@
<?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>
Expand Down
Expand Up @@ -42,6 +42,7 @@ public function display($tpl = null)
$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')))
Expand Down
Expand Up @@ -17,7 +17,7 @@

$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listOrder = $this->escape($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';
Expand Down Expand Up @@ -77,6 +77,14 @@
<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>
Expand Down Expand Up @@ -184,8 +192,22 @@
<?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>
Expand Down
10 changes: 10 additions & 0 deletions administrator/language/en-GB/en-GB.ini
Expand Up @@ -409,8 +409,12 @@ JGLOBAL_LIST_HITS_DESC="Whether to show 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."
Expand Down Expand Up @@ -463,6 +467,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"
Expand Down Expand Up @@ -566,6 +573,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"

Expand Down
4 changes: 2 additions & 2 deletions administrator/modules/mod_latest/helper.php
Expand Up @@ -40,13 +40,13 @@ public static function getList(&$params)
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;
}
Expand Down
2 changes: 1 addition & 1 deletion administrator/modules/mod_popular/helper.php
Expand Up @@ -37,7 +37,7 @@ public static function getList(&$params)
' 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
Expand Down
32 changes: 32 additions & 0 deletions components/com_content/helpers/query.php
Expand Up @@ -109,6 +109,38 @@ public static function orderbySecondary($orderby, $orderDate = 'created')
$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;
Expand Down
7 changes: 7 additions & 0 deletions components/com_content/models/articles.php
Expand Up @@ -253,6 +253,13 @@ protected function getListQuery()
$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');

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 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');
Expand Down
4 changes: 4 additions & 0 deletions components/com_content/views/archive/tmpl/default.xml
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions components/com_content/views/categories/tmpl/default.xml
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions components/com_content/views/category/tmpl/blog.xml
Expand Up @@ -257,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
Expand Down

0 comments on commit 74f875a

Please sign in to comment.