@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | $properties = json_decode(file_get_contents($propFilePath), true); |
| 62 | 62 | |
| 63 | 63 | if (json_last_error() === JSON_ERROR_NONE) { |
| 64 | - if (isset($properties[ 'config' ])) { |
|
| 65 | - $this->presets = $properties[ 'presets' ]; |
|
| 66 | - unset($properties[ 'presets' ]); |
|
| 64 | + if (isset($properties['config'])) { |
|
| 65 | + $this->presets = $properties['presets']; |
|
| 66 | + unset($properties['presets']); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | $this->properties = $properties; |
@@ -199,10 +199,10 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $extensions = ['.php', '.phtml', '.html', '.tpl']; |
| 201 | 201 | |
| 202 | - if (isset($this->presets[ 'extensions' ])) { |
|
| 203 | - array_unshift($partialsExtensions, $this->presets[ 'extension' ]); |
|
| 204 | - } elseif (isset($this->presets[ 'extension' ])) { |
|
| 205 | - array_unshift($extensions, $this->presets[ 'extension' ]); |
|
| 202 | + if (isset($this->presets['extensions'])) { |
|
| 203 | + array_unshift($partialsExtensions, $this->presets['extension']); |
|
| 204 | + } elseif (isset($this->presets['extension'])) { |
|
| 205 | + array_unshift($extensions, $this->presets['extension']); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | foreach ($extensions as $extension) { |
@@ -283,7 +283,7 @@ |
||
| 283 | 283 | $themes = []; |
| 284 | 284 | foreach ($directory->getTree() as $themeName => $themeTree) { |
| 285 | 285 | if (($theme = $this->getTheme($themeName)) instanceof Module\Theme) { |
| 286 | - $themes[ $themeName ] = $theme; |
|
| 286 | + $themes[$themeName] = $theme; |
|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | public function __construct() |
| 42 | 42 | { |
| 43 | 43 | if ($config = config()->loadFile('database', true)) { |
| 44 | - if ( ! empty($config[ 'default' ][ 'hostname' ]) AND ! empty($config[ 'default' ][ 'username' ])) { |
|
| 44 | + if ( ! empty($config['default']['hostname']) AND ! empty($config['default']['username'])) { |
|
| 45 | 45 | |
| 46 | 46 | if (profiler() !== false) { |
| 47 | 47 | profiler()->watch('Starting Database Service'); |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | if (isset($config) AND is_array($config)) { |
| 180 | 180 | // Set default timezone |
| 181 | - if (isset($config[ 'datetime' ][ 'timezone' ])) { |
|
| 182 | - date_default_timezone_set($config[ 'datetime' ][ 'timezone' ]); |
|
| 181 | + if (isset($config['datetime']['timezone'])) { |
|
| 182 | + date_default_timezone_set($config['datetime']['timezone']); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // Setup Language Ideom and Locale |
| 186 | - if (isset($config[ 'language' ])) { |
|
| 187 | - language()->setDefault($config[ 'language' ]); |
|
| 186 | + if (isset($config['language'])) { |
|
| 187 | + language()->setDefault($config['language']); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | config()->merge($config); |
@@ -414,8 +414,8 @@ discard block |
||
| 414 | 414 | $packageJsonFile = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $packageJsonFile); |
| 415 | 415 | $packageJsonFileInfo = pathinfo($packageJsonFile); |
| 416 | 416 | |
| 417 | - if ($packageJsonFileInfo[ 'filename' ] === 'widget' or |
|
| 418 | - $packageJsonFileInfo[ 'filename' ] === 'language' or |
|
| 417 | + if ($packageJsonFileInfo['filename'] === 'widget' or |
|
| 418 | + $packageJsonFileInfo['filename'] === 'language' or |
|
| 419 | 419 | strpos($packageJsonFile, '.svn') !== false // subversion properties file conflict. |
| 420 | 420 | ) { |
| 421 | 421 | continue; |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | if (strpos($packageJsonFile, |
| 448 | - $modularType = ucfirst(plural($packageJsonFileInfo[ 'filename' ])) . DIRECTORY_SEPARATOR) === false) { |
|
| 449 | - $modularType = ucfirst($packageJsonFileInfo[ 'filename' ]) . DIRECTORY_SEPARATOR; |
|
| 448 | + $modularType = ucfirst(plural($packageJsonFileInfo['filename'])) . DIRECTORY_SEPARATOR) === false) { |
|
| 449 | + $modularType = ucfirst($packageJsonFileInfo['filename']) . DIRECTORY_SEPARATOR; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | $modularType = strtolower(rtrim($modularType, DIRECTORY_SEPARATOR)); |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | PATH_PUBLIC, |
| 462 | 462 | PATH_RESOURCES, |
| 463 | 463 | PATH_APP, |
| 464 | - $packageJsonFileInfo[ 'basename' ], |
|
| 464 | + $packageJsonFileInfo['basename'], |
|
| 465 | 465 | ucfirst($modularType) . DIRECTORY_SEPARATOR, |
| 466 | 466 | ], |
| 467 | 467 | '', |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | ) |
| 472 | 472 | ); |
| 473 | 473 | |
| 474 | - $moduleSegments = array_map(function ($string) { |
|
| 474 | + $moduleSegments = array_map(function($string) { |
|
| 475 | 475 | return dash(snakecase($string)); |
| 476 | 476 | }, $moduleSegments); |
| 477 | 477 | |
@@ -479,14 +479,14 @@ discard block |
||
| 479 | 479 | str_replace( |
| 480 | 480 | PATH_ROOT, |
| 481 | 481 | '', |
| 482 | - $packageJsonFileInfo[ 'dirname' ] |
|
| 482 | + $packageJsonFileInfo['dirname'] |
|
| 483 | 483 | ), |
| 484 | 484 | false |
| 485 | 485 | ); |
| 486 | 486 | |
| 487 | - if (isset($packageJsonMetadata[ 'namespace' ])) { |
|
| 488 | - $moduleNamespace = $packageJsonMetadata[ 'namespace' ]; |
|
| 489 | - unset($packageJsonMetadata[ 'namespace' ]); |
|
| 487 | + if (isset($packageJsonMetadata['namespace'])) { |
|
| 488 | + $moduleNamespace = $packageJsonMetadata['namespace']; |
|
| 489 | + unset($packageJsonMetadata['namespace']); |
|
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | $moduleParentSegments = []; |
@@ -500,18 +500,18 @@ discard block |
||
| 500 | 500 | $registryKey = implode('/', $moduleSegments); |
| 501 | 501 | |
| 502 | 502 | if ($registryKey === '') { |
| 503 | - if ($packageJsonFileInfo[ 'dirname' ] . DIRECTORY_SEPARATOR !== PATH_APP and $modularType === 'app') { |
|
| 503 | + if ($packageJsonFileInfo['dirname'] . DIRECTORY_SEPARATOR !== PATH_APP and $modularType === 'app') { |
|
| 504 | 504 | $registryKey = dash(snakecase( |
| 505 | - pathinfo($packageJsonFileInfo[ 'dirname' ], PATHINFO_FILENAME))); |
|
| 505 | + pathinfo($packageJsonFileInfo['dirname'], PATHINFO_FILENAME))); |
|
| 506 | 506 | } |
| 507 | 507 | } else { |
| 508 | 508 | $registryKey = $registryKey; |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - $registry[ $registryKey ] = (new DataStructures\Module( |
|
| 512 | - $packageJsonFileInfo[ 'dirname' ] |
|
| 511 | + $registry[$registryKey] = (new DataStructures\Module( |
|
| 512 | + $packageJsonFileInfo['dirname'] |
|
| 513 | 513 | )) |
| 514 | - ->setType($packageJsonFileInfo[ 'filename' ]) |
|
| 514 | + ->setType($packageJsonFileInfo['filename']) |
|
| 515 | 515 | ->setNamespace($moduleNamespace) |
| 516 | 516 | ->setSegments($moduleSegments) |
| 517 | 517 | ->setParentSegments($moduleParentSegments) |
@@ -673,8 +673,8 @@ discard block |
||
| 673 | 673 | $segment = dash($segment); |
| 674 | 674 | |
| 675 | 675 | if ($this->exists($segment)) { |
| 676 | - if ($this->registry[ $segment ] instanceof DataStructures\Module) { |
|
| 677 | - return $this->registry[ $segment ]; |
|
| 676 | + if ($this->registry[$segment] instanceof DataStructures\Module) { |
|
| 677 | + return $this->registry[$segment]; |
|
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | |
@@ -710,8 +710,8 @@ discard block |
||
| 710 | 710 | */ |
| 711 | 711 | public function first() |
| 712 | 712 | { |
| 713 | - if (isset($this->registry[ '' ])) { |
|
| 714 | - return $this->registry[ '' ]; |
|
| 713 | + if (isset($this->registry[''])) { |
|
| 714 | + return $this->registry['']; |
|
| 715 | 715 | } elseif (reset($this->registry)->type === 'APP') { |
| 716 | 716 | return reset($this->registry); |
| 717 | 717 | } |
@@ -733,7 +733,7 @@ discard block |
||
| 733 | 733 | $segments = (is_array($segments) ? implode('/', array_map('dash', $segments)) : $segments); |
| 734 | 734 | |
| 735 | 735 | if ($this->exists($segments)) { |
| 736 | - return $this->registry[ $segments ]; |
|
| 736 | + return $this->registry[$segments]; |
|
| 737 | 737 | } |
| 738 | 738 | |
| 739 | 739 | return false; |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | |
| 755 | 755 | foreach ($this as $key => $module) { |
| 756 | 756 | if ($module instanceof DataStructures\Module) { |
| 757 | - $namespaces[ $key ] = new SplNamespaceInfo($module->getNamespace(), $module->getRealPath()); |
|
| 757 | + $namespaces[$key] = new SplNamespaceInfo($module->getNamespace(), $module->getRealPath()); |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function offsetExists($offset) |
| 105 | 105 | { |
| 106 | - return isset($GLOBALS[ $offset ]); |
|
| 106 | + return isset($GLOBALS[$offset]); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // ------------------------------------------------------------------------ |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function &__get($offset) |
| 122 | 122 | { |
| 123 | - return $GLOBALS[ $offset ]; |
|
| 123 | + return $GLOBALS[$offset]; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // ------------------------------------------------------------------------ |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function offsetSet($offset, $value) |
| 180 | 180 | { |
| 181 | - $GLOBALS[ $offset ] = $value; |
|
| 181 | + $GLOBALS[$offset] = $value; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // ------------------------------------------------------------------------ |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function offsetUnset($offset) |
| 235 | 235 | { |
| 236 | - if (isset($GLOBALS[ $offset ])) { |
|
| 237 | - unset($GLOBALS[ $offset ]); |
|
| 236 | + if (isset($GLOBALS[$offset])) { |
|
| 237 | + unset($GLOBALS[$offset]); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
@@ -435,6 +435,6 @@ discard block |
||
| 435 | 435 | */ |
| 436 | 436 | public function offsetGet($offset) |
| 437 | 437 | { |
| 438 | - return (isset($GLOBALS[ $offset ])) ? $GLOBALS[ $offset ] : false; |
|
| 438 | + return (isset($GLOBALS[$offset])) ? $GLOBALS[$offset] : false; |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | \ No newline at end of file |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | PATH_APP . 'Config' . DIRECTORY_SEPARATOR, |
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | - if(null !== o2system()->modules) { |
|
| 48 | + if (null !== o2system()->modules) { |
|
| 49 | 49 | $configDirs = modules()->getDirs('Config', true); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | */ |
| 104 | 104 | public function offsetExists($offset) |
| 105 | 105 | { |
| 106 | - return isset($_ENV[ $offset ]); |
|
| 106 | + return isset($_ENV[$offset]); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // ------------------------------------------------------------------------ |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function &__get($offset) |
| 122 | 122 | { |
| 123 | - return $_ENV[ $offset ]; |
|
| 123 | + return $_ENV[$offset]; |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // ------------------------------------------------------------------------ |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function offsetSet($offset, $value) |
| 180 | 180 | { |
| 181 | - $_ENV[ $offset ] = $value; |
|
| 181 | + $_ENV[$offset] = $value; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | // ------------------------------------------------------------------------ |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | public function offsetUnset($offset) |
| 235 | 235 | { |
| 236 | - if (isset($_ENV[ $offset ])) { |
|
| 237 | - unset($_ENV[ $offset ]); |
|
| 236 | + if (isset($_ENV[$offset])) { |
|
| 237 | + unset($_ENV[$offset]); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
@@ -435,6 +435,6 @@ discard block |
||
| 435 | 435 | */ |
| 436 | 436 | public function offsetGet($offset) |
| 437 | 437 | { |
| 438 | - return (isset($_ENV[ $offset ])) ? $_ENV[ $offset ] : false; |
|
| 438 | + return (isset($_ENV[$offset])) ? $_ENV[$offset] : false; |
|
| 439 | 439 | } |
| 440 | 440 | } |
| 441 | 441 | \ No newline at end of file |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | $column = 'id'; |
| 62 | 62 | } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) { |
| 63 | 63 | $column = 'email'; |
| 64 | - } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) { |
|
| 64 | + } elseif (preg_match($this->config['msisdnRegex'], $username)) { |
|
| 65 | 65 | $column = 'msisdn'; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -78,9 +78,9 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | foreach ($account as $key => $value) { |
| 80 | 80 | if (strpos($key, 'record') !== false) { |
| 81 | - unset($account[ $key ]); |
|
| 81 | + unset($account[$key]); |
|
| 82 | 82 | } elseif (in_array($key, ['password', 'pin', 'token', 'sso'])) { |
| 83 | - unset($account[ $key ]); |
|
| 83 | + unset($account[$key]); |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | $column = 'id'; |
| 110 | 110 | } elseif (filter_var($username, FILTER_VALIDATE_EMAIL)) { |
| 111 | 111 | $column = 'email'; |
| 112 | - } elseif (preg_match($this->config[ 'msisdnRegex' ], $username)) { |
|
| 112 | + } elseif (preg_match($this->config['msisdnRegex'], $username)) { |
|
| 113 | 113 | $column = 'msisdn'; |
| 114 | 114 | } elseif (strpos($username, 'token-') !== false) { |
| 115 | 115 | $username = str_replace('token-', '', $username); |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | foreach ($account as $key => $value) { |
| 126 | 126 | if (strpos($key, 'record') !== false) { |
| 127 | - unset($account[ $key ]); |
|
| 127 | + unset($account[$key]); |
|
| 128 | 128 | } elseif (in_array($key, ['password', 'pin', 'token', 'sso'])) { |
| 129 | - unset($account[ $key ]); |
|
| 129 | + unset($account[$key]); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | if ($column === 'token') { |
| 134 | 134 | models('users')->update([ |
| 135 | - 'id' => $account[ 'id' ], |
|
| 135 | + 'id' => $account['id'], |
|
| 136 | 136 | 'token' => null, |
| 137 | 137 | ]); |
| 138 | 138 | } |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | public function authorize(ServerRequest $request) |
| 158 | 158 | { |
| 159 | - if (isset($_SESSION[ 'account' ][ 'role' ])) { |
|
| 159 | + if (isset($_SESSION['account']['role'])) { |
|
| 160 | 160 | $uriSegments = $request->getUri()->getSegments()->getString(); |
| 161 | - $role = $_SESSION[ 'account' ][ 'role' ]; |
|
| 161 | + $role = $_SESSION['account']['role']; |
|
| 162 | 162 | if (in_array($role->code, ['DEVELOPER', 'ADMINISTRATOR'])) { |
| 163 | 163 | globals()->store('authority', new Authority([ |
| 164 | 164 | 'permission' => 'GRANTED', |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | public function getIframeCode() |
| 198 | 198 | { |
| 199 | 199 | if ($this->signedOn() && $this->loggedIn() === false) { |
| 200 | - return '<iframe id="sign-on-iframe" width="1" height="1" src="' . rtrim($this->config[ 'sso' ][ 'server' ], |
|
| 200 | + return '<iframe id="sign-on-iframe" width="1" height="1" src="' . rtrim($this->config['sso']['server'], |
|
| 201 | 201 | '/') . '" style="display: none; visibility: hidden;"></iframe>'; |
| 202 | 202 | } |
| 203 | 203 | |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | $this->config = array_merge($this->config, $config); |
| 228 | 228 | |
| 229 | - if ($this->config[ 'responsive' ]) { |
|
| 229 | + if ($this->config['responsive']) { |
|
| 230 | 230 | $this->responsive(); |
| 231 | 231 | } |
| 232 | 232 | |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | foreach ($columns as $key => $column) { |
| 284 | 284 | $column = array_merge($defaultColumn, $column); |
| 285 | - $this->columns[ $key ] = $column; |
|
| 285 | + $this->columns[$key] = $column; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $this->setAppendColumns(); |
@@ -357,8 +357,8 @@ discard block |
||
| 357 | 357 | ]; |
| 358 | 358 | |
| 359 | 359 | foreach ($prependColumns as $key => $column) { |
| 360 | - if ($this->config[ $key ] === true) { |
|
| 361 | - $this->columns[ $key ] = $column; |
|
| 360 | + if ($this->config[$key] === true) { |
|
| 361 | + $this->columns[$key] = $column; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | 364 | } |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | ]; |
| 436 | 436 | |
| 437 | 437 | foreach ($appendColumns as $key => $column) { |
| 438 | - if ($this->config[ $key ] === true) { |
|
| 439 | - $this->columns[ $key ] = $column; |
|
| 438 | + if ($this->config[$key] === true) { |
|
| 439 | + $this->columns[$key] = $column; |
|
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | } |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | */ |
| 499 | 499 | public function render() |
| 500 | 500 | { |
| 501 | - if ($this->config[ 'ordering' ]) { |
|
| 501 | + if ($this->config['ordering']) { |
|
| 502 | 502 | $this->attributes->addAttributeClass('table-ordering'); |
| 503 | 503 | } |
| 504 | 504 | |
@@ -509,15 +509,15 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | $th = $tr->createColumn('th'); |
| 511 | 511 | |
| 512 | - $column[ 'attr' ][ 'data-column' ] = $key; |
|
| 512 | + $column['attr']['data-column'] = $key; |
|
| 513 | 513 | |
| 514 | - foreach ($column[ 'attr' ] as $name => $value) { |
|
| 514 | + foreach ($column['attr'] as $name => $value) { |
|
| 515 | 515 | if ( ! empty($value)) { |
| 516 | 516 | $th->attributes->addAttribute($name, $value); |
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if ($column[ 'sorting' ] === true) { |
|
| 520 | + if ($column['sorting'] === true) { |
|
| 521 | 521 | $icon = new Ui\Contents\Icon('fa fa-sort'); |
| 522 | 522 | $icon->attributes->addAttributeClass(['text-muted', 'float-right', 'mt-1']); |
| 523 | 523 | |
@@ -526,11 +526,11 @@ discard block |
||
| 526 | 526 | $th->childNodes->push($icon); |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | - if ($column[ 'show' ] === false) { |
|
| 529 | + if ($column['show'] === false) { |
|
| 530 | 530 | $th->attributes->addAttributeClass('hidden'); |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - $th->textContent->push(language()->getLine($column[ 'label' ])); |
|
| 533 | + $th->textContent->push(language()->getLine($column['label'])); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | // Render tbody |
@@ -538,8 +538,8 @@ discard block |
||
| 538 | 538 | $totalEntries = $this->rows->count(); |
| 539 | 539 | $totalRows = $this->rows->countAll(); |
| 540 | 540 | $currentPage = input()->get('page') ? input()->get('page') : 1; |
| 541 | - $startNumber = $currentPage == 1 ? 1 : $currentPage * $this->config[ 'entries' ][ 'minimum' ]; |
|
| 542 | - $totalPages = round($totalRows / $this->config[ 'entries' ][ 'minimum' ]); |
|
| 541 | + $startNumber = $currentPage == 1 ? 1 : $currentPage * $this->config['entries']['minimum']; |
|
| 542 | + $totalPages = round($totalRows / $this->config['entries']['minimum']); |
|
| 543 | 543 | $totalPages = $totalPages == 0 && $totalRows > 0 ? 1 : $totalPages; |
| 544 | 544 | |
| 545 | 545 | $i = $startNumber; |
@@ -550,18 +550,18 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | foreach ($this->columns as $key => $column) { |
| 552 | 552 | |
| 553 | - $column[ 'key' ] = $key; |
|
| 553 | + $column['key'] = $key; |
|
| 554 | 554 | $td = $tr->createColumn(); |
| 555 | 555 | |
| 556 | - $column[ 'attr' ][ 'data-column' ] = $key; |
|
| 556 | + $column['attr']['data-column'] = $key; |
|
| 557 | 557 | |
| 558 | - foreach ($column[ 'attr' ] as $name => $value) { |
|
| 558 | + foreach ($column['attr'] as $name => $value) { |
|
| 559 | 559 | if ( ! empty($value)) { |
| 560 | 560 | $td->attributes->addAttribute($name, $value); |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | - if ($column[ 'show' ] === false) { |
|
| 564 | + if ($column['show'] === false) { |
|
| 565 | 565 | $td->attributes->addAttributeClass('hidden'); |
| 566 | 566 | } |
| 567 | 567 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | $totalPages = 0; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | - $showEntries = input()->get('entries') ? input()->get('entries') : $this->config[ 'entries' ][ 'minimum' ]; |
|
| 583 | + $showEntries = input()->get('entries') ? input()->get('entries') : $this->config['entries']['minimum']; |
|
| 584 | 584 | |
| 585 | 585 | // Build table card |
| 586 | 586 | $card = new Ui\Components\Card(); |
@@ -593,33 +593,33 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | $buttons = new Ui\Components\Buttons\Group(); |
| 595 | 595 | foreach ($this->tools as $key => $tool) { |
| 596 | - if ($tool[ 'show' ] === false) { |
|
| 596 | + if ($tool['show'] === false) { |
|
| 597 | 597 | continue; |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - if ($tool[ 'label' ] === true) { |
|
| 600 | + if ($tool['label'] === true) { |
|
| 601 | 601 | $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
| 602 | - if ( ! empty($tool[ 'icon' ])) { |
|
| 603 | - $button->setIcon($tool[ 'icon' ]); |
|
| 602 | + if ( ! empty($tool['icon'])) { |
|
| 603 | + $button->setIcon($tool['icon']); |
|
| 604 | 604 | } |
| 605 | 605 | } else { |
| 606 | - $button = $buttons->createButton(new Ui\Contents\Icon($tool[ 'icon' ])); |
|
| 606 | + $button = $buttons->createButton(new Ui\Contents\Icon($tool['icon'])); |
|
| 607 | 607 | $button->attributes->addAttribute('data-toggle', 'tooltip'); |
| 608 | 608 | $button->attributes->addAttribute('title', |
| 609 | 609 | language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - if ( ! empty($tool[ 'href' ])) { |
|
| 613 | - $tool[ 'data-url' ] = $tool[ 'href' ]; |
|
| 612 | + if ( ! empty($tool['href'])) { |
|
| 613 | + $tool['data-url'] = $tool['href']; |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if (isset($tool[ 'attr' ])) { |
|
| 617 | - foreach ($tool[ 'attr' ] as $name => $value) { |
|
| 616 | + if (isset($tool['attr'])) { |
|
| 617 | + foreach ($tool['attr'] as $name => $value) { |
|
| 618 | 618 | $button->attributes->addAttribute($name, $value); |
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | - $button->setContextualClass($tool[ 'contextual' ]); |
|
| 622 | + $button->setContextualClass($tool['contextual']); |
|
| 623 | 623 | $button->smallSize(); |
| 624 | 624 | $button->attributes->addAttribute('data-action', $key); |
| 625 | 625 | } |
@@ -634,33 +634,33 @@ discard block |
||
| 634 | 634 | |
| 635 | 635 | $buttons = new Ui\Components\Buttons\Group(); |
| 636 | 636 | foreach ($this->options as $key => $option) { |
| 637 | - if ($option[ 'show' ] === false) { |
|
| 637 | + if ($option['show'] === false) { |
|
| 638 | 638 | continue; |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | - if ($option[ 'label' ] === true) { |
|
| 641 | + if ($option['label'] === true) { |
|
| 642 | 642 | $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
| 643 | - if ( ! empty($option[ 'icon' ])) { |
|
| 644 | - $button->setIcon($option[ 'icon' ]); |
|
| 643 | + if ( ! empty($option['icon'])) { |
|
| 644 | + $button->setIcon($option['icon']); |
|
| 645 | 645 | } |
| 646 | 646 | } else { |
| 647 | - $button = $buttons->createButton(new Ui\Contents\Icon($option[ 'icon' ])); |
|
| 647 | + $button = $buttons->createButton(new Ui\Contents\Icon($option['icon'])); |
|
| 648 | 648 | $button->attributes->addAttribute('data-toggle', 'tooltip'); |
| 649 | 649 | $button->attributes->addAttribute('title', |
| 650 | 650 | language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - if ( ! empty($option[ 'href' ])) { |
|
| 654 | - $option[ 'data-url' ] = $option[ 'href' ]; |
|
| 653 | + if ( ! empty($option['href'])) { |
|
| 654 | + $option['data-url'] = $option['href']; |
|
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - if (isset($option[ 'attr' ])) { |
|
| 658 | - foreach ($option[ 'attr' ] as $name => $value) { |
|
| 657 | + if (isset($option['attr'])) { |
|
| 658 | + foreach ($option['attr'] as $name => $value) { |
|
| 659 | 659 | $button->attributes->addAttribute($name, $value); |
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - $button->setContextualClass($option[ 'contextual' ]); |
|
| 663 | + $button->setContextualClass($option['contextual']); |
|
| 664 | 664 | $button->smallSize(); |
| 665 | 665 | $button->attributes->addAttribute('data-action', $key); |
| 666 | 666 | } |
@@ -695,10 +695,10 @@ discard block |
||
| 695 | 695 | $inputGroup->childNodes->push($addOn); |
| 696 | 696 | |
| 697 | 697 | $options = []; |
| 698 | - foreach (range((int)$this->config[ 'entries' ][ 'minimum' ], (int)$this->config[ 'entries' ][ 'maximum' ], |
|
| 699 | - (int)$this->config[ 'entries' ][ 'step' ]) as $entries |
|
| 698 | + foreach (range((int)$this->config['entries']['minimum'], (int)$this->config['entries']['maximum'], |
|
| 699 | + (int)$this->config['entries']['step']) as $entries |
|
| 700 | 700 | ) { |
| 701 | - $options[ $entries ] = $entries; |
|
| 701 | + $options[$entries] = $entries; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | $columnsDropdown = new Ui\Components\Dropdown(language()->getLine('TABLE_LABEL_COLUMNS')); |
@@ -706,13 +706,13 @@ discard block |
||
| 706 | 706 | |
| 707 | 707 | foreach ($this->columns as $key => $column) { |
| 708 | 708 | |
| 709 | - if ($column[ 'hiding' ] === false) { |
|
| 709 | + if ($column['hiding'] === false) { |
|
| 710 | 710 | continue; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | $label = new Ui\Components\Form\Elements\Label(); |
| 714 | 714 | $label->attributes->addAttributeClass('form-check-label'); |
| 715 | - $label->textContent->push(language()->getLine($column[ 'label' ])); |
|
| 715 | + $label->textContent->push(language()->getLine($column['label'])); |
|
| 716 | 716 | |
| 717 | 717 | $checkbox = new Ui\Components\Form\Elements\Input([ |
| 718 | 718 | 'type' => 'checkbox', |
@@ -723,7 +723,7 @@ discard block |
||
| 723 | 723 | |
| 724 | 724 | $checkbox->attributes->removeAttributeClass('form-control'); |
| 725 | 725 | |
| 726 | - if ($column[ 'show' ] === true) { |
|
| 726 | + if ($column['show'] === true) { |
|
| 727 | 727 | $checkbox->attributes->addAttribute('checked', 'checked'); |
| 728 | 728 | } |
| 729 | 729 | |
@@ -778,33 +778,33 @@ discard block |
||
| 778 | 778 | */ |
| 779 | 779 | protected function renderBodyColumn($td, array $column, Result\Row $row) |
| 780 | 780 | { |
| 781 | - switch ($column[ 'format' ]) { |
|
| 781 | + switch ($column['format']) { |
|
| 782 | 782 | default: |
| 783 | - if (is_callable($column[ 'format' ])) { |
|
| 784 | - if (is_array($column[ 'field' ])) { |
|
| 785 | - foreach ($column[ 'field' ] as $field) { |
|
| 786 | - $args[ $field ] = $row->offsetGet($field); |
|
| 783 | + if (is_callable($column['format'])) { |
|
| 784 | + if (is_array($column['field'])) { |
|
| 785 | + foreach ($column['field'] as $field) { |
|
| 786 | + $args[$field] = $row->offsetGet($field); |
|
| 787 | 787 | } |
| 788 | - $textContent = call_user_func_array($column[ 'format' ], $args); |
|
| 789 | - } elseif ($row->offsetExists($column[ 'field' ])) { |
|
| 790 | - $textContent = call_user_func_array($column[ 'format' ], |
|
| 791 | - [$row->offsetGet($column[ 'field' ])]); |
|
| 788 | + $textContent = call_user_func_array($column['format'], $args); |
|
| 789 | + } elseif ($row->offsetExists($column['field'])) { |
|
| 790 | + $textContent = call_user_func_array($column['format'], |
|
| 791 | + [$row->offsetGet($column['field'])]); |
|
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | $td->textContent->push($textContent); |
| 795 | 795 | |
| 796 | - } elseif (strpos($column[ 'format' ], '{{') !== false) { |
|
| 797 | - $textContent = str_replace(['{{', '}}'], '', $column[ 'format' ]); |
|
| 798 | - if (is_array($column[ 'field' ])) { |
|
| 799 | - foreach ($column[ 'field' ] as $field) { |
|
| 796 | + } elseif (strpos($column['format'], '{{') !== false) { |
|
| 797 | + $textContent = str_replace(['{{', '}}'], '', $column['format']); |
|
| 798 | + if (is_array($column['field'])) { |
|
| 799 | + foreach ($column['field'] as $field) { |
|
| 800 | 800 | if ($row->offsetExists($field)) { |
| 801 | 801 | $textContent = str_replace('$' . $field, $row->offsetGet($field), $textContent); |
| 802 | 802 | } else { |
| 803 | 803 | $textContent = str_replace('$' . $field, '', $textContent); |
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | - } elseif ($row->offsetExists($column[ 'field' ])) { |
|
| 807 | - $textContent = str_replace('$' . $column[ 'field' ], $row->offsetGet($column[ 'field' ]), |
|
| 806 | + } elseif ($row->offsetExists($column['field'])) { |
|
| 807 | + $textContent = str_replace('$' . $column['field'], $row->offsetGet($column['field']), |
|
| 808 | 808 | $textContent); |
| 809 | 809 | } |
| 810 | 810 | |
@@ -824,18 +824,18 @@ discard block |
||
| 824 | 824 | case 'text': |
| 825 | 825 | case 'price': |
| 826 | 826 | case 'number': |
| 827 | - if ($row->offsetExists($column[ 'field' ])) { |
|
| 828 | - $td->textContent->push($row->offsetGet($column[ 'field' ])); |
|
| 827 | + if ($row->offsetExists($column['field'])) { |
|
| 828 | + $td->textContent->push($row->offsetGet($column['field'])); |
|
| 829 | 829 | } |
| 830 | 830 | break; |
| 831 | 831 | case 'date': |
| 832 | - if ($row->offsetExists($column[ 'field' ])) { |
|
| 832 | + if ($row->offsetExists($column['field'])) { |
|
| 833 | 833 | print_out('date'); |
| 834 | 834 | } |
| 835 | 835 | break; |
| 836 | 836 | |
| 837 | 837 | case 'status': |
| 838 | - if ($row->offsetExists($column[ 'field' ])) { |
|
| 838 | + if ($row->offsetExists($column['field'])) { |
|
| 839 | 839 | $options = [ |
| 840 | 840 | 'PUBLISH' => 'success', |
| 841 | 841 | 'UNPUBLISH' => 'warning', |
@@ -845,8 +845,8 @@ discard block |
||
| 845 | 845 | ]; |
| 846 | 846 | |
| 847 | 847 | $badge = new Ui\Components\Badge( |
| 848 | - language()->getLine('TABLE_OPTION_' . $row->offsetGet($column[ 'field' ])), |
|
| 849 | - $options[ $row->offsetGet($column[ 'field' ]) ] |
|
| 848 | + language()->getLine('TABLE_OPTION_' . $row->offsetGet($column['field'])), |
|
| 849 | + $options[$row->offsetGet($column['field'])] |
|
| 850 | 850 | ); |
| 851 | 851 | |
| 852 | 852 | $td->childNodes->push($badge); |
@@ -860,29 +860,29 @@ discard block |
||
| 860 | 860 | |
| 861 | 861 | foreach ($this->actions as $key => $action) { |
| 862 | 862 | |
| 863 | - if ($action[ 'show' ] === false) { |
|
| 863 | + if ($action['show'] === false) { |
|
| 864 | 864 | continue; |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - if ($action[ 'label' ] === true) { |
|
| 867 | + if ($action['label'] === true) { |
|
| 868 | 868 | $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
| 869 | - if ( ! empty($action[ 'icon' ])) { |
|
| 870 | - $button->setIcon($action[ 'icon' ]); |
|
| 869 | + if ( ! empty($action['icon'])) { |
|
| 870 | + $button->setIcon($action['icon']); |
|
| 871 | 871 | } |
| 872 | 872 | } else { |
| 873 | - $button = $buttons->createButton(new Ui\Contents\Icon($action[ 'icon' ])); |
|
| 873 | + $button = $buttons->createButton(new Ui\Contents\Icon($action['icon'])); |
|
| 874 | 874 | $button->attributes->addAttribute('data-toggle', 'tooltip'); |
| 875 | 875 | $button->attributes->addAttribute('title', |
| 876 | 876 | language()->getLine('TABLE_BUTTON_' . strtoupper($key))); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - if (isset($action[ 'attr' ])) { |
|
| 880 | - foreach ($action[ 'attr' ] as $name => $value) { |
|
| 879 | + if (isset($action['attr'])) { |
|
| 880 | + foreach ($action['attr'] as $name => $value) { |
|
| 881 | 881 | $button->attributes->addAttribute($name, $value); |
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | 884 | |
| 885 | - $button->setContextualClass($action[ 'contextual' ]); |
|
| 885 | + $button->setContextualClass($action['contextual']); |
|
| 886 | 886 | $button->smallSize(); |
| 887 | 887 | $button->attributes->addAttribute('data-action', $key); |
| 888 | 888 | } |