| Total Complexity | 12 | 
| Total Lines | 57 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 6 | trait TrapDirectorTableOrder | ||
| 7 | {  | ||
| 8 | /** @var array $order : (db column, 'ASC' | 'DESC') */ | ||
| 9 | protected $order = array(); | ||
| 10 | protected $orderQuery = ''; | ||
| 11 | |||
| 12 | /***************** Ordering ********************/ | ||
| 13 | |||
| 14 | public function applyOrder() | ||
| 15 |     { | ||
| 16 | if (count($this->order) == 0) | ||
| 17 |         { | ||
| 18 | return $this; | ||
| 19 | } | ||
| 20 | $orderSQL=''; | ||
| 21 | foreach ($this->order as $column => $direction) | ||
| 22 |         { | ||
| 23 | if ($orderSQL != "") $orderSQL.=','; | ||
| 24 | |||
| 25 | $orderSQL .= $column . ' ' . $direction; | ||
| 26 | } | ||
| 27 | $this->query = $this->query->order($orderSQL); | ||
|  | |||
| 28 | |||
| 29 | return $this; | ||
| 30 | } | ||
| 31 | |||
| 32 | public function setOrder(array $order) | ||
| 36 | } | ||
| 37 | |||
| 38 | public function isOrderSet() | ||
| 39 |     { | ||
| 40 | if (count($this->order) == 0) return FALSE; | ||
| 41 | return TRUE; | ||
| 42 | } | ||
| 43 | |||
| 44 | public function getOrderQuery(array $getVars) | ||
| 45 |     { | ||
| 46 | if (isset($getVars['o'])) | ||
| 47 |         { | ||
| 48 | $this->orderQuery = $getVars['o']; | ||
| 49 | $match = array(); | ||
| 50 |             if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) | ||
| 51 |             { | ||
| 52 | $orderArray=array($match[1] => $match[2]); | ||
| 53 | echo "$match[1] => $match[2]"; | ||
| 54 | $this->setOrder($orderArray); | ||
| 55 | } | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | protected function curOrderQuery() | ||
| 63 | } | ||
| 64 | |||
| 65 | } |