@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class Application |
| 13 | 13 | { |
| 14 | - private $container = []; |
|
| 14 | + private $container = []; |
|
| 15 | 15 | |
| 16 | - private static $instance; |
|
| 16 | + private static $instance; |
|
| 17 | 17 | |
| 18 | - public function __construct(File $file) |
|
| 19 | - { |
|
| 18 | + public function __construct(File $file) |
|
| 19 | + { |
|
| 20 | 20 | $this->handleErrors(); |
| 21 | 21 | |
| 22 | 22 | $this->share('file', $file); |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | $this->share('alias', $this->file->call($this->file->to('config/alias', '.php'))); |
| 27 | 27 | |
| 28 | 28 | $this->loadHelpers(); |
| 29 | - } |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - private function handleErrors() { |
|
| 31 | + private function handleErrors() { |
|
| 32 | 32 | |
| 33 | 33 | $run = new Whoops(); |
| 34 | 34 | |
@@ -36,23 +36,23 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | if (WhoopsMisc::isAjaxRequest()) { |
| 38 | 38 | |
| 39 | - $jsonHandler = new JsonResponseHandler(); |
|
| 39 | + $jsonHandler = new JsonResponseHandler(); |
|
| 40 | 40 | |
| 41 | - $jsonHandler->setJsonApi(true); |
|
| 41 | + $jsonHandler->setJsonApi(true); |
|
| 42 | 42 | |
| 43 | - $run->prependHandler($jsonHandler); |
|
| 43 | + $run->prependHandler($jsonHandler); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $run->register(); |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public static function getInstance($file = null) |
|
| 50 | - { |
|
| 49 | + public static function getInstance($file = null) |
|
| 50 | + { |
|
| 51 | 51 | return static::$instance = is_null(static::$instance) ? new static($file) : static::$instance; |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - public function run() |
|
| 55 | - { |
|
| 54 | + public function run() |
|
| 55 | + { |
|
| 56 | 56 | $this->session->start(); |
| 57 | 57 | |
| 58 | 58 | $this->request->prepareUrl(); |
@@ -66,63 +66,63 @@ discard block |
||
| 66 | 66 | $this->response->setOutput($output); |
| 67 | 67 | |
| 68 | 68 | $this->response->send(); |
| 69 | - } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - private function loadHelpers() |
|
| 72 | - { |
|
| 71 | + private function loadHelpers() |
|
| 72 | + { |
|
| 73 | 73 | $helpers = $this->file->to('Core/helpers', '.php'); |
| 74 | 74 | |
| 75 | 75 | $this->file->call($helpers); |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - public function coreClasses() |
|
| 79 | - { |
|
| 78 | + public function coreClasses() |
|
| 79 | + { |
|
| 80 | 80 | return $this->alias['classes']; |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function share($key, $value) |
|
| 84 | - { |
|
| 83 | + public function share($key, $value) |
|
| 84 | + { |
|
| 85 | 85 | if ($value instanceof Closure) $value = call_user_func($value, $this); |
| 86 | 86 | |
| 87 | 87 | $this->container[$key] = $value; |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - public function get($key) |
|
| 91 | - { |
|
| 90 | + public function get($key) |
|
| 91 | + { |
|
| 92 | 92 | if (! $this->isSharing($key)) { |
| 93 | 93 | |
| 94 | - if ($this->isCoreAlias($key)) { |
|
| 94 | + if ($this->isCoreAlias($key)) { |
|
| 95 | 95 | |
| 96 | 96 | $this->share($key, $this->createObject($key)); |
| 97 | 97 | |
| 98 | - } else { |
|
| 98 | + } else { |
|
| 99 | 99 | |
| 100 | 100 | throw new Exception("$key is not found"); |
| 101 | 101 | exit(); |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | } |
| 104 | 104 | return $this->container[$key]; |
| 105 | - } |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - public function isSharing($key) |
|
| 108 | - { |
|
| 107 | + public function isSharing($key) |
|
| 108 | + { |
|
| 109 | 109 | return isset($this->container[$key]); |
| 110 | - } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - public function isCoreAlias($key) |
|
| 113 | - { |
|
| 112 | + public function isCoreAlias($key) |
|
| 113 | + { |
|
| 114 | 114 | return isset($this->coreClasses()[$key]); |
| 115 | - } |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - public function createObject($key) |
|
| 118 | - { |
|
| 117 | + public function createObject($key) |
|
| 118 | + { |
|
| 119 | 119 | $object = $this->coreClasses()[$key]; |
| 120 | 120 | |
| 121 | 121 | return new $object($this); |
| 122 | - } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | - public function __get($key) |
|
| 125 | - { |
|
| 124 | + public function __get($key) |
|
| 125 | + { |
|
| 126 | 126 | return $this->get($key); |
| 127 | - } |
|
| 127 | + } |
|
| 128 | 128 | } |
| 129 | 129 | \ No newline at end of file |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | |
| 90 | 90 | public function get($key) |
| 91 | 91 | { |
| 92 | - if (! $this->isSharing($key)) { |
|
| 92 | + if (!$this->isSharing($key)) { |
|
| 93 | 93 | |
| 94 | 94 | if ($this->isCoreAlias($key)) { |
| 95 | 95 | |
@@ -59,7 +59,9 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | $this->file->call($this->file->to('config/constant.php')); |
| 61 | 61 | |
| 62 | - foreach (glob("routes/**/*.php") as $route) $this->file->call($this->file->to($route)); |
|
| 62 | + foreach (glob("routes/**/*.php") as $route) { |
|
| 63 | + $this->file->call($this->file->to($route)); |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | 66 | $output = $this->route->getProperRoute(); |
| 65 | 67 | |
@@ -82,7 +84,9 @@ discard block |
||
| 82 | 84 | |
| 83 | 85 | public function share($key, $value) |
| 84 | 86 | { |
| 85 | - if ($value instanceof Closure) $value = call_user_func($value, $this); |
|
| 87 | + if ($value instanceof Closure) { |
|
| 88 | + $value = call_user_func($value, $this); |
|
| 89 | + } |
|
| 86 | 90 | |
| 87 | 91 | $this->container[$key] = $value; |
| 88 | 92 | } |
@@ -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 |