Skip to content

Commit

Permalink
Add a new function
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsanabbasimov committed Sep 20, 2016
1 parent 7bbd779 commit dfe2688
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/PhpTableGenerator/HeadCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,26 @@ public function getSortDir()
}

/**
* @param string $sortDir
* @param $sortDir
*/
public function setSortDir($sortDir)
{
$this->sortDir = $sortDir === 'asc' ? 'asc' : 'desc';
$this->sortDir = (strtolower($sortDir) === 'asc') ? 'asc' : 'desc';
}

/**
* According the current sorting direction, alias, and etc return
* the next sorting direction
*
* @return string
*/
public function getNewSortDir()
{
$alias = $this->getAlias();
$sortBy = $this->getSortBy();
$sortDir = $this->getSortDir();

return ($alias === $sortBy && $sortDir === 'asc') ? 'desc' : 'asc';
}

/**
Expand Down Expand Up @@ -238,9 +253,8 @@ public function getContent()

$alias = $this->getAlias();
$sortBy = $this->getSortBy();
$sortDir = $this->getSortDir();

$newSortDir = ($alias === $sortBy && $sortDir === 'asc') ? 'desc' : 'asc';

$newSortDir = $this->getNewSortDir();

$sortFunction = $config->getConfig('sorterJSFunction');

Expand Down

0 comments on commit dfe2688

Please sign in to comment.