@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | // Show incoming variables and view helper functions |
| 12 | 12 | //echo showEnvironment(get_defined_vars(), get_defined_functions()); |
| 13 | 13 | |
| 14 | -$htmlClass = $htmlClass ?? []; |
|
| 14 | +$htmlClass = $htmlClass ?? [ ]; |
|
| 15 | 15 | $lang = $lang ?? "sv"; |
| 16 | 16 | $charset = $charset ?? "utf-8"; |
| 17 | 17 | $title = ($title ?? "No title") . ($baseTitle ?? " | No base title defined"); |
@@ -22,33 +22,33 @@ discard block |
||
| 22 | 22 | $session = $di->get("session"); |
| 23 | 23 | if ($request->getGet("style")) { |
| 24 | 24 | $session->set("redirect", currentUrl()); |
| 25 | - redirect("style/update/" . rawurlencode($_GET["style"])); |
|
| 25 | + redirect("style/update/" . rawurlencode($_GET[ "style" ])); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // Get the active stylesheet, if any. |
| 29 | 29 | $activeStyle = $session->get(StyleChooserController::getSessionKey(), null); |
| 30 | 30 | if ($activeStyle) { |
| 31 | - $stylesheets = []; |
|
| 32 | - $stylesheets[] = $activeStyle; |
|
| 31 | + $stylesheets = [ ]; |
|
| 32 | + $stylesheets[ ] = $activeStyle; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Get hgrid & vgrid |
| 36 | 36 | if ($request->hasGet("hgrid")) { |
| 37 | - $htmlClass[] = "hgrid"; |
|
| 37 | + $htmlClass[ ] = "hgrid"; |
|
| 38 | 38 | } |
| 39 | 39 | if ($request->hasGet("vgrid")) { |
| 40 | - $htmlClass[] = "vgrid"; |
|
| 40 | + $htmlClass[ ] = "vgrid"; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // Show regions |
| 44 | 44 | if ($request->hasGet("regions")) { |
| 45 | - $htmlClass[] = "regions"; |
|
| 45 | + $htmlClass[ ] = "regions"; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | // Get flash message if any and add to region flash-message |
| 49 | 49 | $flashMessage = $session->getOnce("flashmessage"); |
| 50 | 50 | if ($flashMessage) { |
| 51 | - $di->get("view")->add(__DIR__ . "/../flashmessage/default", ["message" => $flashMessage], "flash-message"); |
|
| 51 | + $di->get("view")->add(__DIR__ . "/../flashmessage/default", [ "message" => $flashMessage ], "flash-message"); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Get current route to make as body class |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | $sidebarLeft = regionHasContent("sidebar-left"); |
| 212 | 212 | $sidebarRight = regionHasContent("sidebar-right"); |
| 213 | 213 | $class = ""; |
| 214 | -$class .= $sidebarLeft ? "has-sidebar-left " : ""; |
|
| 214 | +$class .= $sidebarLeft ? "has-sidebar-left " : ""; |
|
| 215 | 215 | $class .= $sidebarRight ? "has-sidebar-right " : ""; |
| 216 | 216 | $class .= empty($class) ? "" : "has-sidebar"; |
| 217 | 217 | ?> |
@@ -10,9 +10,9 @@ |
||
| 10 | 10 | //echo showEnvironment(get_defined_vars(), get_defined_functions()); |
| 11 | 11 | |
| 12 | 12 | // Prepare classes |
| 13 | -$classes[] = "article"; |
|
| 13 | +$classes[ ] = "article"; |
|
| 14 | 14 | if (isset($class)) { |
| 15 | - $classes[] = $class; |
|
| 15 | + $classes[ ] = $class; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | |
@@ -10,9 +10,9 @@ discard block |
||
| 10 | 10 | //echo showEnvironment(get_defined_vars(), get_defined_functions()); |
| 11 | 11 | |
| 12 | 12 | // Prepare classes |
| 13 | -$classes[] = "block"; |
|
| 13 | +$classes[ ] = "block"; |
|
| 14 | 14 | if (isset($class)) { |
| 15 | - $classes[] = $class; |
|
| 15 | + $classes[ ] = $class; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | // Load content details from route |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | // Prepare title |
| 24 | -$title = isset($title) && !empty($title)? $title : null; |
|
| 24 | +$title = isset($title) && !empty($title) ? $title : null; |
|
| 25 | 25 | $header = isset($header) ? $header : $title; |
| 26 | 26 | |
| 27 | 27 | // Prepare content into text |
@@ -6,15 +6,15 @@ discard block |
||
| 6 | 6 | class User extends ActiveRecordModel |
| 7 | 7 | { |
| 8 | 8 | /** |
| 9 | - * @var string $tableName name of the database table. |
|
| 10 | - */ |
|
| 9 | + * @var string $tableName name of the database table. |
|
| 10 | + */ |
|
| 11 | 11 | protected $tableName = "User"; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * Columns in the table. |
|
| 15 | - * |
|
| 16 | - * @var integer $id primary key auto incremented. |
|
| 17 | - */ |
|
| 14 | + * Columns in the table. |
|
| 15 | + * |
|
| 16 | + * @var integer $id primary key auto incremented. |
|
| 17 | + */ |
|
| 18 | 18 | public $id; |
| 19 | 19 | public $username; |
| 20 | 20 | public $password; |
@@ -27,26 +27,26 @@ discard block |
||
| 27 | 27 | * A database driven model. |
| 28 | 28 | */ |
| 29 | 29 | /** |
| 30 | - * Set the password. |
|
| 31 | - * |
|
| 32 | - * @param string $password the password to use. |
|
| 33 | - * |
|
| 34 | - * @return void |
|
| 35 | - */ |
|
| 30 | + * Set the password. |
|
| 31 | + * |
|
| 32 | + * @param string $password the password to use. |
|
| 33 | + * |
|
| 34 | + * @return void |
|
| 35 | + */ |
|
| 36 | 36 | public function setPassword($password) |
| 37 | 37 | { |
| 38 | 38 | $this->password = password_hash($password, PASSWORD_DEFAULT); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * Verify the acronym and the password, if successful the object contains |
|
| 43 | - * all details from the database row. |
|
| 44 | - * |
|
| 45 | - * @param string $acronym acronym to check. |
|
| 46 | - * @param string $password the password to use. |
|
| 47 | - * |
|
| 48 | - * @return boolean true if acronym and password matches, else false. |
|
| 49 | - */ |
|
| 42 | + * Verify the acronym and the password, if successful the object contains |
|
| 43 | + * all details from the database row. |
|
| 44 | + * |
|
| 45 | + * @param string $acronym acronym to check. |
|
| 46 | + * @param string $password the password to use. |
|
| 47 | + * |
|
| 48 | + * @return boolean true if acronym and password matches, else false. |
|
| 49 | + */ |
|
| 50 | 50 | public function verifyPassword($username, $password) |
| 51 | 51 | { |
| 52 | 52 | $this->find("username", $username); |
@@ -83,9 +83,9 @@ |
||
| 83 | 83 | $session->set("login", $user->id); |
| 84 | 84 | |
| 85 | 85 | if (!$res) { |
| 86 | - $this->form->rememberValues(); |
|
| 87 | - $this->form->addOutput("User or password did not match."); |
|
| 88 | - return false; |
|
| 86 | + $this->form->rememberValues(); |
|
| 87 | + $this->form->addOutput("User or password did not match."); |
|
| 88 | + return false; |
|
| 89 | 89 | } |
| 90 | 90 | $this->form->addOutput("User " . $user->username . " logged in."); |
| 91 | 91 | return true; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | "submit" => [ |
| 41 | 41 | "type" => "submit", |
| 42 | 42 | "value" => "Login", |
| 43 | - "callback" => [$this, "callbackSubmit"] |
|
| 43 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 44 | 44 | ], |
| 45 | 45 | ] |
| 46 | 46 | ); |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | public function callbackSubmit() |
| 58 | 58 | { |
| 59 | 59 | // Get values from the submitted form |
| 60 | - $username = $this->form->value("username"); |
|
| 61 | - $password = $this->form->value("password"); |
|
| 60 | + $username = $this->form->value("username"); |
|
| 61 | + $password = $this->form->value("password"); |
|
| 62 | 62 | |
| 63 | 63 | // Try to login |
| 64 | 64 | // $db = $this->di->get("dbqb"); |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | * |
| 87 | 87 | * @return boolean true if okey, false if something went wrong. |
| 88 | 88 | */ |
| 89 | - public function callbackSubmit() |
|
| 89 | + public function callbackSubmit() |
|
| 90 | 90 | { |
| 91 | 91 | // Get values from the submitted form |
| 92 | 92 | $user = new User(); |
@@ -26,20 +26,20 @@ discard block |
||
| 26 | 26 | [ |
| 27 | 27 | "id" => [ |
| 28 | 28 | "type" => "text", |
| 29 | - "validation" => ["not_empty"], |
|
| 29 | + "validation" => [ "not_empty" ], |
|
| 30 | 30 | "readonly" => "readonly", |
| 31 | 31 | "value" => $user->id, |
| 32 | 32 | ], |
| 33 | 33 | |
| 34 | 34 | "username" => [ |
| 35 | 35 | "type" => "text", |
| 36 | - "validation" => ["not_empty"], |
|
| 36 | + "validation" => [ "not_empty" ], |
|
| 37 | 37 | "value" => $user->username, |
| 38 | 38 | ], |
| 39 | 39 | |
| 40 | 40 | "password" => [ |
| 41 | 41 | "type" => "password", |
| 42 | - "validation" => ["not_empty"], |
|
| 42 | + "validation" => [ "not_empty" ], |
|
| 43 | 43 | ], |
| 44 | 44 | |
| 45 | 45 | "password-again" => [ |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | "email" => [ |
| 53 | 53 | "type" => "email", |
| 54 | - "validation" => ["not_empty"], |
|
| 54 | + "validation" => [ "not_empty" ], |
|
| 55 | 55 | "value" => $user->email, |
| 56 | 56 | ], |
| 57 | 57 | |
| 58 | 58 | "submit" => [ |
| 59 | 59 | "type" => "submit", |
| 60 | 60 | "value" => "Create user", |
| 61 | - "callback" => [$this, "callbackSubmit"] |
|
| 61 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 62 | 62 | ], |
| 63 | 63 | ] |
| 64 | 64 | ); |
@@ -97,14 +97,14 @@ discard block |
||
| 97 | 97 | $email = $this->form->value("email"); |
| 98 | 98 | |
| 99 | 99 | // Check password matches |
| 100 | - if ($password !== $passwordAgain ) { |
|
| 100 | + if ($password !== $passwordAgain) { |
|
| 101 | 101 | $this->form->rememberValues(); |
| 102 | 102 | $this->form->addOutput("Password did not match."); |
| 103 | 103 | return false; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $user->find("id", $this->form->value("id")); |
| 107 | - $user->username = $this->form->value("username"); |
|
| 107 | + $user->username = $this->form->value("username"); |
|
| 108 | 108 | $user->password = $this->form->value("password"); |
| 109 | 109 | $user->email = $this->form->value("email"); |
| 110 | 110 | $user->save(); |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | * |
| 62 | 62 | * @return boolean true if okey, false if something went wrong. |
| 63 | 63 | */ |
| 64 | - public function callbackSubmit() |
|
| 64 | + public function callbackSubmit() |
|
| 65 | 65 | { |
| 66 | 66 | // Get values from the submitted form |
| 67 | 67 | $username = $this->form->value("username"); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | "submit" => [ |
| 48 | 48 | "type" => "submit", |
| 49 | 49 | "value" => "Create user", |
| 50 | - "callback" => [$this, "callbackSubmit"] |
|
| 50 | + "callback" => [ $this, "callbackSubmit" ] |
|
| 51 | 51 | ], |
| 52 | 52 | ] |
| 53 | 53 | ); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $email = $this->form->value("email"); |
| 71 | 71 | |
| 72 | 72 | // Check password matches |
| 73 | - if ($password !== $passwordAgain ) { |
|
| 73 | + if ($password !== $passwordAgain) { |
|
| 74 | 74 | $this->form->rememberValues(); |
| 75 | 75 | $this->form->addOutput("Password did not match."); |
| 76 | 76 | return false; |
@@ -22,7 +22,6 @@ |
||
| 22 | 22 | * @param string $message with details. |
| 23 | 23 | * |
| 24 | 24 | * @throws Anax\Route\Exception\NotFoundException |
| 25 | - |
|
| 26 | 25 | * @return object as the response. |
| 27 | 26 | */ |
| 28 | 27 | public function catchAll() : object |
@@ -52,13 +52,13 @@ |
||
| 52 | 52 | $page->add( |
| 53 | 53 | "anax/v2/error/default", |
| 54 | 54 | [ |
| 55 | - "header" => $pages[$path][0], |
|
| 56 | - "text" => $pages[$path][1], |
|
| 55 | + "header" => $pages[ $path ][ 0 ], |
|
| 56 | + "text" => $pages[ $path ][ 1 ], |
|
| 57 | 57 | ] |
| 58 | 58 | ); |
| 59 | 59 | |
| 60 | 60 | return $page->render([ |
| 61 | - "title" => $pages[$path][0] . $title |
|
| 61 | + "title" => $pages[ $path ][ 0 ] . $title |
|
| 62 | 62 | ], $path); |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $json = [ |
| 59 | 59 | "message" => __METHOD__ . ", \$db is {$this->db}", |
| 60 | 60 | ]; |
| 61 | - return [$json]; |
|
| 61 | + return [ $json ]; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | "message" => __METHOD__ . "<p>\$di contains: $services", |
| 78 | 78 | "di" => $this->di->getServices(), |
| 79 | 79 | ]; |
| 80 | - return [$json]; |
|
| 80 | + return [ $json ]; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
@@ -94,6 +94,6 @@ discard block |
||
| 94 | 94 | $json = [ |
| 95 | 95 | "message" => __METHOD__ . ", forbidden to access.", |
| 96 | 96 | ]; |
| 97 | - return [$json, 403]; |
|
| 97 | + return [ $json, 403 ]; |
|
| 98 | 98 | } |
| 99 | 99 | } |