| @@ -5,299 +5,299 @@ discard block | ||
| 5 | 5 | |
| 6 | 6 | abstract class TrapDirectorTable | 
| 7 | 7 |  { | 
| 8 | - /** @var array $titles table titles (name, display value) */ | |
| 9 | - protected $titles = null; | |
| 8 | + /** @var array $titles table titles (name, display value) */ | |
| 9 | + protected $titles = null; | |
| 10 | 10 | |
| 11 | - /** @var array $content table content (name, sb column name). name index must be the same as $titles*/ | |
| 12 | - protected $content = null; | |
| 11 | + /** @var array $content table content (name, sb column name). name index must be the same as $titles*/ | |
| 12 | + protected $content = null; | |
| 13 | 13 | |
| 14 | - /** @var array $columnNames names of columns for filtering */ | |
| 15 | - protected $columnNames = array(); | |
| 14 | + /** @var array $columnNames names of columns for filtering */ | |
| 15 | + protected $columnNames = array(); | |
| 16 | 16 | |
| 17 | - /** @var mixed $dbConn connection to database */ | |
| 18 | - protected $dbConn = null; | |
| 17 | + /** @var mixed $dbConn connection to database */ | |
| 18 | + protected $dbConn = null; | |
| 19 | 19 | |
| 20 | - /** Current view **/ | |
| 21 | - protected $view; | |
| 20 | + /** Current view **/ | |
| 21 | + protected $view; | |
| 22 | 22 | |
| 23 | - protected $urlPath; | |
| 23 | + protected $urlPath; | |
| 24 | 24 | |
| 25 | - // Database stuff | |
| 25 | + // Database stuff | |
| 26 | 26 | /** @var array $table (db ref, name) */ | 
| 27 | - protected $table = array(); | |
| 27 | + protected $table = array(); | |
| 28 | 28 | |
| 29 | - /** @var mixed $query Query in database; */ | |
| 30 | - protected $query = null; | |
| 29 | + /** @var mixed $query Query in database; */ | |
| 30 | + protected $query = null; | |
| 31 | 31 | |
| 32 | - /** @var array $order : (db column, 'ASC' | 'DESC') */ | |
| 33 | - protected $order = array(); | |
| 34 | - protected $orderQuery = ''; | |
| 32 | + /** @var array $order : (db column, 'ASC' | 'DESC') */ | |
| 33 | + protected $order = array(); | |
| 34 | + protected $orderQuery = ''; | |
| 35 | 35 | |
| 36 | - /********* Filter ********/ | |
| 37 | - /** @var string $filterString : string filter for db columns */ | |
| 38 | - protected $filterString = ''; | |
| 36 | + /********* Filter ********/ | |
| 37 | + /** @var string $filterString : string filter for db columns */ | |
| 38 | + protected $filterString = ''; | |
| 39 | 39 | |
| 40 | - /** @var array $filterColumn : columns to apply filter to */ | |
| 41 | - protected $filterColumn = array(); | |
| 40 | + /** @var array $filterColumn : columns to apply filter to */ | |
| 41 | + protected $filterColumn = array(); | |
| 42 | 42 | |
| 43 | - protected $filterQuery=''; | |
| 43 | + protected $filterQuery=''; | |
| 44 | 44 | |
| 45 | - /*************** Paging *************/ | |
| 46 | - protected $maxPerPage = 25; | |
| 45 | + /*************** Paging *************/ | |
| 46 | + protected $maxPerPage = 25; | |
| 47 | 47 | |
| 48 | - protected $currentPage = 0; | |
| 48 | + protected $currentPage = 0; | |
| 49 | 49 | |
| 50 | - /*************** Grouping ************/ | |
| 51 | - protected $grouppingActive=false; | |
| 50 | + /*************** Grouping ************/ | |
| 51 | + protected $grouppingActive=false; | |
| 52 | 52 | |
| 53 | - protected $groupingColumn=''; | |
| 53 | + protected $groupingColumn=''; | |
| 54 | 54 | |
| 55 | - protected $groupingVal=''; | |
| 55 | + protected $groupingVal=''; | |
| 56 | 56 | |
| 57 | - protected $groupingColSpan=1; | |
| 57 | + protected $groupingColSpan=1; | |
| 58 | 58 | |
| 59 | - function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath) | |
| 60 | -    { | |
| 61 | - $this->table = $table; | |
| 62 | - $this->titles = $titles; | |
| 63 | - $this->content = $columns; | |
| 64 | - $this->columnNames = $columnNames; | |
| 65 | - $this->dbConn = $dbConn; | |
| 59 | + function __construct(array $table,array $titles, array $columns, array $columnNames, $dbConn , $view, $urlPath) | |
| 60 | +	{ | |
| 61 | + $this->table = $table; | |
| 62 | + $this->titles = $titles; | |
| 63 | + $this->content = $columns; | |
| 64 | + $this->columnNames = $columnNames; | |
| 65 | + $this->dbConn = $dbConn; | |
| 66 | 66 | |
| 67 | - $this->view = $view; | |
| 68 | - $this->urlPath = $urlPath; | |
| 67 | + $this->view = $view; | |
| 68 | + $this->urlPath = $urlPath; | |
| 69 | 69 | |
| 70 | - return $this; | |
| 71 | - } | |
| 70 | + return $this; | |
| 71 | + } | |
| 72 | 72 | |
| 73 | 73 | |
| 74 | - /************** GET variables and URLs *************/ | |
| 75 | - public function getParams(array $getVars) | |
| 76 | -    { | |
| 77 | - $this->getFilterQuery($getVars); | |
| 78 | - $this->getPagingQuery($getVars); | |
| 79 | - $this->getOrderQuery($getVars); | |
| 80 | - } | |
| 81 | - | |
| 82 | - public function getCurrentURL() | |
| 83 | -    { | |
| 84 | - return '?'; | |
| 85 | - } | |
| 86 | - | |
| 87 | - protected function getCurrentURLAndQS(string $caller) | |
| 88 | -    { | |
| 89 | - $actionURL = $this->getCurrentURL() . '?' ; | |
| 90 | - $QSList=array(); | |
| 91 | - if ($caller != 'filter' && $this->curFilterQuery() != '') | |
| 92 | - array_push($QSList , $this->curFilterQuery()); | |
| 74 | + /************** GET variables and URLs *************/ | |
| 75 | + public function getParams(array $getVars) | |
| 76 | +	{ | |
| 77 | + $this->getFilterQuery($getVars); | |
| 78 | + $this->getPagingQuery($getVars); | |
| 79 | + $this->getOrderQuery($getVars); | |
| 80 | + } | |
| 81 | + | |
| 82 | + public function getCurrentURL() | |
| 83 | +	{ | |
| 84 | + return '?'; | |
| 85 | + } | |
| 86 | + | |
| 87 | + protected function getCurrentURLAndQS(string $caller) | |
| 88 | +	{ | |
| 89 | + $actionURL = $this->getCurrentURL() . '?' ; | |
| 90 | + $QSList=array(); | |
| 91 | + if ($caller != 'filter' && $this->curFilterQuery() != '') | |
| 92 | + array_push($QSList , $this->curFilterQuery()); | |
| 93 | 93 | |
| 94 | - if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') | |
| 95 | - array_push($QSList , $this->curPagingQuery()); | |
| 94 | + if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') | |
| 95 | + array_push($QSList , $this->curPagingQuery()); | |
| 96 | 96 | |
| 97 | - if ($caller != 'order' && $this->curOrderQuery() != '') | |
| 98 | - array_push($QSList , $this->curOrderQuery()); | |
| 97 | + if ($caller != 'order' && $this->curOrderQuery() != '') | |
| 98 | + array_push($QSList , $this->curOrderQuery()); | |
| 99 | 99 | |
| 100 | - if (count($QSList) != 0) | |
| 101 | -            $actionURL .=  implode('&', $QSList) . '&'; | |
| 100 | + if (count($QSList) != 0) | |
| 101 | +			$actionURL .=  implode('&', $QSList) . '&'; | |
| 102 | 102 | |
| 103 | - return $actionURL; | |
| 104 | - } | |
| 105 | - | |
| 106 | - /************* DB queries ******************/ | |
| 107 | - /** | |
| 108 | - * Get base query in $this->query | |
| 109 | - * @return TrapDirectorTable | |
| 110 | - */ | |
| 111 | - public function getBaseQuery() | |
| 112 | -    { | |
| 113 | - $this->query = $this->dbConn->select(); | |
| 114 | - $this->query = $this->query->from( | |
| 115 | - $this->table, | |
| 116 | - $this->content | |
| 117 | - ); | |
| 103 | + return $actionURL; | |
| 104 | + } | |
| 105 | + | |
| 106 | + /************* DB queries ******************/ | |
| 107 | + /** | |
| 108 | + * Get base query in $this->query | |
| 109 | + * @return TrapDirectorTable | |
| 110 | + */ | |
| 111 | + public function getBaseQuery() | |
| 112 | +	{ | |
| 113 | + $this->query = $this->dbConn->select(); | |
| 114 | + $this->query = $this->query->from( | |
| 115 | + $this->table, | |
| 116 | + $this->content | |
| 117 | + ); | |
| 118 | 118 | |
| 119 | - return $this; | |
| 120 | - } | |
| 121 | - | |
| 122 | - public function fullQuery() | |
| 123 | -    { | |
| 124 | - $this->getBaseQuery() | |
| 125 | - ->applyFilter() | |
| 126 | - ->applyPaging() | |
| 127 | - ->applyOrder(); | |
| 119 | + return $this; | |
| 120 | + } | |
| 121 | + | |
| 122 | + public function fullQuery() | |
| 123 | +	{ | |
| 124 | + $this->getBaseQuery() | |
| 125 | + ->applyFilter() | |
| 126 | + ->applyPaging() | |
| 127 | + ->applyOrder(); | |
| 128 | 128 | |
| 129 | - return $this->dbConn->fetchAll($this->query); | |
| 130 | - //return $this->query->fetchAll(); | |
| 131 | - } | |
| 132 | - | |
| 133 | - | |
| 134 | - /**************** Filtering ******************/ | |
| 135 | - | |
| 136 | - public function applyFilter() | |
| 137 | -    { | |
| 138 | - if ($this->filterString == '' || count($this->filterColumn) == 0) | |
| 139 | -        { | |
| 140 | - return $this; | |
| 141 | - } | |
| 142 | - $filter=''; | |
| 143 | - foreach ($this->filterColumn as $column) | |
| 144 | -        { | |
| 145 | - if ($filter != "") $filter.=' OR '; | |
| 146 | - //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; | |
| 147 | - $filter .= $column . " LIKE '%" . $this->filterString. "%'"; | |
| 148 | - } | |
| 149 | - //echo $filter; | |
| 129 | + return $this->dbConn->fetchAll($this->query); | |
| 130 | + //return $this->query->fetchAll(); | |
| 131 | + } | |
| 132 | + | |
| 133 | + | |
| 134 | + /**************** Filtering ******************/ | |
| 135 | + | |
| 136 | + public function applyFilter() | |
| 137 | +	{ | |
| 138 | + if ($this->filterString == '' || count($this->filterColumn) == 0) | |
| 139 | +		{ | |
| 140 | + return $this; | |
| 141 | + } | |
| 142 | + $filter=''; | |
| 143 | + foreach ($this->filterColumn as $column) | |
| 144 | +		{ | |
| 145 | + if ($filter != "") $filter.=' OR '; | |
| 146 | + //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; | |
| 147 | + $filter .= $column . " LIKE '%" . $this->filterString. "%'"; | |
| 148 | + } | |
| 149 | + //echo $filter; | |
| 150 | 150 | |
| 151 | - $this->query=$this->query->where($filter); | |
| 151 | + $this->query=$this->query->where($filter); | |
| 152 | 152 | |
| 153 | - return $this; | |
| 154 | - } | |
| 153 | + return $this; | |
| 154 | + } | |
| 155 | 155 | |
| 156 | - public function setFilter(string $filter, array $filterCol) | |
| 157 | -    { | |
| 158 | - $this->filterString = $filter; | |
| 159 | - $this->filterColumn = $filterCol; | |
| 160 | - return $this; | |
| 161 | - } | |
| 156 | + public function setFilter(string $filter, array $filterCol) | |
| 157 | +	{ | |
| 158 | + $this->filterString = $filter; | |
| 159 | + $this->filterColumn = $filterCol; | |
| 160 | + return $this; | |
| 161 | + } | |
| 162 | 162 | |
| 163 | - public function renderFilter() | |
| 164 | -    { | |
| 163 | + public function renderFilter() | |
| 164 | +	{ | |
| 165 | 165 | |
| 166 | - $html=' <form id="genfilter" name="mainFilterGen" | |
| 166 | + $html=' <form id="genfilter" name="mainFilterGen" | |
| 167 | 167 | enctype="application/x-www-form-urlencoded" | 
| 168 | 168 |  			action="'.$this->getCurrentURLAndQS('filter').'" | 
| 169 | 169 | method="get">'; | 
| 170 | - $html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words" | |
| 170 | + $html.='<input type="text" name="f" title="Search is simple! Try to combine multiple words" | |
| 171 | 171 | placeholder="Search..." value="'.$this->filterQuery.'">'; | 
| 172 | 172 | |
| 173 | - $html.='</form>'; | |
| 174 | - return $html; | |
| 175 | - } | |
| 173 | + $html.='</form>'; | |
| 174 | + return $html; | |
| 175 | + } | |
| 176 | 176 | |
| 177 | - public function getFilterQuery(array $getVars) | |
| 178 | -    { | |
| 179 | - if (isset($getVars['f'])) | |
| 180 | -        { | |
| 181 | - $this->filterQuery = $getVars['f']; | |
| 182 | - $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames); | |
| 183 | - } | |
| 184 | - } | |
| 185 | - | |
| 186 | - protected function curFilterQuery() | |
| 187 | -    { | |
| 188 | - if ($this->filterQuery == '') return ''; | |
| 189 | - return 'f='.$this->filterQuery; | |
| 190 | - } | |
| 191 | - | |
| 192 | - /***************** Ordering ********************/ | |
| 193 | - | |
| 194 | - public function applyOrder() | |
| 195 | -    { | |
| 196 | - if (count($this->order) == 0) | |
| 197 | -        { | |
| 198 | - return $this; | |
| 199 | - } | |
| 200 | - $orderSQL=''; | |
| 201 | - foreach ($this->order as $column => $direction) | |
| 202 | -        { | |
| 203 | - if ($orderSQL != "") $orderSQL.=','; | |
| 177 | + public function getFilterQuery(array $getVars) | |
| 178 | +	{ | |
| 179 | + if (isset($getVars['f'])) | |
| 180 | +		{ | |
| 181 | + $this->filterQuery = $getVars['f']; | |
| 182 | + $this->setFilter(html_entity_decode($getVars['f']), $this->columnNames); | |
| 183 | + } | |
| 184 | + } | |
| 185 | + | |
| 186 | + protected function curFilterQuery() | |
| 187 | +	{ | |
| 188 | + if ($this->filterQuery == '') return ''; | |
| 189 | + return 'f='.$this->filterQuery; | |
| 190 | + } | |
| 191 | + | |
| 192 | + /***************** Ordering ********************/ | |
| 193 | + | |
| 194 | + public function applyOrder() | |
| 195 | +	{ | |
| 196 | + if (count($this->order) == 0) | |
| 197 | +		{ | |
| 198 | + return $this; | |
| 199 | + } | |
| 200 | + $orderSQL=''; | |
| 201 | + foreach ($this->order as $column => $direction) | |
| 202 | +		{ | |
| 203 | + if ($orderSQL != "") $orderSQL.=','; | |
| 204 | 204 | |
| 205 | - $orderSQL .= $column . ' ' . $direction; | |
| 206 | - } | |
| 207 | - $this->query = $this->query->order($orderSQL); | |
| 205 | + $orderSQL .= $column . ' ' . $direction; | |
| 206 | + } | |
| 207 | + $this->query = $this->query->order($orderSQL); | |
| 208 | 208 | |
| 209 | - return $this; | |
| 210 | - } | |
| 211 | - | |
| 212 | - public function setOrder(array $order) | |
| 213 | -    { | |
| 214 | - $this->order = $order; | |
| 215 | - return $this; | |
| 216 | - } | |
| 209 | + return $this; | |
| 210 | + } | |
| 211 | + | |
| 212 | + public function setOrder(array $order) | |
| 213 | +	{ | |
| 214 | + $this->order = $order; | |
| 215 | + return $this; | |
| 216 | + } | |
| 217 | 217 | |
| 218 | - public function isOrderSet() | |
| 219 | -    { | |
| 220 | - if (count($this->order) == 0) return FALSE; | |
| 221 | - return TRUE; | |
| 222 | - } | |
| 223 | - | |
| 224 | - public function getOrderQuery(array $getVars) | |
| 225 | -    { | |
| 226 | - if (isset($getVars['o'])) | |
| 227 | -        { | |
| 228 | - $this->orderQuery = $getVars['o']; | |
| 229 | - $match = array(); | |
| 230 | -            if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) | |
| 231 | -            { | |
| 232 | - $orderArray=array($match[1] => $match[2]); | |
| 233 | - echo "$match[1] => $match[2]"; | |
| 234 | - $this->setOrder($orderArray); | |
| 235 | - } | |
| 236 | - } | |
| 237 | - } | |
| 238 | - | |
| 239 | - protected function curOrderQuery() | |
| 240 | -    { | |
| 241 | - if ($this->orderQuery == '') return ''; | |
| 242 | - return 'o='.$this->orderQuery; | |
| 243 | - } | |
| 244 | - | |
| 245 | - /***************** Paging and counting *********/ | |
| 246 | - | |
| 247 | - public function countQuery() | |
| 248 | -    { | |
| 249 | - $this->query = $this->dbConn->select(); | |
| 250 | - $this->query = $this->query | |
| 251 | - ->from( | |
| 252 | - $this->table, | |
| 253 | -                array('COUNT(*)') | |
| 254 | - ); | |
| 255 | - $this->applyFilter(); | |
| 256 | - } | |
| 257 | - | |
| 258 | - public function count() | |
| 259 | -    { | |
| 260 | - $this->countQuery(); | |
| 261 | - return $this->dbConn->fetchOne($this->query); | |
| 262 | - } | |
| 263 | - | |
| 264 | - public function setMaxPerPage(int $max) | |
| 265 | -    { | |
| 266 | - $this->maxPerPage = $max; | |
| 267 | - } | |
| 268 | - | |
| 269 | - protected function getPagingQuery(array $getVars) | |
| 270 | -    { | |
| 271 | - if (isset($getVars['page'])) | |
| 272 | -        { | |
| 273 | - $this->currentPage = $getVars['page']; | |
| 274 | - } | |
| 275 | - } | |
| 218 | + public function isOrderSet() | |
| 219 | +	{ | |
| 220 | + if (count($this->order) == 0) return FALSE; | |
| 221 | + return TRUE; | |
| 222 | + } | |
| 223 | + | |
| 224 | + public function getOrderQuery(array $getVars) | |
| 225 | +	{ | |
| 226 | + if (isset($getVars['o'])) | |
| 227 | +		{ | |
| 228 | + $this->orderQuery = $getVars['o']; | |
| 229 | + $match = array(); | |
| 230 | +			if (preg_match('/(.*)(ASC|DESC)$/', $this->orderQuery , $match)) | |
| 231 | +			{ | |
| 232 | + $orderArray=array($match[1] => $match[2]); | |
| 233 | + echo "$match[1] => $match[2]"; | |
| 234 | + $this->setOrder($orderArray); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + } | |
| 238 | + | |
| 239 | + protected function curOrderQuery() | |
| 240 | +	{ | |
| 241 | + if ($this->orderQuery == '') return ''; | |
| 242 | + return 'o='.$this->orderQuery; | |
| 243 | + } | |
| 244 | + | |
| 245 | + /***************** Paging and counting *********/ | |
| 246 | + | |
| 247 | + public function countQuery() | |
| 248 | +	{ | |
| 249 | + $this->query = $this->dbConn->select(); | |
| 250 | + $this->query = $this->query | |
| 251 | + ->from( | |
| 252 | + $this->table, | |
| 253 | +				array('COUNT(*)') | |
| 254 | + ); | |
| 255 | + $this->applyFilter(); | |
| 256 | + } | |
| 257 | + | |
| 258 | + public function count() | |
| 259 | +	{ | |
| 260 | + $this->countQuery(); | |
| 261 | + return $this->dbConn->fetchOne($this->query); | |
| 262 | + } | |
| 263 | + | |
| 264 | + public function setMaxPerPage(int $max) | |
| 265 | +	{ | |
| 266 | + $this->maxPerPage = $max; | |
| 267 | + } | |
| 268 | + | |
| 269 | + protected function getPagingQuery(array $getVars) | |
| 270 | +	{ | |
| 271 | + if (isset($getVars['page'])) | |
| 272 | +		{ | |
| 273 | + $this->currentPage = $getVars['page']; | |
| 274 | + } | |
| 275 | + } | |
| 276 | 276 | |
| 277 | - protected function curPagingQuery() | |
| 278 | -    { | |
| 279 | - if ($this->currentPage == '') return ''; | |
| 280 | - return 'page='.$this->currentPage; | |
| 281 | - } | |
| 282 | - | |
| 283 | - public function renderPagingHeader() | |
| 284 | -    { | |
| 285 | - $count = $this->count(); | |
| 286 | - if ($count <= $this->maxPerPage ) | |
| 287 | -        { | |
| 288 | - return 'count : ' . $this->count() . '<br>'; | |
| 289 | - } | |
| 277 | + protected function curPagingQuery() | |
| 278 | +	{ | |
| 279 | + if ($this->currentPage == '') return ''; | |
| 280 | + return 'page='.$this->currentPage; | |
| 281 | + } | |
| 282 | + | |
| 283 | + public function renderPagingHeader() | |
| 284 | +	{ | |
| 285 | + $count = $this->count(); | |
| 286 | + if ($count <= $this->maxPerPage ) | |
| 287 | +		{ | |
| 288 | + return 'count : ' . $this->count() . '<br>'; | |
| 289 | + } | |
| 290 | 290 | |
| 291 | - if ($this->currentPage == 0) $this->currentPage = 1; | |
| 291 | + if ($this->currentPage == 0) $this->currentPage = 1; | |
| 292 | 292 | |
| 293 | - $numPages = intdiv($count , $this->maxPerPage); | |
| 294 | - if ($count % $this->maxPerPage != 0 ) $numPages++; | |
| 293 | + $numPages = intdiv($count , $this->maxPerPage); | |
| 294 | + if ($count % $this->maxPerPage != 0 ) $numPages++; | |
| 295 | 295 | |
| 296 | - $html = '<div class="pagination-control" role="navigation">'; | |
| 297 | - $html .= '<ul class="nav tab-nav">'; | |
| 298 | - if ($this->currentPage <=1) | |
| 299 | -        { | |
| 300 | - $html .= ' | |
| 296 | + $html = '<div class="pagination-control" role="navigation">'; | |
| 297 | + $html .= '<ul class="nav tab-nav">'; | |
| 298 | + if ($this->currentPage <=1) | |
| 299 | +		{ | |
| 300 | + $html .= ' | |
| 301 | 301 | <li class="nav-item disabled" aria-hidden="true"> | 
| 302 | 302 | <span class="previous-page"> | 
| 303 | 303 | <span class="sr-only">Previous page</span> | 
| @@ -305,35 +305,35 @@ discard block | ||
| 305 | 305 | </span> | 
| 306 | 306 | </li> | 
| 307 | 307 | '; | 
| 308 | - } | |
| 309 | - else | |
| 310 | -        { | |
| 311 | - $html .= ' | |
| 308 | + } | |
| 309 | + else | |
| 310 | +		{ | |
| 311 | + $html .= ' | |
| 312 | 312 | <li class="nav-item"> | 
| 313 | 313 |                      <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage - 1 ).'" class="previous-page" > | 
| 314 | 314 | <i aria-hidden="true" class="icon-angle-double-left"></i> | 
| 315 | 315 | </a> | 
| 316 | 316 | </li> | 
| 317 | 317 | '; | 
| 318 | - } | |
| 318 | + } | |
| 319 | 319 | |
| 320 | - for ($i=1; $i <= $numPages ; $i++) | |
| 321 | -        { | |
| 322 | - $active = ($this->currentPage == $i) ? 'active' : ''; | |
| 323 | - $first = ($i-1)*$this->maxPerPage+1; | |
| 324 | - $last = $i * $this->maxPerPage; | |
| 325 | - if ($last > $count) $last = $count; | |
| 326 | - $display = 'Show rows '. $first . ' to '. $last .' of '. $count; | |
| 327 | - $html .= '<li class="' . $active . ' nav-item"> | |
| 320 | + for ($i=1; $i <= $numPages ; $i++) | |
| 321 | +		{ | |
| 322 | + $active = ($this->currentPage == $i) ? 'active' : ''; | |
| 323 | + $first = ($i-1)*$this->maxPerPage+1; | |
| 324 | + $last = $i * $this->maxPerPage; | |
| 325 | + if ($last > $count) $last = $count; | |
| 326 | + $display = 'Show rows '. $first . ' to '. $last .' of '. $count; | |
| 327 | + $html .= '<li class="' . $active . ' nav-item"> | |
| 328 | 328 |                      <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '"> | 
| 329 | 329 | '.$i.' | 
| 330 | 330 | </a> | 
| 331 | 331 | </li>'; | 
| 332 | - } | |
| 332 | + } | |
| 333 | 333 | |
| 334 | - if ($this->currentPage == $numPages) | |
| 335 | -        { | |
| 336 | - $html .= ' | |
| 334 | + if ($this->currentPage == $numPages) | |
| 335 | +		{ | |
| 336 | + $html .= ' | |
| 337 | 337 | <li class="nav-item disabled" aria-hidden="true"> | 
| 338 | 338 | <span class="previous-page"> | 
| 339 | 339 | <span class="sr-only">Previous page</span> | 
| @@ -341,150 +341,150 @@ discard block | ||
| 341 | 341 | </span> | 
| 342 | 342 | </li> | 
| 343 | 343 | '; | 
| 344 | - } | |
| 345 | - else | |
| 346 | -        { | |
| 347 | - $html .= ' | |
| 344 | + } | |
| 345 | + else | |
| 346 | +		{ | |
| 347 | + $html .= ' | |
| 348 | 348 | <li class="nav-item"> | 
| 349 | 349 |                      <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. ($this->currentPage + 1 ).'" class="next-page"> | 
| 350 | 350 | <i aria-hidden="true" class="icon-angle-double-right"></i> | 
| 351 | 351 | </a> | 
| 352 | 352 | </li> | 
| 353 | 353 | '; | 
| 354 | - } | |
| 354 | + } | |
| 355 | 355 | |
| 356 | - $html .= '</ul> </div>'; | |
| 356 | + $html .= '</ul> </div>'; | |
| 357 | 357 | |
| 358 | - return $html; | |
| 359 | - } | |
| 360 | - | |
| 361 | - public function applyPaging() | |
| 362 | -    { | |
| 363 | - $this->query->limitPage($this->currentPage,$this->maxPerPage); | |
| 364 | - return $this; | |
| 365 | - } | |
| 366 | - | |
| 367 | - /***************** Grouping ****************/ | |
| 368 | - | |
| 369 | - public function setGrouping($columnDBName) | |
| 370 | -    { | |
| 371 | - $this->groupingColumn = $columnDBName; | |
| 372 | - $this->grouppingActive = TRUE; | |
| 373 | - } | |
| 374 | - | |
| 375 | - public function initGrouping() | |
| 376 | -    { | |
| 377 | - $this->groupingVal = ''; | |
| 378 | - $this->groupingColSpan = count($this->titles); | |
| 379 | - } | |
| 380 | - | |
| 381 | - public function groupingPrintData( $value) | |
| 382 | -    { | |
| 383 | - $html = "$value"; | |
| 384 | - return $html; | |
| 385 | - } | |
| 386 | - | |
| 387 | - public function groupingNextLine( $values) | |
| 388 | -    { | |
| 389 | - if ($this->grouppingActive === FALSE) return ''; | |
| 358 | + return $html; | |
| 359 | + } | |
| 360 | + | |
| 361 | + public function applyPaging() | |
| 362 | +	{ | |
| 363 | + $this->query->limitPage($this->currentPage,$this->maxPerPage); | |
| 364 | + return $this; | |
| 365 | + } | |
| 366 | + | |
| 367 | + /***************** Grouping ****************/ | |
| 368 | + | |
| 369 | + public function setGrouping($columnDBName) | |
| 370 | +	{ | |
| 371 | + $this->groupingColumn = $columnDBName; | |
| 372 | + $this->grouppingActive = TRUE; | |
| 373 | + } | |
| 374 | + | |
| 375 | + public function initGrouping() | |
| 376 | +	{ | |
| 377 | + $this->groupingVal = ''; | |
| 378 | + $this->groupingColSpan = count($this->titles); | |
| 379 | + } | |
| 380 | + | |
| 381 | + public function groupingPrintData( $value) | |
| 382 | +	{ | |
| 383 | + $html = "$value"; | |
| 384 | + return $html; | |
| 385 | + } | |
| 386 | + | |
| 387 | + public function groupingNextLine( $values) | |
| 388 | +	{ | |
| 389 | + if ($this->grouppingActive === FALSE) return ''; | |
| 390 | 390 | |
| 391 | - $dbcol = $this->groupingColumn; | |
| 392 | - if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol ) | |
| 393 | -        { | |
| 394 | - $this->groupingVal = $values->$dbcol; | |
| 395 | - $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>'; | |
| 396 | - return $html; | |
| 397 | - } | |
| 398 | - return ''; | |
| 391 | + $dbcol = $this->groupingColumn; | |
| 392 | + if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol ) | |
| 393 | +		{ | |
| 394 | + $this->groupingVal = $values->$dbcol; | |
| 395 | + $html = '<tr><th colspan="'. $this->groupingColSpan .'">'. $this->groupingPrintData($this->groupingVal) .'</th></tr>'; | |
| 396 | + return $html; | |
| 397 | + } | |
| 398 | + return ''; | |
| 399 | 399 | |
| 400 | - } | |
| 401 | - | |
| 402 | - /*************** Rendering *************************/ | |
| 403 | - | |
| 404 | - public function titleOrder($name) | |
| 405 | -    { | |
| 406 | - return $this->content[$name]; | |
| 407 | - } | |
| 408 | - | |
| 409 | - public function renderTitles() | |
| 410 | -    { | |
| 411 | - $html = "<thead>\n<tr>\n"; | |
| 412 | - foreach ($this->titles as $name => $values) | |
| 413 | -        { | |
| 414 | - $titleOrder = $this->titleOrder($name); | |
| 415 | - if ($titleOrder != NULL) | |
| 416 | -            { | |
| 417 | - if (isset($this->order[$titleOrder])) | |
| 418 | -                { | |
| 419 | - if ($this->order[$titleOrder] == 'ASC') | |
| 420 | -                    { | |
| 421 | - $titleOrder.='DESC'; | |
| 422 | - } | |
| 423 | - else | |
| 424 | -                    { | |
| 425 | - $titleOrder.='ASC'; | |
| 426 | - } | |
| 427 | - } | |
| 428 | - else | |
| 429 | -                { | |
| 430 | - $titleOrder.='ASC'; | |
| 431 | - } | |
| 432 | -                $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; | |
| 433 | - $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; | |
| 434 | - } | |
| 435 | - else | |
| 436 | -            { | |
| 437 | - $html .= '<th>' . $values . '</th>'; | |
| 438 | - } | |
| 439 | - } | |
| 440 | - $html .= "</tr>\n</thead>\n"; | |
| 441 | - return $html; | |
| 442 | - } | |
| 443 | - | |
| 444 | - public function renderLine( $value) | |
| 445 | -    { | |
| 446 | - $html = ''; | |
| 447 | - $titleNames = array_keys($this->titles); | |
| 448 | - foreach ($titleNames as $name ) | |
| 449 | -        { | |
| 450 | - $html .= '<td>'; | |
| 451 | - $html .= $value->$name; | |
| 452 | - $html .= "</td>\n"; | |
| 453 | - } | |
| 454 | - return $html; | |
| 455 | - } | |
| 456 | - | |
| 457 | - public function renderTable(array $values) | |
| 458 | -    { | |
| 459 | - $html = '<tbody id="obj_table_body">'; | |
| 460 | - foreach($values as $value) | |
| 461 | -       { | |
| 462 | - $html .= $this->groupingNextLine($value); | |
| 400 | + } | |
| 401 | + | |
| 402 | + /*************** Rendering *************************/ | |
| 403 | + | |
| 404 | + public function titleOrder($name) | |
| 405 | +	{ | |
| 406 | + return $this->content[$name]; | |
| 407 | + } | |
| 408 | + | |
| 409 | + public function renderTitles() | |
| 410 | +	{ | |
| 411 | + $html = "<thead>\n<tr>\n"; | |
| 412 | + foreach ($this->titles as $name => $values) | |
| 413 | +		{ | |
| 414 | + $titleOrder = $this->titleOrder($name); | |
| 415 | + if ($titleOrder != NULL) | |
| 416 | +			{ | |
| 417 | + if (isset($this->order[$titleOrder])) | |
| 418 | +				{ | |
| 419 | + if ($this->order[$titleOrder] == 'ASC') | |
| 420 | +					{ | |
| 421 | + $titleOrder.='DESC'; | |
| 422 | + } | |
| 423 | + else | |
| 424 | +					{ | |
| 425 | + $titleOrder.='ASC'; | |
| 426 | + } | |
| 427 | + } | |
| 428 | + else | |
| 429 | +				{ | |
| 430 | + $titleOrder.='ASC'; | |
| 431 | + } | |
| 432 | +				$actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; | |
| 433 | + $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; | |
| 434 | + } | |
| 435 | + else | |
| 436 | +			{ | |
| 437 | + $html .= '<th>' . $values . '</th>'; | |
| 438 | + } | |
| 439 | + } | |
| 440 | + $html .= "</tr>\n</thead>\n"; | |
| 441 | + return $html; | |
| 442 | + } | |
| 443 | + | |
| 444 | + public function renderLine( $value) | |
| 445 | +	{ | |
| 446 | + $html = ''; | |
| 447 | + $titleNames = array_keys($this->titles); | |
| 448 | + foreach ($titleNames as $name ) | |
| 449 | +		{ | |
| 450 | + $html .= '<td>'; | |
| 451 | + $html .= $value->$name; | |
| 452 | + $html .= "</td>\n"; | |
| 453 | + } | |
| 454 | + return $html; | |
| 455 | + } | |
| 456 | + | |
| 457 | + public function renderTable(array $values) | |
| 458 | +	{ | |
| 459 | + $html = '<tbody id="obj_table_body">'; | |
| 460 | + foreach($values as $value) | |
| 461 | +	   { | |
| 462 | + $html .= $this->groupingNextLine($value); | |
| 463 | 463 | |
| 464 | - $html .= "<tr>\n"; | |
| 465 | - $html .= $this->renderLine($value); | |
| 466 | - $html .= "</tr>\n"; | |
| 467 | - } | |
| 468 | - $html .= '</tbody>'; | |
| 469 | - return $html; | |
| 470 | - } | |
| 471 | - | |
| 472 | - public function render() | |
| 473 | -    { | |
| 474 | - $html = ''; | |
| 464 | + $html .= "<tr>\n"; | |
| 465 | + $html .= $this->renderLine($value); | |
| 466 | + $html .= "</tr>\n"; | |
| 467 | + } | |
| 468 | + $html .= '</tbody>'; | |
| 469 | + return $html; | |
| 470 | + } | |
| 471 | + | |
| 472 | + public function render() | |
| 473 | +	{ | |
| 474 | + $html = ''; | |
| 475 | 475 | |
| 476 | 476 | |
| 477 | - $values = $this->fullQuery(); | |
| 478 | - $this->initGrouping(); | |
| 477 | + $values = $this->fullQuery(); | |
| 478 | + $this->initGrouping(); | |
| 479 | 479 | |
| 480 | - $html.="<table class='simple common-table table-row-selectable'>\n"; | |
| 480 | + $html.="<table class='simple common-table table-row-selectable'>\n"; | |
| 481 | 481 | |
| 482 | - $html .= $this->renderTitles(); | |
| 483 | - $html .= $this->renderTable($values); | |
| 484 | - $html .= '</table>'; | |
| 482 | + $html .= $this->renderTitles(); | |
| 483 | + $html .= $this->renderTable($values); | |
| 484 | + $html .= '</table>'; | |
| 485 | 485 | |
| 486 | 486 | |
| 487 | - return $html; | |
| 488 | - } | |
| 487 | + return $html; | |
| 488 | + } | |
| 489 | 489 | |
| 490 | 490 | } | 
| 491 | 491 | \ No newline at end of file | 
| @@ -88,17 +88,21 @@ discard block | ||
| 88 | 88 |      { | 
| 89 | 89 | $actionURL = $this->getCurrentURL() . '?' ; | 
| 90 | 90 | $QSList=array(); | 
| 91 | - if ($caller != 'filter' && $this->curFilterQuery() != '') | |
| 92 | - array_push($QSList , $this->curFilterQuery()); | |
| 91 | +        if ($caller != 'filter' && $this->curFilterQuery() != '') { | |
| 92 | + array_push($QSList , $this->curFilterQuery()); | |
| 93 | + } | |
| 93 | 94 | |
| 94 | - if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') | |
| 95 | - array_push($QSList , $this->curPagingQuery()); | |
| 95 | +        if ($caller != 'paging' && $caller != 'filter' && $this->curPagingQuery() != '') { | |
| 96 | + array_push($QSList , $this->curPagingQuery()); | |
| 97 | + } | |
| 96 | 98 | |
| 97 | - if ($caller != 'order' && $this->curOrderQuery() != '') | |
| 98 | - array_push($QSList , $this->curOrderQuery()); | |
| 99 | +        if ($caller != 'order' && $this->curOrderQuery() != '') { | |
| 100 | + array_push($QSList , $this->curOrderQuery()); | |
| 101 | + } | |
| 99 | 102 | |
| 100 | - if (count($QSList) != 0) | |
| 101 | -            $actionURL .=  implode('&', $QSList) . '&'; | |
| 103 | +        if (count($QSList) != 0) { | |
| 104 | +                    $actionURL .=  implode('&', $QSList) . '&'; | |
| 105 | + } | |
| 102 | 106 | |
| 103 | 107 | return $actionURL; | 
| 104 | 108 | } | 
| @@ -142,7 +146,9 @@ discard block | ||
| 142 | 146 | $filter=''; | 
| 143 | 147 | foreach ($this->filterColumn as $column) | 
| 144 | 148 |          { | 
| 145 | - if ($filter != "") $filter.=' OR '; | |
| 149 | +            if ($filter != "") { | |
| 150 | + $filter.=' OR '; | |
| 151 | + } | |
| 146 | 152 | //$filter .= "'" . $column . "' LIKE '%" . $this->filterString. "%'"; | 
| 147 | 153 | $filter .= $column . " LIKE '%" . $this->filterString. "%'"; | 
| 148 | 154 | } | 
| @@ -185,7 +191,9 @@ discard block | ||
| 185 | 191 | |
| 186 | 192 | protected function curFilterQuery() | 
| 187 | 193 |      { | 
| 188 | - if ($this->filterQuery == '') return ''; | |
| 194 | +        if ($this->filterQuery == '') { | |
| 195 | + return ''; | |
| 196 | + } | |
| 189 | 197 | return 'f='.$this->filterQuery; | 
| 190 | 198 | } | 
| 191 | 199 | |
| @@ -200,7 +208,9 @@ discard block | ||
| 200 | 208 | $orderSQL=''; | 
| 201 | 209 | foreach ($this->order as $column => $direction) | 
| 202 | 210 |          { | 
| 203 | - if ($orderSQL != "") $orderSQL.=','; | |
| 211 | +            if ($orderSQL != "") { | |
| 212 | + $orderSQL.=','; | |
| 213 | + } | |
| 204 | 214 | |
| 205 | 215 | $orderSQL .= $column . ' ' . $direction; | 
| 206 | 216 | } | 
| @@ -217,7 +227,9 @@ discard block | ||
| 217 | 227 | |
| 218 | 228 | public function isOrderSet() | 
| 219 | 229 |      { | 
| 220 | - if (count($this->order) == 0) return FALSE; | |
| 230 | +        if (count($this->order) == 0) { | |
| 231 | + return FALSE; | |
| 232 | + } | |
| 221 | 233 | return TRUE; | 
| 222 | 234 | } | 
| 223 | 235 | |
| @@ -238,7 +250,9 @@ discard block | ||
| 238 | 250 | |
| 239 | 251 | protected function curOrderQuery() | 
| 240 | 252 |      { | 
| 241 | - if ($this->orderQuery == '') return ''; | |
| 253 | +        if ($this->orderQuery == '') { | |
| 254 | + return ''; | |
| 255 | + } | |
| 242 | 256 | return 'o='.$this->orderQuery; | 
| 243 | 257 | } | 
| 244 | 258 | |
| @@ -276,7 +290,9 @@ discard block | ||
| 276 | 290 | |
| 277 | 291 | protected function curPagingQuery() | 
| 278 | 292 |      { | 
| 279 | - if ($this->currentPage == '') return ''; | |
| 293 | +        if ($this->currentPage == '') { | |
| 294 | + return ''; | |
| 295 | + } | |
| 280 | 296 | return 'page='.$this->currentPage; | 
| 281 | 297 | } | 
| 282 | 298 | |
| @@ -288,10 +304,14 @@ discard block | ||
| 288 | 304 | return 'count : ' . $this->count() . '<br>'; | 
| 289 | 305 | } | 
| 290 | 306 | |
| 291 | - if ($this->currentPage == 0) $this->currentPage = 1; | |
| 307 | +        if ($this->currentPage == 0) { | |
| 308 | + $this->currentPage = 1; | |
| 309 | + } | |
| 292 | 310 | |
| 293 | 311 | $numPages = intdiv($count , $this->maxPerPage); | 
| 294 | - if ($count % $this->maxPerPage != 0 ) $numPages++; | |
| 312 | +        if ($count % $this->maxPerPage != 0 ) { | |
| 313 | + $numPages++; | |
| 314 | + } | |
| 295 | 315 | |
| 296 | 316 | $html = '<div class="pagination-control" role="navigation">'; | 
| 297 | 317 | $html .= '<ul class="nav tab-nav">'; | 
| @@ -305,8 +325,7 @@ discard block | ||
| 305 | 325 | </span> | 
| 306 | 326 | </li> | 
| 307 | 327 | '; | 
| 308 | - } | |
| 309 | - else | |
| 328 | + } else | |
| 310 | 329 |          { | 
| 311 | 330 | $html .= ' | 
| 312 | 331 | <li class="nav-item"> | 
| @@ -322,7 +341,9 @@ discard block | ||
| 322 | 341 | $active = ($this->currentPage == $i) ? 'active' : ''; | 
| 323 | 342 | $first = ($i-1)*$this->maxPerPage+1; | 
| 324 | 343 | $last = $i * $this->maxPerPage; | 
| 325 | - if ($last > $count) $last = $count; | |
| 344 | +            if ($last > $count) { | |
| 345 | + $last = $count; | |
| 346 | + } | |
| 326 | 347 | $display = 'Show rows '. $first . ' to '. $last .' of '. $count; | 
| 327 | 348 | $html .= '<li class="' . $active . ' nav-item"> | 
| 328 | 349 |                      <a href="'. $this->getCurrentURLAndQS('paging') .'&page='. $i .'" title="' . $display . '" aria-label="' . $display . '"> | 
| @@ -341,8 +362,7 @@ discard block | ||
| 341 | 362 | </span> | 
| 342 | 363 | </li> | 
| 343 | 364 | '; | 
| 344 | - } | |
| 345 | - else | |
| 365 | + } else | |
| 346 | 366 |          { | 
| 347 | 367 | $html .= ' | 
| 348 | 368 | <li class="nav-item"> | 
| @@ -386,7 +406,9 @@ discard block | ||
| 386 | 406 | |
| 387 | 407 | public function groupingNextLine( $values) | 
| 388 | 408 |      { | 
| 389 | - if ($this->grouppingActive === FALSE) return ''; | |
| 409 | +        if ($this->grouppingActive === FALSE) { | |
| 410 | + return ''; | |
| 411 | + } | |
| 390 | 412 | |
| 391 | 413 | $dbcol = $this->groupingColumn; | 
| 392 | 414 | if ($this->groupingVal == '' || $this->groupingVal != $values->$dbcol ) | 
| @@ -419,20 +441,17 @@ discard block | ||
| 419 | 441 | if ($this->order[$titleOrder] == 'ASC') | 
| 420 | 442 |                      { | 
| 421 | 443 | $titleOrder.='DESC'; | 
| 422 | - } | |
| 423 | - else | |
| 444 | + } else | |
| 424 | 445 |                      { | 
| 425 | 446 | $titleOrder.='ASC'; | 
| 426 | 447 | } | 
| 427 | - } | |
| 428 | - else | |
| 448 | + } else | |
| 429 | 449 |                  { | 
| 430 | 450 | $titleOrder.='ASC'; | 
| 431 | 451 | } | 
| 432 | 452 |                  $actionURL = $this->getCurrentURLAndQS('order').'o='.$titleOrder; | 
| 433 | 453 | $html .= '<th><a href="'.$actionURL.'">' . $values . '</a></th>'; | 
| 434 | - } | |
| 435 | - else | |
| 454 | + } else | |
| 436 | 455 |              { | 
| 437 | 456 | $html .= '<th>' . $values . '</th>'; | 
| 438 | 457 | } |