Source for file query.php
Documentation is available at query.php
* @subpackage com_content
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Content Component Query Helper
* @subpackage com_content
* Translate an order code to a field for primary category ordering.
* @param string $orderby The ordering code.
* @return string The SQL field(s) to order by.
$orderby =
'c.path DESC, ';
* Translate an order code to a field for secondary category ordering.
* @param string $orderby The ordering code.
* @param string $orderDate The ordering code for the date.
* @return string The SQL field(s) to order by.
$queryDate =
self::getQueryDate($orderDate);
$orderby =
$queryDate .
' DESC ';
$orderby =
'a.title DESC';
$orderby =
'a.hits DESC';
$orderby =
'author DESC';
$orderby =
'a.featured DESC, fp.ordering';
* Translate an order code to a field for primary category ordering.
* @param string $orderDate The ordering code.
* @return string The SQL field(s) to order by.
$queryDate =
' CASE WHEN a.modified = ' .
$db->quote($db->getNullDate()) .
' THEN a.created ELSE a.modified END';
// use created if publish_up is not set
$queryDate =
' CASE WHEN a.publish_up = ' .
$db->quote($db->getNullDate()) .
' THEN a.created ELSE a.publish_up END ';
$queryDate =
' a.created ';
* Get join information for the voting query.
* @param JRegistry $param An options object for the article.
* @return array A named array with "select" and "join" keys.
$voting =
$params->get('show_vote');
// calculate voting count
$select =
' , ROUND(v.rating_sum / v.rating_count) AS rating, v.rating_count';
$join =
' LEFT JOIN #__content_rating AS v ON a.id = v.content_id';
$results =
array ('select' =>
$select, 'join' =>
$join);
* Method to order the intro articles array for ordering
* down the columns instead of across.
* The layout always lays the introtext articles out across columns.
* Array is reordered so that, when articles are displayed in index order
* across columns in the layout, the result is that the
* desired article ordering is achieved down the columns.
* @param array $articles Array of intro text articles
* @param integer $numColumns Number of columns in the layout
* @return array Reordered array to achieve desired ordering down columns
$count =
count($articles);
// just return the same array if there is nothing to change
if ($numColumns ==
1 ||
!is_array($articles) ||
$count <=
$numColumns)
// we need to re-order the intro articles array
// we need to preserve the original array keys
$maxRows =
ceil($count /
$numColumns);
$numCells =
$maxRows *
$numColumns;
$numEmpty =
$numCells -
$count;
// calculate number of empty cells in the array
// fill in all cells of the array
// put -1 in empty cells so we can skip later
for ($row =
1, $i =
1; $row <=
$maxRows; $row++
)
for ($col =
1; $col <=
$numColumns; $col++
)
if ($numEmpty >
($numCells -
$i))
// put in zero as placeholder
// layout the articles in column order, skipping empty cells
for ($col =
1; ($col <=
$numColumns) &&
($i <
$count); $col++
)
for ($row =
1; ($row <=
$maxRows) &&
($i <
$count); $row++
)
if ($index[$row][$col] != -
1)
$index[$row][$col] =
$keys[$i];
// now read the $index back row by row to get articles in right row/col
// so that they will actually be ordered down the columns (when read by row in the layout)
for ($row =
1; ($row <=
$maxRows) &&
($i <
$count); $row++
)
for ($col =
1; ($col <=
$numColumns) &&
($i <
$count); $col++
)
$return[$keys[$i]] =
$articles[$index[$row][$col]];
Documentation generated on Tue, 19 Nov 2013 15:11:25 +0100 by phpDocumentor 1.4.3