@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function index() |
| 17 | 17 | { |
| 18 | - if(!$this->auth->isUser()){ |
|
| 18 | + if (!$this->auth->isUser()) { |
|
| 19 | 19 | $this->alertBox->setAlert("You must be connected to access the admin interface", 'warning'); |
| 20 | 20 | $this->container->getResponse()->redirect(); |
| 21 | 21 | } |
@@ -43,14 +43,14 @@ discard block |
||
| 43 | 43 | private function getFilename(string $folder, string $file): string |
| 44 | 44 | { |
| 45 | 45 | |
| 46 | - $fileUrl = $folder . $file; |
|
| 46 | + $fileUrl = $folder.$file; |
|
| 47 | 47 | $docRoot = $this->request->getDocumentRoot(); |
| 48 | - $filePath = $docRoot . "/public/" . $fileUrl; |
|
| 48 | + $filePath = $docRoot."/public/".$fileUrl; |
|
| 49 | 49 | if (file_exists($filePath) !== 1) { |
| 50 | 50 | $fileNum = 0; |
| 51 | 51 | while (file_exists($filePath)) { |
| 52 | - $fileUrl = $folder . $fileNum . "_" . $file; |
|
| 53 | - $filePath = $docRoot . "/public/" . $fileUrl; |
|
| 52 | + $fileUrl = $folder.$fileNum."_".$file; |
|
| 53 | + $filePath = $docRoot."/public/".$fileUrl; |
|
| 54 | 54 | $fileNum += 1; |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | // Respond to the successful upload with JSON. |
| 76 | 76 | echo json_encode(array('location' => $filetowrite)); |
| 77 | - } else { |
|
| 77 | + }else { |
|
| 78 | 78 | // Notify editor that the upload failed |
| 79 | 79 | echo json_encode(array('error' => 'Upload failed, file might be too big')); |
| 80 | 80 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | // Respond to the successful upload with JSON. |
| 110 | 110 | echo json_encode(array('location' => $filetowrite)); |
| 111 | - } else { |
|
| 111 | + }else { |
|
| 112 | 112 | // Notify editor that the upload failed |
| 113 | 113 | header("HTTP/1.1 500 Server Error"); |
| 114 | 114 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | if (!$this->container->getRequest()->isPost()) { |
| 29 | 29 | throw new \Core\JsonException('Call is not post'); |
| 30 | 30 | } |
| 31 | - $state = (bool)($this->request->getData("state") === 'true'); |
|
| 32 | - $postId = (int)$this->request->getData("postId"); |
|
| 31 | + $state = (bool) ($this->request->getData("state") === 'true'); |
|
| 32 | + $postId = (int) $this->request->getData("postId"); |
|
| 33 | 33 | |
| 34 | 34 | $result = array(); |
| 35 | 35 | $result["success"] = $this->postModule->setPublished(!$state, $postId); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | throw new \Core\JsonException('Call is not post'); |
| 50 | 50 | } |
| 51 | 51 | $state = ($this->request->getData("state") === 'true'); |
| 52 | - $postId = (int)$this->request->getData("postId"); |
|
| 52 | + $postId = (int) $this->request->getData("postId"); |
|
| 53 | 53 | |
| 54 | 54 | $result = array(); |
| 55 | 55 | $result["success"] = $this->postModule->setOnFrontPage(!$state, $postId); |
@@ -36,9 +36,11 @@ |
||
| 36 | 36 | |
| 37 | 37 | $data = $postModel->isPostSlugUnique($postSlug); |
| 38 | 38 | |
| 39 | - if ($data === false) //slug is not unique, but could be from the same post |
|
| 39 | + if ($data === false) { |
|
| 40 | + //slug is not unique, but could be from the same post |
|
| 40 | 41 | { |
| 41 | 42 | $slugOfId = $postModel->getPostSlugFromId($postId); |
| 43 | + } |
|
| 42 | 44 | if ($slugOfId === $postSlug) { |
| 43 | 45 | //it's the same post, return true |
| 44 | 46 | $data = true; |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | //make sure we have the right type or throw an error |
| 30 | 30 | |
| 31 | 31 | if (!in_array($type, $this->allowedTypes)) { |
| 32 | - throw new \Exception("Invalid toastr alert type " . $type); |
|
| 32 | + throw new \Exception("Invalid toastr alert type ".$type); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $message = htmlspecialchars($message); //avoid any injection |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | //check if email is valid for sanity |
| 68 | 68 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
| 69 | 69 | $email = htmlspecialchars($email); |
| 70 | - throw new \Exception("invalid email " . $email); |
|
| 70 | + throw new \Exception("invalid email ".$email); |
|
| 71 | 71 | } |
| 72 | 72 | $sql = " |
| 73 | 73 | SELECT idusers, username, avatar, email, surname, name, creation_date, last_update, locked_out, role_name, role_level |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | $this->bind(':roles_idroles', 1); |
| 124 | 124 | $this->execute(); |
| 125 | 125 | |
| 126 | - return (int)$this->dbh->lastInsertId(); |
|
| 126 | + return (int) $this->dbh->lastInsertId(); |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | \ No newline at end of file |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | use Core\JsonException; |
| 9 | 9 | use Core\Traits\StringFunctions; |
| 10 | 10 | |
| 11 | -class User extends AjaxController{ |
|
| 11 | +class User extends AjaxController { |
|
| 12 | 12 | |
| 13 | 13 | use StringFunctions; |
| 14 | 14 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | //the router needs a parameter with get functions else throsw a wobbly |
| 26 | 26 | //we pass a get variable and call the /controller/function/get?bla |
| 27 | 27 | //for better use and security, we must pass "get" as the parameter |
| 28 | - if(!$this->startsWith(strtolower($get),"get")) |
|
| 28 | + if (!$this->startsWith(strtolower($get), "get")) |
|
| 29 | 29 | { |
| 30 | 30 | throw new JsonException("invalid call"); |
| 31 | 31 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | private function populateUserFromId(int $userId) |
| 61 | 61 | { |
| 62 | 62 | $result = $this->userModel->getUserDetailsById($userId); |
| 63 | - $this->populateUser((array)$result); |
|
| 63 | + $this->populateUser((array) $result); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | $authUser = $this->userModel->authenticateUser($email, $password); |
| 166 | - if(!$authUser) |
|
| 166 | + if (!$authUser) |
|
| 167 | 167 | { |
| 168 | 168 | $error = true; |
| 169 | 169 | $loginErrors->password = "Incorrect Password"; |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | //we are authenticated here |
| 179 | 179 | |
| 180 | 180 | //populate the user object with returned data |
| 181 | - $this->populateUser((array)$authUser); |
|
| 181 | + $this->populateUser((array) $authUser); |
|
| 182 | 182 | $this->setUserSession(); |
| 183 | 183 | |
| 184 | 184 | //if all is valid, redirect to user admin page |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | $loadModuleObj = $this->getModuleNamespace($loadModule); |
| 107 | 107 | //Modules must be children of the Module template |
| 108 | 108 | if (!is_subclass_of($loadModuleObj, 'Core\Modules\Module')) { |
| 109 | - throw new \ErrorException('Module ' . $loadModuleName . ' must be a sub class of module'); |
|
| 109 | + throw new \ErrorException('Module '.$loadModuleName.' must be a sub class of module'); |
|
| 110 | 110 | } |
| 111 | 111 | $loadedModule = new $loadModuleObj($this->container); |
| 112 | 112 | //we are not allowed to create public modules, they must be a placeholder ready |
| 113 | 113 | if (!property_exists($this, $loadModuleName)) { |
| 114 | - throw new \ErrorException('the protected or private variable of ' . $loadModuleName . ' is not present'); |
|
| 114 | + throw new \ErrorException('the protected or private variable of '.$loadModuleName.' is not present'); |
|
| 115 | 115 | } |
| 116 | 116 | $this->$loadModuleName = $loadedModule; |
| 117 | 117 | } |
@@ -128,23 +128,23 @@ discard block |
||
| 128 | 128 | $childClass = new \ReflectionClass(get_class($this)); |
| 129 | 129 | $childClassNamespace = $childClass->getNamespaceName(); |
| 130 | 130 | //check in classNameSpace |
| 131 | - if (class_exists($childClassNamespace . '\\Modules\\' . $loadModule)) { |
|
| 132 | - $this->addToDevHelper('module ' . $loadModule . ' loaded', $childClassNamespace . '\\' . $loadModule); |
|
| 133 | - return $childClassNamespace . '\\' . $loadModule; |
|
| 131 | + if (class_exists($childClassNamespace.'\\Modules\\'.$loadModule)) { |
|
| 132 | + $this->addToDevHelper('module '.$loadModule.' loaded', $childClassNamespace.'\\'.$loadModule); |
|
| 133 | + return $childClassNamespace.'\\'.$loadModule; |
|
| 134 | 134 | } |
| 135 | 135 | //check in app |
| 136 | - if (class_exists('App\\Modules\\' . $loadModule)) { |
|
| 137 | - $this->addToDevHelper('module ' . $loadModule . ' loaded', 'App\\Modules\\' . $loadModule); |
|
| 138 | - return 'App\\Modules\\' . $loadModule; |
|
| 136 | + if (class_exists('App\\Modules\\'.$loadModule)) { |
|
| 137 | + $this->addToDevHelper('module '.$loadModule.' loaded', 'App\\Modules\\'.$loadModule); |
|
| 138 | + return 'App\\Modules\\'.$loadModule; |
|
| 139 | 139 | } |
| 140 | 140 | //check in core, send error popup if overcharged |
| 141 | - if (class_exists('Core\\Modules\\' . $loadModule)) { |
|
| 142 | - $this->addToDevHelper('module ' . $loadModule . ' loaded', 'Core\\Modules\\' . $loadModule); |
|
| 143 | - return 'Core\\Modules\\' . $loadModule; |
|
| 141 | + if (class_exists('Core\\Modules\\'.$loadModule)) { |
|
| 142 | + $this->addToDevHelper('module '.$loadModule.' loaded', 'Core\\Modules\\'.$loadModule); |
|
| 143 | + return 'Core\\Modules\\'.$loadModule; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | //if we are here then no module found |
| 147 | - throw new \ErrorException('module ' . $loadModule . ' does not exist or not loaded'); |
|
| 147 | + throw new \ErrorException('module '.$loadModule.' does not exist or not loaded'); |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | public function getView($template) |
| 170 | 170 | { |
| 171 | 171 | $twig = $this->container->getTemplate(); |
| 172 | - return $twig->render($template . '.twig', $this->data); |
|
| 172 | + return $twig->render($template.'.twig', $this->data); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | $twig = $this->container->getTemplate(); |
| 198 | - $twig->display($template . '.twig', $this->data); |
|
| 198 | + $twig->display($template.'.twig', $this->data); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | protected function addToDevHelper($name, $var) |
| 228 | 228 | { |
| 229 | 229 | //only populate if in dev environment |
| 230 | - if (Config::DEV_ENVIRONMENT){ |
|
| 230 | + if (Config::DEV_ENVIRONMENT) { |
|
| 231 | 231 | $classMethods = []; |
| 232 | 232 | $classMethods[$name] = $var; |
| 233 | 233 | if (!isset($this->data['dev_info'])) { |