Skip to content

Commit

Permalink
Replace reorder parameter $alternative to object var $_large_ordering…
Browse files Browse the repository at this point in the history
…_number
  • Loading branch information
Tomasz Narloch committed Jul 27, 2016
1 parent cf473c1 commit 1d2beb0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 38 deletions.
24 changes: 8 additions & 16 deletions administrator/components/com_content/tables/featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
*/
class ContentTableFeatured extends JTable
{
/**
* Indicator that the column ordering use large numbers.
*
* @var boolean
* @since 3.6.1
*/
protected $_large_ordering_numbers = true;

/**
* Constructor
*
Expand All @@ -27,20 +35,4 @@ public function __construct(&$db)
{
parent::__construct('#__content_frontpage', 'content_id', $db);
}

/**
* Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.
*
* @param string $where WHERE clause to use for limiting the selection of rows to compact the ordering values.
* @param boolean $alternative True to use a more efficient alternative.
*
* @return mixed Boolean True on success.
*
* @since 3.6.1
* @throws UnexpectedValueException
*/
public function reorder($where = '', $alternative = true)
{
return parent::reorder($where, $alternative);
}
}
19 changes: 13 additions & 6 deletions libraries/joomla/table/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ abstract class JTable extends JObject implements JObservableInterface, JTableInt
*/
protected $_jsonEncode = array();

/**
* Indicator that the column ordering use large numbers.
*
* @var boolean
* @since 3.6.1
*/
protected $_large_ordering_numbers = false;

/**
* Object constructor to set table and key fields. In most cases this will
* be overridden by child classes to explicitly set the table and key fields
Expand Down Expand Up @@ -1277,7 +1285,7 @@ public function isCheckedOut($with = 0, $against = null)
*
* @return integer The first free ordering value.
*
* @since 3.6
* @since 3.6.1
* @throws UnexpectedValueException
*/
public function getEarlierOrder($where = '')
Expand Down Expand Up @@ -1371,15 +1379,14 @@ public function getPrimaryKey(array $keys = array())
/**
* Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.
*
* @param string $where WHERE clause to use for limiting the selection of rows to compact the ordering values.
* @param boolean $alternative True to use a more efficient alternative.
* @param string $where WHERE clause to use for limiting the selection of rows to compact the ordering values.
*
* @return mixed Boolean True on success.
*
* @since 11.1
* @throws UnexpectedValueException
*/
public function reorder($where = '', $alternative = false)
public function reorder($where = '')
{
// If there is no ordering field set an error and return false.
if (!property_exists($this, 'ordering'))
Expand All @@ -1390,7 +1397,7 @@ public function reorder($where = '', $alternative = false)
$k = $this->_tbl_key;

// To use more efficient alternative sort in descending order
$order_by = $alternative ? 'ordering DESC' : 'ordering';
$order_by = $this->_large_ordering_numbers ? 'ordering DESC' : 'ordering';

// Get the primary keys and ordering values for the selection.
$query = $this->_db->getQuery(true)
Expand All @@ -1417,7 +1424,7 @@ public function reorder($where = '', $alternative = false)
// Make sure the ordering is a positive integer.
if ($row->ordering >= 0)
{
$ordering = $alternative ? ($last - $i - 1) : ($i + 1);
$ordering = $this->_large_ordering_numbers ? ($last - $i - 1) : ($i + 1);

// Only update rows that are necessary.
if ($row->ordering != $ordering)
Expand Down
24 changes: 8 additions & 16 deletions libraries/legacy/table/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
*/
class JTableContent extends JTable
{
/**
* Indicator that the column ordering use large numbers.
*
* @var boolean
* @since 3.6.1
*/
protected $_large_ordering_numbers = true;

/**
* Constructor
*
Expand Down Expand Up @@ -345,20 +353,4 @@ public function store($updateNulls = false)

return parent::store($updateNulls);
}

/**
* Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.
*
* @param string $where WHERE clause to use for limiting the selection of rows to compact the ordering values.
* @param boolean $alternative True to use a more efficient alternative.
*
* @return mixed Boolean True on success.
*
* @since 3.6.1
* @throws UnexpectedValueException
*/
public function reorder($where = '', $alternative = true)
{
return parent::reorder($where, $alternative);
}
}

0 comments on commit 1d2beb0

Please sign in to comment.