@@ -4,15 +4,15 @@ |
||
4 | 4 | |
5 | 5 | abstract class Controller |
6 | 6 | { |
7 | - protected $app; |
|
7 | + protected $app; |
|
8 | 8 | |
9 | - public function __construct(Application $app) |
|
10 | - { |
|
9 | + public function __construct(Application $app) |
|
10 | + { |
|
11 | 11 | $this->app = $app; |
12 | - } |
|
12 | + } |
|
13 | 13 | |
14 | - public function __get($key) |
|
15 | - { |
|
14 | + public function __get($key) |
|
15 | + { |
|
16 | 16 | return $this->app->get($key); |
17 | - } |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -6,27 +6,27 @@ discard block |
||
6 | 6 | |
7 | 7 | class File |
8 | 8 | { |
9 | - const DS = DIRECTORY_SEPARATOR; |
|
9 | + const DS = DIRECTORY_SEPARATOR; |
|
10 | 10 | |
11 | - private $root; |
|
11 | + private $root; |
|
12 | 12 | |
13 | - public function __construct($root) |
|
14 | - { |
|
13 | + public function __construct($root) |
|
14 | + { |
|
15 | 15 | $this->root = $root; |
16 | - } |
|
16 | + } |
|
17 | 17 | |
18 | - public function root() |
|
19 | - { |
|
18 | + public function root() |
|
19 | + { |
|
20 | 20 | return $this->root; |
21 | - } |
|
21 | + } |
|
22 | 22 | |
23 | - public function exists($file) |
|
24 | - { |
|
23 | + public function exists($file) |
|
24 | + { |
|
25 | 25 | return file_exists($file); |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | - public function call($file) |
|
29 | - { |
|
28 | + public function call($file) |
|
29 | + { |
|
30 | 30 | if ($this->exists($file)) { |
31 | 31 | |
32 | 32 | return require $file; |
@@ -35,30 +35,30 @@ discard block |
||
35 | 35 | |
36 | 36 | throw new Exception("$file is not found"); |
37 | 37 | } |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public function to($path, $ext = null) |
|
41 | - { |
|
40 | + public function to($path, $ext = null) |
|
41 | + { |
|
42 | 42 | return $this->root . static::DS . str_replace('/', static::DS, $path . $ext); |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public function toPublic($target = null) |
|
46 | - { |
|
45 | + public function toPublic($target = null) |
|
46 | + { |
|
47 | 47 | return $this->to('public/' . $target); |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | - public function images() |
|
51 | - { |
|
50 | + public function images() |
|
51 | + { |
|
52 | 52 | return $this->toPublic('images'); |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - public function js() |
|
56 | - { |
|
55 | + public function js() |
|
56 | + { |
|
57 | 57 | return $this->toPublic('js'); |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - public function css() |
|
61 | - { |
|
60 | + public function css() |
|
61 | + { |
|
62 | 62 | return $this->toPublic('css'); |
63 | - } |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -6,44 +6,44 @@ |
||
6 | 6 | |
7 | 7 | class Response |
8 | 8 | { |
9 | - private $app; |
|
9 | + private $app; |
|
10 | 10 | |
11 | - private $headers = []; |
|
11 | + private $headers = []; |
|
12 | 12 | |
13 | - private $content = ''; |
|
13 | + private $content = ''; |
|
14 | 14 | |
15 | - public function __construct(Application $app) |
|
16 | - { |
|
15 | + public function __construct(Application $app) |
|
16 | + { |
|
17 | 17 | $this->app = $app; |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - public function setOutput($content) |
|
21 | - { |
|
20 | + public function setOutput($content) |
|
21 | + { |
|
22 | 22 | $this->content = $content; |
23 | - } |
|
23 | + } |
|
24 | 24 | |
25 | - public function setHeaders($header, $value) |
|
26 | - { |
|
25 | + public function setHeaders($header, $value) |
|
26 | + { |
|
27 | 27 | $this->headers[$header] = $value; |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - public function sendOutput() |
|
31 | - { |
|
30 | + public function sendOutput() |
|
31 | + { |
|
32 | 32 | echo $this->content; |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - public function sendHeaders() |
|
36 | - { |
|
35 | + public function sendHeaders() |
|
36 | + { |
|
37 | 37 | foreach($this->headers as $header => $value) |
38 | 38 | { |
39 | - header($header . ':' . $value); |
|
39 | + header($header . ':' . $value); |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | 42 | |
43 | - public function send() |
|
44 | - { |
|
43 | + public function send() |
|
44 | + { |
|
45 | 45 | $this->sendHeaders(); |
46 | 46 | |
47 | 47 | $this->sendOutput(); |
48 | - } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -34,7 +34,7 @@ |
||
34 | 34 | |
35 | 35 | public function sendHeaders() |
36 | 36 | { |
37 | - foreach($this->headers as $header => $value) |
|
37 | + foreach ($this->headers as $header => $value) |
|
38 | 38 | { |
39 | 39 | header($header . ':' . $value); |
40 | 40 | } |
@@ -4,87 +4,87 @@ |
||
4 | 4 | |
5 | 5 | class Pagination |
6 | 6 | { |
7 | - private $app; |
|
7 | + private $app; |
|
8 | 8 | |
9 | - private $totalItems; |
|
9 | + private $totalItems; |
|
10 | 10 | |
11 | - private $itemsPerPage = 10; |
|
11 | + private $itemsPerPage = 10; |
|
12 | 12 | |
13 | - private $lastPage; |
|
13 | + private $lastPage; |
|
14 | 14 | |
15 | - private $page = 1; |
|
15 | + private $page = 1; |
|
16 | 16 | |
17 | - public function __construct(Application $app) |
|
18 | - { |
|
17 | + public function __construct(Application $app) |
|
18 | + { |
|
19 | 19 | $this->app = $app; |
20 | 20 | |
21 | 21 | $this->setCurrentPage(); |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - private function setCurrentPage() |
|
25 | - { |
|
24 | + private function setCurrentPage() |
|
25 | + { |
|
26 | 26 | $page = $this->app->request->get('page'); |
27 | 27 | |
28 | 28 | if (! is_numeric($page) || $page < 1) { |
29 | - $page = 1; |
|
29 | + $page = 1; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $this->page = $page; |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | - public function page() |
|
36 | - { |
|
35 | + public function page() |
|
36 | + { |
|
37 | 37 | return $this->page; |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - public function itemsPerPage() |
|
41 | - { |
|
40 | + public function itemsPerPage() |
|
41 | + { |
|
42 | 42 | return $this->itemsPerPage; |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - public function totalItems() |
|
46 | - { |
|
45 | + public function totalItems() |
|
46 | + { |
|
47 | 47 | return $this->totalItems; |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | - public function last() |
|
51 | - { |
|
50 | + public function last() |
|
51 | + { |
|
52 | 52 | return $this->lastPage; |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - public function next() |
|
56 | - { |
|
55 | + public function next() |
|
56 | + { |
|
57 | 57 | return $this->page + 1; |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - public function prev() |
|
61 | - { |
|
60 | + public function prev() |
|
61 | + { |
|
62 | 62 | return $this->page - 1; |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - public function setTotalItems($totalItems) |
|
66 | - { |
|
65 | + public function setTotalItems($totalItems) |
|
66 | + { |
|
67 | 67 | $this->totalItems = $totalItems; |
68 | 68 | |
69 | 69 | return $this; |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - public function setItemsPerPage($itemsPerPage) |
|
73 | - { |
|
72 | + public function setItemsPerPage($itemsPerPage) |
|
73 | + { |
|
74 | 74 | $this->itemsPerPage = $itemsPerPage; |
75 | 75 | |
76 | 76 | return $this; |
77 | - } |
|
77 | + } |
|
78 | 78 | |
79 | - public function paginate() |
|
80 | - { |
|
79 | + public function paginate() |
|
80 | + { |
|
81 | 81 | $this->setLastPage(); |
82 | 82 | |
83 | 83 | return $this; |
84 | - } |
|
84 | + } |
|
85 | 85 | |
86 | - private function setLastPage() |
|
87 | - { |
|
86 | + private function setLastPage() |
|
87 | + { |
|
88 | 88 | $this->lastPage = ceil($this->totalItems / $this->itemsPerPage); |
89 | - } |
|
89 | + } |
|
90 | 90 | } |
91 | 91 | \ No newline at end of file |
@@ -25,7 +25,7 @@ |
||
25 | 25 | { |
26 | 26 | $page = $this->app->request->get('page'); |
27 | 27 | |
28 | - if (! is_numeric($page) || $page < 1) { |
|
28 | + if (!is_numeric($page) || $page < 1) { |
|
29 | 29 | $page = 1; |
30 | 30 | } |
31 | 31 |
@@ -7,16 +7,16 @@ |
||
7 | 7 | |
8 | 8 | class RedirectMiddleware implements Middleware |
9 | 9 | { |
10 | - public function handle(Application $app, $next) |
|
11 | - { |
|
10 | + public function handle(Application $app, $next) |
|
11 | + { |
|
12 | 12 | |
13 | 13 | if (! $this->session->has('error') || $this->session->get('error') != true) { |
14 | 14 | |
15 | - $this->url->redirectTo('/'); |
|
15 | + $this->url->redirectTo('/'); |
|
16 | 16 | |
17 | 17 | } else { |
18 | 18 | |
19 | - $this->session->remove('error'); |
|
19 | + $this->session->remove('error'); |
|
20 | + } |
|
20 | 21 | } |
21 | - } |
|
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public function handle(Application $app, $next) |
11 | 11 | { |
12 | 12 | |
13 | - if (! $this->session->has('error') || $this->session->get('error') != true) { |
|
13 | + if (!$this->session->has('error') || $this->session->get('error') != true) { |
|
14 | 14 | |
15 | 15 | $this->url->redirectTo('/'); |
16 | 16 |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'db' => [ |
|
4 | + 'db' => [ |
|
5 | 5 | 'server' => 'localhost', |
6 | 6 | 'dbname' => 'blog', |
7 | 7 | 'dbuser' => 'root', |
8 | 8 | 'dbpass' => '' |
9 | - ], |
|
10 | - 'website' => [ |
|
9 | + ], |
|
10 | + 'website' => [ |
|
11 | 11 | 'websiteLang' => 'de', |
12 | 12 | 'websiteCharset' => 'UTF-8', |
13 | 13 | 'websiteDecsription' => 'Nice Framework', |
14 | 14 | 'websiteKeywords' => 'framework', |
15 | 15 | 'websiteAuth' => 'Refat Alsakka', |
16 | 16 | 'websiteName' => 'framework', |
17 | - ], |
|
17 | + ], |
|
18 | 18 | ]; |
19 | 19 | \ No newline at end of file |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class DataProtectionController extends Controller |
8 | 8 | { |
9 | - public function index() |
|
10 | - { |
|
9 | + public function index() |
|
10 | + { |
|
11 | 11 | $context = [ |
12 | 12 | |
13 | 13 | ]; |
14 | 14 | return $this->PugView->render('website/pages/dataProtection', $context); |
15 | - } |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |
@@ -6,8 +6,8 @@ |
||
6 | 6 | |
7 | 7 | class LogoutController extends Controller |
8 | 8 | { |
9 | - public function index() |
|
10 | - { |
|
9 | + public function index() |
|
10 | + { |
|
11 | 11 | |
12 | - } |
|
12 | + } |
|
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -6,11 +6,11 @@ |
||
6 | 6 | |
7 | 7 | class NotfoundController extends Controller |
8 | 8 | { |
9 | - public function index() |
|
10 | - { |
|
9 | + public function index() |
|
10 | + { |
|
11 | 11 | $context = [ |
12 | 12 | |
13 | 13 | ]; |
14 | 14 | return $this->PugView->render('notfound', $context); |
15 | - } |
|
15 | + } |
|
16 | 16 | } |
17 | 17 | \ No newline at end of file |