@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | /********* Filter ********/ |
| 10 | 10 | /** @var string $filterString : string filter for db columns */ |
| 11 | - protected $filterString = ''; |
|
| 11 | + protected $filterString=''; |
|
| 12 | 12 | |
| 13 | 13 | /** @var array $filterColumn : columns to apply filter to */ |
| 14 | - protected $filterColumn = array(); |
|
| 14 | + protected $filterColumn=array(); |
|
| 15 | 15 | |
| 16 | 16 | protected $filterQuery=''; |
| 17 | 17 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | if ($filter != "") $filter.=' OR '; |
| 31 | 31 | //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; |
| 32 | - $filter .= $column . " LIKE '%" . $this->filterString. "%'"; |
|
| 32 | + $filter.=$column." LIKE '%".$this->filterString."%'"; |
|
| 33 | 33 | } |
| 34 | 34 | //echo $filter; |
| 35 | 35 | |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | public function setFilter(string $filter, array $filterCol) |
| 42 | 42 | { |
| 43 | - $this->filterString = $filter; |
|
| 44 | - $this->filterColumn = $filterCol; |
|
| 43 | + $this->filterString=$filter; |
|
| 44 | + $this->filterColumn=$filterCol; |
|
| 45 | 45 | return $this; |
| 46 | 46 | } |
| 47 | 47 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | { |
| 64 | 64 | if (isset($getVars['f'])) |
| 65 | 65 | { |
| 66 | - $this->filterQuery = $getVars['f']; |
|
| 66 | + $this->filterQuery=$getVars['f']; |
|
| 67 | 67 | $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -12,16 +12,16 @@ discard block |
||
| 12 | 12 | use TrapDirectorTableGrouping; |
| 13 | 13 | |
| 14 | 14 | /** @var array $titles table titles (name, display value) */ |
| 15 | - protected $titles = null; |
|
| 15 | + protected $titles=null; |
|
| 16 | 16 | |
| 17 | 17 | /** @var array $content table content (name, sb column name). name index must be the same as $titles*/ |
| 18 | - protected $content = null; |
|
| 18 | + protected $content=null; |
|
| 19 | 19 | |
| 20 | 20 | /** @var array $columnNames names of columns for filtering */ |
| 21 | - protected $columnNames = array(); |
|
| 21 | + protected $columnNames=array(); |
|
| 22 | 22 | |
| 23 | 23 | /** @var mixed $dbConn connection to database */ |
| 24 | - protected $dbConn = null; |
|
| 24 | + protected $dbConn=null; |
|
| 25 | 25 | |
| 26 | 26 | /** Current view **/ |
| 27 | 27 | protected $view; |
@@ -30,21 +30,21 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | // Database stuff |
| 32 | 32 | /** @var array $table (db ref, name) */ |
| 33 | - protected $table = array(); |
|
| 33 | + protected $table=array(); |
|
| 34 | 34 | |
| 35 | 35 | /** @var mixed $query Query in database; */ |
| 36 | - protected $query = null; |
|
| 36 | + protected $query=null; |
|
| 37 | 37 | |
| 38 | - function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath) |
|
| 38 | + function __construct(array $table, array $titles, array $columns, array $columnNames, $dbConn, $view, $urlPath) |
|
| 39 | 39 | { |
| 40 | - $this->table = $table; |
|
| 41 | - $this->titles = $titles; |
|
| 42 | - $this->content = $columns; |
|
| 43 | - $this->columnNames = $columnNames; |
|
| 44 | - $this->dbConn = $dbConn; |
|
| 40 | + $this->table=$table; |
|
| 41 | + $this->titles=$titles; |
|
| 42 | + $this->content=$columns; |
|
| 43 | + $this->columnNames=$columnNames; |
|
| 44 | + $this->dbConn=$dbConn; |
|
| 45 | 45 | |
| 46 | - $this->view = $view; |
|
| 47 | - $this->urlPath = $urlPath; |
|
| 46 | + $this->view=$view; |
|
| 47 | + $this->urlPath=$urlPath; |
|
| 48 | 48 | |
| 49 | 49 | return $this; |
| 50 | 50 | } |
@@ -65,19 +65,19 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | protected function getCurrentURLAndQS(string $caller) |
| 67 | 67 | { |
| 68 | - $actionURL = $this->getCurrentURL() . '?' ; |
|
| 68 | + $actionURL=$this->getCurrentURL().'?'; |
|
| 69 | 69 | $QSList=array(); |
| 70 | 70 | if ($caller != 'filter' && $this->curFilterQuery() != '') |
| 71 | - array_push($QSList , $this->curFilterQuery()); |
|
| 71 | + array_push($QSList, $this->curFilterQuery()); |
|
| 72 | 72 | |
| 73 | 73 | if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') |
| 74 | - array_push($QSList , $this->curPagingQuery()); |
|
| 74 | + array_push($QSList, $this->curPagingQuery()); |
|
| 75 | 75 | |
| 76 | 76 | if ($caller != 'order' && $this->curOrderQuery() != '') |
| 77 | - array_push($QSList , $this->curOrderQuery()); |
|
| 77 | + array_push($QSList, $this->curOrderQuery()); |
|
| 78 | 78 | |
| 79 | 79 | if (count($QSList) != 0) |
| 80 | - $actionURL .= implode('&', $QSList) . '&'; |
|
| 80 | + $actionURL.=implode('&', $QSList).'&'; |
|
| 81 | 81 | |
| 82 | 82 | return $actionURL; |
| 83 | 83 | } |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function getBaseQuery() |
| 91 | 91 | { |
| 92 | - $this->query = $this->dbConn->select(); |
|
| 93 | - $this->query = $this->query->from( |
|
| 92 | + $this->query=$this->dbConn->select(); |
|
| 93 | + $this->query=$this->query->from( |
|
| 94 | 94 | $this->table, |
| 95 | 95 | $this->content |
| 96 | 96 | ); |
@@ -118,10 +118,10 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | public function renderTitles() |
| 120 | 120 | { |
| 121 | - $html = "<thead>\n<tr>\n"; |
|
| 121 | + $html="<thead>\n<tr>\n"; |
|
| 122 | 122 | foreach ($this->titles as $name => $values) |
| 123 | 123 | { |
| 124 | - $titleOrder = $this->titleOrder($name); // TODO : put this as function of order trait |
|
| 124 | + $titleOrder=$this->titleOrder($name); // TODO : put this as function of order trait |
|
| 125 | 125 | if ($titleOrder != NULL) |
| 126 | 126 | { |
| 127 | 127 | if (isset($this->order[$titleOrder])) |
@@ -139,59 +139,59 @@ discard block |
||
| 139 | 139 | { |
| 140 | 140 | $titleOrder.='ASC'; |
| 141 | 141 | } |
| 142 | - $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 143 | - $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; |
|
| 142 | + $actionURL=$this->getCurrentURLAndQS('order').'o='.$titleOrder; |
|
| 143 | + $html.='<th><a href="'.$actionURL.'">'.$values.'</a></th>'; |
|
| 144 | 144 | } |
| 145 | 145 | else |
| 146 | 146 | { |
| 147 | - $html .= '<th>' . $values . '</th>'; |
|
| 147 | + $html.='<th>'.$values.'</th>'; |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | - $html .= "</tr>\n</thead>\n"; |
|
| 150 | + $html.="</tr>\n</thead>\n"; |
|
| 151 | 151 | return $html; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - public function renderLine( $value) |
|
| 154 | + public function renderLine($value) |
|
| 155 | 155 | { |
| 156 | - $html = ''; |
|
| 157 | - $titleNames = array_keys($this->titles); |
|
| 158 | - foreach ($titleNames as $name ) |
|
| 156 | + $html=''; |
|
| 157 | + $titleNames=array_keys($this->titles); |
|
| 158 | + foreach ($titleNames as $name) |
|
| 159 | 159 | { |
| 160 | - $html .= '<td>'; |
|
| 161 | - $html .= $value->$name; |
|
| 162 | - $html .= "</td>\n"; |
|
| 160 | + $html.='<td>'; |
|
| 161 | + $html.=$value->$name; |
|
| 162 | + $html.="</td>\n"; |
|
| 163 | 163 | } |
| 164 | 164 | return $html; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | public function renderTable(array $values) |
| 168 | 168 | { |
| 169 | - $html = '<tbody id="obj_table_body">'; |
|
| 170 | - foreach($values as $value) |
|
| 169 | + $html='<tbody id="obj_table_body">'; |
|
| 170 | + foreach ($values as $value) |
|
| 171 | 171 | { |
| 172 | - $html .= $this->groupingNextLine($value); |
|
| 172 | + $html.=$this->groupingNextLine($value); |
|
| 173 | 173 | |
| 174 | - $html .= "<tr>\n"; |
|
| 175 | - $html .= $this->renderLine($value); |
|
| 176 | - $html .= "</tr>\n"; |
|
| 174 | + $html.="<tr>\n"; |
|
| 175 | + $html.=$this->renderLine($value); |
|
| 176 | + $html.="</tr>\n"; |
|
| 177 | 177 | } |
| 178 | - $html .= '</tbody>'; |
|
| 178 | + $html.='</tbody>'; |
|
| 179 | 179 | return $html; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function render() |
| 183 | 183 | { |
| 184 | - $html = ''; |
|
| 184 | + $html=''; |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | - $values = $this->fullQuery(); |
|
| 187 | + $values=$this->fullQuery(); |
|
| 188 | 188 | $this->initGrouping(); |
| 189 | 189 | |
| 190 | 190 | $html.="<table class='simple common-table table-row-selectable'>\n"; |
| 191 | 191 | |
| 192 | - $html .= $this->renderTitles(); |
|
| 193 | - $html .= $this->renderTable($values); |
|
| 194 | - $html .= '</table>'; |
|
| 192 | + $html.=$this->renderTitles(); |
|
| 193 | + $html.=$this->renderTable($values); |
|
| 194 | + $html.='</table>'; |
|
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | return $html; |
@@ -7,17 +7,17 @@ discard block |
||
| 7 | 7 | { |
| 8 | 8 | |
| 9 | 9 | /*************** Paging *************/ |
| 10 | - protected $maxPerPage = 25; |
|
| 10 | + protected $maxPerPage=25; |
|
| 11 | 11 | |
| 12 | - protected $currentPage = 0; |
|
| 12 | + protected $currentPage=0; |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /***************** Paging and counting *********/ |
| 16 | 16 | |
| 17 | 17 | public function countQuery() |
| 18 | 18 | { |
| 19 | - $this->query = $this->dbConn->select(); |
|
| 20 | - $this->query = $this->query |
|
| 19 | + $this->query=$this->dbConn->select(); |
|
| 20 | + $this->query=$this->query |
|
| 21 | 21 | ->from( |
| 22 | 22 | $this->table, |
| 23 | 23 | array('COUNT(*)') |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function setMaxPerPage(int $max) |
| 35 | 35 | { |
| 36 | - $this->maxPerPage = $max; |
|
| 36 | + $this->maxPerPage=$max; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | protected function getPagingQuery(array $getVars) |
| 40 | 40 | { |
| 41 | 41 | if (isset($getVars['page'])) |
| 42 | 42 | { |
| 43 | - $this->currentPage = $getVars['page']; |
|
| 43 | + $this->currentPage=$getVars['page']; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
@@ -52,22 +52,22 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function renderPagingHeader() |
| 54 | 54 | { |
| 55 | - $count = $this->count(); |
|
| 56 | - if ($count <= $this->maxPerPage ) |
|
| 55 | + $count=$this->count(); |
|
| 56 | + if ($count <= $this->maxPerPage) |
|
| 57 | 57 | { |
| 58 | - return 'count : ' . $this->count() . '<br>'; |
|
| 58 | + return 'count : '.$this->count().'<br>'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if ($this->currentPage == 0) $this->currentPage = 1; |
|
| 61 | + if ($this->currentPage == 0) $this->currentPage=1; |
|
| 62 | 62 | |
| 63 | - $numPages = intdiv($count , $this->maxPerPage); |
|
| 64 | - if ($count % $this->maxPerPage != 0 ) $numPages++; |
|
| 63 | + $numPages=intdiv($count, $this->maxPerPage); |
|
| 64 | + if ($count % $this->maxPerPage != 0) $numPages++; |
|
| 65 | 65 | |
| 66 | - $html = '<div class="pagination-control" role="navigation">'; |
|
| 67 | - $html .= '<ul class="nav tab-nav">'; |
|
| 68 | - if ($this->currentPage <=1) |
|
| 66 | + $html='<div class="pagination-control" role="navigation">'; |
|
| 67 | + $html.='<ul class="nav tab-nav">'; |
|
| 68 | + if ($this->currentPage <= 1) |
|
| 69 | 69 | { |
| 70 | - $html .= ' |
|
| 70 | + $html.=' |
|
| 71 | 71 | <li class="nav-item disabled" aria-hidden="true"> |
| 72 | 72 | <span class="previous-page"> |
| 73 | 73 | <span class="sr-only">Previous page</span> |
@@ -78,24 +78,24 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | else |
| 80 | 80 | { |
| 81 | - $html .= ' |
|
| 81 | + $html.=' |
|
| 82 | 82 | <li class="nav-item"> |
| 83 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" > |
|
| 83 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage - 1).'" class="previous-page" > |
|
| 84 | 84 | <i aria-hidden="true" class="icon-angle-double-left"></i> |
| 85 | 85 | </a> |
| 86 | 86 | </li> |
| 87 | 87 | '; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - for ($i=1; $i <= $numPages ; $i++) |
|
| 90 | + for ($i=1; $i <= $numPages; $i++) |
|
| 91 | 91 | { |
| 92 | - $active = ($this->currentPage == $i) ? 'active' : ''; |
|
| 93 | - $first = ($i-1)*$this->maxPerPage+1; |
|
| 94 | - $last = $i * $this->maxPerPage; |
|
| 95 | - if ($last > $count) $last = $count; |
|
| 96 | - $display = 'Show rows '. $first . ' to '. $last .' of '. $count; |
|
| 97 | - $html .= '<li class="' . $active . ' nav-item"> |
|
| 98 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '"> |
|
| 92 | + $active=($this->currentPage == $i) ? 'active' : ''; |
|
| 93 | + $first=($i - 1) * $this->maxPerPage + 1; |
|
| 94 | + $last=$i * $this->maxPerPage; |
|
| 95 | + if ($last > $count) $last=$count; |
|
| 96 | + $display='Show rows '.$first.' to '.$last.' of '.$count; |
|
| 97 | + $html.='<li class="'.$active.' nav-item"> |
|
| 98 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.$i.'" title="'.$display.'" aria-label="'.$display.'"> |
|
| 99 | 99 | '.$i.' |
| 100 | 100 | </a> |
| 101 | 101 | </li>'; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | if ($this->currentPage == $numPages) |
| 105 | 105 | { |
| 106 | - $html .= ' |
|
| 106 | + $html.=' |
|
| 107 | 107 | <li class="nav-item disabled" aria-hidden="true"> |
| 108 | 108 | <span class="previous-page"> |
| 109 | 109 | <span class="sr-only">Previous page</span> |
@@ -114,23 +114,23 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | else |
| 116 | 116 | { |
| 117 | - $html .= ' |
|
| 117 | + $html.=' |
|
| 118 | 118 | <li class="nav-item"> |
| 119 | - <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page"> |
|
| 119 | + <a href="'. $this->getCurrentURLAndQS('paging').'&page='.($this->currentPage + 1).'" class="next-page"> |
|
| 120 | 120 | <i aria-hidden="true" class="icon-angle-double-right"></i> |
| 121 | 121 | </a> |
| 122 | 122 | </li> |
| 123 | 123 | '; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $html .= '</ul> </div>'; |
|
| 126 | + $html.='</ul> </div>'; |
|
| 127 | 127 | |
| 128 | 128 | return $html; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | public function applyPaging() |
| 132 | 132 | { |
| 133 | - $this->query->limitPage($this->currentPage,$this->maxPerPage); |
|
| 133 | + $this->query->limitPage($this->currentPage, $this->maxPerPage); |
|
| 134 | 134 | return $this; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | trait TrapDirectorTableOrder |
| 7 | 7 | { |
| 8 | 8 | /** @var array $order : (db column, 'ASC' | 'DESC') */ |
| 9 | - protected $order = array(); |
|
| 10 | - protected $orderQuery = ''; |
|
| 9 | + protected $order=array(); |
|
| 10 | + protected $orderQuery=''; |
|
| 11 | 11 | |
| 12 | 12 | /***************** Ordering ********************/ |
| 13 | 13 | |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | if ($orderSQL != "") $orderSQL.=','; |
| 24 | 24 | |
| 25 | - $orderSQL .= $column . ' ' . $direction; |
|
| 25 | + $orderSQL.=$column.' '.$direction; |
|
| 26 | 26 | } |
| 27 | - $this->query = $this->query->order($orderSQL); |
|
| 27 | + $this->query=$this->query->order($orderSQL); |
|
| 28 | 28 | |
| 29 | 29 | return $this; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function setOrder(array $order) |
| 33 | 33 | { |
| 34 | - $this->order = $order; |
|
| 34 | + $this->order=$order; |
|
| 35 | 35 | return $this; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | if (isset($getVars['o'])) |
| 47 | 47 | { |
| 48 | - $this->orderQuery = $getVars['o']; |
|
| 49 | - $match = array(); |
|
| 50 | - if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) |
|
| 48 | + $this->orderQuery=$getVars['o']; |
|
| 49 | + $match=array(); |
|
| 50 | + if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery, $match)) |
|
| 51 | 51 | { |
| 52 | 52 | $orderArray=array($match[1] => $match[2]); |
| 53 | 53 | echo "$match[1] => $match[2]"; |
@@ -20,31 +20,31 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function setGrouping($columnDBName) |
| 22 | 22 | { |
| 23 | - $this->groupingColumn = $columnDBName; |
|
| 24 | - $this->grouppingActive = TRUE; |
|
| 23 | + $this->groupingColumn=$columnDBName; |
|
| 24 | + $this->grouppingActive=TRUE; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function initGrouping() |
| 28 | 28 | { |
| 29 | - $this->groupingVal = ''; |
|
| 30 | - $this->groupingColSpan = count($this->titles); |
|
| 29 | + $this->groupingVal=''; |
|
| 30 | + $this->groupingColSpan=count($this->titles); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function groupingPrintData( $value) |
|
| 33 | + public function groupingPrintData($value) |
|
| 34 | 34 | { |
| 35 | - $html = "$value"; |
|
| 35 | + $html="$value"; |
|
| 36 | 36 | return $html; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function groupingNextLine( $values) |
|
| 39 | + public function groupingNextLine($values) |
|
| 40 | 40 | { |
| 41 | 41 | if ($this->grouppingActive === FALSE) return ''; |
| 42 | 42 | |
| 43 | - $dbcol = $this->groupingColumn; |
|
| 44 | - if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol ) |
|
| 43 | + $dbcol=$this->groupingColumn; |
|
| 44 | + if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol) |
|
| 45 | 45 | { |
| 46 | - $this->groupingVal = $values->$dbcol; |
|
| 47 | - $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>'; |
|
| 46 | + $this->groupingVal=$values->$dbcol; |
|
| 47 | + $html='<tr><th colspan="'.$this->groupingColSpan.'">'.$this->groupingPrintData($this->groupingVal).'</th></tr>'; |
|
| 48 | 48 | return $html; |
| 49 | 49 | } |
| 50 | 50 | return ''; |