diff --git a/administrator/components/com_content/config.xml b/administrator/components/com_content/config.xml index 41d2f1203edbf..9b27e940bc543 100644 --- a/administrator/components/com_content/config.xml +++ b/administrator/components/com_content/config.xml @@ -786,6 +786,24 @@ + + + + + + + + + +
JGLOBAL_LEAST_HITS + + + + 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 @@ protected function getListQuery() $orderCol = $this->state->get('list.ordering', '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') + if (JPluginHelper::isEnabled('content', 'vote')) { - $orderCol = 'ag.title'; + $orderCol = empty($this->state->get('list.fullordering', 'a.id')) ? 'a.id' : $this->state->get('list.fullordering', 'a.id'); + $orderDirn = ''; } - $query->order($db->escape($orderCol . ' ' . $orderDirn)); + $query->order($db->escape($orderCol) . ' ' . $orderDirn); return $query; } diff --git a/administrator/components/com_content/models/featured.php b/administrator/components/com_content/models/featured.php index f5d2ef8faeb59..16df710dfbc45 100644 --- a/administrator/components/com_content/models/featured.php +++ b/administrator/components/com_content/models/featured.php @@ -109,6 +109,14 @@ 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')) { diff --git a/administrator/components/com_content/models/forms/filter_articles.xml b/administrator/components/com_content/models/forms/filter_articles.xml index 51e0dca100994..f8afdfe735446 100644 --- a/administrator/components/com_content/models/forms/filter_articles.xml +++ b/administrator/components/com_content/models/forms/filter_articles.xml @@ -112,6 +112,10 @@ + + + + diff --git a/administrator/components/com_content/models/forms/filter_featured.xml b/administrator/components/com_content/models/forms/filter_featured.xml index 1982c54a48839..f47211bb809ea 100644 --- a/administrator/components/com_content/models/forms/filter_featured.xml +++ b/administrator/components/com_content/models/forms/filter_featured.xml @@ -107,6 +107,10 @@ + + + + diff --git a/administrator/components/com_content/views/articles/tmpl/default.php b/administrator/components/com_content/views/articles/tmpl/default.php index 9b2876b9a3760..70bc8d17252c3 100644 --- a/administrator/components/com_content/views/articles/tmpl/default.php +++ b/administrator/components/com_content/views/articles/tmpl/default.php @@ -18,7 +18,7 @@ $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 @@ + vote) : ?> + + + + + + + + + @@ -199,8 +209,22 @@ created, JText::_('DATE_FORMAT_LC4')); ?> - hits; ?> + + hits; ?> + + vote) : ?> + + + rating_count; ?> + + + + + rating; ?> + + + id; ?> diff --git a/administrator/components/com_content/views/articles/view.html.php b/administrator/components/com_content/views/articles/view.html.php index f72919292456a..116dd98b0de77 100644 --- a/administrator/components/com_content/views/articles/view.html.php +++ b/administrator/components/com_content/views/articles/view.html.php @@ -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'))) diff --git a/administrator/components/com_content/views/featured/tmpl/default.php b/administrator/components/com_content/views/featured/tmpl/default.php index 161469ce2be31..f155658bd876b 100644 --- a/administrator/components/com_content/views/featured/tmpl/default.php +++ b/administrator/components/com_content/views/featured/tmpl/default.php @@ -17,7 +17,7 @@ $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 @@ + vote) : ?> + + + + + + + @@ -184,8 +192,22 @@ created, JText::_('DATE_FORMAT_LC4')); ?> + hits; ?> + + vote) : ?> + + + rating_count; ?> + + + + + rating; ?> + + + id; ?> diff --git a/administrator/components/com_content/views/featured/view.html.php b/administrator/components/com_content/views/featured/view.html.php index d47b64a54b258..eb4718c375ace 100644 --- a/administrator/components/com_content/views/featured/view.html.php +++ b/administrator/components/com_content/views/featured/view.html.php @@ -39,6 +39,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'))) diff --git a/administrator/language/en-GB/en-GB.ini b/administrator/language/en-GB/en-GB.ini index 2f30d77f274d0..e8a6ba700215c 100644 --- a/administrator/language/en-GB/en-GB.ini +++ b/administrator/language/en-GB/en-GB.ini @@ -410,8 +410,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="(Note: %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="<" JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC="The number of subcategory levels to display." @@ -464,6 +468,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" @@ -567,6 +574,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" diff --git a/administrator/modules/mod_latest/helper.php b/administrator/modules/mod_latest/helper.php index ea59efc5b8946..9dc0a0172b821 100644 --- a/administrator/modules/mod_latest/helper.php +++ b/administrator/modules/mod_latest/helper.php @@ -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; } diff --git a/administrator/modules/mod_popular/helper.php b/administrator/modules/mod_popular/helper.php index 9a72c4b740aa0..8591798606892 100644 --- a/administrator/modules/mod_popular/helper.php +++ b/administrator/modules/mod_popular/helper.php @@ -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 diff --git a/components/com_content/helpers/query.php b/components/com_content/helpers/query.php index bcb789bc03142..e7f11a50a5354 100644 --- a/components/com_content/helpers/query.php +++ b/components/com_content/helpers/query.php @@ -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; diff --git a/components/com_content/models/articles.php b/components/com_content/models/articles.php index 15d0fa8f61967..e8a282c68a947 100644 --- a/components/com_content/models/articles.php +++ b/components/com_content/models/articles.php @@ -253,9 +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'); - // 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'); diff --git a/components/com_content/views/archive/tmpl/default.xml b/components/com_content/views/archive/tmpl/default.xml index 3da7861688405..b067559fbde59 100644 --- a/components/com_content/views/archive/tmpl/default.xml +++ b/components/com_content/views/archive/tmpl/default.xml @@ -30,6 +30,10 @@ + + + + JGLOBAL_MOST_HITS + + + + JGLOBAL_LEAST_HITS + + + + JSHOW + + + + + + + + + + + + JGLOBAL_LEAST_HITS + + + + params->get('show_headings')) : ?> @@ -89,6 +91,8 @@ $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"'; ?> @@ -117,6 +121,16 @@ + params->get('list_show_votes', 0)) && ($this->vote)) : ?> + + + + + params->get('list_show_ratings', 0)) && ($this->vote)) : ?> + + + + @@ -191,12 +205,28 @@ hits); ?> - - - - class="list-edit"> - params->get('access-edit')) : ?> - + + + params->get('list_show_votes', 0)) && ($this->vote)) : ?> + class="list-votes"> + + rating_count); ?> + + + + params->get('list_show_ratings', 0)) && ($this->vote)) : ?> + class="list-ratings"> + + rating); ?> + + + + + class="list-edit"> + params->get('access-edit')) : ?> + + + @@ -225,5 +255,5 @@ pagination->getPagesLinks(); ?> - + diff --git a/components/com_content/views/category/view.html.php b/components/com_content/views/category/view.html.php index 4b65b92a0e292..4e9bb7e2a3fee 100644 --- a/components/com_content/views/category/view.html.php +++ b/components/com_content/views/category/view.html.php @@ -77,6 +77,7 @@ public function display($tpl = null) $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) diff --git a/components/com_content/views/featured/tmpl/default.xml b/components/com_content/views/featured/tmpl/default.xml index b62b0c6fc2273..1740432025e17 100644 --- a/components/com_content/views/featured/tmpl/default.xml +++ b/components/com_content/views/featured/tmpl/default.xml @@ -91,6 +91,10 @@ + + + + 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 diff --git a/modules/mod_articles_category/mod_articles_category.xml b/modules/mod_articles_category/mod_articles_category.xml index b9275f74950f3..c9da4d5bd00e7 100644 --- a/modules/mod_articles_category/mod_articles_category.xml +++ b/modules/mod_articles_category/mod_articles_category.xml @@ -295,6 +295,8 @@ + +