@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | */ |
10 | 10 | function getGet($key, $default = null) |
11 | 11 | { |
12 | - return isset($_GET[$key]) |
|
13 | - ? $_GET[$key] |
|
12 | + return isset($_GET[ $key ]) |
|
13 | + ? $_GET[ $key ] |
|
14 | 14 | : $default; |
15 | 15 | } |
16 | 16 | |
@@ -30,8 +30,8 @@ discard block |
||
30 | 30 | return array_replace($key, array_intersect_key($_POST, $key)); |
31 | 31 | } |
32 | 32 | |
33 | - return isset($_POST[$key]) |
|
34 | - ? $_POST[$key] |
|
33 | + return isset($_POST[ $key ]) |
|
34 | + ? $_POST[ $key ] |
|
35 | 35 | : $default; |
36 | 36 | } |
37 | 37 | |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | */ |
67 | 67 | function orderby2($column, $route) |
68 | 68 | { |
69 | - $asc = mergeQueryString(["orderby" => $column, "order" => "asc"], $route); |
|
70 | - $desc = mergeQueryString(["orderby" => $column, "order" => "desc"], $route); |
|
69 | + $asc = mergeQueryString([ "orderby" => $column, "order" => "asc" ], $route); |
|
70 | + $desc = mergeQueryString([ "orderby" => $column, "order" => "desc" ], $route); |
|
71 | 71 | |
72 | 72 | return <<<EOD |
73 | 73 | <span class="orderby"> |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | function mergeQueryString($options, $prepend = "?") |
93 | 93 | { |
94 | 94 | // Parse querystring into array |
95 | - $query = []; |
|
96 | - parse_str($_SERVER["QUERY_STRING"], $query); |
|
95 | + $query = [ ]; |
|
96 | + parse_str($_SERVER[ "QUERY_STRING" ], $query); |
|
97 | 97 | |
98 | 98 | // Merge query string with new options |
99 | 99 | $query = array_merge($query, $options); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | function slugify($str) |
142 | 142 | { |
143 | 143 | $str = mb_strtolower(trim($str)); |
144 | - $str = str_replace(['å','ä'], 'a', $str); |
|
144 | + $str = str_replace([ 'å', 'ä' ], 'a', $str); |
|
145 | 145 | $str = str_replace('ö', 'o', $str); |
146 | 146 | $str = preg_replace('/[^a-z0-9-]/', '-', $str); |
147 | 147 | $str = trim(preg_replace('/-+/', '-', $str), '-'); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function add( |
54 | 54 | $template, |
55 | - array $data = [], |
|
55 | + array $data = [ ], |
|
56 | 56 | string $region = "main", |
57 | 57 | int $sort = 0 |
58 | 58 | ) : object { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return object |
73 | 73 | */ |
74 | - public function render(array $data = [], int $status = 200) |
|
74 | + public function render(array $data = [ ], int $status = 200) |
|
75 | 75 | { |
76 | 76 | $view = $this->di->get("view"); |
77 | 77 | $view->add($this->layout, $data, "layout"); |
@@ -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(...$args) : object |
@@ -51,13 +51,13 @@ |
||
51 | 51 | $page->add( |
52 | 52 | "anax/v2/error/default", |
53 | 53 | [ |
54 | - "header" => $pages[$path][0], |
|
55 | - "text" => $pages[$path][1], |
|
54 | + "header" => $pages[ $path ][ 0 ], |
|
55 | + "text" => $pages[ $path ][ 1 ], |
|
56 | 56 | ] |
57 | 57 | ); |
58 | 58 | |
59 | 59 | return $page->render([ |
60 | - "title" => $pages[$path][0] |
|
60 | + "title" => $pages[ $path ][ 0 ] |
|
61 | 61 | ], $path); |
62 | 62 | } |
63 | 63 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $content = file_get_contents($file); |
50 | 50 | $content = $this->di->get("textfilter")->parse( |
51 | 51 | $content, |
52 | - ["frontmatter", "variable", "shortcode", "markdown", "titlefromheader"] |
|
52 | + [ "frontmatter", "variable", "shortcode", "markdown", "titlefromheader" ] |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | // Add content as a view and then render the page |
@@ -21,7 +21,6 @@ |
||
21 | 21 | * @param array $args as a variadic to catch all arguments. |
22 | 22 | * |
23 | 23 | * @throws Anax\Route\Exception\NotFoundException when route is not found. |
24 | - |
|
25 | 24 | * @return object as the response. |
26 | 25 | * |
27 | 26 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
@@ -47,14 +47,14 @@ |
||
47 | 47 | |
48 | 48 | $page = $this->di->get("page"); |
49 | 49 | $page->add( |
50 | - "anax/v2/dev/{$pages[$path]}", |
|
50 | + "anax/v2/dev/{$pages[ $path ]}", |
|
51 | 51 | [ |
52 | 52 | "mount" => "dev/" |
53 | 53 | ] |
54 | 54 | ); |
55 | 55 | |
56 | 56 | return $page->render([ |
57 | - "title" => ucfirst($pages[$path]), |
|
57 | + "title" => ucfirst($pages[ $path ]), |
|
58 | 58 | "baseTitle" => " | Anax development utilities" |
59 | 59 | ]); |
60 | 60 | } |
@@ -33,26 +33,26 @@ |
||
33 | 33 | public $deleted; |
34 | 34 | |
35 | 35 | /** |
36 | - * Set the password. |
|
37 | - * |
|
38 | - * @param string $password the password to use. |
|
39 | - * |
|
40 | - * @return void |
|
41 | - */ |
|
36 | + * Set the password. |
|
37 | + * |
|
38 | + * @param string $password the password to use. |
|
39 | + * |
|
40 | + * @return void |
|
41 | + */ |
|
42 | 42 | public function setPassword($password) |
43 | 43 | { |
44 | 44 | $this->password = password_hash($password, PASSWORD_DEFAULT); |
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | - * Verify the acronym and the password, if successful the object contains |
|
49 | - * all details from the database row. |
|
50 | - * |
|
51 | - * @param string $acronym acronym to check. |
|
52 | - * @param string $password the password to use. |
|
53 | - * |
|
54 | - * @return boolean true if acronym and password matches, else false. |
|
55 | - */ |
|
48 | + * Verify the acronym and the password, if successful the object contains |
|
49 | + * all details from the database row. |
|
50 | + * |
|
51 | + * @param string $acronym acronym to check. |
|
52 | + * @param string $password the password to use. |
|
53 | + * |
|
54 | + * @return boolean true if acronym and password matches, else false. |
|
55 | + */ |
|
56 | 56 | public function verifyPassword($acronym, $password) |
57 | 57 | { |
58 | 58 | $this->find("username", $acronym); |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | // Connect the database |
45 | 45 | $this->db = $this->di->get("db"); |
46 | 46 | $this->db->connect(); |
47 | - if ($this->currentUser !=null) { |
|
47 | + if ($this->currentUser!=null) { |
|
48 | 48 | $sql = "SELECT id from users where username = ?;"; |
49 | - $res = $this->db->executeFetchAll($sql, [$this->currentUser]); |
|
50 | - $this->userId = $res[0]->id; |
|
49 | + $res = $this->db->executeFetchAll($sql, [ $this->currentUser ]); |
|
50 | + $this->userId = $res[ 0 ]->id; |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
@@ -76,11 +76,11 @@ discard block |
||
76 | 76 | //Get Posts |
77 | 77 | $user_id = $res->id; |
78 | 78 | $sql = "SELECT * from v_all WHERE user_id=?;"; |
79 | - $posts = $this->db->executeFetchAll($sql, [$user_id]); |
|
79 | + $posts = $this->db->executeFetchAll($sql, [ $user_id ]); |
|
80 | 80 | // var_dump($posts); |
81 | 81 | //Get the answers for the user |
82 | 82 | $sql = "SELECT * from v_comments_user WHERE user_id=? and answer=1;"; |
83 | - $answers = $this->db->executeFetchAll($sql, [$user_id]); |
|
83 | + $answers = $this->db->executeFetchAll($sql, [ $user_id ]); |
|
84 | 84 | $bonus = 0; |
85 | 85 | foreach ($answers as $value) { |
86 | 86 | if ($value->accepted==1) { |
@@ -90,19 +90,19 @@ discard block |
||
90 | 90 | |
91 | 91 | // Get the comments for the user |
92 | 92 | $sql = "SELECT * from v_comments_user WHERE user_id=? and answer=0;"; |
93 | - $comments = $this->db->executeFetchAll($sql, [$user_id]); |
|
93 | + $comments = $this->db->executeFetchAll($sql, [ $user_id ]); |
|
94 | 94 | // var_dump($comments); |
95 | - $reputation = count($posts)*3 + (count($answers)- $bonus)*3 + |
|
95 | + $reputation = count($posts)*3 + (count($answers) - $bonus)*3 + |
|
96 | 96 | + $bonus*100 + count($comments); |
97 | 97 | $page->add("user/index", |
98 | - ["current_user" => $this->currentUser, |
|
98 | + [ "current_user" => $this->currentUser, |
|
99 | 99 | "avatar" => $avatar, |
100 | 100 | "reputation" => $reputation, |
101 | 101 | "posts" => $posts, |
102 | 102 | "answers" => $answers, |
103 | 103 | "comments" => $comments, |
104 | 104 | ]); |
105 | - return $page->render(["title" => $title, ]); |
|
105 | + return $page->render([ "title" => $title, ]); |
|
106 | 106 | } |
107 | 107 | $response = $this->di->get("response"); |
108 | 108 | return $response->redirect("user/login"); |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | //Get Posts |
123 | 123 | |
124 | 124 | $sql = "SELECT * from v_all WHERE user_id=?;"; |
125 | - $posts = $this->db->executeFetchAll($sql, [$user_id]); |
|
125 | + $posts = $this->db->executeFetchAll($sql, [ $user_id ]); |
|
126 | 126 | // var_dump($res->email); |
127 | 127 | //Get the answers for the user |
128 | 128 | $sql = "SELECT * from v_comments_user WHERE user_id=? and answer=1;"; |
129 | - $answers = $this->db->executeFetchAll($sql, [$user_id]); |
|
129 | + $answers = $this->db->executeFetchAll($sql, [ $user_id ]); |
|
130 | 130 | $bonus = 0; |
131 | 131 | foreach ($answers as $value) { |
132 | 132 | if ($value->accepted==1) { |
@@ -136,19 +136,19 @@ discard block |
||
136 | 136 | |
137 | 137 | // Get the comments for the user |
138 | 138 | $sql = "SELECT * from v_comments_user WHERE user_id=? and answer=0;"; |
139 | - $comments = $this->db->executeFetchAll($sql, [$user_id]); |
|
139 | + $comments = $this->db->executeFetchAll($sql, [ $user_id ]); |
|
140 | 140 | // var_dump($comments); |
141 | - $reputation = count($posts)*3 + (count($answers)- $bonus)*3 + |
|
141 | + $reputation = count($posts)*3 + (count($answers) - $bonus)*3 + |
|
142 | 142 | + $bonus*100 + count($comments); |
143 | 143 | $page->add("user/profile", |
144 | - ["user" => $res->username, |
|
144 | + [ "user" => $res->username, |
|
145 | 145 | "avatar" => $avatar, |
146 | 146 | "reputation" => $reputation, |
147 | 147 | "posts" => $posts, |
148 | 148 | "answers" => $answers, |
149 | 149 | "comments" => $comments, |
150 | 150 | ]); |
151 | - return $page->render(["title" => $title, ]); |
|
151 | + return $page->render([ "title" => $title, ]); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | "submit" => [ |
42 | 42 | "type" => "submit", |
43 | 43 | "value" => "Login", |
44 | - "callback" => [$this, "callbackSubmit"] |
|
44 | + "callback" => [ $this, "callbackSubmit" ] |
|
45 | 45 | ], |
46 | 46 | ] |
47 | 47 | ); |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | public function callbackSubmit() |
59 | 59 | { |
60 | 60 | // Get values from the submitted form |
61 | - $username = $this->form->value("username"); |
|
62 | - $password = $this->form->value("password"); |
|
61 | + $username = $this->form->value("username"); |
|
62 | + $password = $this->form->value("password"); |
|
63 | 63 | |
64 | 64 | // Try to login |
65 | 65 | $user = new User(); |
@@ -43,13 +43,13 @@ discard block |
||
43 | 43 | "email" => [ |
44 | 44 | "type" =>"email", |
45 | 45 | "label" => "Email", |
46 | - "validation" => ["email"], |
|
46 | + "validation" => [ "email" ], |
|
47 | 47 | ], |
48 | 48 | |
49 | 49 | "submit" => [ |
50 | 50 | "type" => "submit", |
51 | 51 | "value" => "Register", |
52 | - "callback" => [$this, "callbackSubmit"] |
|
52 | + "callback" => [ $this, "callbackSubmit" ] |
|
53 | 53 | ], |
54 | 54 | ] |
55 | 55 | ); |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | public function callbackSubmit() : bool |
67 | 67 | { |
68 | 68 | // Get values from the submitted form |
69 | - $username = $this->form->value("username"); |
|
69 | + $username = $this->form->value("username"); |
|
70 | 70 | $password = $this->form->value("password"); |
71 | 71 | $passwordAgain = $this->form->value("password-again"); |
72 | 72 | $email = $this->form->value("email"); |
73 | 73 | |
74 | 74 | // Check password matches |
75 | - if ($password !== $passwordAgain ) { |
|
75 | + if ($password!==$passwordAgain) { |
|
76 | 76 | $this->form->rememberValues(); |
77 | 77 | $this->form->addOutput("Password did not match."); |
78 | 78 | return false; |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | $db = $this->di->get("dbqb"); |
83 | 83 | $password = password_hash($password, PASSWORD_DEFAULT); |
84 | 84 | $db->connect() |
85 | - ->insert("users", ["username", "password", "email"]) |
|
86 | - ->execute([$username, $password, $email]); |
|
85 | + ->insert("users", [ "username", "password", "email" ]) |
|
86 | + ->execute([ $username, $password, $email ]); |
|
87 | 87 | |
88 | 88 | // $this->form->addOutput("User was created."); |
89 | 89 | return true; |